svn commit: r411580 [1/2] - in /jakarta/bcel/trunk/src: main/java/org/apache/bcel/ main/java/org/apache/bcel/classfile/ test/java/ test/java/org/ test/java/org/apache/ test/java/org/apache/bcel/ test/java/org/apache/bcel/data/ test/java/org/apache/bcel...

[email protected]
Newsgroups gmane.comp.jakarta.bcel.devel
Message-ID <[email protected]>
Author: tcurdt
Date: Sun Jun  4 08:52:18 2006
New Revision: 411580

URL: http://svn.apache.org/viewvc?rev=411580&view=rev
Log:
GSoC port to maven2, first code changes by Dmitriy Khayredinov


Added:
    jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/EnclosingMethod.java   (with props)
    jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/LocalVariableTypeTable.java   (with props)
    jakarta/bcel/trunk/src/test/java/
    jakarta/bcel/trunk/src/test/java/org/
    jakarta/bcel/trunk/src/test/java/org/apache/
    jakarta/bcel/trunk/src/test/java/org/apache/bcel/
    jakarta/bcel/trunk/src/test/java/org/apache/bcel/AbstractCounterVisitorTestCase.java   (with props)
    jakarta/bcel/trunk/src/test/java/org/apache/bcel/CounterVisitorTestCase.java   (with props)
    jakarta/bcel/trunk/src/test/java/org/apache/bcel/data/
    jakarta/bcel/trunk/src/test/java/org/apache/bcel/data/MarkedType.java   (with props)
    jakarta/bcel/trunk/src/test/java/org/apache/bcel/data/MarkerAnnotation.java   (with props)
    jakarta/bcel/trunk/src/test/java/org/apache/bcel/data/MarkerAnnotationInvisible.java   (with props)
    jakarta/bcel/trunk/src/test/java/org/apache/bcel/data/SimpleAnnotation.java   (with props)
    jakarta/bcel/trunk/src/test/java/org/apache/bcel/data/package-info.java   (with props)
    jakarta/bcel/trunk/src/test/java/org/apache/bcel/visitors/
    jakarta/bcel/trunk/src/test/java/org/apache/bcel/visitors/CounterVisitor.java   (with props)
Modified:
    jakarta/bcel/trunk/src/main/java/org/apache/bcel/Constants.java
    jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/AnnotationDefault.java
    jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/AnnotationEntry.java
    jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/Annotations.java
    jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/Attribute.java
    jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/DescendingVisitor.java
    jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/ElementValue.java
    jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/ElementValuePair.java
    jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/EmptyVisitor.java
    jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/ParameterAnnotationEntry.java
    jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/ParameterAnnotations.java
    jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/RuntimeInvisibleAnnotations.java
    jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/RuntimeInvisibleParameterAnnotations.java
    jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/RuntimeVisibleAnnotations.java
    jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/RuntimeVisibleParameterAnnotations.java
    jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/Visitor.java

Modified: jakarta/bcel/trunk/src/main/java/org/apache/bcel/Constants.java
URL: http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/main/java/org/apache/bcel/Constants.java?rev=411580&r1=411579&r2=411580&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/main/java/org/apache/bcel/Constants.java (original)
+++ jakarta/bcel/trunk/src/main/java/org/apache/bcel/Constants.java Sun Jun  4 08:52:18 2006
@@ -35,6 +35,8 @@
   public final static short MINOR_1_4 = 0;
   public final static short MAJOR_1_5 = 49;
   public final static short MINOR_1_5 = 0;
+  public final static short MAJOR_1_6 = 50;
+  public final static short MINOR_1_6 = 0;
   public final static short MAJOR     = MAJOR_1_1; // Defaults
   public final static short MINOR     = MINOR_1_1;
 
@@ -55,6 +57,7 @@
 
   public final static short ACC_FINAL        = 0x0010;
   public final static short ACC_SYNCHRONIZED = 0x0020;
+  public final static short ACC_SYPER        = 0x0020;
   public final static short ACC_VOLATILE     = 0x0040;
   public final static short ACC_BRIDGE       = 0x0040;
   public final static short ACC_TRANSIENT    = 0x0080;
@@ -729,14 +732,17 @@
   public static final byte ATTR_PMG                           			= 9;
   public static final byte ATTR_SIGNATURE                     			= 10;
   public static final byte ATTR_STACK_MAP                     			= 11;
-  public static final byte ATTR_RUNTIMEVISIBLE_ANNOTATIONS    			= 12;
-  public static final byte ATTR_RUNTIMEINVISIBLE_ANNOTATIONS  			= 13;
-  public static final byte ATTR_RUNTIMEVISIBLE_PARAMETER_ANNOTATIONS 	= 14;
-  public static final byte ATTR_RUNTIMEINVISIBLE_PARAMETER_ANNOTATIONS 	= 15;
+  public static final byte ATTR_RUNTIME_VISIBLE_ANNOTATIONS    			= 12;
+  public static final byte ATTR_RUNTIMEIN_VISIBLE_ANNOTATIONS  			= 13;
+  public static final byte ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS 	= 14;
+  public static final byte ATTR_RUNTIMEIN_VISIBLE_PARAMETER_ANNOTATIONS = 15;
   public static final byte ATTR_ANNOTATION_DEFAULT                      = 16;
+  public static final byte ATTR_LOCAL_VARIABLE_TYPE_TABLE               = 17;
+  public static final byte ATTR_ENCLOSING_METHOD                      	= 18;
 
-  public static final short KNOWN_ATTRIBUTES = 12;//should be 17
+  public static final short KNOWN_ATTRIBUTES = 19;
 
+  // TOFO: FIXXXXX
   public static final String[] ATTRIBUTE_NAMES = {
     "SourceFile", "ConstantValue", "Code", "Exceptions",
     "LineNumberTable", "LocalVariableTable",
@@ -744,7 +750,7 @@
     "PMGClass", "Signature", "StackMap", 
     "RuntimeVisibleAnnotations", "RuntimeInvisibleAnnotations",
     "RuntimeVisibleParameterAnnotations", "RuntimeInvisibleParameterAnnotations",
-    "AnnotationDefault"
+    "AnnotationDefault", "LocalVariableTypeTable", "EnclosingMethod"
   };
 
   /** Constants used in the StackMap attribute.

Modified: jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/AnnotationDefault.java
URL: http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/AnnotationDefault.java?rev=411580&r1=411579&r2=411580&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/AnnotationDefault.java (original)
+++ jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/AnnotationDefault.java Sun Jun  4 08:52:18 2006
@@ -1,88 +1,108 @@
-/*
- * Copyright  2000-2004 The Apache Software Foundation
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
-package org.apache.bcel.classfile;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-
-/**
- * represents the default value of a annotation for a method info
- * 
- * @version $Id: AnnotationDefault 1 2005-02-13 03:15:08Z dbrosius $
- * @author  <A HREF="mailto:[email protected]">D. Brosius</A>
- * @since 5.2
- */
-public abstract class AnnotationDefault extends Attribute {
-
-    ElementValue default_value;
-
-
-    /**
-     * @param annotation_type the subclass type of the annotation
-     * @param name_index Index pointing to the name <em>Code</em>
-     * @param length Content length in bytes
-     * @param file Input stream
-     * @param constant_pool Array of constants
-     */
-    AnnotationDefault(byte annotation_type, int name_index, int length, DataInputStream file,
-            ConstantPool constant_pool) throws IOException {
-        this(annotation_type, name_index, length, (ElementValue) null, constant_pool);
-        default_value = new ElementValue(file, constant_pool);
-    }
-
-
-    /**
-     * @param annotation_type the subclass type of the annotation
-     * @param name_index Index pointing to the name <em>Code</em>
-     * @param length Content length in bytes
-     * @param defaultValue the annotation's default value
-     * @param constant_pool Array of constants
-     */
-    public AnnotationDefault(byte annotation_type, int name_index, int length,
-            ElementValue defaultValue, ConstantPool constant_pool) {
-        super(annotation_type, name_index, length, constant_pool);
-        setDefaultValue(defaultValue);
-    }
-
-
-    /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
-     *
-     * @param v Visitor object
-     */
-    public void accept( Visitor v ) {
-        //	    v.visitAnnotationDefault(this);
-    }
-
-
-    /**
-     * @param defaultValue the default value of this methodinfo's annotation
-     */
-    public final void setDefaultValue( ElementValue defaultValue ) {
-        default_value = defaultValue;
-    }
-
-
-    /**
-     * @return the default value
-     */
-    public final ElementValue getDefaultValue() {
-        return default_value;
-    }
-}
+/*
+ * Copyright  2000-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.bcel.classfile;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import org.apache.bcel.Constants;
+
+/**
+ * represents the default value of a annotation for a method info
+ * 
+ * @version $Id: AnnotationDefault 1 2005-02-13 03:15:08Z dbrosius $
+ * @author <A HREF="mailto:[email protected]">D. Brosius</A>
+ * @since 5.2
+ */
+public class AnnotationDefault extends Attribute
+{
+	ElementValue default_value;
+
+	/**
+	 * @param annotation_type
+	 *            the subclass type of the annotation
+	 * @param name_index
+	 *            Index pointing to the name <em>Code</em>
+	 * @param length
+	 *            Content length in bytes
+	 * @param file
+	 *            Input stream
+	 * @param constant_pool
+	 *            Array of constants
+	 */
+	public AnnotationDefault(int name_index, int length,
+			DataInputStream file, ConstantPool constant_pool)
+			throws IOException
+	{
+		this(name_index, length, (ElementValue) null,
+				constant_pool);
+		default_value = new ElementValue(file, constant_pool);
+	}
+
+	/**
+	 * @param annotation_type
+	 *            the subclass type of the annotation
+	 * @param name_index
+	 *            Index pointing to the name <em>Code</em>
+	 * @param length
+	 *            Content length in bytes
+	 * @param defaultValue
+	 *            the annotation's default value
+	 * @param constant_pool
+	 *            Array of constants
+	 */
+	public AnnotationDefault(int name_index, int length,
+			ElementValue defaultValue, ConstantPool constant_pool)
+	{
+		super(Constants.ATTR_ANNOTATION_DEFAULT, name_index, length, constant_pool);
+		setDefaultValue(defaultValue);
+	}
+
+	/**
+	 * Called by objects that are traversing the nodes of the tree implicitely
+	 * defined by the contents of a Java class. I.e., the hierarchy of methods,
+	 * fields, attributes, etc. spawns a tree of objects.
+	 * 
+	 * @param v
+	 *            Visitor object
+	 */
+	public void accept(Visitor v)
+	{
+		// v.visitAnnotationDefault(this);
+	}
+
+	/**
+	 * @param defaultValue
+	 *            the default value of this methodinfo's annotation
+	 */
+	public final void setDefaultValue(ElementValue defaultValue)
+	{
+		default_value = defaultValue;
+	}
+
+	/**
+	 * @return the default value
+	 */
+	public final ElementValue getDefaultValue()
+	{
+		return default_value;
+	}
+
+	public Attribute copy(ConstantPool _constant_pool)
+	{
+		throw new RuntimeException("Not implemented yet!");
+	}
+}

Modified: jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/AnnotationEntry.java
URL: http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/AnnotationEntry.java?rev=411580&r1=411579&r2=411580&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/AnnotationEntry.java (original)
+++ jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/AnnotationEntry.java Sun Jun  4 08:52:18 2006
@@ -1,90 +1,90 @@
-/*
- * Copyright  2000-2004 The Apache Software Foundation
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
-package org.apache.bcel.classfile;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-import org.apache.bcel.Constants;
-
-/**
- * represents one annotation in the annotation table
- * 
- * @version $Id: AnnotationEntry
- * @author  <A HREF="mailto:[email protected]">D. Brosius</A>
- * @since 5.2
- */
-public class AnnotationEntry implements Node, Constants {
-
-    private int type_index;
-    private int num_element_value_pairs;
-    private ElementValuePair[] element_value_pairs;
-    private ConstantPool constant_pool;
-
-
-    /**
-     * Construct object from file stream.
-     * @param file Input stream
-     * @throws IOException
-     */
-    AnnotationEntry(DataInputStream file, ConstantPool constant_pool) throws IOException {
-        type_index = (file.readUnsignedShort());
-        num_element_value_pairs = (file.readUnsignedShort());
-        element_value_pairs = new ElementValuePair[num_element_value_pairs];
-        for (int i = 0; i < num_element_value_pairs; i++) {
-            element_value_pairs[i] = new ElementValuePair(file, constant_pool);
-        }
-        this.constant_pool = constant_pool;
-    }
-
-
-    /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
-     *
-     * @param v Visitor object
-     */
-    public void accept( Visitor v ) {
-        //	    v.visitAnnotationEntry(this);
-    }
-
-
-    /**
-     * @return the annotation type name
-     */
-    public String getAnnotationType() {
-        ConstantUtf8 c;
-        c = (ConstantUtf8) constant_pool.getConstant(type_index, CONSTANT_Utf8);
-        return c.getBytes();
-    }
-
-
-    /**
-     * @return the number of element value pairs in this annotation entry
-     */
-    public final int getNumElementValuePairs() {
-        return num_element_value_pairs;
-    }
-
-
-    /**
-     * @return the element value pairs in this annotation entry
-     */
-    public ElementValuePair[] getElementValuePairs() {
-        return element_value_pairs;
-    }
-}
+/*
+ * Copyright  2000-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.bcel.classfile;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import org.apache.bcel.Constants;
+
+/**
+ * represents one annotation in the annotation table
+ * 
+ * @version $Id: AnnotationEntry
+ * @author  <A HREF="mailto:[email protected]">D. Brosius</A>
+ * @since 5.2
+ */
+public class AnnotationEntry implements Node, Constants {
+
+    private int type_index;
+    private int num_element_value_pairs;
+    private ElementValuePair[] element_value_pairs;
+    private ConstantPool constant_pool;
+
+
+    /**
+     * Construct object from file stream.
+     * @param file Input stream
+     * @throws IOException
+     */
+    AnnotationEntry(DataInputStream file, ConstantPool constant_pool) throws IOException {
+        type_index = (file.readUnsignedShort());
+        num_element_value_pairs = (file.readUnsignedShort());
+        element_value_pairs = new ElementValuePair[num_element_value_pairs];
+        for (int i = 0; i < num_element_value_pairs; i++) {
+            element_value_pairs[i] = new ElementValuePair(file, constant_pool);
+        }
+        this.constant_pool = constant_pool;
+    }
+
+
+    /**
+     * Called by objects that are traversing the nodes of the tree implicitely
+     * defined by the contents of a Java class. I.e., the hierarchy of methods,
+     * fields, attributes, etc. spawns a tree of objects.
+     *
+     * @param v Visitor object
+     */
+    public void accept( Visitor v ) {
+        //	    v.visitAnnotationEntry(this);
+    }
+
+
+    /**
+     * @return the annotation type name
+     */
+    public String getAnnotationType() {
+        ConstantUtf8 c;
+        c = (ConstantUtf8) constant_pool.getConstant(type_index, CONSTANT_Utf8);
+        return c.getBytes();
+    }
+
+
+    /**
+     * @return the number of element value pairs in this annotation entry
+     */
+    public final int getNumElementValuePairs() {
+        return num_element_value_pairs;
+    }
+
+
+    /**
+     * @return the element value pairs in this annotation entry
+     */
+    public ElementValuePair[] getElementValuePairs() {
+        return element_value_pairs;
+    }
+}

Modified: jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/Annotations.java
URL: http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/Annotations.java?rev=411580&r1=411579&r2=411580&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/Annotations.java (original)
+++ jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/Annotations.java Sun Jun  4 08:52:18 2006
@@ -1,110 +1,110 @@
-/*
- * Copyright  2000-2004 The Apache Software Foundation
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
-package org.apache.bcel.classfile;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-
-/**
- * base class for annotations
- * 
- * @version $Id: Annotations
- * @author  <A HREF="mailto:[email protected]">D. Brosius</A>
- * @since 5.2
- */
-public abstract class Annotations extends Attribute {
-
-    private int annotation_table_length;
-    private AnnotationEntry[] annotation_table; // Table of annotations
-
-
-    /**
-     * @param annotation_type the subclass type of the annotation
-     * @param name_index Index pointing to the name <em>Code</em>
-     * @param length Content length in bytes
-     * @param file Input stream
-     * @param constant_pool Array of constants
-     */
-    Annotations(byte annotation_type, int name_index, int length, DataInputStream file,
-            ConstantPool constant_pool) throws IOException {
-        this(annotation_type, name_index, length, (AnnotationEntry[]) null, constant_pool);
-        annotation_table_length = (file.readUnsignedShort());
-        annotation_table = new AnnotationEntry[annotation_table_length];
-        for (int i = 0; i < annotation_table_length; i++) {
-            annotation_table[i] = new AnnotationEntry(file, constant_pool);
-        }
-    }
-
-
-    /**
-     * @param annotation_type the subclass type of the annotation
-     * @param name_index Index pointing to the name <em>Code</em>
-     * @param length Content length in bytes
-     * @param annotation_table the actual annotations
-     * @param constant_pool Array of constants
-     */
-    public Annotations(byte annotation_type, int name_index, int length,
-            AnnotationEntry[] annotation_table, ConstantPool constant_pool) {
-        super(annotation_type, name_index, length, constant_pool);
-        setAnnotationTable(annotation_table);
-    }
-
-
-    /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
-     *
-     * @param v Visitor object
-     */
-    public void accept( Visitor v ) {
-        //	    v.visitAnnotation(this);
-    }
-
-
-    /**
-     * @param annotation_table the entries to set in this annotation
-     */
-    public final void setAnnotationTable( AnnotationEntry[] annotation_table ) {
-        this.annotation_table = annotation_table;
-        annotation_table_length = (annotation_table == null) ? 0 : annotation_table.length;
-    }
-
-
-    /**
-     * @return the annotation entry table
-     */
-    public final AnnotationEntry[] getAnnotationTable() {
-        return annotation_table;
-    }
-
-
-    /**
-     * returns the array of annotation entries in this annotation
-     */
-    public AnnotationEntry[] getAnnotationEntries() {
-        return annotation_table;
-    }
-
-
-    /**
-     * @return the number of annotation entries in this annotation
-     */
-    public final int getNumAnnotations() {
-        return annotation_table_length;
-    }
-}
+/*
+ * Copyright  2000-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.bcel.classfile;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+
+/**
+ * base class for annotations
+ * 
+ * @version $Id: Annotations
+ * @author  <A HREF="mailto:[email protected]">D. Brosius</A>
+ * @since 5.2
+ */
+public abstract class Annotations extends Attribute {
+
+    private int annotation_table_length;
+    private AnnotationEntry[] annotation_table; // Table of annotations
+
+
+    /**
+     * @param annotation_type the subclass type of the annotation
+     * @param name_index Index pointing to the name <em>Code</em>
+     * @param length Content length in bytes
+     * @param file Input stream
+     * @param constant_pool Array of constants
+     */
+    Annotations(byte annotation_type, int name_index, int length, DataInputStream file,
+            ConstantPool constant_pool) throws IOException {
+        this(annotation_type, name_index, length, (AnnotationEntry[]) null, constant_pool);
+        annotation_table_length = (file.readUnsignedShort());
+        annotation_table = new AnnotationEntry[annotation_table_length];
+        for (int i = 0; i < annotation_table_length; i++) {
+            annotation_table[i] = new AnnotationEntry(file, constant_pool);
+        }
+    }
+
+
+    /**
+     * @param annotation_type the subclass type of the annotation
+     * @param name_index Index pointing to the name <em>Code</em>
+     * @param length Content length in bytes
+     * @param annotation_table the actual annotations
+     * @param constant_pool Array of constants
+     */
+    public Annotations(byte annotation_type, int name_index, int length,
+            AnnotationEntry[] annotation_table, ConstantPool constant_pool) {
+        super(annotation_type, name_index, length, constant_pool);
+        setAnnotationTable(annotation_table);
+    }
+
+
+    /**
+     * Called by objects that are traversing the nodes of the tree implicitely
+     * defined by the contents of a Java class. I.e., the hierarchy of methods,
+     * fields, attributes, etc. spawns a tree of objects.
+     *
+     * @param v Visitor object
+     */
+    public void accept( Visitor v ) {
+        v.visitAnnotation(this);
+    }
+
+
+    /**
+     * @param annotation_table the entries to set in this annotation
+     */
+    public final void setAnnotationTable( AnnotationEntry[] annotation_table ) {
+        this.annotation_table = annotation_table;
+        annotation_table_length = (annotation_table == null) ? 0 : annotation_table.length;
+    }
+
+
+    /**
+     * @return the annotation entry table
+     */
+    public final AnnotationEntry[] getAnnotationTable() {
+        return annotation_table;
+    }
+
+
+    /**
+     * returns the array of annotation entries in this annotation
+     */
+    public AnnotationEntry[] getAnnotationEntries() {
+        return annotation_table;
+    }
+
+
+    /**
+     * @return the number of annotation entries in this annotation
+     */
+    public final int getNumAnnotations() {
+        return annotation_table_length;
+    }
+}

Modified: jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/Attribute.java
URL: http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/Attribute.java?rev=411580&r1=411579&r2=411580&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/Attribute.java (original)
+++ jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/Attribute.java Sun Jun  4 08:52:18 2006
@@ -27,252 +27,284 @@
 /**
  * Abstract super class for <em>Attribute</em> objects. Currently the
  * <em>ConstantValue</em>, <em>SourceFile</em>, <em>Code</em>,
- * <em>Exceptiontable</em>, <em>LineNumberTable</em>, 
+ * <em>Exceptiontable</em>, <em>LineNumberTable</em>,
  * <em>LocalVariableTable</em>, <em>InnerClasses</em> and
- * <em>Synthetic</em> attributes are supported. The
- * <em>Unknown</em> attribute stands for non-standard-attributes.
- *
+ * <em>Synthetic</em> attributes are supported. The <em>Unknown</em>
+ * attribute stands for non-standard-attributes.
+ * 
  * @version $Id$
- * @author  <A HREF="mailto:[email protected]">M. Dahm</A>
- * @see     ConstantValue
- * @see     SourceFile
- * @see     Code
- * @see     Unknown
- * @see     ExceptionTable
- * @see     LineNumberTable
- * @see     LocalVariableTable 
- * @see     InnerClasses
- * @see     Synthetic
- * @see     Deprecated
- * @see     Signature
+ * @author <A HREF="mailto:[email protected]">M. Dahm</A>
+ * @see ConstantValue
+ * @see SourceFile
+ * @see Code
+ * @see Unknown
+ * @see ExceptionTable
+ * @see LineNumberTable
+ * @see LocalVariableTable
+ * @see InnerClasses
+ * @see Synthetic
+ * @see Deprecated
+ * @see Signature
  */
-public abstract class Attribute implements Cloneable, Node, Serializable {
-
-    protected int name_index; // Points to attribute name in constant pool
-    protected int length; // Content length of attribute field
-    protected byte tag; // Tag to distiguish subclasses
-    protected ConstantPool constant_pool;
-
-
-    protected Attribute(byte tag, int name_index, int length, ConstantPool constant_pool) {
-        this.tag = tag;
-        this.name_index = name_index;
-        this.length = length;
-        this.constant_pool = constant_pool;
-    }
-
-
-    /**
-     * Called by objects that are traversing the nodes of the tree implicitely
-     * defined by the contents of a Java class. I.e., the hierarchy of methods,
-     * fields, attributes, etc. spawns a tree of objects.
-     *
-     * @param v Visitor object
-     */
-    public abstract void accept( Visitor v );
-
-
-    /**
-     * Dump attribute to file stream in binary format.
-     *
-     * @param file Output file stream
-     * @throws IOException
-     */
-    public void dump( DataOutputStream file ) throws IOException {
-        file.writeShort(name_index);
-        file.writeInt(length);
-    }
-
-    private static Map readers = new HashMap();
-
-
-    /** Add an Attribute reader capable of parsing (user-defined) attributes
-     * named "name". You should not add readers for the standard attributes
-     * such as "LineNumberTable", because those are handled internally.
-     *
-     * @param name the name of the attribute as stored in the class file
-     * @param r the reader object
-     */
-    public static void addAttributeReader( String name, AttributeReader r ) {
-        readers.put(name, r);
-    }
-
-
-    /** Remove attribute reader
-     *
-     * @param name the name of the attribute as stored in the class file
-     */
-    public static void removeAttributeReader( String name ) {
-        readers.remove(name);
-    }
-
-
-    /* Class method reads one attribute from the input data stream.
-     * This method must not be accessible from the outside.  It is
-     * called by the Field and Method constructor methods.
-     *
-     * @see    Field
-     * @see    Method
-     * @param  file Input stream
-     * @param  constant_pool Array of constants
-     * @return Attribute
-     * @throws  IOException
-     * @throws  ClassFormatException
-     */
-    public static final Attribute readAttribute( DataInputStream file, ConstantPool constant_pool )
-            throws IOException, ClassFormatException {
-        ConstantUtf8 c;
-        String name;
-        int name_index;
-        int length;
-        byte tag = Constants.ATTR_UNKNOWN; // Unknown attribute
-        // Get class name from constant pool via `name_index' indirection
-        name_index = file.readUnsignedShort();
-        c = (ConstantUtf8) constant_pool.getConstant(name_index, Constants.CONSTANT_Utf8);
-        name = c.getBytes();
-        // Length of data in bytes
-        length = file.readInt();
-        // Compare strings to find known attribute
-        for (byte i = 0; i < Constants.KNOWN_ATTRIBUTES; i++) {
-            if (name.equals(Constants.ATTRIBUTE_NAMES[i])) {
-                tag = i; // found!
-                break;
-            }
-        }
-        // Call proper constructor, depending on `tag'
-        switch (tag) {
-            case Constants.ATTR_UNKNOWN:
-                AttributeReader r = (AttributeReader) readers.get(name);
-                if (r != null) {
-                    return r.createAttribute(name_index, length, file, constant_pool);
-                }
-                return new Unknown(name_index, length, file, constant_pool);
-            case Constants.ATTR_CONSTANT_VALUE:
-                return new ConstantValue(name_index, length, file, constant_pool);
-            case Constants.ATTR_SOURCE_FILE:
-                return new SourceFile(name_index, length, file, constant_pool);
-            case Constants.ATTR_CODE:
-                return new Code(name_index, length, file, constant_pool);
-            case Constants.ATTR_EXCEPTIONS:
-                return new ExceptionTable(name_index, length, file, constant_pool);
-            case Constants.ATTR_LINE_NUMBER_TABLE:
-                return new LineNumberTable(name_index, length, file, constant_pool);
-            case Constants.ATTR_LOCAL_VARIABLE_TABLE:
-                return new LocalVariableTable(name_index, length, file, constant_pool);
-            case Constants.ATTR_INNER_CLASSES:
-                return new InnerClasses(name_index, length, file, constant_pool);
-            case Constants.ATTR_SYNTHETIC:
-                return new Synthetic(name_index, length, file, constant_pool);
-            case Constants.ATTR_DEPRECATED:
-                return new Deprecated(name_index, length, file, constant_pool);
-            case Constants.ATTR_PMG:
-                return new PMGClass(name_index, length, file, constant_pool);
-            case Constants.ATTR_SIGNATURE:
-                return new Signature(name_index, length, file, constant_pool);
-            case Constants.ATTR_STACK_MAP:
-                return new StackMap(name_index, length, file, constant_pool);
-                //    case Constants.ATTR_RUNTIMEVISIBLE_ANNOTATIONS:
-                //      return new RuntimeVisibleAnnotations(name_index, length, file, constant_pool);
-                //    case Constants.ATTR_RUNTIMEINVISIBLE_ANNOTATIONS:
-                //      return new RuntimeInvisibleAnnotations(name_index, length, file, constant_pool);
-                //    case Constants.ATTR_RUNTIMEVISIBLE_PARAMETER_ANNOTATIONS:
-                //      return new RuntimeVisibleParameterAnnotations(name_index, length, file, constant_pool);
-                //    case Constants.ATTR_RUNTIMEINVISIBLE_PARAMETER_ANNOTATIONS:
-                //      return new RuntimeInvisibleParameterAnnotations(name_index, length, file, constant_pool);
-                //    case Constants.ATTR_ANNOTATION_DEFAULT:
-                //      return new AnnotationDefault(name_index, length, file, constant_pool);
-            default: // Never reached
-                throw new IllegalStateException("Ooops! default case reached.");
-        }
-    }
-
-
-    /**
-     * @return Length of attribute field in bytes.
-     */
-    public final int getLength() {
-        return length;
-    }
-
-
-    /**
-     * @param length length in bytes.
-     */
-    public final void setLength( int length ) {
-        this.length = length;
-    }
-
-
-    /**
-     * @param name_index of attribute.
-     */
-    public final void setNameIndex( int name_index ) {
-        this.name_index = name_index;
-    }
-
-
-    /**
-     * @return Name index in constant pool of attribute name.
-     */
-    public final int getNameIndex() {
-        return name_index;
-    }
-
-
-    /**
-     * @return Tag of attribute, i.e., its type. Value may not be altered, thus
-     * there is no setTag() method.
-     */
-    public final byte getTag() {
-        return tag;
-    }
-
-
-    /**
-     * @return Constant pool used by this object.
-     * @see ConstantPool
-     */
-    public final ConstantPool getConstantPool() {
-        return constant_pool;
-    }
-
-
-    /**
-     * @param constant_pool Constant pool to be used for this object.
-     * @see ConstantPool
-     */
-    public final void setConstantPool( ConstantPool constant_pool ) {
-        this.constant_pool = constant_pool;
-    }
-
-
-    /**
-     * Use copy() if you want to have a deep copy(), i.e., with all references
-     * copied correctly.
-     *
-     * @return shallow copy of this attribute
-     */
-    public Object clone() {
-        Object o = null;
-        try {
-            o = super.clone();
-        } catch (CloneNotSupportedException e) {
-            e.printStackTrace(); // Never occurs
-        }
-        return o;
-    }
-
-
-    /**
-     * @return deep copy of this attribute
-     */
-    public abstract Attribute copy( ConstantPool _constant_pool );
-
-
-    /**
-     * @return attribute name.
-     */
-    public String toString() {
-        return Constants.ATTRIBUTE_NAMES[tag];
-    }
+public abstract class Attribute implements Cloneable, Node, Serializable
+{
+	protected int name_index; // Points to attribute name in constant pool
+
+	protected int length; // Content length of attribute field
+
+	protected byte tag; // Tag to distiguish subclasses
+
+	protected ConstantPool constant_pool;
+
+	protected Attribute(byte tag, int name_index, int length,
+			ConstantPool constant_pool)
+	{
+		this.tag = tag;
+		this.name_index = name_index;
+		this.length = length;
+		this.constant_pool = constant_pool;
+	}
+
+	/**
+	 * Called by objects that are traversing the nodes of the tree implicitely
+	 * defined by the contents of a Java class. I.e., the hierarchy of methods,
+	 * fields, attributes, etc. spawns a tree of objects.
+	 * 
+	 * @param v
+	 *            Visitor object
+	 */
+	public abstract void accept(Visitor v);
+
+	/**
+	 * Dump attribute to file stream in binary format.
+	 * 
+	 * @param file
+	 *            Output file stream
+	 * @throws IOException
+	 */
+	public void dump(DataOutputStream file) throws IOException
+	{
+		file.writeShort(name_index);
+		file.writeInt(length);
+	}
+
+	private static Map readers = new HashMap();
+
+	/**
+	 * Add an Attribute reader capable of parsing (user-defined) attributes
+	 * named "name". You should not add readers for the standard attributes such
+	 * as "LineNumberTable", because those are handled internally.
+	 * 
+	 * @param name
+	 *            the name of the attribute as stored in the class file
+	 * @param r
+	 *            the reader object
+	 */
+	public static void addAttributeReader(String name, AttributeReader r)
+	{
+		readers.put(name, r);
+	}
+
+	/**
+	 * Remove attribute reader
+	 * 
+	 * @param name
+	 *            the name of the attribute as stored in the class file
+	 */
+	public static void removeAttributeReader(String name)
+	{
+		readers.remove(name);
+	}
+
+	/*
+	 * Class method reads one attribute from the input data stream. This method
+	 * must not be accessible from the outside. It is called by the Field and
+	 * Method constructor methods.
+	 * 
+	 * @see Field
+	 * @see Method @param file Input stream @param constant_pool Array of
+	 *      constants @return Attribute @throws IOException @throws
+	 *      ClassFormatException
+	 */
+	public static final Attribute readAttribute(DataInputStream file,
+			ConstantPool constant_pool) throws IOException,
+			ClassFormatException
+	{
+		ConstantUtf8 c;
+		String name;
+		int name_index;
+		int length;
+		byte tag = Constants.ATTR_UNKNOWN; // Unknown attribute
+		// Get class name from constant pool via `name_index' indirection
+		name_index = file.readUnsignedShort();
+		c = (ConstantUtf8) constant_pool.getConstant(name_index,
+				Constants.CONSTANT_Utf8);
+		name = c.getBytes();
+		// Length of data in bytes
+		length = file.readInt();
+		// Compare strings to find known attribute
+		System.out.println(name);
+		for (byte i = 0; i < Constants.KNOWN_ATTRIBUTES; i++)
+		{
+			if (name.equals(Constants.ATTRIBUTE_NAMES[i]))
+			{
+				tag = i; // found!
+				break;
+			}
+		}
+		// Call proper constructor, depending on `tag'
+		switch (tag)
+		{
+		case Constants.ATTR_UNKNOWN:
+			AttributeReader r = (AttributeReader) readers.get(name);
+			if (r != null)
+			{
+				return r.createAttribute(name_index, length, file,
+						constant_pool);
+			}
+			return new Unknown(name_index, length, file, constant_pool);
+		case Constants.ATTR_CONSTANT_VALUE:
+			return new ConstantValue(name_index, length, file, constant_pool);
+		case Constants.ATTR_SOURCE_FILE:
+			return new SourceFile(name_index, length, file, constant_pool);
+		case Constants.ATTR_CODE:
+			return new Code(name_index, length, file, constant_pool);
+		case Constants.ATTR_EXCEPTIONS:
+			return new ExceptionTable(name_index, length, file, constant_pool);
+		case Constants.ATTR_LINE_NUMBER_TABLE:
+			return new LineNumberTable(name_index, length, file, constant_pool);
+		case Constants.ATTR_LOCAL_VARIABLE_TABLE:
+			return new LocalVariableTable(name_index, length, file,
+					constant_pool);
+		case Constants.ATTR_INNER_CLASSES:
+			return new InnerClasses(name_index, length, file, constant_pool);
+		case Constants.ATTR_SYNTHETIC:
+			return new Synthetic(name_index, length, file, constant_pool);
+		case Constants.ATTR_DEPRECATED:
+			return new Deprecated(name_index, length, file, constant_pool);
+		case Constants.ATTR_PMG:
+			return new PMGClass(name_index, length, file, constant_pool);
+		case Constants.ATTR_SIGNATURE:
+			return new Signature(name_index, length, file, constant_pool);
+		case Constants.ATTR_STACK_MAP:
+			return new StackMap(name_index, length, file, constant_pool);
+		case Constants.ATTR_RUNTIME_VISIBLE_ANNOTATIONS:
+			return new RuntimeVisibleAnnotations(name_index, length, file,
+					constant_pool);
+		case Constants.ATTR_RUNTIMEIN_VISIBLE_ANNOTATIONS:
+			return new RuntimeInvisibleAnnotations(name_index, length, file,
+					constant_pool);
+		case Constants.ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS:
+			return new RuntimeVisibleParameterAnnotations(name_index, length,
+					file, constant_pool);
+		case Constants.ATTR_RUNTIMEIN_VISIBLE_PARAMETER_ANNOTATIONS:
+			return new RuntimeInvisibleParameterAnnotations(name_index, length,
+					file, constant_pool);
+		case Constants.ATTR_ANNOTATION_DEFAULT:
+			return new AnnotationDefault(name_index, length, file,
+					constant_pool);
+		case Constants.ATTR_LOCAL_VARIABLE_TYPE_TABLE:
+			return new LocalVariableTypeTable(name_index, length, file,
+					constant_pool);
+		case Constants.ATTR_ENCLOSING_METHOD:
+			return new EnclosingMethod(name_index, length, file, constant_pool);
+		default: // Never reached
+			throw new IllegalStateException("Ooops! default case reached.");
+		}
+	}
+
+	/**
+	 * @return Length of attribute field in bytes.
+	 */
+	public final int getLength()
+	{
+		return length;
+	}
+
+	/**
+	 * @param length
+	 *            length in bytes.
+	 */
+	public final void setLength(int length)
+	{
+		this.length = length;
+	}
+
+	/**
+	 * @param name_index
+	 *            of attribute.
+	 */
+	public final void setNameIndex(int name_index)
+	{
+		this.name_index = name_index;
+	}
+
+	/**
+	 * @return Name index in constant pool of attribute name.
+	 */
+	public final int getNameIndex()
+	{
+		return name_index;
+	}
+
+	/**
+	 * @return Tag of attribute, i.e., its type. Value may not be altered, thus
+	 *         there is no setTag() method.
+	 */
+	public final byte getTag()
+	{
+		return tag;
+	}
+
+	/**
+	 * @return Constant pool used by this object.
+	 * @see ConstantPool
+	 */
+	public final ConstantPool getConstantPool()
+	{
+		return constant_pool;
+	}
+
+	/**
+	 * @param constant_pool
+	 *            Constant pool to be used for this object.
+	 * @see ConstantPool
+	 */
+	public final void setConstantPool(ConstantPool constant_pool)
+	{
+		this.constant_pool = constant_pool;
+	}
+
+	/**
+	 * Use copy() if you want to have a deep copy(), i.e., with all references
+	 * copied correctly.
+	 * 
+	 * @return shallow copy of this attribute
+	 */
+	public Object clone()
+	{
+		Object o = null;
+		try
+		{
+			o = super.clone();
+		}
+		catch (CloneNotSupportedException e)
+		{
+			e.printStackTrace(); // Never occurs
+		}
+		return o;
+	}
+
+	/**
+	 * @return deep copy of this attribute
+	 */
+	public abstract Attribute copy(ConstantPool _constant_pool);
+
+	/**
+	 * @return attribute name.
+	 */
+	public String toString()
+	{
+		return Constants.ATTRIBUTE_NAMES[tag];
+	}
 }

Modified: jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/DescendingVisitor.java
URL: http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/DescendingVisitor.java?rev=411580&r1=411579&r2=411580&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/DescendingVisitor.java (original)
+++ jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/DescendingVisitor.java Sun Jun  4 08:52:18 2006
@@ -19,356 +19,408 @@
 import java.util.Stack;
 
 /**
- * Traverses a JavaClass with another Visitor object 'piggy-backed'
- * that is applied to all components of a JavaClass object. I.e. this
- * class supplies the traversal strategy, other classes can make use
- * of it.
- *
+ * Traverses a JavaClass with another Visitor object 'piggy-backed' that is
+ * applied to all components of a JavaClass object. I.e. this class supplies the
+ * traversal strategy, other classes can make use of it.
+ * 
  * @version $Id$
- * @author <A HREF="mailto:[email protected]">M. Dahm</A> 
+ * @author <A HREF="mailto:[email protected]">M. Dahm</A>
  */
-public class DescendingVisitor implements Visitor {
-
-    private JavaClass clazz;
-    private Visitor visitor;
-    private Stack stack = new Stack();
-
-
-    /** @return container of current entitity, i.e., predecessor during traversal
-     */
-    public Object predecessor() {
-        return predecessor(0);
-    }
-
-
-    /**
-     * @param level nesting level, i.e., 0 returns the direct predecessor
-     * @return container of current entitity, i.e., predecessor during traversal
-     */
-    public Object predecessor( int level ) {
-        int size = stack.size();
-        if ((size < 2) || (level < 0)) {
-            return null;
-        } else {
-            return stack.elementAt(size - (level + 2)); // size - 1 == current
-        }
-    }
-
-
-    /** @return current object
-     */
-    public Object current() {
-        return stack.peek();
-    }
-
-
-    /**
-     * @param clazz Class to traverse
-     * @param visitor visitor object to apply to all components
-     */
-    public DescendingVisitor(JavaClass clazz, Visitor visitor) {
-        this.clazz = clazz;
-        this.visitor = visitor;
-    }
-
-
-    /**
-     * Start traversal.
-     */
-    public void visit() {
-        clazz.accept(this);
-    }
-
-
-    public void visitJavaClass( JavaClass _clazz ) {
-        stack.push(_clazz);
-        _clazz.accept(visitor);
-        Field[] fields = _clazz.getFields();
-        for (int i = 0; i < fields.length; i++) {
-            fields[i].accept(this);
-        }
-        Method[] methods = _clazz.getMethods();
-        for (int i = 0; i < methods.length; i++) {
-            methods[i].accept(this);
-        }
-        Attribute[] attributes = _clazz.getAttributes();
-        for (int i = 0; i < attributes.length; i++) {
-            attributes[i].accept(this);
-        }
-        _clazz.getConstantPool().accept(this);
-        stack.pop();
-    }
-
-
-    public void visitAnnotation( Annotations annotation ) {
-        stack.push(annotation);
-        annotation.accept(visitor);
-        AnnotationEntry[] entries = annotation.getAnnotationEntries();
-        for (int i = 0; i < entries.length; i++) {
-            entries[i].accept(this);
-        }
-        stack.pop();
-    }
-
-
-    public void visitAnnotationEntry( AnnotationEntry annotationEntry ) {
-        stack.push(annotationEntry);
-        annotationEntry.accept(visitor);
-        stack.pop();
-    }
-
-
-    public void visitField( Field field ) {
-        stack.push(field);
-        field.accept(visitor);
-        Attribute[] attributes = field.getAttributes();
-        for (int i = 0; i < attributes.length; i++) {
-            attributes[i].accept(this);
-        }
-        stack.pop();
-    }
-
-
-    public void visitConstantValue( ConstantValue cv ) {
-        stack.push(cv);
-        cv.accept(visitor);
-        stack.pop();
-    }
-
-
-    public void visitMethod( Method method ) {
-        stack.push(method);
-        method.accept(visitor);
-        Attribute[] attributes = method.getAttributes();
-        for (int i = 0; i < attributes.length; i++) {
-            attributes[i].accept(this);
-        }
-        stack.pop();
-    }
-
-
-    public void visitExceptionTable( ExceptionTable table ) {
-        stack.push(table);
-        table.accept(visitor);
-        stack.pop();
-    }
-
-
-    public void visitCode( Code code ) {
-        stack.push(code);
-        code.accept(visitor);
-        CodeException[] table = code.getExceptionTable();
-        for (int i = 0; i < table.length; i++) {
-            table[i].accept(this);
-        }
-        Attribute[] attributes = code.getAttributes();
-        for (int i = 0; i < attributes.length; i++) {
-            attributes[i].accept(this);
-        }
-        stack.pop();
-    }
-
-
-    public void visitCodeException( CodeException ce ) {
-        stack.push(ce);
-        ce.accept(visitor);
-        stack.pop();
-    }
-
-
-    public void visitLineNumberTable( LineNumberTable table ) {
-        stack.push(table);
-        table.accept(visitor);
-        LineNumber[] numbers = table.getLineNumberTable();
-        for (int i = 0; i < numbers.length; i++) {
-            numbers[i].accept(this);
-        }
-        stack.pop();
-    }
-
-
-    public void visitLineNumber( LineNumber number ) {
-        stack.push(number);
-        number.accept(visitor);
-        stack.pop();
-    }
-
-
-    public void visitLocalVariableTable( LocalVariableTable table ) {
-        stack.push(table);
-        table.accept(visitor);
-        LocalVariable[] vars = table.getLocalVariableTable();
-        for (int i = 0; i < vars.length; i++) {
-            vars[i].accept(this);
-        }
-        stack.pop();
-    }
-
-
-    public void visitStackMap( StackMap table ) {
-        stack.push(table);
-        table.accept(visitor);
-        StackMapEntry[] vars = table.getStackMap();
-        for (int i = 0; i < vars.length; i++) {
-            vars[i].accept(this);
-        }
-        stack.pop();
-    }
-
-
-    public void visitStackMapEntry( StackMapEntry var ) {
-        stack.push(var);
-        var.accept(visitor);
-        stack.pop();
-    }
-
-
-    public void visitLocalVariable( LocalVariable var ) {
-        stack.push(var);
-        var.accept(visitor);
-        stack.pop();
-    }
-
-
-    public void visitConstantPool( ConstantPool cp ) {
-        stack.push(cp);
-        cp.accept(visitor);
-        Constant[] constants = cp.getConstantPool();
-        for (int i = 1; i < constants.length; i++) {
-            if (constants[i] != null) {
-                constants[i].accept(this);
-            }
-        }
-        stack.pop();
-    }
-
-
-    public void visitConstantClass( ConstantClass constant ) {
-        stack.push(constant);
-        constant.accept(visitor);
-        stack.pop();
-    }
-
-
-    public void visitConstantDouble( ConstantDouble constant ) {
-        stack.push(constant);
-        constant.accept(visitor);
-        stack.pop();
-    }
-
-
-    public void visitConstantFieldref( ConstantFieldref constant ) {
-        stack.push(constant);
-        constant.accept(visitor);
-        stack.pop();
-    }
-
-
-    public void visitConstantFloat( ConstantFloat constant ) {
-        stack.push(constant);
-        constant.accept(visitor);
-        stack.pop();
-    }
-
-
-    public void visitConstantInteger( ConstantInteger constant ) {
-        stack.push(constant);
-        constant.accept(visitor);
-        stack.pop();
-    }
-
-
-    public void visitConstantInterfaceMethodref( ConstantInterfaceMethodref constant ) {
-        stack.push(constant);
-        constant.accept(visitor);
-        stack.pop();
-    }
-
-
-    public void visitConstantLong( ConstantLong constant ) {
-        stack.push(constant);
-        constant.accept(visitor);
-        stack.pop();
-    }
-
-
-    public void visitConstantMethodref( ConstantMethodref constant ) {
-        stack.push(constant);
-        constant.accept(visitor);
-        stack.pop();
-    }
-
-
-    public void visitConstantNameAndType( ConstantNameAndType constant ) {
-        stack.push(constant);
-        constant.accept(visitor);
-        stack.pop();
-    }
-
-
-    public void visitConstantString( ConstantString constant ) {
-        stack.push(constant);
-        constant.accept(visitor);
-        stack.pop();
-    }
-
-
-    public void visitConstantUtf8( ConstantUtf8 constant ) {
-        stack.push(constant);
-        constant.accept(visitor);
-        stack.pop();
-    }
-
-
-    public void visitInnerClasses( InnerClasses ic ) {
-        stack.push(ic);
-        ic.accept(visitor);
-        InnerClass[] ics = ic.getInnerClasses();
-        for (int i = 0; i < ics.length; i++) {
-            ics[i].accept(this);
-        }
-        stack.pop();
-    }
-
-
-    public void visitInnerClass( InnerClass inner ) {
-        stack.push(inner);
-        inner.accept(visitor);
-        stack.pop();
-    }
-
-
-    public void visitDeprecated( Deprecated attribute ) {
-        stack.push(attribute);
-        attribute.accept(visitor);
-        stack.pop();
-    }
-
-
-    public void visitSignature( Signature attribute ) {
-        stack.push(attribute);
-        attribute.accept(visitor);
-        stack.pop();
-    }
-
-
-    public void visitSourceFile( SourceFile attribute ) {
-        stack.push(attribute);
-        attribute.accept(visitor);
-        stack.pop();
-    }
-
-
-    public void visitSynthetic( Synthetic attribute ) {
-        stack.push(attribute);
-        attribute.accept(visitor);
-        stack.pop();
-    }
-
-
-    public void visitUnknown( Unknown attribute ) {
-        stack.push(attribute);
-        attribute.accept(visitor);
-        stack.pop();
-    }
+public class DescendingVisitor implements Visitor
+{
+	private JavaClass clazz;
+
+	private Visitor visitor;
+
+	private Stack stack = new Stack();
+
+	/**
+	 * @return container of current entitity, i.e., predecessor during traversal
+	 */
+	public Object predecessor()
+	{
+		return predecessor(0);
+	}
+
+	/**
+	 * @param level
+	 *            nesting level, i.e., 0 returns the direct predecessor
+	 * @return container of current entitity, i.e., predecessor during traversal
+	 */
+	public Object predecessor(int level)
+	{
+		int size = stack.size();
+		if ((size < 2) || (level < 0))
+		{
+			return null;
+		}
+		else
+		{
+			return stack.elementAt(size - (level + 2)); // size - 1 == current
+		}
+	}
+
+	/**
+	 * @return current object
+	 */
+	public Object current()
+	{
+		return stack.peek();
+	}
+
+	/**
+	 * @param clazz
+	 *            Class to traverse
+	 * @param visitor
+	 *            visitor object to apply to all components
+	 */
+	public DescendingVisitor(JavaClass clazz, Visitor visitor)
+	{
+		this.clazz = clazz;
+		this.visitor = visitor;
+	}
+
+	/**
+	 * Start traversal.
+	 */
+	public void visit()
+	{
+		clazz.accept(this);
+	}
+
+	public void visitJavaClass(JavaClass _clazz)
+	{
+		stack.push(_clazz);
+		_clazz.accept(visitor);
+		Field[] fields = _clazz.getFields();
+		for (int i = 0; i < fields.length; i++)
+		{
+			fields[i].accept(this);
+		}
+		Method[] methods = _clazz.getMethods();
+		for (int i = 0; i < methods.length; i++)
+		{
+			methods[i].accept(this);
+		}
+		Attribute[] attributes = _clazz.getAttributes();
+		for (int i = 0; i < attributes.length; i++)
+		{
+			attributes[i].accept(this);
+		}
+		_clazz.getConstantPool().accept(this);
+		stack.pop();
+	}
+
+	public void visitAnnotation(Annotations annotation)
+	{
+		stack.push(annotation);
+		annotation.accept(visitor);
+		AnnotationEntry[] entries = annotation.getAnnotationEntries();
+		for (int i = 0; i < entries.length; i++)
+		{
+			entries[i].accept(this);
+		}
+		stack.pop();
+	}
+
+	public void visitAnnotationEntry(AnnotationEntry annotationEntry)
+	{
+		stack.push(annotationEntry);
+		annotationEntry.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitField(Field field)
+	{
+		stack.push(field);
+		field.accept(visitor);
+		Attribute[] attributes = field.getAttributes();
+		for (int i = 0; i < attributes.length; i++)
+		{
+			attributes[i].accept(this);
+		}
+		stack.pop();
+	}
+
+	public void visitConstantValue(ConstantValue cv)
+	{
+		stack.push(cv);
+		cv.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitMethod(Method method)
+	{
+		stack.push(method);
+		method.accept(visitor);
+		Attribute[] attributes = method.getAttributes();
+		for (int i = 0; i < attributes.length; i++)
+		{
+			attributes[i].accept(this);
+		}
+		stack.pop();
+	}
+
+	public void visitExceptionTable(ExceptionTable table)
+	{
+		stack.push(table);
+		table.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitCode(Code code)
+	{
+		stack.push(code);
+		code.accept(visitor);
+		CodeException[] table = code.getExceptionTable();
+		for (int i = 0; i < table.length; i++)
+		{
+			table[i].accept(this);
+		}
+		Attribute[] attributes = code.getAttributes();
+		for (int i = 0; i < attributes.length; i++)
+		{
+			attributes[i].accept(this);
+		}
+		stack.pop();
+	}
+
+	public void visitCodeException(CodeException ce)
+	{
+		stack.push(ce);
+		ce.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitLineNumberTable(LineNumberTable table)
+	{
+		stack.push(table);
+		table.accept(visitor);
+		LineNumber[] numbers = table.getLineNumberTable();
+		for (int i = 0; i < numbers.length; i++)
+		{
+			numbers[i].accept(this);
+		}
+		stack.pop();
+	}
+
+	public void visitLineNumber(LineNumber number)
+	{
+		stack.push(number);
+		number.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitLocalVariableTable(LocalVariableTable table)
+	{
+		stack.push(table);
+		table.accept(visitor);
+		LocalVariable[] vars = table.getLocalVariableTable();
+		for (int i = 0; i < vars.length; i++)
+		{
+			vars[i].accept(this);
+		}
+		stack.pop();
+	}
+
+	public void visitStackMap(StackMap table)
+	{
+		stack.push(table);
+		table.accept(visitor);
+		StackMapEntry[] vars = table.getStackMap();
+		for (int i = 0; i < vars.length; i++)
+		{
+			vars[i].accept(this);
+		}
+		stack.pop();
+	}
+
+	public void visitStackMapEntry(StackMapEntry var)
+	{
+		stack.push(var);
+		var.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitLocalVariable(LocalVariable var)
+	{
+		stack.push(var);
+		var.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitConstantPool(ConstantPool cp)
+	{
+		stack.push(cp);
+		cp.accept(visitor);
+		Constant[] constants = cp.getConstantPool();
+		for (int i = 1; i < constants.length; i++)
+		{
+			if (constants[i] != null)
+			{
+				constants[i].accept(this);
+			}
+		}
+		stack.pop();
+	}
+
+	public void visitConstantClass(ConstantClass constant)
+	{
+		stack.push(constant);
+		constant.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitConstantDouble(ConstantDouble constant)
+	{
+		stack.push(constant);
+		constant.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitConstantFieldref(ConstantFieldref constant)
+	{
+		stack.push(constant);
+		constant.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitConstantFloat(ConstantFloat constant)
+	{
+		stack.push(constant);
+		constant.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitConstantInteger(ConstantInteger constant)
+	{
+		stack.push(constant);
+		constant.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitConstantInterfaceMethodref(
+			ConstantInterfaceMethodref constant)
+	{
+		stack.push(constant);
+		constant.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitConstantLong(ConstantLong constant)
+	{
+		stack.push(constant);
+		constant.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitConstantMethodref(ConstantMethodref constant)
+	{
+		stack.push(constant);
+		constant.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitConstantNameAndType(ConstantNameAndType constant)
+	{
+		stack.push(constant);
+		constant.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitConstantString(ConstantString constant)
+	{
+		stack.push(constant);
+		constant.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitConstantUtf8(ConstantUtf8 constant)
+	{
+		stack.push(constant);
+		constant.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitInnerClasses(InnerClasses ic)
+	{
+		stack.push(ic);
+		ic.accept(visitor);
+		InnerClass[] ics = ic.getInnerClasses();
+		for (int i = 0; i < ics.length; i++)
+		{
+			ics[i].accept(this);
+		}
+		stack.pop();
+	}
+
+	public void visitInnerClass(InnerClass inner)
+	{
+		stack.push(inner);
+		inner.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitDeprecated(Deprecated attribute)
+	{
+		stack.push(attribute);
+		attribute.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitSignature(Signature attribute)
+	{
+		stack.push(attribute);
+		attribute.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitSourceFile(SourceFile attribute)
+	{
+		stack.push(attribute);
+		attribute.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitSynthetic(Synthetic attribute)
+	{
+		stack.push(attribute);
+		attribute.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitUnknown(Unknown attribute)
+	{
+		stack.push(attribute);
+		attribute.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitAnnotationDefault(AnnotationDefault obj)
+	{
+		stack.push(obj);
+		obj.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitEnclosingMethod(EnclosingMethod obj)
+	{
+		stack.push(obj);
+		obj.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitLocalVariableTypeTable(LocalVariableTypeTable obj)
+	{
+		stack.push(obj);
+		obj.accept(visitor);
+		stack.pop();
+	}
+
+	public void visitParameterAnnotation(ParameterAnnotations obj)
+	{
+		stack.push(obj);
+		obj.accept(visitor);
+		stack.pop();
+	}
 }

Modified: jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/ElementValue.java
URL: http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/ElementValue.java?rev=411580&r1=411579&r2=411580&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/ElementValue.java (original)
+++ jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/ElementValue.java Sun Jun  4 08:52:18 2006
@@ -1,83 +1,83 @@
-/*
- * Copyright  2000-2004 The Apache Software Foundation
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
-package org.apache.bcel.classfile;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-
-/**
- * an ElementValuePair's element value. This class will be broken out into
- * different subclasses. This is a temporary implementation.
- * 
- * @version $Id: ElementValue
- * @author  <A HREF="mailto:[email protected]">D. Brosius</A>
- * @since 5.2
- */
-public class ElementValue {
-
-    private byte tag;
-    private int const_value_index;
-    private int type_name_index;
-    private int const_name_index;
-    private int class_info_index;
-    private AnnotationEntry annotation;
-    private int num_values;
-    private ElementValue[] values;
-
-
-    /**
-     * Construct object from file stream.
-     * @param file Input stream
-     * @param constant_pool the constant pool
-     * @throws IOException
-     */
-    ElementValue(DataInputStream file, ConstantPool constant_pool) throws IOException {
-        tag = (file.readByte());
-        switch (tag) {
-            case 'B':
-            case 'C':
-            case 'D':
-            case 'F':
-            case 'I':
-            case 'J':
-            case 'S':
-            case 'Z':
-            case 's':
-                const_value_index = (file.readUnsignedShort());
-                break;
-            case 'e':
-                type_name_index = (file.readUnsignedShort());
-                const_name_index = (file.readUnsignedShort());
-                break;
-            case 'c':
-                class_info_index = (file.readUnsignedShort());
-                break;
-            case '@':
-                annotation = new AnnotationEntry(file, constant_pool);
-                break;
-            case '[':
-                num_values = (file.readUnsignedShort());
-                values = new ElementValue[num_values];
-                for (int i = 0; i < num_values; i++) {
-                    values[i] = new ElementValue(file, constant_pool);
-                }
-                break;
-            default:
-                throw new IOException("Invalid ElementValue tag: " + tag);
-        }
-    }
-}
+/*
+ * Copyright  2000-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.bcel.classfile;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+
+/**
+ * an ElementValuePair's element value. This class will be broken out into
+ * different subclasses. This is a temporary implementation.
+ * 
+ * @version $Id: ElementValue
+ * @author  <A HREF="mailto:[email protected]">D. Brosius</A>
+ * @since 5.2
+ */
+public class ElementValue {
+
+    private byte tag;
+    private int const_value_index;
+    private int type_name_index;
+    private int const_name_index;
+    private int class_info_index;
+    private AnnotationEntry annotation;
+    private int num_values;
+    private ElementValue[] values;
+
+
+    /**
+     * Construct object from file stream.
+     * @param file Input stream
+     * @param constant_pool the constant pool
+     * @throws IOException
+     */
+    ElementValue(DataInputStream file, ConstantPool constant_pool) throws IOException {
+        tag = (file.readByte());
+        switch (tag) {
+            case 'B':
+            case 'C':
+            case 'D':
+            case 'F':
+            case 'I':
+            case 'J':
+            case 'S':
+            case 'Z':
+            case 's':
+                const_value_index = (file.readUnsignedShort());
+                break;
+            case 'e':
+                type_name_index = (file.readUnsignedShort());
+                const_name_index = (file.readUnsignedShort());
+                break;
+            case 'c':
+                class_info_index = (file.readUnsignedShort());
+                break;
+            case '@':
+                annotation = new AnnotationEntry(file, constant_pool);
+                break;
+            case '[':
+                num_values = (file.readUnsignedShort());
+                values = new ElementValue[num_values];
+                for (int i = 0; i < num_values; i++) {
+                    values[i] = new ElementValue(file, constant_pool);
+                }
+                break;
+            default:
+                throw new IOException("Invalid ElementValue tag: " + tag);
+        }
+    }
+}

Modified: jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/ElementValuePair.java
URL: http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/ElementValuePair.java?rev=411580&r1=411579&r2=411580&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/ElementValuePair.java (original)
+++ jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/ElementValuePair.java Sun Jun  4 08:52:18 2006
@@ -1,45 +1,45 @@
-/*
- * Copyright  2000-2004 The Apache Software Foundation
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
-package org.apache.bcel.classfile;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-
-/**
- * an annotation's element value pair
- * 
- * @version $Id: ElementValuePair
- * @author  <A HREF="mailto:[email protected]">D. Brosius</A>
- * @since 5.2
- */
-public class ElementValuePair {
-
-    private int element_name_index;
-    private ElementValue value;
-
-
-    /**
-     * Construct object from file stream.
-     * @param file Input stream
-     * @param constant_pool the constant pool
-     * @throws IOException
-     */
-    ElementValuePair(DataInputStream file, ConstantPool constant_pool) throws IOException {
-        element_name_index = (file.readUnsignedShort());
-        value = new ElementValue(file, constant_pool);
-    }
-}
+/*
+ * Copyright  2000-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.bcel.classfile;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+
+/**
+ * an annotation's element value pair
+ * 
+ * @version $Id: ElementValuePair
+ * @author  <A HREF="mailto:[email protected]">D. Brosius</A>
+ * @since 5.2
+ */
+public class ElementValuePair {
+
+    private int element_name_index;
+    private ElementValue value;
+
+
+    /**
+     * Construct object from file stream.
+     * @param file Input stream
+     * @param constant_pool the constant pool
+     * @throws IOException
+     */
+    ElementValuePair(DataInputStream file, ConstantPool constant_pool) throws IOException {
+        element_name_index = (file.readUnsignedShort());
+        value = new ElementValue(file, constant_pool);
+    }
+}

Modified: jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/EmptyVisitor.java
URL: http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/EmptyVisitor.java?rev=411580&r1=411579&r2=411580&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/EmptyVisitor.java (original)
+++ jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/EmptyVisitor.java Sun Jun  4 08:52:18 2006
@@ -17,161 +17,167 @@
 package org.apache.bcel.classfile;
 
 /**
- * Visitor with empty method bodies, can be extended and used in conjunction with the
- * DescendingVisitor class, e.g.
- *
- * By courtesy of David Spencer.
- *
+ * Visitor with empty method bodies, can be extended and used in conjunction
+ * with the DescendingVisitor class, e.g. By courtesy of David Spencer.
+ * 
  * @see DescendingVisitor
  * @version $Id$
- * 
  */
-public class EmptyVisitor implements Visitor {
-
-    protected EmptyVisitor() {
-    }
-
-
-    public void visitAnnotation( Annotations obj ) {
-    }
-
-
-    public void visitParameterAnnotation( ParameterAnnotations obj ) {
-    }
-
-
-    public void visitAnnotationEntry( AnnotationEntry obj ) {
-    }
-
-
-    public void visitAnnotationDefault( AnnotationDefault obj ) {
-    }
-
-
-    public void visitCode( Code obj ) {
-    }
-
-
-    public void visitCodeException( CodeException obj ) {
-    }
-
-
-    public void visitConstantClass( ConstantClass obj ) {
-    }
-
-
-    public void visitConstantDouble( ConstantDouble obj ) {
-    }
-
-
-    public void visitConstantFieldref( ConstantFieldref obj ) {
-    }
-
-
-    public void visitConstantFloat( ConstantFloat obj ) {
-    }
-
-
-    public void visitConstantInteger( ConstantInteger obj ) {
-    }
-
-
-    public void visitConstantInterfaceMethodref( ConstantInterfaceMethodref obj ) {
-    }
-
-
-    public void visitConstantLong( ConstantLong obj ) {
-    }
-
-
-    public void visitConstantMethodref( ConstantMethodref obj ) {
-    }
-
-
-    public void visitConstantNameAndType( ConstantNameAndType obj ) {
-    }
-
-
-    public void visitConstantPool( ConstantPool obj ) {
-    }
-
-
-    public void visitConstantString( ConstantString obj ) {
-    }
-
-
-    public void visitConstantUtf8( ConstantUtf8 obj ) {
-    }
-
-
-    public void visitConstantValue( ConstantValue obj ) {
-    }
-
-
-    public void visitDeprecated( Deprecated obj ) {
-    }
-
-
-    public void visitExceptionTable( ExceptionTable obj ) {
-    }
-
-
-    public void visitField( Field obj ) {
-    }
-
-
-    public void visitInnerClass( InnerClass obj ) {
-    }
-
-
-    public void visitInnerClasses( InnerClasses obj ) {
-    }
-
-
-    public void visitJavaClass( JavaClass obj ) {
-    }
-
-
-    public void visitLineNumber( LineNumber obj ) {
-    }
-
-
-    public void visitLineNumberTable( LineNumberTable obj ) {
-    }
-
-
-    public void visitLocalVariable( LocalVariable obj ) {
-    }
-
-
-    public void visitLocalVariableTable( LocalVariableTable obj ) {
-    }
-
-
-    public void visitMethod( Method obj ) {
-    }
-
-
-    public void visitSignature( Signature obj ) {
-    }
-
-
-    public void visitSourceFile( SourceFile obj ) {
-    }
-
-
-    public void visitSynthetic( Synthetic obj ) {
-    }
-
-
-    public void visitUnknown( Unknown obj ) {
-    }
-
-
-    public void visitStackMap( StackMap obj ) {
-    }
-
-
-    public void visitStackMapEntry( StackMapEntry obj ) {
-    }
+public class EmptyVisitor implements Visitor
+{
+	protected EmptyVisitor()
+	{
+	}
+
+	public void visitAnnotation(Annotations obj)
+	{
+	}
+
+	public void visitParameterAnnotation(ParameterAnnotations obj)
+	{
+	}
+
+	public void visitAnnotationEntry(AnnotationEntry obj)
+	{
+	}
+
+	public void visitAnnotationDefault(AnnotationDefault obj)
+	{
+	}
+
+	public void visitCode(Code obj)
+	{
+	}
+
+	public void visitCodeException(CodeException obj)
+	{
+	}
+
+	public void visitConstantClass(ConstantClass obj)
+	{
+	}
+
+	public void visitConstantDouble(ConstantDouble obj)
+	{
+	}
+
+	public void visitConstantFieldref(ConstantFieldref obj)
+	{
+	}
+
+	public void visitConstantFloat(ConstantFloat obj)
+	{
+	}
+
+	public void visitConstantInteger(ConstantInteger obj)
+	{
+	}
+
+	public void visitConstantInterfaceMethodref(ConstantInterfaceMethodref obj)
+	{
+	}
+
+	public void visitConstantLong(ConstantLong obj)
+	{
+	}
+
+	public void visitConstantMethodref(ConstantMethodref obj)
+	{
+	}
+
+	public void visitConstantNameAndType(ConstantNameAndType obj)
+	{
+	}
+
+	public void visitConstantPool(ConstantPool obj)
+	{
+	}
+
+	public void visitConstantString(ConstantString obj)
+	{
+	}
+
+	public void visitConstantUtf8(ConstantUtf8 obj)
+	{
+	}
+
+	public void visitConstantValue(ConstantValue obj)
+	{
+	}
+
+	public void visitDeprecated(Deprecated obj)
+	{
+	}
+
+	public void visitExceptionTable(ExceptionTable obj)
+	{
+	}
+
+	public void visitField(Field obj)
+	{
+	}
+
+	public void visitInnerClass(InnerClass obj)
+	{
+	}
+
+	public void visitInnerClasses(InnerClasses obj)
+	{
+	}
+
+	public void visitJavaClass(JavaClass obj)
+	{
+	}
+
+	public void visitLineNumber(LineNumber obj)
+	{
+	}
+
+	public void visitLineNumberTable(LineNumberTable obj)
+	{
+	}
+
+	public void visitLocalVariable(LocalVariable obj)
+	{
+	}
+
+	public void visitLocalVariableTable(LocalVariableTable obj)
+	{
+	}
+
+	public void visitMethod(Method obj)
+	{
+	}
+
+	public void visitSignature(Signature obj)
+	{
+	}
+
+	public void visitSourceFile(SourceFile obj)
+	{
+	}
+
+	public void visitSynthetic(Synthetic obj)
+	{
+	}
+
+	public void visitUnknown(Unknown obj)
+	{
+	}
+
+	public void visitStackMap(StackMap obj)
+	{
+	}
+
+	public void visitStackMapEntry(StackMapEntry obj)
+	{
+	}
+
+	public void visitEnclosingMethod(EnclosingMethod obj)
+	{
+	}
+
+	public void visitLocalVariableTypeTable(LocalVariableTypeTable obj)
+	{
+	}
 }

Added: jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/EnclosingMethod.java
URL: http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/EnclosingMethod.java?rev=411580&view=auto
==============================================================================
--- jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/EnclosingMethod.java (added)
+++ jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/EnclosingMethod.java Sun Jun  4 08:52:18 2006
@@ -0,0 +1,87 @@
+/* *******************************************************************
+ * Copyright (c) 2004 IBM Corporation
+ * 
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Common Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://www.eclipse.org/legal/cpl-v10.html 
+ *  
+ * Contributors: 
+ *    Andy Clement     initial implementation 
+ * ******************************************************************/
+package org.apache.bcel.classfile;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.apache.bcel.Constants;
+
+/**
+ * This attribute exists for local or 
+ * anonymous classes and ... there can be only one.
+ */
+public class EnclosingMethod extends Attribute {
+	
+	// Pointer to the CONSTANT_Class_info structure representing the 
+	// innermost class that encloses the declaration of the current class.
+	private int classIndex;
+	
+	// If the current class is not immediately enclosed by a method or 
+	// constructor, then the value of the method_index item must be zero.  
+	// Otherwise, the value of the  method_index item must point to a 
+	// CONSTANT_NameAndType_info structure representing the name and the 
+	// type of a method in the class referenced by the class we point 
+	// to in the class_index.  *It is the compiler responsibility* to 
+	// ensure that the method identified by this index is the closest 
+	// lexically enclosing method that includes the local/anonymous class.
+	private int methodIndex;
+
+	// Ctors - and code to read an attribute in.
+	public EnclosingMethod(int nameIndex, int len, DataInputStream dis, ConstantPool cpool) throws IOException {
+		this(nameIndex, len, dis.readUnsignedShort(), dis.readUnsignedShort(), cpool);
+	}
+
+	private EnclosingMethod(int nameIndex, int len, int classIdx,int methodIdx, ConstantPool cpool) {
+	    super(Constants.ATTR_ENCLOSING_METHOD, nameIndex, len, cpool);
+	    classIndex  = classIdx;
+	    methodIndex = methodIdx;
+	}
+
+	public void accept(Visitor v) {
+	  v.visitEnclosingMethod(this);
+	}
+
+	public Attribute copy(ConstantPool constant_pool) {
+		throw new RuntimeException("Not implemented yet!");
+		// is this next line sufficient?
+		// return (EnclosingMethod)clone();
+	}
+	
+	// Accessors
+	public final int getEnclosingClassIndex() { return classIndex; }  
+	public final int getEnclosingMethodIndex(){ return methodIndex;}
+	
+	public final void setEnclosingClassIndex(int idx) {classIndex = idx;}
+	public final void setEnclosingMethodIndex(int idx){methodIndex= idx;}
+
+	public final ConstantClass getEnclosingClass() {
+		ConstantClass c = 
+			(ConstantClass)constant_pool.getConstant(classIndex,Constants.CONSTANT_Class);
+		return c;
+	}
+	
+	public final ConstantNameAndType getEnclosingMethod() {
+		if (methodIndex == 0) return null;
+		ConstantNameAndType nat = 
+			(ConstantNameAndType)constant_pool.getConstant(methodIndex,Constants.CONSTANT_NameAndType);
+		return nat;
+	}
+
+    public final void dump(DataOutputStream file) throws IOException {
+	    super.dump(file);
+	    file.writeShort(classIndex);
+	    file.writeShort(methodIndex);
+    }    
+}

Propchange: jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/EnclosingMethod.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/EnclosingMethod.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/EnclosingMethod.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/LocalVariableTypeTable.java
URL: http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/LocalVariableTypeTable.java?rev=411580&view=auto
==============================================================================
--- jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/LocalVariableTypeTable.java (added)
+++ jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/LocalVariableTypeTable.java Sun Jun  4 08:52:18 2006
@@ -0,0 +1,135 @@
+/* *******************************************************************
+ * Copyright (c) 2004 IBM Corporation
+ * 
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Common Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://www.eclipse.org/legal/cpl-v10.html 
+ *  
+ * Contributors: 
+ *    Andy Clement     initial implementation 
+ *    Heavily based on LocalVariableTable
+ * ******************************************************************/
+package org.apache.bcel.classfile;
+
+
+import  org.apache.bcel.Constants;
+import  java.io.*;
+
+// The new table is used when generic types are about...
+
+//LocalVariableTable_attribute {
+//	   u2 attribute_name_index;
+//	   u4 attribute_length;
+//	   u2 local_variable_table_length;
+//	   {  u2 start_pc;
+//	      u2 length;
+//	      u2 name_index;
+//	      u2 descriptor_index;
+//	      u2 index;
+//	   } local_variable_table[local_variable_table_length];
+//	 }
+
+//LocalVariableTypeTable_attribute {
+//    u2 attribute_name_index;
+//    u4 attribute_length;
+//    u2 local_variable_type_table_length;
+//    { 
+//      u2 start_pc;
+//      u2 length;
+//      u2 name_index;
+//      u2 signature_index;
+//      u2 index;
+//    } local_variable_type_table[local_variable_type_table_length];
+//  }
+// J5TODO: Needs some testing !
+public class LocalVariableTypeTable extends Attribute {
+  private int             local_variable_type_table_length; // Table of local
+  private LocalVariable[] local_variable_type_table;        // variables
+
+  public LocalVariableTypeTable(LocalVariableTypeTable c) {
+    this(c.getNameIndex(), c.getLength(), c.getLocalVariableTypeTable(),
+	 c.getConstantPool());
+  }
+
+  public LocalVariableTypeTable(int name_index, int length,
+			    LocalVariable[] local_variable_table,
+			    ConstantPool    constant_pool)
+  {
+    super(Constants.ATTR_LOCAL_VARIABLE_TYPE_TABLE, name_index, length, constant_pool);
+    setLocalVariableTable(local_variable_table);
+  }    
+
+  LocalVariableTypeTable(int nameIdx, int len, DataInputStream dis,ConstantPool cpool) throws IOException {
+    this(nameIdx, len, (LocalVariable[])null, cpool);
+
+    local_variable_type_table_length = (dis.readUnsignedShort());
+    local_variable_type_table = new LocalVariable[local_variable_type_table_length];
+
+    for(int i=0; i < local_variable_type_table_length; i++)
+      local_variable_type_table[i] = new LocalVariable(dis, cpool);
+  }
+
+  public void accept(Visitor v) {
+    v.visitLocalVariableTypeTable(this);
+  }
+
+  public final void dump(DataOutputStream file) throws IOException
+  {
+    super.dump(file);
+    file.writeShort(local_variable_type_table_length);
+    for(int i=0; i < local_variable_type_table_length; i++)
+      local_variable_type_table[i].dump(file);
+  }
+
+  public final LocalVariable[] getLocalVariableTypeTable() {
+    return local_variable_type_table;
+  }    
+
+  public final LocalVariable getLocalVariable(int index) {
+    for(int i=0; i < local_variable_type_table_length; i++)
+      if(local_variable_type_table[i].getIndex() == index)
+	return local_variable_type_table[i];
+
+    return null;
+  }
+
+  public final void setLocalVariableTable(LocalVariable[] local_variable_table)
+  {
+    this.local_variable_type_table = local_variable_table;
+    local_variable_type_table_length = (local_variable_table == null)? 0 :
+      local_variable_table.length;
+  }
+
+  /**
+   * @return String representation.
+   */ 
+  public final String toString() {
+    StringBuffer buf = new StringBuffer("");
+
+    for(int i=0; i < local_variable_type_table_length; i++) {
+      buf.append(local_variable_type_table[i].toString());
+
+      if(i < local_variable_type_table_length - 1) buf.append('\n');
+    }
+
+    return buf.toString();
+  }
+
+  /**
+   * @return deep copy of this attribute
+   */
+  public Attribute copy(ConstantPool constant_pool) {
+    LocalVariableTypeTable c = (LocalVariableTypeTable)clone();
+
+    c.local_variable_type_table = new LocalVariable[local_variable_type_table_length];
+    for(int i=0; i < local_variable_type_table_length; i++)
+      c.local_variable_type_table[i] = local_variable_type_table[i].copy();
+
+    c.constant_pool = constant_pool;
+    return c;
+  }
+
+  public final int getTableLength() { return local_variable_type_table_length; }
+}

Propchange: jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/LocalVariableTypeTable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/LocalVariableTypeTable.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: jakarta/bcel/trunk/src/main/java/org/apache/bcel/classfile/LocalVariableTypeTable.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.