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 org.ejb3unit.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
046: * the class version.
047: * @param access
048: * the class's access flags (see {@link Opcodes}). This
049: * parameter also indicates if the class is deprecated.
050: * @param name
051: * the internal name of the class (see
052: * {@link Type#getInternalName() getInternalName}).
053: * @param signature
054: * the signature of this class. May be <tt>null</tt> if the
055: * class is not a generic one, and does not extend or implement
056: * generic classes or interfaces.
057: * @param superName
058: * the internal of name of the super class (see
059: * {@link Type#getInternalName() getInternalName}). For
060: * interfaces, the super class is {@link Object}. May be
061: * <tt>null</tt>, but only for the {@link Object} class.
062: * @param interfaces
063: * the internal names of the class's interfaces (see
064: * {@link Type#getInternalName() getInternalName}). May be
065: * <tt>null</tt>.
066: */
067: void visit(int version, int access, String name, String signature,
068: String super Name, String[] interfaces);
069:
070: /**
071: * Visits the source of the class.
072: *
073: * @param source
074: * the name of the source file from which the class was compiled.
075: * May be <tt>null</tt>.
076: * @param debug
077: * additional debug information to compute the correspondance
078: * between source and compiled elements of the class. May be
079: * <tt>null</tt>.
080: */
081: void visitSource(String source, String debug);
082:
083: /**
084: * Visits the enclosing class of the class. This method must be called only
085: * if the class has an enclosing class.
086: *
087: * @param owner
088: * internal name of the enclosing class of the class.
089: * @param name
090: * the name of the method that contains the class, or
091: * <tt>null</tt> if the class is not enclosed in a method of
092: * its enclosing class.
093: * @param desc
094: * the descriptor of the method that contains the class, or
095: * <tt>null</tt> if the class is not enclosed in a method of
096: * its enclosing class.
097: */
098: void visitOuterClass(String owner, String name, String desc);
099:
100: /**
101: * Visits an annotation of the class.
102: *
103: * @param desc
104: * the class descriptor of the annotation class.
105: * @param visible
106: * <tt>true</tt> if the annotation is visible at runtime.
107: * @return a visitor to visit the annotation values, or <tt>null</tt> if
108: * this visitor is not interested in visiting this annotation.
109: */
110: AnnotationVisitor visitAnnotation(String desc, boolean visible);
111:
112: /**
113: * Visits a non standard attribute of the class.
114: *
115: * @param attr
116: * an attribute.
117: */
118: void visitAttribute(Attribute attr);
119:
120: /**
121: * Visits information about an inner class. This inner class is not
122: * necessarily a member of the class being visited.
123: *
124: * @param name
125: * the internal name of an inner class (see
126: * {@link Type#getInternalName() getInternalName}).
127: * @param outerName
128: * the internal name of the class to which the inner class
129: * belongs (see {@link Type#getInternalName() getInternalName}).
130: * May be <tt>null</tt> for not member classes.
131: * @param innerName
132: * the (simple) name of the inner class inside its enclosing
133: * class. May be <tt>null</tt> for anonymous inner classes.
134: * @param access
135: * the access flags of the inner class as originally declared in
136: * the enclosing class.
137: */
138: void visitInnerClass(String name, String outerName,
139: String innerName, int access);
140:
141: /**
142: * Visits a field of the class.
143: *
144: * @param access
145: * the field's access flags (see {@link Opcodes}). This
146: * parameter also indicates if the field is synthetic and/or
147: * deprecated.
148: * @param name
149: * the field's name.
150: * @param desc
151: * the field's descriptor (see {@link Type Type}).
152: * @param signature
153: * the field's signature. May be <tt>null</tt> if the field's
154: * type does not use generic types.
155: * @param value
156: * the field's initial value. This parameter, which may be
157: * <tt>null</tt> if the field does not have an initial value,
158: * must be an {@link Integer}, a {@link Float}, a {@link Long},
159: * a {@link Double} or a {@link String} (for <tt>int</tt>,
160: * <tt>float</tt>, <tt>long</tt> or <tt>String</tt> fields
161: * respectively). <i>This parameter is only used for static
162: * fields</i>. Its value is ignored for non static fields, which
163: * must be initialized through bytecode instructions in
164: * constructors or methods.
165: * @return a visitor to visit field annotations and attributes, or
166: * <tt>null</tt> if this class visitor is not interested in
167: * visiting these annotations and attributes.
168: */
169: FieldVisitor visitField(int access, String name, String desc,
170: String signature, Object value);
171:
172: /**
173: * Visits a method of the class. This method <i>must</i> return a new
174: * {@link MethodVisitor} instance (or <tt>null</tt>) each time it is
175: * called, i.e., it should not return a previously returned visitor.
176: *
177: * @param access
178: * the method's access flags (see {@link Opcodes}). This
179: * parameter also indicates if the method is synthetic and/or
180: * deprecated.
181: * @param name
182: * the method's name.
183: * @param desc
184: * the method's descriptor (see {@link Type Type}).
185: * @param signature
186: * the method's signature. May be <tt>null</tt> if the method
187: * parameters, return type and exceptions do not use generic
188: * types.
189: * @param exceptions
190: * the internal names of the method's exception classes (see
191: * {@link Type#getInternalName() getInternalName}). May be
192: * <tt>null</tt>.
193: * @return an object to visit the byte code of the method, or <tt>null</tt>
194: * if this class visitor is not interested in visiting the code of
195: * this method.
196: */
197: MethodVisitor visitMethod(int access, String name, String desc,
198: String signature, String[] exceptions);
199:
200: /**
201: * Visits the end of the class. This method, which is the last one to be
202: * called, is used to inform the visitor that all the fields and methods of
203: * the class have been visited.
204: */
205: void visitEnd();
206: }
|