< prev index next >

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

Print this page
rev 47452 : imported patch jdk-new-asmv6.patch


  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
  63  * the following order: <tt>visit</tt> [ <tt>visitSource</tt> ] [
  64  * <tt>visitOuterClass</tt> ] ( <tt>visitAnnotation</tt> |
  65  * <tt>visitTypeAnnotation</tt> | <tt>visitAttribute</tt> )* (
  66  * <tt>visitInnerClass</tt> | <tt>visitField</tt> | <tt>visitMethod</tt> )*
  67  * <tt>visitEnd</tt>.
  68  *
  69  * @author Eric Bruneton
  70  */
  71 public abstract class ClassVisitor {
  72 
  73     /**
  74      * The ASM API version implemented by this visitor. The value of this field
  75      * must be one of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
  76      */
  77     protected final int api;
  78 
  79     /**
  80      * The class visitor to which this visitor must delegate method calls. May
  81      * be null.
  82      */
  83     protected ClassVisitor cv;
  84 
  85     /**
  86      * Constructs a new {@link ClassVisitor}.
  87      *
  88      * @param api
  89      *            the ASM API version implemented by this visitor. Must be one
  90      *            of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
  91      */
  92     public ClassVisitor(final int api) {
  93         this(api, null);
  94     }
  95 
  96     /**
  97      * Constructs a new {@link ClassVisitor}.
  98      *
  99      * @param api
 100      *            the ASM API version implemented by this visitor. Must be one
 101      *            of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
 102      * @param cv
 103      *            the class visitor to which this visitor must delegate method
 104      *            calls. May be null.
 105      */
 106     public ClassVisitor(final int api, final ClassVisitor cv) {
 107         if (api != Opcodes.ASM4 && api != Opcodes.ASM5) {
 108             throw new IllegalArgumentException();
 109         }
 110         this.api = api;
 111         this.cv = cv;
 112     }
 113 
 114     /**
 115      * Visits the header of the class.
 116      *
 117      * @param version
 118      *            the class version.
 119      * @param access
 120      *            the class's access flags (see {@link Opcodes}). This parameter
 121      *            also indicates if the class is deprecated.
 122      * @param name
 123      *            the internal name of the class (see
 124      *            {@link Type#getInternalName() getInternalName}).
 125      * @param signature
 126      *            the signature of this class. May be <tt>null</tt> if the class
 127      *            is not a generic one, and does not extend or implement generic


 143         }
 144     }
 145 
 146     /**
 147      * Visits the source of the class.
 148      *
 149      * @param source
 150      *            the name of the source file from which the class was compiled.
 151      *            May be <tt>null</tt>.
 152      * @param debug
 153      *            additional debug information to compute the correspondance
 154      *            between source and compiled elements of the class. May be
 155      *            <tt>null</tt>.
 156      */
 157     public void visitSource(String source, String debug) {
 158         if (cv != null) {
 159             cv.visitSource(source, debug);
 160         }
 161     }
 162 






















 163     /**
 164      * Visits the enclosing class of the class. This method must be called only
 165      * if the class has an enclosing class.
 166      *
 167      * @param owner
 168      *            internal name of the enclosing class of the class.
 169      * @param name
 170      *            the name of the method that contains the class, or
 171      *            <tt>null</tt> if the class is not enclosed in a method of its
 172      *            enclosing class.
 173      * @param desc
 174      *            the descriptor of the method that contains the class, or
 175      *            <tt>null</tt> if the class is not enclosed in a method of its
 176      *            enclosing class.
 177      */
 178     public void visitOuterClass(String owner, String name, String desc) {
 179         if (cv != null) {
 180             cv.visitOuterClass(owner, name, desc);
 181         }
 182     }




  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
  63  * the following order: <tt>visit</tt> [ <tt>visitSource</tt> ] [
  64  * <tt>visitModule</tt> ][ <tt>visitOuterClass</tt> ] ( <tt>visitAnnotation</tt> |
  65  * <tt>visitTypeAnnotation</tt> | <tt>visitAttribute</tt> )* (
  66  * <tt>visitInnerClass</tt> | <tt>visitField</tt> | <tt>visitMethod</tt> )*
  67  * <tt>visitEnd</tt>.
  68  *
  69  * @author Eric Bruneton
  70  */
  71 public abstract class ClassVisitor {
  72 
  73     /**
  74      * The ASM API version implemented by this visitor. The value of this field
  75      * must be one of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
  76      */
  77     protected final int api;
  78 
  79     /**
  80      * The class visitor to which this visitor must delegate method calls. May
  81      * be null.
  82      */
  83     protected ClassVisitor cv;
  84 
  85     /**
  86      * Constructs a new {@link ClassVisitor}.
  87      *
  88      * @param api
  89      *            the ASM API version implemented by this visitor. Must be one
  90      *            of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
  91      */
  92     public ClassVisitor(final int api) {
  93         this(api, null);
  94     }
  95 
  96     /**
  97      * Constructs a new {@link ClassVisitor}.
  98      *
  99      * @param api
 100      *            the ASM API version implemented by this visitor. Must be one
 101      *            of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
 102      * @param cv
 103      *            the class visitor to which this visitor must delegate method
 104      *            calls. May be null.
 105      */
 106     public ClassVisitor(final int api, final ClassVisitor cv) {
 107         if (api < Opcodes.ASM4 || api > Opcodes.ASM6) {
 108             throw new IllegalArgumentException();
 109         }
 110         this.api = api;
 111         this.cv = cv;
 112     }
 113 
 114     /**
 115      * Visits the header of the class.
 116      *
 117      * @param version
 118      *            the class version.
 119      * @param access
 120      *            the class's access flags (see {@link Opcodes}). This parameter
 121      *            also indicates if the class is deprecated.
 122      * @param name
 123      *            the internal name of the class (see
 124      *            {@link Type#getInternalName() getInternalName}).
 125      * @param signature
 126      *            the signature of this class. May be <tt>null</tt> if the class
 127      *            is not a generic one, and does not extend or implement generic


 143         }
 144     }
 145 
 146     /**
 147      * Visits the source of the class.
 148      *
 149      * @param source
 150      *            the name of the source file from which the class was compiled.
 151      *            May be <tt>null</tt>.
 152      * @param debug
 153      *            additional debug information to compute the correspondance
 154      *            between source and compiled elements of the class. May be
 155      *            <tt>null</tt>.
 156      */
 157     public void visitSource(String source, String debug) {
 158         if (cv != null) {
 159             cv.visitSource(source, debug);
 160         }
 161     }
 162 
 163     /**
 164      * Visit the module corresponding to the class.
 165      * @param name
 166      *            module name
 167      * @param access
 168      *            module flags, among {@code ACC_OPEN}, {@code ACC_SYNTHETIC}
 169      *            and {@code ACC_MANDATED}.
 170      * @param version
 171      *            module version or null.
 172      * @return a visitor to visit the module values, or <tt>null</tt> if
 173      *         this visitor is not interested in visiting this module.
 174      */
 175     public ModuleVisitor visitModule(String name, int access, String version) {
 176         if (api < Opcodes.ASM6) {
 177             throw new RuntimeException();
 178         }
 179         if (cv != null) {
 180             return cv.visitModule(name, access, version);
 181         }
 182         return null;
 183     }
 184 
 185     /**
 186      * Visits the enclosing class of the class. This method must be called only
 187      * if the class has an enclosing class.
 188      *
 189      * @param owner
 190      *            internal name of the enclosing class of the class.
 191      * @param name
 192      *            the name of the method that contains the class, or
 193      *            <tt>null</tt> if the class is not enclosed in a method of its
 194      *            enclosing class.
 195      * @param desc
 196      *            the descriptor of the method that contains the class, or
 197      *            <tt>null</tt> if the class is not enclosed in a method of its
 198      *            enclosing class.
 199      */
 200     public void visitOuterClass(String owner, String name, String desc) {
 201         if (cv != null) {
 202             cv.visitOuterClass(owner, name, desc);
 203         }
 204     }


< prev index next >