< prev index next >

src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassVisitor.java

Print this page




  44  *    contributors may be used to endorse or promote products derived from
  45  *    this software without specific prior written permission.
  46  *
  47  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  48  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  49  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  50  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  51  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  52  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  53  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  54  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  55  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  56  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  57  * THE POSSIBILITY OF SUCH DAMAGE.
  58  */
  59 package jdk.internal.org.objectweb.asm;
  60 
  61 /**
  62  * A visitor to visit a Java class. The methods of this class must be called in the following order:
  63  * {@code visit} [ {@code visitSource} ] [ {@code visitModule} ][ {@code visitNestHost} ][ {@code
  64  * visitPermittedSubtype} ][ {@code visitOuterClass} ] ( {@code visitAnnotation} | {@code
  65  * visitTypeAnnotation} | {@code visitAttribute} )* ( {@code visitNestMember} | {@code
  66  * visitInnerClass} | {@code visitField} | {@code visitMethod} )* {@code visitEnd}.
  67  *
  68  * @author Eric Bruneton
  69  */
  70 public abstract class ClassVisitor {
  71 
  72     /**
  73       * The ASM API version implemented by this visitor. The value of this field must be one of {@link
  74       * Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
  75       */
  76     protected final int api;
  77 
  78     /** The class visitor to which this visitor must delegate method calls. May be {@literal null}. */
  79     protected ClassVisitor cv;
  80 
  81     /**
  82       * Constructs a new {@link ClassVisitor}.
  83       *
  84       * @param api the ASM API version implemented by this visitor. Must be one of {@link


 270     /**
 271       * Visits a member of the nest. A nest is a set of classes of the same package that share access
 272       * to their private members. One of these classes, called the host, lists the other members of the
 273       * nest, which in turn should link to the host of their nest. This method must be called only if
 274       * the visited class is the host of a nest. A nest host is implicitly a member of its own nest, so
 275       * it's invalid to call this method with the visited class name as argument.
 276       *
 277       * @param nestMember the internal name of a nest member.
 278       */
 279     public void visitNestMember(final String nestMember) {
 280         if (api < Opcodes.ASM7) {
 281             throw new UnsupportedOperationException("This feature requires ASM7");
 282         }
 283         if (cv != null) {
 284             cv.visitNestMember(nestMember);
 285         }
 286     }
 287 
 288     /**
 289       * <b>Experimental, use at your own risk. This method will be renamed when it becomes stable, this
 290       * will break existing code using it</b>. Visits a permitted subtypes. A permitted subtypes is one
 291       * of the allowed subtypes of the current class.
 292       *
 293       * @param permittedSubtype the internal name of a permitted subtype.
 294       * @deprecated this API is experimental.
 295       */
 296     @Deprecated
 297     public void visitPermittedSubtypeExperimental(final String permittedSubtype) {
 298         if (api != Opcodes.ASM9_EXPERIMENTAL) {
 299             throw new UnsupportedOperationException("This feature requires ASM9_EXPERIMENTAL");
 300         }
 301         if (cv != null) {
 302             cv.visitPermittedSubtypeExperimental(permittedSubtype);
 303         }
 304     }
 305 
 306     /**
 307       * Visits information about an inner class. This inner class is not necessarily a member of the
 308       * class being visited.
 309       *
 310       * @param name the internal name of an inner class (see {@link Type#getInternalName()}).
 311       * @param outerName the internal name of the class to which the inner class belongs (see {@link
 312       *     Type#getInternalName()}). May be {@literal null} for not member classes.
 313       * @param innerName the (simple) name of the inner class inside its enclosing class. May be
 314       *     {@literal null} for anonymous inner classes.
 315       * @param access the access flags of the inner class as originally declared in the enclosing
 316       *     class.
 317       */
 318     public void visitInnerClass(
 319             final String name, final String outerName, final String innerName, final int access) {
 320         if (cv != null) {
 321             cv.visitInnerClass(name, outerName, innerName, access);
 322         }




  44  *    contributors may be used to endorse or promote products derived from
  45  *    this software without specific prior written permission.
  46  *
  47  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  48  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  49  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  50  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  51  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  52  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  53  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  54  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  55  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  56  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  57  * THE POSSIBILITY OF SUCH DAMAGE.
  58  */
  59 package jdk.internal.org.objectweb.asm;
  60 
  61 /**
  62  * A visitor to visit a Java class. The methods of this class must be called in the following order:
  63  * {@code visit} [ {@code visitSource} ] [ {@code visitModule} ][ {@code visitNestHost} ][ {@code
  64  * visitPermittedSubclass} ][ {@code visitOuterClass} ] ( {@code visitAnnotation} | {@code
  65  * visitTypeAnnotation} | {@code visitAttribute} )* ( {@code visitNestMember} | {@code
  66  * visitInnerClass} | {@code visitField} | {@code visitMethod} )* {@code visitEnd}.
  67  *
  68  * @author Eric Bruneton
  69  */
  70 public abstract class ClassVisitor {
  71 
  72     /**
  73       * The ASM API version implemented by this visitor. The value of this field must be one of {@link
  74       * Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
  75       */
  76     protected final int api;
  77 
  78     /** The class visitor to which this visitor must delegate method calls. May be {@literal null}. */
  79     protected ClassVisitor cv;
  80 
  81     /**
  82       * Constructs a new {@link ClassVisitor}.
  83       *
  84       * @param api the ASM API version implemented by this visitor. Must be one of {@link


 270     /**
 271       * Visits a member of the nest. A nest is a set of classes of the same package that share access
 272       * to their private members. One of these classes, called the host, lists the other members of the
 273       * nest, which in turn should link to the host of their nest. This method must be called only if
 274       * the visited class is the host of a nest. A nest host is implicitly a member of its own nest, so
 275       * it's invalid to call this method with the visited class name as argument.
 276       *
 277       * @param nestMember the internal name of a nest member.
 278       */
 279     public void visitNestMember(final String nestMember) {
 280         if (api < Opcodes.ASM7) {
 281             throw new UnsupportedOperationException("This feature requires ASM7");
 282         }
 283         if (cv != null) {
 284             cv.visitNestMember(nestMember);
 285         }
 286     }
 287 
 288     /**
 289       * <b>Experimental, use at your own risk. This method will be renamed when it becomes stable, this
 290       * will break existing code using it</b>. Visits a permitted subclass. A permitted subclass is one
 291       * of the allowed subclasses of the current class.
 292       *
 293       * @param permittedSubclass the internal name of a permitted subclass.
 294       * @deprecated this API is experimental.
 295       */
 296     @Deprecated
 297     public void visitPermittedSubclassExperimental(final String permittedSubclass) {
 298         if (api != Opcodes.ASM9_EXPERIMENTAL) {
 299             throw new UnsupportedOperationException("This feature requires ASM9_EXPERIMENTAL");
 300         }
 301         if (cv != null) {
 302             cv.visitPermittedSubclassExperimental(permittedSubclass);
 303         }
 304     }
 305 
 306     /**
 307       * Visits information about an inner class. This inner class is not necessarily a member of the
 308       * class being visited.
 309       *
 310       * @param name the internal name of an inner class (see {@link Type#getInternalName()}).
 311       * @param outerName the internal name of the class to which the inner class belongs (see {@link
 312       *     Type#getInternalName()}). May be {@literal null} for not member classes.
 313       * @param innerName the (simple) name of the inner class inside its enclosing class. May be
 314       *     {@literal null} for anonymous inner classes.
 315       * @param access the access flags of the inner class as originally declared in the enclosing
 316       *     class.
 317       */
 318     public void visitInnerClass(
 319             final String name, final String outerName, final String innerName, final int access) {
 320         if (cv != null) {
 321             cv.visitInnerClass(name, outerName, innerName, access);
 322         }


< prev index next >