001// ASM: a very small and fast Java bytecode manipulation framework 002// Copyright (c) 2000-2011 INRIA, France Telecom 003// All rights reserved. 004// 005// Redistribution and use in source and binary forms, with or without 006// modification, are permitted provided that the following conditions 007// are met: 008// 1. Redistributions of source code must retain the above copyright 009// notice, this list of conditions and the following disclaimer. 010// 2. Redistributions in binary form must reproduce the above copyright 011// notice, this list of conditions and the following disclaimer in the 012// documentation and/or other materials provided with the distribution. 013// 3. Neither the name of the copyright holders nor the names of its 014// contributors may be used to endorse or promote products derived from 015// this software without specific prior written permission. 016// 017// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 018// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 019// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 020// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 021// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 022// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 023// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 024// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 025// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 026// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 027// THE POSSIBILITY OF SUCH DAMAGE. 028package org.springframework.asm; 029 030/** 031 * A visitor to visit a record component. The methods of this class must be called in the following 032 * order: ( {@code visitAnnotation} | {@code visitTypeAnnotation} | {@code visitAttribute} )* {@code 033 * visitEnd}. 034 * 035 * @author Remi Forax 036 * @author Eric Bruneton 037 * @deprecated this API is experimental. 038 */ 039@Deprecated 040public abstract class RecordComponentVisitor { 041 /** 042 * The ASM API version implemented by this visitor. The value of this field must be {@link 043 * Opcodes#ASM8_EXPERIMENTAL}. 044 */ 045 protected final int api; 046 047 /** 048 * The record visitor to which this visitor must delegate method calls. May be {@literal null}. 049 */ 050 /*package-private*/ RecordComponentVisitor delegate; 051 052 /** 053 * Constructs a new {@link RecordComponentVisitor}. 054 * 055 * @param api the ASM API version implemented by this visitor. Must be {@link 056 * Opcodes#ASM8_EXPERIMENTAL}. 057 * @deprecated this API is experimental. 058 */ 059 @Deprecated 060 public RecordComponentVisitor(final int api) { 061 this(api, null); 062 } 063 064 /** 065 * Constructs a new {@link RecordComponentVisitor}. 066 * 067 * @param api the ASM API version implemented by this visitor. Must be {@link 068 * Opcodes#ASM8_EXPERIMENTAL}. 069 * @param recordComponentVisitor the record component visitor to which this visitor must delegate 070 * method calls. May be null. 071 * @deprecated this API is experimental. 072 */ 073 @Deprecated 074 public RecordComponentVisitor( 075 final int api, final RecordComponentVisitor recordComponentVisitor) { 076 if (api != Opcodes.ASM7 077 && api != Opcodes.ASM6 078 && api != Opcodes.ASM5 079 && api != Opcodes.ASM4 080 && api != Opcodes.ASM8_EXPERIMENTAL) { 081 throw new IllegalArgumentException("Unsupported api " + api); 082 } 083 // SPRING PATCH: no preview mode check for ASM 8 experimental 084 this.api = api; 085 this.delegate = recordComponentVisitor; 086 } 087 088 /** 089 * The record visitor to which this visitor must delegate method calls. May be {@literal null}. 090 * 091 * @return the record visitor to which this visitor must delegate method calls or {@literal null}. 092 * @deprecated this API is experimental. 093 */ 094 @Deprecated 095 public RecordComponentVisitor getDelegateExperimental() { 096 return delegate; 097 } 098 099 /** 100 * Visits an annotation of the record component. 101 * 102 * @param descriptor the class descriptor of the annotation class. 103 * @param visible {@literal true} if the annotation is visible at runtime. 104 * @return a visitor to visit the annotation values, or {@literal null} if this visitor is not 105 * interested in visiting this annotation. 106 * @deprecated this API is experimental. 107 */ 108 @Deprecated 109 public AnnotationVisitor visitAnnotationExperimental( 110 final String descriptor, final boolean visible) { 111 if (delegate != null) { 112 return delegate.visitAnnotationExperimental(descriptor, visible); 113 } 114 return null; 115 } 116 117 /** 118 * Visits an annotation on a type in the record component signature. 119 * 120 * @param typeRef a reference to the annotated type. The sort of this type reference must be 121 * {@link TypeReference#CLASS_TYPE_PARAMETER}, {@link 122 * TypeReference#CLASS_TYPE_PARAMETER_BOUND} or {@link TypeReference#CLASS_EXTENDS}. See 123 * {@link TypeReference}. 124 * @param typePath the path to the annotated type argument, wildcard bound, array element type, or 125 * static inner type within 'typeRef'. May be {@literal null} if the annotation targets 126 * 'typeRef' as a whole. 127 * @param descriptor the class descriptor of the annotation class. 128 * @param visible {@literal true} if the annotation is visible at runtime. 129 * @return a visitor to visit the annotation values, or {@literal null} if this visitor is not 130 * interested in visiting this annotation. 131 * @deprecated this API is experimental. 132 */ 133 @Deprecated 134 public AnnotationVisitor visitTypeAnnotationExperimental( 135 final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) { 136 if (delegate != null) { 137 return delegate.visitTypeAnnotationExperimental(typeRef, typePath, descriptor, visible); 138 } 139 return null; 140 } 141 142 /** 143 * Visits a non standard attribute of the record component. 144 * 145 * @param attribute an attribute. 146 * @deprecated this API is experimental. 147 */ 148 @Deprecated 149 public void visitAttributeExperimental(final Attribute attribute) { 150 if (delegate != null) { 151 delegate.visitAttributeExperimental(attribute); 152 } 153 } 154 155 /** 156 * Visits the end of the record component. This method, which is the last one to be called, is 157 * used to inform the visitor that everything have been visited. 158 * 159 * @deprecated this API is experimental. 160 */ 161 @Deprecated 162 public void visitEndExperimental() { 163 if (delegate != null) { 164 delegate.visitEndExperimental(); 165 } 166 } 167}