001: /***
002: * ASM: a very small and fast Java bytecode manipulation framework
003: * Copyright (c) 2000-2005 INRIA, France Telecom
004: * All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions
008: * are met:
009: * 1. Redistributions of source code must retain the above copyright
010: * notice, this list of conditions and the following disclaimer.
011: * 2. Redistributions in binary form must reproduce the above copyright
012: * notice, this list of conditions and the following disclaimer in the
013: * documentation and/or other materials provided with the distribution.
014: * 3. Neither the name of the copyright holders nor the names of its
015: * contributors may be used to endorse or promote products derived from
016: * this software without specific prior written permission.
017: *
018: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
021: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
022: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
023: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
024: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
025: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
026: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
027: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
028: * THE POSSIBILITY OF SUCH DAMAGE.
029: */package com.uwyn.rife.asm;
030:
031: /**
032: * A visitor to visit a Java class. The methods of this interface must be called
033: * in the following order: <tt>visit</tt> [ <tt>visitSource</tt> ] [
034: * <tt>visitOuterClass</tt> ] ( <tt>visitAnnotation</tt> |
035: * <tt>visitAttribute</tt> )* (<tt>visitInnerClass</tt> |
036: * <tt>visitField</tt> | <tt>visitMethod</tt> )* <tt>visitEnd</tt>.
037: *
038: * @author Eric Bruneton
039: */
040: public interface ClassVisitor {
041:
042: /**
043: * Visits the header of the class.
044: *
045: * @param version the class version.
046: * @param access the class's access flags (see {@link Opcodes}). This
047: * parameter also indicates if the class is deprecated.
048: * @param name the internal name of the class (see
049: * {@link Type#getInternalName() getInternalName}).
050: * @param signature the signature of this class. May be <tt>null</tt> if
051: * the class is not a generic one, and does not extend or implement
052: * generic classes or interfaces.
053: * @param superName the internal of name of the super class (see
054: * {@link Type#getInternalName() getInternalName}). For interfaces,
055: * the super class is {@link Object}. May be <tt>null</tt>, but
056: * only for the {@link Object} class.
057: * @param interfaces the internal names of the class's interfaces (see
058: * {@link Type#getInternalName() getInternalName}). May be
059: * <tt>null</tt>.
060: */
061: void visit(int version, int access, String name, String signature,
062: String super Name, String[] interfaces);
063:
064: /**
065: * Visits the source of the class.
066: *
067: * @param source the name of the source file from which the class was
068: * compiled. May be <tt>null</tt>.
069: * @param debug additional debug information to compute the correspondance
070: * between source and compiled elements of the class. May be
071: * <tt>null</tt>.
072: */
073: void visitSource(String source, String debug);
074:
075: /**
076: * Visits the enclosing class of the class. This method must be called only
077: * if the class has an enclosing class.
078: *
079: * @param owner internal name of the enclosing class of the class.
080: * @param name the name of the method that contains the class, or
081: * <tt>null</tt> if the class is not enclosed in a method of its
082: * enclosing class.
083: * @param desc the descriptor of the method that contains the class, or
084: * <tt>null</tt> if the class is not enclosed in a method of its
085: * enclosing class.
086: */
087: void visitOuterClass(String owner, String name, String desc);
088:
089: /**
090: * Visits an annotation of the class.
091: *
092: * @param desc the class descriptor of the annotation class.
093: * @param visible <tt>true</tt> if the annotation is visible at runtime.
094: * @return a non null visitor to visit the annotation values.
095: */
096: AnnotationVisitor visitAnnotation(String desc, boolean visible);
097:
098: /**
099: * Visits a non standard attribute of the class.
100: *
101: * @param attr an attribute.
102: */
103: void visitAttribute(Attribute attr);
104:
105: /**
106: * Visits information about an inner class. This inner class is not
107: * necessarily a member of the class being visited.
108: *
109: * @param name the internal name of an inner class (see
110: * {@link Type#getInternalName() getInternalName}).
111: * @param outerName the internal name of the class to which the inner class
112: * belongs (see {@link Type#getInternalName() getInternalName}). May
113: * be <tt>null</tt>.
114: * @param innerName the (simple) name of the inner class inside its
115: * enclosing class. May be <tt>null</tt> for anonymous inner
116: * classes.
117: * @param access the access flags of the inner class as originally declared
118: * in the enclosing class.
119: */
120: void visitInnerClass(String name, String outerName,
121: String innerName, int access);
122:
123: /**
124: * Visits a field of the class.
125: *
126: * @param access the field's access flags (see {@link Opcodes}). This
127: * parameter also indicates if the field is synthetic and/or
128: * deprecated.
129: * @param name the field's name.
130: * @param desc the field's descriptor (see {@link Type Type}).
131: * @param signature the field's signature. May be <tt>null</tt> if the
132: * field's type does not use generic types.
133: * @param value the field's initial value. This parameter, which may be
134: * <tt>null</tt> if the field does not have an initial value, must
135: * be an {@link Integer}, a {@link Float}, a {@link Long}, a
136: * {@link Double} or a {@link String} (for <tt>int</tt>,
137: * <tt>float</tt>, <tt>long</tt> or <tt>String</tt> fields
138: * respectively). <i>This parameter is only used for static fields</i>.
139: * Its value is ignored for non static fields, which must be
140: * initialized through bytecode instructions in constructors or
141: * methods.
142: * @return a visitor to visit field annotations and attributes, or
143: * <tt>null</tt> if this class visitor is not interested in
144: * visiting these annotations and attributes.
145: */
146: FieldVisitor visitField(int access, String name, String desc,
147: String signature, Object value);
148:
149: /**
150: * Visits a method of the class. This method <i>must</i> return a new
151: * {@link MethodVisitor} instance (or <tt>null</tt>) each time it is
152: * called, i.e., it should not return a previously returned visitor.
153: *
154: * @param access the method's access flags (see {@link Opcodes}). This
155: * parameter also indicates if the method is synthetic and/or
156: * deprecated.
157: * @param name the method's name.
158: * @param desc the method's descriptor (see {@link Type Type}).
159: * @param signature the method's signature. May be <tt>null</tt> if the
160: * method parameters, return type and exceptions do not use generic
161: * types.
162: * @param exceptions the internal names of the method's exception classes
163: * (see {@link Type#getInternalName() getInternalName}). May be
164: * <tt>null</tt>.
165: * @return an object to visit the byte code of the method, or <tt>null</tt>
166: * if this class visitor is not interested in visiting the code of
167: * this method.
168: */
169: MethodVisitor visitMethod(int access, String name, String desc,
170: String signature, String[] exceptions);
171:
172: /**
173: * Visits the end of the class. This method, which is the last one to be
174: * called, is used to inform the visitor that all the fields and methods of
175: * the class have been visited.
176: */
177: void visitEnd();
178: }
|