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.mvel.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 visitor to visit the annotation values, or <tt>null</tt> if
095: * this visitor is not interested in visiting this annotation.
096: */
097: AnnotationVisitor visitAnnotation(String desc, boolean visible);
098:
099: /**
100: * Visits a non standard attribute of the class.
101: *
102: * @param attr an attribute.
103: */
104: void visitAttribute(Attribute attr);
105:
106: /**
107: * Visits information about an inner class. This inner class is not
108: * necessarily a member of the class being visited.
109: *
110: * @param name the internal name of an inner class (see
111: * {@link Type#getInternalName() getInternalName}).
112: * @param outerName the internal name of the class to which the inner class
113: * belongs (see {@link Type#getInternalName() getInternalName}). May
114: * be <tt>null</tt> for not member classes.
115: * @param innerName the (simple) name of the inner class inside its
116: * enclosing class. May be <tt>null</tt> for anonymous inner
117: * classes.
118: * @param access the access flags of the inner class as originally declared
119: * in the enclosing class.
120: */
121: void visitInnerClass(String name, String outerName,
122: String innerName, int access);
123:
124: /**
125: * Visits a field of the class.
126: *
127: * @param access the field's access flags (see {@link Opcodes}). This
128: * parameter also indicates if the field is synthetic and/or
129: * deprecated.
130: * @param name the field's name.
131: * @param desc the field's descriptor (see {@link Type Type}).
132: * @param signature the field's signature. May be <tt>null</tt> if the
133: * field's type does not use generic types.
134: * @param value the field's initial value. This parameter, which may be
135: * <tt>null</tt> if the field does not have an initial value, must
136: * be an {@link Integer}, a {@link Float}, a {@link Long}, a
137: * {@link Double} or a {@link String} (for <tt>int</tt>,
138: * <tt>float</tt>, <tt>long</tt> or <tt>String</tt> fields
139: * respectively). <i>This parameter is only used for static fields</i>.
140: * Its value is ignored for non static fields, which must be
141: * initialized through bytecode instructions in constructors or
142: * methods.
143: * @return a visitor to visit field annotations and attributes, or
144: * <tt>null</tt> if this class visitor is not interested in
145: * visiting these annotations and attributes.
146: */
147: FieldVisitor visitField(int access, String name, String desc,
148: String signature, Object value);
149:
150: /**
151: * Visits a method of the class. This method <i>must</i> return a new
152: * {@link MethodVisitor} instance (or <tt>null</tt>) each time it is
153: * called, i.e., it should not return a previously returned visitor.
154: *
155: * @param access the method's access flags (see {@link Opcodes}). This
156: * parameter also indicates if the method is synthetic and/or
157: * deprecated.
158: * @param name the method's name.
159: * @param desc the method's descriptor (see {@link Type Type}).
160: * @param signature the method's signature. May be <tt>null</tt> if the
161: * method parameters, return type and exceptions do not use generic
162: * types.
163: * @param exceptions the internal names of the method's exception classes
164: * (see {@link Type#getInternalName() getInternalName}). May be
165: * <tt>null</tt>.
166: * @return an object to visit the byte code of the method, or <tt>null</tt>
167: * if this class visitor is not interested in visiting the code of
168: * this method.
169: */
170: MethodVisitor visitMethod(int access, String name, String desc,
171: String signature, String[] exceptions);
172:
173: /**
174: * Visits the end of the class. This method, which is the last one to be
175: * called, is used to inform the visitor that all the fields and methods of
176: * the class have been visited.
177: */
178: void visitEnd();
179: }
|