You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-dev@jakarta.apache.org by db...@apache.org on 2005/02/13 05:59:18 UTC
svn commit: r153604 - in jakarta/bcel/trunk/src/java/org/apache/bcel:
Constants.java classfile/Annotations.java classfile/Attribute.java
classfile/EmptyVisitor.java classfile/ParameterAnnotationEntry.java
classfile/ParameterAnnotations.java classfile/Visitor.java
Author: dbrosius
Date: Sat Feb 12 20:59:14 2005
New Revision: 153604
URL: http://svn.apache.org/viewcvs?view=rev&rev=153604
Log:
Start adding support for Parameter Annotations (still commnted out)
Added:
jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ParameterAnnotationEntry.java
jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ParameterAnnotations.java
Modified:
jakarta/bcel/trunk/src/java/org/apache/bcel/Constants.java
jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Annotations.java
jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Attribute.java
jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/EmptyVisitor.java
jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Visitor.java
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/Constants.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/Constants.java?view=diff&r1=153603&r2=153604
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/Constants.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/Constants.java Sat Feb 12 20:59:14 2005
@@ -698,21 +698,23 @@
/** Attributes and their corresponding names.
*/
- public static final byte ATTR_UNKNOWN = -1;
- public static final byte ATTR_SOURCE_FILE = 0;
- public static final byte ATTR_CONSTANT_VALUE = 1;
- public static final byte ATTR_CODE = 2;
- public static final byte ATTR_EXCEPTIONS = 3;
- public static final byte ATTR_LINE_NUMBER_TABLE = 4;
- public static final byte ATTR_LOCAL_VARIABLE_TABLE = 5;
- public static final byte ATTR_INNER_CLASSES = 6;
- public static final byte ATTR_SYNTHETIC = 7;
- public static final byte ATTR_DEPRECATED = 8;
- 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_UNKNOWN = -1;
+ public static final byte ATTR_SOURCE_FILE = 0;
+ public static final byte ATTR_CONSTANT_VALUE = 1;
+ public static final byte ATTR_CODE = 2;
+ public static final byte ATTR_EXCEPTIONS = 3;
+ public static final byte ATTR_LINE_NUMBER_TABLE = 4;
+ public static final byte ATTR_LOCAL_VARIABLE_TABLE = 5;
+ public static final byte ATTR_INNER_CLASSES = 6;
+ public static final byte ATTR_SYNTHETIC = 7;
+ public static final byte ATTR_DEPRECATED = 8;
+ 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 = 14;
public static final short KNOWN_ATTRIBUTES = 14;
@@ -721,7 +723,8 @@
"LineNumberTable", "LocalVariableTable",
"InnerClasses", "Synthetic", "Deprecated",
"PMGClass", "Signature", "StackMap",
- "RuntimeVisibleAnnotations", "RuntimeInvisibleAnnotations"
+ "RuntimeVisibleAnnotations", "RuntimeInvisibleAnnotations",
+ "RuntimeVisibleParameterAnnotations", "RuntimeInvisibleParameterAnnotations"
};
/** Constants used in the StackMap attribute.
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Annotations.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Annotations.java?view=diff&r1=153603&r2=153604
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Annotations.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Annotations.java Sat Feb 12 20:59:14 2005
@@ -104,5 +104,5 @@
/**
* @returns the number of annotation entries in this annotation
*/
- public final int getNumAnnotation() { return annotation_table_length; }
+ public final int getNumAnnotations() { return annotation_table_length; }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Attribute.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Attribute.java?view=diff&r1=153603&r2=153604
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Attribute.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Attribute.java Sat Feb 12 20:59:14 2005
@@ -184,11 +184,17 @@
return new StackMap(name_index, length, file, constant_pool);
// case Constants.ATTR_RUNTIMEVISIBLE_ANNOTATIONS:
-// return new RuntimeVisibleAnnotations(name_index, length, file, constant_pool);
+// 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);
+
default: // Never reached
throw new IllegalStateException("Ooops! default case reached.");
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/EmptyVisitor.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/EmptyVisitor.java?view=diff&r1=153603&r2=153604
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/EmptyVisitor.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/EmptyVisitor.java Sat Feb 12 20:59:14 2005
@@ -31,8 +31,9 @@
public class EmptyVisitor implements Visitor {
protected EmptyVisitor() { }
- //public void visitAnnotation(Annotations obj) {}
- //public void visitAnnotationEntry(AnnotationEntry obj) {}
+ public void visitAnnotation(Annotations obj) {}
+ public void visitParameterAnnotation(ParameterAnnotations obj) {}
+ public void visitAnnotationEntry(AnnotationEntry obj) {}
public void visitCode(Code obj) {}
public void visitCodeException(CodeException obj) {}
public void visitConstantClass(ConstantClass obj) {}
Added: jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ParameterAnnotationEntry.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ParameterAnnotationEntry.java?view=auto&rev=153604
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ParameterAnnotationEntry.java (added)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ParameterAnnotationEntry.java Sat Feb 12 20:59:14 2005
@@ -0,0 +1,73 @@
+/*
+ * 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 parameter annotation in the parameter annotation table
+ *
+ * @version $Id: ParameterAnnotationEntry
+ * @author <A HREF="mailto:dbrosius@qis.net">D. Brosius</A>
+ */
+public class ParameterAnnotationEntry implements Node, Constants
+{
+ private int annotation_table_length;
+ private AnnotationEntry[] annotation_table;
+
+ /**
+ * Construct object from file stream.
+ * @param file Input stream
+ * @throws IOException
+ */
+ ParameterAnnotationEntry(DataInputStream file, ConstantPool constant_pool)
+ throws IOException
+ {
+ 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);
+ }
+
+ /**
+ * 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.visitParameterAnnotationEntry(this);
+ }
+
+ /**
+ * @returns the number of annotation entries in this parameter annotation
+ */
+ public final int getNumAnnotations() { return annotation_table_length; }
+
+ /**
+ * returns the array of annotation entries in this annotation
+ */
+ public AnnotationEntry[] getAnnotationEntries() {
+ return annotation_table;
+ }
+}
Added: jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ParameterAnnotations.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ParameterAnnotations.java?view=auto&rev=153604
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ParameterAnnotations.java (added)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/ParameterAnnotations.java Sat Feb 12 20:59:14 2005
@@ -0,0 +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;
+
+import org.apache.bcel.Constants;
+
+/**
+ * base class for parameter annotations
+ *
+ * @version $Id: ParameterAnnotations
+ * @author <A HREF="mailto:dbrosius@qis.net">D. Brosius</A>
+ */
+public abstract class ParameterAnnotations extends Attribute {
+
+ private int num_parameters;
+ private ParameterAnnotationEntry[] parameter_annotation_table; // Table of parameter annotations
+
+ /**
+ * @param parameter_annotation_type the subclass type of the parameter 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
+ */
+ ParameterAnnotations(byte parameter_annotation_type, int name_index, int length, DataInputStream file,
+ ConstantPool constant_pool) throws IOException
+ {
+ this(parameter_annotation_type, name_index, length, (ParameterAnnotationEntry[]) null, constant_pool);
+
+ num_parameters = (file.readUnsignedShort());
+ parameter_annotation_table = new ParameterAnnotationEntry[num_parameters];
+
+ for(int i=0; i < num_parameters; i++)
+ parameter_annotation_table[i] = new ParameterAnnotationEntry(file, constant_pool);
+ }
+
+ /**
+ * @param parameter_annotation_type the subclass type of the parameter annotation
+ * @param name_index Index pointing to the name <em>Code</em>
+ * @param length Content length in bytes
+ * @param parameter_annotation_table the actual parameter annotations
+ * @param constant_pool Array of constants
+ */
+ public ParameterAnnotations(byte parameter_annotation_type, int name_index, int length, ParameterAnnotationEntry[] parameter_annotation_table, ConstantPool constant_pool)
+ {
+ super(parameter_annotation_type, name_index, length, constant_pool);
+ setParameterAnnotationTable(parameter_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.visitParameterAnnotation(this);
+ }
+
+ /**
+ * @param parameter_annotation_table the entries to set in this parameter annotation
+ */
+ public final void setParameterAnnotationTable(ParameterAnnotationEntry[] parameter_annotation_table)
+ {
+ this.parameter_annotation_table = parameter_annotation_table;
+ num_parameters = (parameter_annotation_table == null)? 0 :
+ parameter_annotation_table.length;
+ }
+
+ /**
+ * @returns the parameter annotation entry table
+ */
+ public final ParameterAnnotationEntry[] getParameterAnnotationTable()
+ {
+ return parameter_annotation_table;
+ }
+
+ /**
+ * returns the array of parameter annotation entries in this parameter annotation
+ */
+ public ParameterAnnotationEntry[] getParameterAnnotationEntries() {
+ return parameter_annotation_table;
+ }
+
+ /**
+ * @returns the number of parameter annotation entries in this parameter annotation
+ */
+ public final int getNumParameterAnnotation() { return num_parameters; }
+}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Visitor.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Visitor.java?view=diff&r1=153603&r2=153604
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Visitor.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Visitor.java Sat Feb 12 20:59:14 2005
@@ -30,6 +30,7 @@
*/
public interface Visitor {
//public void visitAnnotation(Annotations obj);
+ //public void visitParameterAnnotation(ParameterAnnotations obj);
//public void visitAnnotationEntry(AnnotationEntry obj);
public void visitCode(Code obj);
public void visitCodeException(CodeException obj);
---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-dev-help@jakarta.apache.org