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?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Visitor.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/classfile/Visitor.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.classfile;
-
/**
* Interface to make use of the Visitor pattern programming style.
* I.e. a class that implements this interface can traverse the contents of
@@ -26,40 +25,103 @@
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
public interface Visitor {
- //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 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 );
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/AALOAD.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/AALOAD.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/AALOAD.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/AALOAD.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* AALOAD - Load reference from array
* <PRE>Stack: ..., arrayref, index -> value</PRE>
@@ -25,26 +24,27 @@
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
public class AALOAD extends ArrayInstruction implements StackProducer {
- /** Load reference from array
- */
- public AALOAD() {
- super(org.apache.bcel.Constants.AALOAD);
- }
+
+ /** Load reference from array
+ */
+ public AALOAD() {
+ super(org.apache.bcel.Constants.AALOAD);
+ }
- /**
- * Call corresponding visitor method(s). The order is:
- * Call visitor methods of implemented interfaces first, then
- * call methods according to the class hierarchy in descending order,
- * i.e., the most specific visitXXX() call comes last.
- *
- * @param v Visitor object
- */
- public void accept(Visitor v) {
- v.visitStackProducer(this);
- v.visitExceptionThrower(this);
- v.visitTypedInstruction(this);
- v.visitArrayInstruction(this);
- v.visitAALOAD(this);
- }
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept( Visitor v ) {
+ v.visitStackProducer(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitArrayInstruction(this);
+ v.visitAALOAD(this);
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/AASTORE.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/AASTORE.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/AASTORE.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/AASTORE.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* AASTORE - Store into reference array
* <PRE>Stack: ..., arrayref, index, value -> ...</PRE>
@@ -25,26 +24,27 @@
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
public class AASTORE extends ArrayInstruction implements StackConsumer {
- /** Store into reference array
- */
- public AASTORE() {
- super(org.apache.bcel.Constants.AASTORE);
- }
+
+ /** Store into reference array
+ */
+ public AASTORE() {
+ super(org.apache.bcel.Constants.AASTORE);
+ }
- /**
- * Call corresponding visitor method(s). The order is:
- * Call visitor methods of implemented interfaces first, then
- * call methods according to the class hierarchy in descending order,
- * i.e., the most specific visitXXX() call comes last.
- *
- * @param v Visitor object
- */
- public void accept(Visitor v) {
- v.visitStackConsumer(this);
- v.visitExceptionThrower(this);
- v.visitTypedInstruction(this);
- v.visitArrayInstruction(this);
- v.visitAASTORE(this);
- }
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept( Visitor v ) {
+ v.visitStackConsumer(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitArrayInstruction(this);
+ v.visitAASTORE(this);
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ACONST_NULL.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ACONST_NULL.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ACONST_NULL.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ACONST_NULL.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* ACONST_NULL - Push null reference
* <PRE>Stack: ... -> ..., null</PRE>
@@ -24,34 +23,35 @@
* @version $Id$
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
-public class ACONST_NULL extends Instruction
- implements PushInstruction, TypedInstruction {
- /**
- * Push null reference
- */
- public ACONST_NULL() {
- super(org.apache.bcel.Constants.ACONST_NULL, (short)1);
- }
-
- /** @return Type.NULL
- */
- public Type getType(ConstantPoolGen cp) {
- return Type.NULL;
- }
-
-
- /**
- * Call corresponding visitor method(s). The order is:
- * Call visitor methods of implemented interfaces first, then
- * call methods according to the class hierarchy in descending order,
- * i.e., the most specific visitXXX() call comes last.
- *
- * @param v Visitor object
- */
- public void accept(Visitor v) {
- v.visitStackProducer(this);
- v.visitPushInstruction(this);
- v.visitTypedInstruction(this);
- v.visitACONST_NULL(this);
- }
+public class ACONST_NULL extends Instruction implements PushInstruction, TypedInstruction {
+
+ /**
+ * Push null reference
+ */
+ public ACONST_NULL() {
+ super(org.apache.bcel.Constants.ACONST_NULL, (short) 1);
+ }
+
+
+ /** @return Type.NULL
+ */
+ public Type getType( ConstantPoolGen cp ) {
+ return Type.NULL;
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept( Visitor v ) {
+ v.visitStackProducer(this);
+ v.visitPushInstruction(this);
+ v.visitTypedInstruction(this);
+ v.visitACONST_NULL(this);
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ALOAD.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ALOAD.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ALOAD.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ALOAD.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* ALOAD - Load reference from local variable
* <PRE>Stack: ... -> ..., objectref</PRE>
@@ -25,31 +24,34 @@
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
public class ALOAD extends LoadInstruction {
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- ALOAD() {
- super(org.apache.bcel.Constants.ALOAD, org.apache.bcel.Constants.ALOAD_0);
- }
-
- /** Load reference from local variable
- * @param n index of local variable
- */
- public ALOAD(int n) {
- super(org.apache.bcel.Constants.ALOAD, org.apache.bcel.Constants.ALOAD_0, n);
- }
-
- /**
- * Call corresponding visitor method(s). The order is:
- * Call visitor methods of implemented interfaces first, then
- * call methods according to the class hierarchy in descending order,
- * i.e., the most specific visitXXX() call comes last.
- *
- * @param v Visitor object
- */
- public void accept(Visitor v) {
- super.accept(v);
- v.visitALOAD(this);
- }
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ ALOAD() {
+ super(org.apache.bcel.Constants.ALOAD, org.apache.bcel.Constants.ALOAD_0);
+ }
+
+
+ /** Load reference from local variable
+ * @param n index of local variable
+ */
+ public ALOAD(int n) {
+ super(org.apache.bcel.Constants.ALOAD, org.apache.bcel.Constants.ALOAD_0, n);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept( Visitor v ) {
+ super.accept(v);
+ v.visitALOAD(this);
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ANEWARRAY.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ANEWARRAY.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ANEWARRAY.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ANEWARRAY.java Wed Mar 15 03:31:56 2006
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
import org.apache.bcel.ExceptionConstants;
@@ -25,53 +25,55 @@
* @version $Id$
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
-public class ANEWARRAY extends CPInstruction
- implements LoadClass, AllocationInstruction, ExceptionThrower, StackConsumer, StackProducer {
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- ANEWARRAY() {}
-
- public ANEWARRAY(int index) {
- super(org.apache.bcel.Constants.ANEWARRAY, index);
- }
-
- public Class[] getExceptions(){
- Class[] cs = new Class[1 + ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length];
-
- System.arraycopy(ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION, 0,
- cs, 0, ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length);
- cs[ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length] =
- ExceptionConstants.NEGATIVE_ARRAY_SIZE_EXCEPTION;
- return cs;
- }
-
- /**
- * Call corresponding visitor method(s). The order is:
- * Call visitor methods of implemented interfaces first, then
- * call methods according to the class hierarchy in descending order,
- * i.e., the most specific visitXXX() call comes last.
- *
- * @param v Visitor object
- */
- public void accept(Visitor v) {
- v.visitLoadClass(this);
- v.visitAllocationInstruction(this);
- v.visitExceptionThrower(this);
- v.visitStackProducer(this);
- v.visitTypedInstruction(this);
- v.visitCPInstruction(this);
- v.visitANEWARRAY(this);
- }
-
- public ObjectType getLoadClassType(ConstantPoolGen cpg) {
- Type t = getType(cpg);
-
- if (t instanceof ArrayType){
- t = ((ArrayType) t).getBasicType();
+public class ANEWARRAY extends CPInstruction implements LoadClass, AllocationInstruction,
+ ExceptionThrower, StackConsumer, StackProducer {
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ ANEWARRAY() {
+ }
+
+
+ public ANEWARRAY(int index) {
+ super(org.apache.bcel.Constants.ANEWARRAY, index);
+ }
+
+
+ public Class[] getExceptions() {
+ Class[] cs = new Class[1 + ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length];
+ System.arraycopy(ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION, 0, cs, 0,
+ ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length);
+ cs[ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length] = ExceptionConstants.NEGATIVE_ARRAY_SIZE_EXCEPTION;
+ return cs;
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept( Visitor v ) {
+ v.visitLoadClass(this);
+ v.visitAllocationInstruction(this);
+ v.visitExceptionThrower(this);
+ v.visitStackProducer(this);
+ v.visitTypedInstruction(this);
+ v.visitCPInstruction(this);
+ v.visitANEWARRAY(this);
+ }
+
+
+ public ObjectType getLoadClassType( ConstantPoolGen cpg ) {
+ Type t = getType(cpg);
+ if (t instanceof ArrayType) {
+ t = ((ArrayType) t).getBasicType();
+ }
+ return (t instanceof ObjectType) ? (ObjectType) t : null;
}
-
- return (t instanceof ObjectType)? (ObjectType) t : null;
- }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ARETURN.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ARETURN.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ARETURN.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ARETURN.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* ARETURN - Return reference from method
* <PRE>Stack: ..., objectref -> <empty></PRE>
@@ -25,27 +24,28 @@
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
public class ARETURN extends ReturnInstruction {
- /**
- * Return reference from method
- */
- public ARETURN() {
- super(org.apache.bcel.Constants.ARETURN);
- }
+
+ /**
+ * Return reference from method
+ */
+ public ARETURN() {
+ super(org.apache.bcel.Constants.ARETURN);
+ }
- /**
- * Call corresponding visitor method(s). The order is:
- * Call visitor methods of implemented interfaces first, then
- * call methods according to the class hierarchy in descending order,
- * i.e., the most specific visitXXX() call comes last.
- *
- * @param v Visitor object
- */
- public void accept(Visitor v) {
- v.visitExceptionThrower(this);
- v.visitTypedInstruction(this);
- v.visitStackConsumer(this);
- v.visitReturnInstruction(this);
- v.visitARETURN(this);
- }
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept( Visitor v ) {
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitStackConsumer(this);
+ v.visitReturnInstruction(this);
+ v.visitARETURN(this);
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ARRAYLENGTH.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ARRAYLENGTH.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ARRAYLENGTH.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ARRAYLENGTH.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* ARRAYLENGTH - Get length of array
* <PRE>Stack: ..., arrayref -> ..., length</PRE>
@@ -24,32 +23,35 @@
* @version $Id$
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
-public class ARRAYLENGTH extends Instruction
- implements ExceptionThrower, StackProducer {
- /** Get length of array
- */
- public ARRAYLENGTH() {
- super(org.apache.bcel.Constants.ARRAYLENGTH, (short)1);
- }
-
- /** @return exceptions this instruction may cause
- */
- public Class[] getExceptions() {
- return new Class[] { org.apache.bcel.ExceptionConstants.NULL_POINTER_EXCEPTION };
- }
-
-
- /**
- * Call corresponding visitor method(s). The order is:
- * Call visitor methods of implemented interfaces first, then
- * call methods according to the class hierarchy in descending order,
- * i.e., the most specific visitXXX() call comes last.
- *
- * @param v Visitor object
- */
- public void accept(Visitor v) {
- v.visitExceptionThrower(this);
- v.visitStackProducer(this);
- v.visitARRAYLENGTH(this);
- }
+public class ARRAYLENGTH extends Instruction implements ExceptionThrower, StackProducer {
+
+ /** Get length of array
+ */
+ public ARRAYLENGTH() {
+ super(org.apache.bcel.Constants.ARRAYLENGTH, (short) 1);
+ }
+
+
+ /** @return exceptions this instruction may cause
+ */
+ public Class[] getExceptions() {
+ return new Class[] {
+ org.apache.bcel.ExceptionConstants.NULL_POINTER_EXCEPTION
+ };
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept( Visitor v ) {
+ v.visitExceptionThrower(this);
+ v.visitStackProducer(this);
+ v.visitARRAYLENGTH(this);
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ASTORE.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ASTORE.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ASTORE.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ASTORE.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* ASTORE - Store reference into local variable
* <PRE>Stack ..., objectref -> ... </PRE>
@@ -25,31 +24,34 @@
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
public class ASTORE extends StoreInstruction {
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- ASTORE() {
- super(org.apache.bcel.Constants.ASTORE, org.apache.bcel.Constants.ASTORE_0);
- }
-
- /** Store reference into local variable
- * @param n index of local variable
- */
- public ASTORE(int n) {
- super(org.apache.bcel.Constants.ASTORE, org.apache.bcel.Constants.ASTORE_0, n);
- }
-
- /**
- * Call corresponding visitor method(s). The order is:
- * Call visitor methods of implemented interfaces first, then
- * call methods according to the class hierarchy in descending order,
- * i.e., the most specific visitXXX() call comes last.
- *
- * @param v Visitor object
- */
- public void accept(Visitor v) {
- super.accept(v);
- v.visitASTORE(this);
- }
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ ASTORE() {
+ super(org.apache.bcel.Constants.ASTORE, org.apache.bcel.Constants.ASTORE_0);
+ }
+
+
+ /** Store reference into local variable
+ * @param n index of local variable
+ */
+ public ASTORE(int n) {
+ super(org.apache.bcel.Constants.ASTORE, org.apache.bcel.Constants.ASTORE_0, n);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept( Visitor v ) {
+ super.accept(v);
+ v.visitASTORE(this);
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ATHROW.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ATHROW.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ATHROW.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ATHROW.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* ATHROW - Throw exception
* <PRE>Stack: ..., objectref -> objectref</PRE>
@@ -25,31 +24,35 @@
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
public class ATHROW extends Instruction implements UnconditionalBranch, ExceptionThrower {
- /**
- * Throw exception
- */
- public ATHROW() {
- super(org.apache.bcel.Constants.ATHROW, (short)1);
- }
-
- /** @return exceptions this instruction may cause
- */
- public Class[] getExceptions() {
- return new Class[] { org.apache.bcel.ExceptionConstants.THROWABLE };
- }
-
-
- /**
- * Call corresponding visitor method(s). The order is:
- * Call visitor methods of implemented interfaces first, then
- * call methods according to the class hierarchy in descending order,
- * i.e., the most specific visitXXX() call comes last.
- *
- * @param v Visitor object
- */
- public void accept(Visitor v) {
- v.visitUnconditionalBranch(this);
- v.visitExceptionThrower(this);
- v.visitATHROW(this);
- }
+
+ /**
+ * Throw exception
+ */
+ public ATHROW() {
+ super(org.apache.bcel.Constants.ATHROW, (short) 1);
+ }
+
+
+ /** @return exceptions this instruction may cause
+ */
+ public Class[] getExceptions() {
+ return new Class[] {
+ org.apache.bcel.ExceptionConstants.THROWABLE
+ };
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept( Visitor v ) {
+ v.visitUnconditionalBranch(this);
+ v.visitExceptionThrower(this);
+ v.visitATHROW(this);
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/AllocationInstruction.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/AllocationInstruction.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/AllocationInstruction.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/AllocationInstruction.java Wed Mar 15 03:31:56 2006
@@ -13,15 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* Denote family of instructions that allocates space in the heap.
*
* @version $Id$
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
-public interface AllocationInstruction {}
-
+public interface AllocationInstruction {
+}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ArithmeticInstruction.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ArithmeticInstruction.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ArithmeticInstruction.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ArithmeticInstruction.java Wed Mar 15 03:31:56 2006
@@ -13,57 +13,82 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
import org.apache.bcel.Constants;
+
/**
* Super class for the family of arithmetic instructions.
*
* @version $Id$
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
-public abstract class ArithmeticInstruction extends Instruction
- implements TypedInstruction, StackProducer, StackConsumer {
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- ArithmeticInstruction() {}
-
- /**
- * @param opcode of instruction
- */
- protected ArithmeticInstruction(short opcode) {
- super(opcode, (short)1);
- }
-
- /** @return type associated with the instruction
- */
- public Type getType(ConstantPoolGen cp) {
- switch(opcode) {
- case Constants.DADD: case Constants.DDIV: case Constants.DMUL:
- case Constants.DNEG: case Constants.DREM: case Constants.DSUB:
- return Type.DOUBLE;
-
- case Constants.FADD: case Constants.FDIV: case Constants.FMUL:
- case Constants.FNEG: case Constants.FREM: case Constants.FSUB:
- return Type.FLOAT;
-
- case Constants.IADD: case Constants.IAND: case Constants.IDIV:
- case Constants.IMUL: case Constants.INEG: case Constants.IOR: case Constants.IREM:
- case Constants.ISHL: case Constants.ISHR: case Constants.ISUB:
- case Constants.IUSHR: case Constants.IXOR:
- return Type.INT;
-
- case Constants.LADD: case Constants.LAND: case Constants.LDIV:
- case Constants.LMUL: case Constants.LNEG: case Constants.LOR: case Constants.LREM:
- case Constants.LSHL: case Constants.LSHR: case Constants.LSUB:
- case Constants.LUSHR: case Constants.LXOR:
- return Type.LONG;
+public abstract class ArithmeticInstruction extends Instruction implements TypedInstruction,
+ StackProducer, StackConsumer {
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ ArithmeticInstruction() {
+ }
+
+
+ /**
+ * @param opcode of instruction
+ */
+ protected ArithmeticInstruction(short opcode) {
+ super(opcode, (short) 1);
+ }
+
- default: // Never reached
- throw new ClassGenException("Unknown type " + opcode);
+ /** @return type associated with the instruction
+ */
+ public Type getType( ConstantPoolGen cp ) {
+ switch (opcode) {
+ case Constants.DADD:
+ case Constants.DDIV:
+ case Constants.DMUL:
+ case Constants.DNEG:
+ case Constants.DREM:
+ case Constants.DSUB:
+ return Type.DOUBLE;
+ case Constants.FADD:
+ case Constants.FDIV:
+ case Constants.FMUL:
+ case Constants.FNEG:
+ case Constants.FREM:
+ case Constants.FSUB:
+ return Type.FLOAT;
+ case Constants.IADD:
+ case Constants.IAND:
+ case Constants.IDIV:
+ case Constants.IMUL:
+ case Constants.INEG:
+ case Constants.IOR:
+ case Constants.IREM:
+ case Constants.ISHL:
+ case Constants.ISHR:
+ case Constants.ISUB:
+ case Constants.IUSHR:
+ case Constants.IXOR:
+ return Type.INT;
+ case Constants.LADD:
+ case Constants.LAND:
+ case Constants.LDIV:
+ case Constants.LMUL:
+ case Constants.LNEG:
+ case Constants.LOR:
+ case Constants.LREM:
+ case Constants.LSHL:
+ case Constants.LSHR:
+ case Constants.LSUB:
+ case Constants.LUSHR:
+ case Constants.LXOR:
+ return Type.LONG;
+ default: // Never reached
+ throw new ClassGenException("Unknown type " + opcode);
+ }
}
- }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ArrayInstruction.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ArrayInstruction.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ArrayInstruction.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ArrayInstruction.java Wed Mar 15 03:31:56 2006
@@ -13,57 +13,69 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* Super class for instructions dealing with array access such as IALOAD.
*
* @version $Id$
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
-public abstract class ArrayInstruction extends Instruction
- implements ExceptionThrower, TypedInstruction {
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- ArrayInstruction() {}
-
- /**
- * @param opcode of instruction
- */
- protected ArrayInstruction(short opcode) {
- super(opcode, (short)1);
- }
-
- public Class[] getExceptions() {
- return org.apache.bcel.ExceptionConstants.EXCS_ARRAY_EXCEPTION;
- }
-
- /** @return type associated with the instruction
- */
- public Type getType(ConstantPoolGen cp) {
- switch(opcode) {
- case org.apache.bcel.Constants.IALOAD: case org.apache.bcel.Constants.IASTORE:
- return Type.INT;
- case org.apache.bcel.Constants.CALOAD: case org.apache.bcel.Constants.CASTORE:
- return Type.CHAR;
- case org.apache.bcel.Constants.BALOAD: case org.apache.bcel.Constants.BASTORE:
- return Type.BYTE;
- case org.apache.bcel.Constants.SALOAD: case org.apache.bcel.Constants.SASTORE:
- return Type.SHORT;
- case org.apache.bcel.Constants.LALOAD: case org.apache.bcel.Constants.LASTORE:
- return Type.LONG;
- case org.apache.bcel.Constants.DALOAD: case org.apache.bcel.Constants.DASTORE:
- return Type.DOUBLE;
- case org.apache.bcel.Constants.FALOAD: case org.apache.bcel.Constants.FASTORE:
- return Type.FLOAT;
- case org.apache.bcel.Constants.AALOAD: case org.apache.bcel.Constants.AASTORE:
- return Type.OBJECT;
+public abstract class ArrayInstruction extends Instruction implements ExceptionThrower,
+ TypedInstruction {
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ ArrayInstruction() {
+ }
+
+
+ /**
+ * @param opcode of instruction
+ */
+ protected ArrayInstruction(short opcode) {
+ super(opcode, (short) 1);
+ }
+
+
+ public Class[] getExceptions() {
+ return org.apache.bcel.ExceptionConstants.EXCS_ARRAY_EXCEPTION;
+ }
+
- default: throw new ClassGenException("Oops: unknown case in switch" + opcode);
+ /** @return type associated with the instruction
+ */
+ public Type getType( ConstantPoolGen cp ) {
+ switch (opcode) {
+ case org.apache.bcel.Constants.IALOAD:
+ case org.apache.bcel.Constants.IASTORE:
+ return Type.INT;
+ case org.apache.bcel.Constants.CALOAD:
+ case org.apache.bcel.Constants.CASTORE:
+ return Type.CHAR;
+ case org.apache.bcel.Constants.BALOAD:
+ case org.apache.bcel.Constants.BASTORE:
+ return Type.BYTE;
+ case org.apache.bcel.Constants.SALOAD:
+ case org.apache.bcel.Constants.SASTORE:
+ return Type.SHORT;
+ case org.apache.bcel.Constants.LALOAD:
+ case org.apache.bcel.Constants.LASTORE:
+ return Type.LONG;
+ case org.apache.bcel.Constants.DALOAD:
+ case org.apache.bcel.Constants.DASTORE:
+ return Type.DOUBLE;
+ case org.apache.bcel.Constants.FALOAD:
+ case org.apache.bcel.Constants.FASTORE:
+ return Type.FLOAT;
+ case org.apache.bcel.Constants.AALOAD:
+ case org.apache.bcel.Constants.AASTORE:
+ return Type.OBJECT;
+ default:
+ throw new ClassGenException("Oops: unknown case in switch" + opcode);
+ }
}
- }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ArrayType.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ArrayType.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ArrayType.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ArrayType.java Wed Mar 15 03:31:56 2006
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
import org.apache.bcel.Constants;
@@ -25,96 +25,103 @@
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
public final class ArrayType extends ReferenceType {
- private int dimensions;
- private Type basic_type;
- /**
- * Convenience constructor for array type, e.g. int[]
- *
- * @param type array type, e.g. T_INT
- */
- public ArrayType(byte type, int dimensions) {
- this(BasicType.getType(type), dimensions);
- }
-
- /**
- * Convenience constructor for reference array type, e.g. Object[]
- *
- * @param class_name complete name of class (java.lang.String, e.g.)
- */
- public ArrayType(String class_name, int dimensions) {
- this(new ObjectType(class_name), dimensions);
- }
-
- /**
- * Constructor for array of given type
- *
- * @param type type of array (may be an array itself)
- */
- public ArrayType(Type type, int dimensions) {
- super(Constants.T_ARRAY, "<dummy>");
-
- if((dimensions < 1) || (dimensions > Constants.MAX_BYTE))
- throw new ClassGenException("Invalid number of dimensions: " + dimensions);
-
- switch(type.getType()) {
- case Constants.T_ARRAY:
- ArrayType array = (ArrayType)type;
- this.dimensions = dimensions + array.dimensions;
- basic_type = array.basic_type;
- break;
-
- case Constants.T_VOID:
- throw new ClassGenException("Invalid type: void[]");
-
- default: // Basic type or reference
- this.dimensions = dimensions;
- basic_type = type;
- break;
- }
-
- StringBuffer buf = new StringBuffer();
- for(int i=0; i < this.dimensions; i++)
- buf.append('[');
-
- buf.append(basic_type.getSignature());
-
- signature = buf.toString();
- }
-
- /**
- * @return basic type of array, i.e., for int[][][] the basic type is int
- */
- public Type getBasicType() {
- return basic_type;
- }
-
- /**
- * @return element type of array, i.e., for int[][][] the element type is int[][]
- */
- public Type getElementType() {
- if(dimensions == 1)
- return basic_type;
-
- return new ArrayType(basic_type, dimensions - 1);
- }
-
- /** @return number of dimensions of array
- */
- public int getDimensions() { return dimensions; }
-
- /** @return a hash code value for the object.
- */
- public int hashCode() { return basic_type.hashCode() ^ dimensions; }
-
- /** @return true if both type objects refer to the same array type.
- */
- public boolean equals(Object _type) {
- if(_type instanceof ArrayType) {
- ArrayType array = (ArrayType)_type;
- return (array.dimensions == dimensions) && array.basic_type.equals(basic_type);
- }
-
- return false;
- }
+ private int dimensions;
+ private Type basic_type;
+
+
+ /**
+ * Convenience constructor for array type, e.g. int[]
+ *
+ * @param type array type, e.g. T_INT
+ */
+ public ArrayType(byte type, int dimensions) {
+ this(BasicType.getType(type), dimensions);
+ }
+
+
+ /**
+ * Convenience constructor for reference array type, e.g. Object[]
+ *
+ * @param class_name complete name of class (java.lang.String, e.g.)
+ */
+ public ArrayType(String class_name, int dimensions) {
+ this(new ObjectType(class_name), dimensions);
+ }
+
+
+ /**
+ * Constructor for array of given type
+ *
+ * @param type type of array (may be an array itself)
+ */
+ public ArrayType(Type type, int dimensions) {
+ super(Constants.T_ARRAY, "<dummy>");
+ if ((dimensions < 1) || (dimensions > Constants.MAX_BYTE)) {
+ throw new ClassGenException("Invalid number of dimensions: " + dimensions);
+ }
+ switch (type.getType()) {
+ case Constants.T_ARRAY:
+ ArrayType array = (ArrayType) type;
+ this.dimensions = dimensions + array.dimensions;
+ basic_type = array.basic_type;
+ break;
+ case Constants.T_VOID:
+ throw new ClassGenException("Invalid type: void[]");
+ default: // Basic type or reference
+ this.dimensions = dimensions;
+ basic_type = type;
+ break;
+ }
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < this.dimensions; i++) {
+ buf.append('[');
+ }
+ buf.append(basic_type.getSignature());
+ signature = buf.toString();
+ }
+
+
+ /**
+ * @return basic type of array, i.e., for int[][][] the basic type is int
+ */
+ public Type getBasicType() {
+ return basic_type;
+ }
+
+
+ /**
+ * @return element type of array, i.e., for int[][][] the element type is int[][]
+ */
+ public Type getElementType() {
+ if (dimensions == 1) {
+ return basic_type;
+ }
+ return new ArrayType(basic_type, dimensions - 1);
+ }
+
+
+ /** @return number of dimensions of array
+ */
+ public int getDimensions() {
+ return dimensions;
+ }
+
+
+ /** @return a hash code value for the object.
+ */
+ public int hashCode() {
+ return basic_type.hashCode() ^ dimensions;
+ }
+
+
+ /** @return true if both type objects refer to the same array type.
+ */
+ public boolean equals( Object _type ) {
+ if (_type instanceof ArrayType) {
+ ArrayType array = (ArrayType) _type;
+ return (array.dimensions == dimensions) && array.basic_type.equals(basic_type);
+ }
+ return false;
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BALOAD.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BALOAD.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BALOAD.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BALOAD.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* BALOAD - Load byte or boolean from array
* <PRE>Stack: ..., arrayref, index -> ..., value</PRE>
@@ -25,26 +24,27 @@
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
public class BALOAD extends ArrayInstruction implements StackProducer {
- /** Load byte or boolean from array
- */
- public BALOAD() {
- super(org.apache.bcel.Constants.BALOAD);
- }
+
+ /** Load byte or boolean from array
+ */
+ public BALOAD() {
+ super(org.apache.bcel.Constants.BALOAD);
+ }
- /**
- * Call corresponding visitor method(s). The order is:
- * Call visitor methods of implemented interfaces first, then
- * call methods according to the class hierarchy in descending order,
- * i.e., the most specific visitXXX() call comes last.
- *
- * @param v Visitor object
- */
- public void accept(Visitor v) {
- v.visitStackProducer(this);
- v.visitExceptionThrower(this);
- v.visitTypedInstruction(this);
- v.visitArrayInstruction(this);
- v.visitBALOAD(this);
- }
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept( Visitor v ) {
+ v.visitStackProducer(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitArrayInstruction(this);
+ v.visitBALOAD(this);
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BASTORE.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BASTORE.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BASTORE.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BASTORE.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* BASTORE - Store into byte or boolean array
* <PRE>Stack: ..., arrayref, index, value -> ...</PRE>
@@ -25,26 +24,27 @@
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
public class BASTORE extends ArrayInstruction implements StackConsumer {
- /** Store byte or boolean into array
- */
- public BASTORE() {
- super(org.apache.bcel.Constants.BASTORE);
- }
+
+ /** Store byte or boolean into array
+ */
+ public BASTORE() {
+ super(org.apache.bcel.Constants.BASTORE);
+ }
- /**
- * Call corresponding visitor method(s). The order is:
- * Call visitor methods of implemented interfaces first, then
- * call methods according to the class hierarchy in descending order,
- * i.e., the most specific visitXXX() call comes last.
- *
- * @param v Visitor object
- */
- public void accept(Visitor v) {
- v.visitStackConsumer(this);
- v.visitExceptionThrower(this);
- v.visitTypedInstruction(this);
- v.visitArrayInstruction(this);
- v.visitBASTORE(this);
- }
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept( Visitor v ) {
+ v.visitStackConsumer(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitArrayInstruction(this);
+ v.visitBASTORE(this);
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BIPUSH.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BIPUSH.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BIPUSH.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BIPUSH.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
import java.io.DataOutputStream;
import java.io.IOException;
import org.apache.bcel.util.ByteSequence;
@@ -30,66 +29,77 @@
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
public class BIPUSH extends Instruction implements ConstantPushInstruction {
- private byte b;
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- BIPUSH() {}
-
- /** Push byte on stack
- */
- public BIPUSH(byte b) {
- super(org.apache.bcel.Constants.BIPUSH, (short)2);
- this.b = b;
- }
-
- /**
- * Dump instruction as byte code to stream out.
- */
- public void dump(DataOutputStream out) throws IOException {
- super.dump(out);
- out.writeByte(b);
- }
-
- /**
- * @return mnemonic for instruction
- */
- public String toString(boolean verbose) {
- return super.toString(verbose) + " " + b;
- }
-
- /**
- * Read needed data (e.g. index) from file.
- */
- protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
- {
- length = 2;
- b = bytes.readByte();
- }
-
- public Number getValue() { return new Integer(b); }
-
- /** @return Type.BYTE
- */
- public Type getType(ConstantPoolGen cp) {
- return Type.BYTE;
- }
-
- /**
- * Call corresponding visitor method(s). The order is:
- * Call visitor methods of implemented interfaces first, then
- * call methods according to the class hierarchy in descending order,
- * i.e., the most specific visitXXX() call comes last.
- *
- * @param v Visitor object
- */
- public void accept(Visitor v) {
- v.visitPushInstruction(this);
- v.visitStackProducer(this);
- v.visitTypedInstruction(this);
- v.visitConstantPushInstruction(this);
- v.visitBIPUSH(this);
- }
+ private byte b;
+
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ BIPUSH() {
+ }
+
+
+ /** Push byte on stack
+ */
+ public BIPUSH(byte b) {
+ super(org.apache.bcel.Constants.BIPUSH, (short) 2);
+ this.b = b;
+ }
+
+
+ /**
+ * Dump instruction as byte code to stream out.
+ */
+ public void dump( DataOutputStream out ) throws IOException {
+ super.dump(out);
+ out.writeByte(b);
+ }
+
+
+ /**
+ * @return mnemonic for instruction
+ */
+ public String toString( boolean verbose ) {
+ return super.toString(verbose) + " " + b;
+ }
+
+
+ /**
+ * Read needed data (e.g. index) from file.
+ */
+ protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
+ length = 2;
+ b = bytes.readByte();
+ }
+
+
+ public Number getValue() {
+ return new Integer(b);
+ }
+
+
+ /** @return Type.BYTE
+ */
+ public Type getType( ConstantPoolGen cp ) {
+ return Type.BYTE;
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept( Visitor v ) {
+ v.visitPushInstruction(this);
+ v.visitStackProducer(this);
+ v.visitTypedInstruction(this);
+ v.visitConstantPushInstruction(this);
+ v.visitBIPUSH(this);
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BREAKPOINT.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BREAKPOINT.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BREAKPOINT.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BREAKPOINT.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* BREAKPOINT, JVM dependent, ignored by default
*
@@ -24,19 +23,21 @@
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
public class BREAKPOINT extends Instruction {
- public BREAKPOINT() {
- super(org.apache.bcel.Constants.BREAKPOINT, (short)1);
- }
- /**
- * Call corresponding visitor method(s). The order is:
- * Call visitor methods of implemented interfaces first, then
- * call methods according to the class hierarchy in descending order,
- * i.e., the most specific visitXXX() call comes last.
- *
- * @param v Visitor object
- */
- public void accept(Visitor v) {
- v.visitBREAKPOINT(this);
- }
+ public BREAKPOINT() {
+ super(org.apache.bcel.Constants.BREAKPOINT, (short) 1);
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept( Visitor v ) {
+ v.visitBREAKPOINT(this);
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BasicType.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BasicType.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BasicType.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BasicType.java Wed Mar 15 03:31:56 2006
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
import org.apache.bcel.Constants;
@@ -25,44 +25,57 @@
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
public final class BasicType extends Type {
- /**
- * Constructor for basic types such as int, long, `void'
- *
- * @param type one of T_INT, T_BOOLEAN, ..., T_VOID
- * @see org.apache.bcel.Constants
- */
- BasicType(byte type) {
- super(type, Constants.SHORT_TYPE_NAMES[type]);
-
- if((type < Constants.T_BOOLEAN) || (type > Constants.T_VOID))
- throw new ClassGenException("Invalid type: " + type);
- }
-
- public static final BasicType getType(byte type) {
- switch(type) {
- case Constants.T_VOID: return VOID;
- case Constants.T_BOOLEAN: return BOOLEAN;
- case Constants.T_BYTE: return BYTE;
- case Constants.T_SHORT: return SHORT;
- case Constants.T_CHAR: return CHAR;
- case Constants.T_INT: return INT;
- case Constants.T_LONG: return LONG;
- case Constants.T_DOUBLE: return DOUBLE;
- case Constants.T_FLOAT: return FLOAT;
- default:
- throw new ClassGenException("Invalid type: " + type);
+ /**
+ * Constructor for basic types such as int, long, `void'
+ *
+ * @param type one of T_INT, T_BOOLEAN, ..., T_VOID
+ * @see org.apache.bcel.Constants
+ */
+ BasicType(byte type) {
+ super(type, Constants.SHORT_TYPE_NAMES[type]);
+ if ((type < Constants.T_BOOLEAN) || (type > Constants.T_VOID)) {
+ throw new ClassGenException("Invalid type: " + type);
+ }
}
- }
- /** @return a hash code value for the object.
- */
- public int hashCode() { return type; }
-
- /** @return true if both type objects refer to the same type
- */
- public boolean equals(Object _type) {
- return (_type instanceof BasicType)?
- ((BasicType)_type).type == this.type : false;
- }
+
+ public static final BasicType getType( byte type ) {
+ switch (type) {
+ case Constants.T_VOID:
+ return VOID;
+ case Constants.T_BOOLEAN:
+ return BOOLEAN;
+ case Constants.T_BYTE:
+ return BYTE;
+ case Constants.T_SHORT:
+ return SHORT;
+ case Constants.T_CHAR:
+ return CHAR;
+ case Constants.T_INT:
+ return INT;
+ case Constants.T_LONG:
+ return LONG;
+ case Constants.T_DOUBLE:
+ return DOUBLE;
+ case Constants.T_FLOAT:
+ return FLOAT;
+ default:
+ throw new ClassGenException("Invalid type: " + type);
+ }
+ }
+
+
+ /** @return a hash code value for the object.
+ */
+ public int hashCode() {
+ return type;
+ }
+
+
+ /** @return true if both type objects refer to the same type
+ */
+ public boolean equals( Object _type ) {
+ return (_type instanceof BasicType) ? ((BasicType) _type).type == this.type : false;
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BranchHandle.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BranchHandle.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BranchHandle.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BranchHandle.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* BranchHandle is returned by specialized InstructionList.append() whenever a
* BranchInstruction is appended. This is useful when the target of this
@@ -30,84 +29,93 @@
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
public final class BranchHandle extends InstructionHandle {
- private BranchInstruction bi; // An alias in fact, but saves lots of casts
- private BranchHandle(BranchInstruction i) {
- super(i);
- bi = i;
- }
-
- /** Factory methods.
- */
- private static BranchHandle bh_list = null; // List of reusable handles
-
- static final BranchHandle getBranchHandle(BranchInstruction i) {
- if(bh_list == null)
- return new BranchHandle(i);
-
- BranchHandle bh = bh_list;
- bh_list = (BranchHandle)bh.next;
-
- bh.setInstruction(i);
-
- return bh;
- }
-
- /** Handle adds itself to the list of resuable handles.
- */
- protected void addHandle() {
- next = bh_list;
- bh_list = this;
- }
-
- /* Override InstructionHandle methods: delegate to branch instruction.
- * Through this overriding all access to the private i_position field should
- * be prevented.
- */
- public int getPosition() { return bi.position; }
-
- void setPosition(int pos) {
- i_position = bi.position = pos;
- }
-
- protected int updatePosition(int offset, int max_offset) {
- int x = bi.updatePosition(offset, max_offset);
- i_position = bi.position;
- return x;
- }
-
- /**
- * Pass new target to instruction.
- */
- public void setTarget(InstructionHandle ih) {
- bi.setTarget(ih);
- }
-
- /**
- * Update target of instruction.
- */
- public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
- bi.updateTarget(old_ih, new_ih);
- }
-
- /**
- * @return target of instruction.
- */
- public InstructionHandle getTarget() {
- return bi.getTarget();
- }
-
- /**
- * Set new contents. Old instruction is disposed and may not be used anymore.
- */
- public void setInstruction(Instruction i) {
- super.setInstruction(i);
-
- if(!(i instanceof BranchInstruction))
- throw new ClassGenException("Assigning " + i +
- " to branch handle which is not a branch instruction");
+ private BranchInstruction bi; // An alias in fact, but saves lots of casts
- bi = (BranchInstruction)i;
- }
-}
+ private BranchHandle(BranchInstruction i) {
+ super(i);
+ bi = i;
+ }
+
+ /** Factory methods.
+ */
+ private static BranchHandle bh_list = null; // List of reusable handles
+
+
+ static final BranchHandle getBranchHandle( BranchInstruction i ) {
+ if (bh_list == null) {
+ return new BranchHandle(i);
+ }
+ BranchHandle bh = bh_list;
+ bh_list = (BranchHandle) bh.next;
+ bh.setInstruction(i);
+ return bh;
+ }
+
+
+ /** Handle adds itself to the list of resuable handles.
+ */
+ protected void addHandle() {
+ next = bh_list;
+ bh_list = this;
+ }
+
+
+ /* Override InstructionHandle methods: delegate to branch instruction.
+ * Through this overriding all access to the private i_position field should
+ * be prevented.
+ */
+ public int getPosition() {
+ return bi.position;
+ }
+
+
+ void setPosition( int pos ) {
+ i_position = bi.position = pos;
+ }
+
+
+ protected int updatePosition( int offset, int max_offset ) {
+ int x = bi.updatePosition(offset, max_offset);
+ i_position = bi.position;
+ return x;
+ }
+
+
+ /**
+ * Pass new target to instruction.
+ */
+ public void setTarget( InstructionHandle ih ) {
+ bi.setTarget(ih);
+ }
+
+
+ /**
+ * Update target of instruction.
+ */
+ public void updateTarget( InstructionHandle old_ih, InstructionHandle new_ih ) {
+ bi.updateTarget(old_ih, new_ih);
+ }
+
+
+ /**
+ * @return target of instruction.
+ */
+ public InstructionHandle getTarget() {
+ return bi.getTarget();
+ }
+
+
+ /**
+ * Set new contents. Old instruction is disposed and may not be used anymore.
+ */
+ public void setInstruction( Instruction i ) {
+ super.setInstruction(i);
+ if (!(i instanceof BranchInstruction)) {
+ throw new ClassGenException("Assigning " + i
+ + " to branch handle which is not a branch instruction");
+ }
+ bi = (BranchInstruction) i;
+ }
+}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BranchInstruction.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BranchInstruction.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BranchInstruction.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/BranchInstruction.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
import java.io.DataOutputStream;
import java.io.IOException;
import org.apache.bcel.util.ByteSequence;
@@ -31,180 +30,201 @@
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
public abstract class BranchInstruction extends Instruction implements InstructionTargeter {
- protected int index; // Branch target relative to this instruction
- protected InstructionHandle target; // Target object in instruction list
- protected int position; // Byte code offset
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- BranchInstruction() {}
-
- /** Common super constructor
- * @param opcode Instruction opcode
- * @param target instruction to branch to
- */
- protected BranchInstruction(short opcode, InstructionHandle target) {
- super(opcode, (short)3);
- setTarget(target);
- }
-
- /**
- * Dump instruction as byte code to stream out.
- * @param out Output stream
- */
- public void dump(DataOutputStream out) throws IOException {
- out.writeByte(opcode);
-
- index = getTargetOffset();
-
- if(Math.abs(index) >= 32767) // too large for short
- throw new ClassGenException("Branch target offset too large for short");
-
- out.writeShort(index); // May be negative, i.e., point backwards
- }
-
- /**
- * @param _target branch target
- * @return the offset to `target' relative to this instruction
- */
- protected int getTargetOffset(InstructionHandle _target) {
- if(_target == null)
- throw new ClassGenException("Target of " + super.toString(true) +
- " is invalid null handle");
-
- int t = _target.getPosition();
-
- if(t < 0)
- throw new ClassGenException("Invalid branch target position offset for " +
- super.toString(true) + ":" + t + ":" + _target);
-
- return t - position;
- }
-
- /**
- * @return the offset to this instruction's target
- */
- protected int getTargetOffset() { return getTargetOffset(target); }
-
- /**
- * Called by InstructionList.setPositions when setting the position for every
- * instruction. In the presence of variable length instructions `setPositions'
- * performs multiple passes over the instruction list to calculate the
- * correct (byte) positions and offsets by calling this function.
- *
- * @param offset additional offset caused by preceding (variable length) instructions
- * @param max_offset the maximum offset that may be caused by these instructions
- * @return additional offset caused by possible change of this instruction's length
- */
- protected int updatePosition(int offset, int max_offset) {
- position += offset;
- return 0;
- }
-
- /**
- * Long output format:
- *
- * <position in byte code>
- * <name of opcode> "["<opcode number>"]"
- * "("<length of instruction>")"
- * "<"<target instruction>">" "@"<branch target offset>
- *
- * @param verbose long/short format switch
- * @return mnemonic for instruction
- */
- public String toString(boolean verbose) {
- String s = super.toString(verbose);
- String t = "null";
-
- if(verbose) {
- if(target != null) {
- if(target.getInstruction() == this)
- t = "<points to itself>";
- else if(target.getInstruction() == null)
- t = "<null instruction!!!?>";
- else
- t = target.getInstruction().toString(false); // Avoid circles
- }
- } else {
- if(target != null) {
- index = getTargetOffset();
- t = "" + (index + position);
- }
- }
-
- return s + " -> " + t;
- }
-
- /**
- * Read needed data (e.g. index) from file. Conversion to a InstructionHandle
- * is done in InstructionList(byte[]).
- *
- * @param bytes input stream
- * @param wide wide prefix?
- * @see InstructionList
- */
- protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
- {
- length = 3;
- index = bytes.readShort();
- }
-
- /**
- * @return target offset in byte code
- */
- public final int getIndex() { return index; }
-
- /**
- * @return target of branch instruction
- */
- public InstructionHandle getTarget() { return target; }
-
- /**
- * Set branch target
- * @param target branch target
- */
- public void setTarget(InstructionHandle target) {
- notifyTarget(this.target, target, this);
- this.target = target;
- }
-
- /**
- * Used by BranchInstruction, LocalVariableGen, CodeExceptionGen
- */
- static final void notifyTarget(InstructionHandle old_ih, InstructionHandle new_ih,
- InstructionTargeter t) {
- if(old_ih != null)
- old_ih.removeTargeter(t);
- if(new_ih != null)
- new_ih.addTargeter(t);
- }
-
- /**
- * @param old_ih old target
- * @param new_ih new target
- */
- public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
- if(target == old_ih)
- setTarget(new_ih);
- else
- throw new ClassGenException("Not targeting " + old_ih + ", but " + target);
- }
-
- /**
- * @return true, if ih is target of this instruction
- */
- public boolean containsTarget(InstructionHandle ih) {
- return (target == ih);
- }
-
- /**
- * Inform target that it's not targeted anymore.
- */
- void dispose() {
- setTarget(null);
- index=-1;
- position=-1;
- }
+
+ protected int index; // Branch target relative to this instruction
+ protected InstructionHandle target; // Target object in instruction list
+ protected int position; // Byte code offset
+
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ BranchInstruction() {
+ }
+
+
+ /** Common super constructor
+ * @param opcode Instruction opcode
+ * @param target instruction to branch to
+ */
+ protected BranchInstruction(short opcode, InstructionHandle target) {
+ super(opcode, (short) 3);
+ setTarget(target);
+ }
+
+
+ /**
+ * Dump instruction as byte code to stream out.
+ * @param out Output stream
+ */
+ public void dump( DataOutputStream out ) throws IOException {
+ out.writeByte(opcode);
+ index = getTargetOffset();
+ if (Math.abs(index) >= 32767) {
+ throw new ClassGenException("Branch target offset too large for short");
+ }
+ out.writeShort(index); // May be negative, i.e., point backwards
+ }
+
+
+ /**
+ * @param _target branch target
+ * @return the offset to `target' relative to this instruction
+ */
+ protected int getTargetOffset( InstructionHandle _target ) {
+ if (_target == null) {
+ throw new ClassGenException("Target of " + super.toString(true)
+ + " is invalid null handle");
+ }
+ int t = _target.getPosition();
+ if (t < 0) {
+ throw new ClassGenException("Invalid branch target position offset for "
+ + super.toString(true) + ":" + t + ":" + _target);
+ }
+ return t - position;
+ }
+
+
+ /**
+ * @return the offset to this instruction's target
+ */
+ protected int getTargetOffset() {
+ return getTargetOffset(target);
+ }
+
+
+ /**
+ * Called by InstructionList.setPositions when setting the position for every
+ * instruction. In the presence of variable length instructions `setPositions'
+ * performs multiple passes over the instruction list to calculate the
+ * correct (byte) positions and offsets by calling this function.
+ *
+ * @param offset additional offset caused by preceding (variable length) instructions
+ * @param max_offset the maximum offset that may be caused by these instructions
+ * @return additional offset caused by possible change of this instruction's length
+ */
+ protected int updatePosition( int offset, int max_offset ) {
+ position += offset;
+ return 0;
+ }
+
+
+ /**
+ * Long output format:
+ *
+ * <position in byte code>
+ * <name of opcode> "["<opcode number>"]"
+ * "("<length of instruction>")"
+ * "<"<target instruction>">" "@"<branch target offset>
+ *
+ * @param verbose long/short format switch
+ * @return mnemonic for instruction
+ */
+ public String toString( boolean verbose ) {
+ String s = super.toString(verbose);
+ String t = "null";
+ if (verbose) {
+ if (target != null) {
+ if (target.getInstruction() == this) {
+ t = "<points to itself>";
+ } else if (target.getInstruction() == null) {
+ t = "<null instruction!!!?>";
+ } else {
+ t = target.getInstruction().toString(false); // Avoid circles
+ }
+ }
+ } else {
+ if (target != null) {
+ index = getTargetOffset();
+ t = "" + (index + position);
+ }
+ }
+ return s + " -> " + t;
+ }
+
+
+ /**
+ * Read needed data (e.g. index) from file. Conversion to a InstructionHandle
+ * is done in InstructionList(byte[]).
+ *
+ * @param bytes input stream
+ * @param wide wide prefix?
+ * @see InstructionList
+ */
+ protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
+ length = 3;
+ index = bytes.readShort();
+ }
+
+
+ /**
+ * @return target offset in byte code
+ */
+ public final int getIndex() {
+ return index;
+ }
+
+
+ /**
+ * @return target of branch instruction
+ */
+ public InstructionHandle getTarget() {
+ return target;
+ }
+
+
+ /**
+ * Set branch target
+ * @param target branch target
+ */
+ public void setTarget( InstructionHandle target ) {
+ notifyTarget(this.target, target, this);
+ this.target = target;
+ }
+
+
+ /**
+ * Used by BranchInstruction, LocalVariableGen, CodeExceptionGen
+ */
+ static final void notifyTarget( InstructionHandle old_ih, InstructionHandle new_ih,
+ InstructionTargeter t ) {
+ if (old_ih != null) {
+ old_ih.removeTargeter(t);
+ }
+ if (new_ih != null) {
+ new_ih.addTargeter(t);
+ }
+ }
+
+
+ /**
+ * @param old_ih old target
+ * @param new_ih new target
+ */
+ public void updateTarget( InstructionHandle old_ih, InstructionHandle new_ih ) {
+ if (target == old_ih) {
+ setTarget(new_ih);
+ } else {
+ throw new ClassGenException("Not targeting " + old_ih + ", but " + target);
+ }
+ }
+
+
+ /**
+ * @return true, if ih is target of this instruction
+ */
+ public boolean containsTarget( InstructionHandle ih ) {
+ return (target == ih);
+ }
+
+
+ /**
+ * Inform target that it's not targeted anymore.
+ */
+ void dispose() {
+ setTarget(null);
+ index = -1;
+ position = -1;
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/CALOAD.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/CALOAD.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/CALOAD.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/CALOAD.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* CALOAD - Load char from array
* <PRE>Stack: ..., arrayref, index -> ..., value</PRE>
@@ -25,26 +24,27 @@
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
public class CALOAD extends ArrayInstruction implements StackProducer {
- /** Load char from array
- */
- public CALOAD() {
- super(org.apache.bcel.Constants.CALOAD);
- }
+
+ /** Load char from array
+ */
+ public CALOAD() {
+ super(org.apache.bcel.Constants.CALOAD);
+ }
- /**
- * Call corresponding visitor method(s). The order is:
- * Call visitor methods of implemented interfaces first, then
- * call methods according to the class hierarchy in descending order,
- * i.e., the most specific visitXXX() call comes last.
- *
- * @param v Visitor object
- */
- public void accept(Visitor v) {
- v.visitStackProducer(this);
- v.visitExceptionThrower(this);
- v.visitTypedInstruction(this);
- v.visitArrayInstruction(this);
- v.visitCALOAD(this);
- }
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept( Visitor v ) {
+ v.visitStackProducer(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitArrayInstruction(this);
+ v.visitCALOAD(this);
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/CASTORE.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/CASTORE.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/CASTORE.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/CASTORE.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
-
/**
* CASTORE - Store into char array
* <PRE>Stack: ..., arrayref, index, value -> ...</PRE>
@@ -25,26 +24,27 @@
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
public class CASTORE extends ArrayInstruction implements StackConsumer {
- /** Store char into array
- */
- public CASTORE() {
- super(org.apache.bcel.Constants.CASTORE);
- }
+
+ /** Store char into array
+ */
+ public CASTORE() {
+ super(org.apache.bcel.Constants.CASTORE);
+ }
- /**
- * Call corresponding visitor method(s). The order is:
- * Call visitor methods of implemented interfaces first, then
- * call methods according to the class hierarchy in descending order,
- * i.e., the most specific visitXXX() call comes last.
- *
- * @param v Visitor object
- */
- public void accept(Visitor v) {
- v.visitStackConsumer(this);
- v.visitExceptionThrower(this);
- v.visitTypedInstruction(this);
- v.visitArrayInstruction(this);
- v.visitCASTORE(this);
- }
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept( Visitor v ) {
+ v.visitStackConsumer(this);
+ v.visitExceptionThrower(this);
+ v.visitTypedInstruction(this);
+ v.visitArrayInstruction(this);
+ v.visitCASTORE(this);
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/CHECKCAST.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/CHECKCAST.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/CHECKCAST.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/CHECKCAST.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.generic;
import org.apache.bcel.ExceptionConstants;
+
/**
* CHECKCAST - Check whether object is of given type
* <PRE>Stack: ..., objectref -> ..., objectref</PRE>
@@ -24,57 +25,60 @@
* @version $Id$
* @author <A HREF="mailto:[email protected]">M. Dahm</A>
*/
-public class CHECKCAST extends CPInstruction
- implements LoadClass, ExceptionThrower, StackProducer, StackConsumer {
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- CHECKCAST() {}
-
- /** Check whether object is of given type
- * @param index index to class in constant pool
- */
- public CHECKCAST(int index) {
- super(org.apache.bcel.Constants.CHECKCAST, index);
- }
-
- /** @return exceptions this instruction may cause
- */
- public Class[] getExceptions() {
- Class[] cs = new Class[1 + ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length];
-
- System.arraycopy(ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION, 0,
- cs, 0, ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length);
- cs[ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length] =
- ExceptionConstants.CLASS_CAST_EXCEPTION;
- return cs;
- }
-
- public ObjectType getLoadClassType(ConstantPoolGen cpg) {
- Type t = getType(cpg);
-
- if(t instanceof ArrayType)
- t = ((ArrayType) t).getBasicType();
-
- return (t instanceof ObjectType)? (ObjectType) t : null;
- }
-
- /**
- * Call corresponding visitor method(s). The order is:
- * Call visitor methods of implemented interfaces first, then
- * call methods according to the class hierarchy in descending order,
- * i.e., the most specific visitXXX() call comes last.
- *
- * @param v Visitor object
- */
- public void accept(Visitor v) {
- v.visitLoadClass(this);
- v.visitExceptionThrower(this);
- v.visitStackProducer(this);
- v.visitStackConsumer(this);
- v.visitTypedInstruction(this);
- v.visitCPInstruction(this);
- v.visitCHECKCAST(this);
- }
+public class CHECKCAST extends CPInstruction implements LoadClass, ExceptionThrower, StackProducer,
+ StackConsumer {
+
+ /**
+ * Empty constructor needed for the Class.newInstance() statement in
+ * Instruction.readInstruction(). Not to be used otherwise.
+ */
+ CHECKCAST() {
+ }
+
+
+ /** Check whether object is of given type
+ * @param index index to class in constant pool
+ */
+ public CHECKCAST(int index) {
+ super(org.apache.bcel.Constants.CHECKCAST, index);
+ }
+
+
+ /** @return exceptions this instruction may cause
+ */
+ public Class[] getExceptions() {
+ Class[] cs = new Class[1 + ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length];
+ System.arraycopy(ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION, 0, cs, 0,
+ ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length);
+ cs[ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length] = ExceptionConstants.CLASS_CAST_EXCEPTION;
+ return cs;
+ }
+
+
+ public ObjectType getLoadClassType( ConstantPoolGen cpg ) {
+ Type t = getType(cpg);
+ if (t instanceof ArrayType) {
+ t = ((ArrayType) t).getBasicType();
+ }
+ return (t instanceof ObjectType) ? (ObjectType) t : null;
+ }
+
+
+ /**
+ * Call corresponding visitor method(s). The order is:
+ * Call visitor methods of implemented interfaces first, then
+ * call methods according to the class hierarchy in descending order,
+ * i.e., the most specific visitXXX() call comes last.
+ *
+ * @param v Visitor object
+ */
+ public void accept( Visitor v ) {
+ v.visitLoadClass(this);
+ v.visitExceptionThrower(this);
+ v.visitStackProducer(this);
+ v.visitStackConsumer(this);
+ v.visitTypedInstruction(this);
+ v.visitCPInstruction(this);
+ v.visitCHECKCAST(this);
+ }
}
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.