diff options
Diffstat (limited to 'bcel-builder')
401 files changed, 6865 insertions, 27195 deletions
diff --git a/bcel-builder/.classpath b/bcel-builder/.classpath index 955afd2c0..5cb8fd272 100644 --- a/bcel-builder/.classpath +++ b/bcel-builder/.classpath @@ -1,9 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="verifier-src"/> <classpathentry kind="src" path="testsrc"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="lib" path="/lib/regexp/jakarta-regexp-1.2.jar"/> - <classpathentry sourcepath="/lib/junit/junit-src.jar" kind="lib" path="/lib/junit/junit.jar"/> + <classpathentry kind="lib" path="/lib/junit/junit.jar" sourcepath="/lib/junit/junit-src.jar"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/bcel-builder/bcel-builder.refactored.jar b/bcel-builder/bcel-builder.refactored.jar Binary files differdeleted file mode 100644 index 320a30046..000000000 --- a/bcel-builder/bcel-builder.refactored.jar +++ /dev/null diff --git a/bcel-builder/build.xml b/bcel-builder/build.xml index 157cfb9f5..76e42651f 100644 --- a/bcel-builder/build.xml +++ b/bcel-builder/build.xml @@ -1,10 +1,5 @@ <project name="bcel-builder" default="packageAndPush" basedir="."> - <!-- *********************************************************************** --> - <!-- compliance for Alex build --> - <!-- *********************************************************************** --> - <!--<import file="../build/build-common.xml"/>--> - <path id="bcel-builder.test.src.path"> <fileset dir="${basedir}/../lib"> <include name="junit/*.jar"/> @@ -21,7 +16,6 @@ <target name="cleanall" depends="clean"> <delete dir="bin"/> <delete dir="bintest"/> - <!-- FIXME: not consistent with Alex policy --> <mkdir dir="bin"/> </target> @@ -63,14 +57,20 @@ <target name="push"> <copy file="bcel.jar" todir="../lib/bcel" /> + <copy file="bcel-verifier.jar" todir="../lib/bcel" /> <copy file="bcel-src.zip" todir="../lib/bcel" /> + <copy file="bcel-verifier-src.zip" todir="../lib/bcel" /> <delete file="bcel.jar"/> + <delete file="bcel-verifier.jar"/> <delete file="bcel-src.zip"/> + <delete file="bcel-verifier-src.zip"/> </target> <target name="buildTheJars"> - <zip file="bcel.jar" basedir="bin" includes="**/*" excludes="**/tests/*.class"/> - <zip file="bcel-src.zip" basedir="src" includes="**/*"/> + <zip file="bcel.jar" basedir="bin" includes="**/*" excludes="**/tests/*,**/verifier/**/*,**/tests"/> + <zip file="bcel-verifier.jar" basedir="bin" includes="**/verifier/**/*" excludes="**/tests,**/tests/*"/> + <zip file="bcel-src.zip" basedir="src" includes="**/*" excludes="**/tests/*.java,**/verifier/**/*"/> + <zip file="bcel-verifier-src.zip" basedir="verifier-src" includes="**/verifier/**/*" excludes="**/tests,**/tests/*"/> </target> <target name="diff" depends="transformFromAJ,pack"> diff --git a/bcel-builder/patch.txt b/bcel-builder/patch.txt deleted file mode 100644 index 63ff8b5de..000000000 --- a/bcel-builder/patch.txt +++ /dev/null @@ -1,310 +0,0 @@ -diff -N -a -u -r -b bcel-5.1/build.xml bcel/build.xml ---- bcel-5.1/build.xml 2003-04-25 09:06:14.000000000 +0100 -+++ bcel/build.xml 2004-08-11 21:25:17.449281600 +0100 -@@ -65,7 +65,7 @@ - <target name="build" depends="compile"/> - - <!-- Jar the library --> -- <target name="jar" depends="examples"> -+ <target name="jar" depends="init,compile"> - <jar jarfile="${build.dir}/${name}.jar" - basedir="${build.dest}" - manifest="${basedir}/manifest.txt" -diff -N -a -u -r -b bcel-5.1/manifest.txt bcel/manifest.txt ---- bcel-5.1/manifest.txt 1970-01-01 00:00:00.000000000 +0000 -+++ bcel/manifest.txt 2004-08-11 21:25:17.509368000 +0100 -@@ -0,0 +1,3 @@ -+Created-By: Jakarta BCEL 5.1 -+Manifest-Version: 1.0 -+Main-Class: listclass -diff -N -a -u -r -b bcel-5.1/src/java/org/apache/bcel/generic/Instruction.java bcel/src/java/org/apache/bcel/generic/Instruction.java ---- bcel-5.1/src/java/org/apache/bcel/generic/Instruction.java 2003-04-25 09:06:16.000000000 +0100 -+++ bcel/src/java/org/apache/bcel/generic/Instruction.java 2004-08-11 21:28:49.424086400 +0100 -@@ -190,26 +190,223 @@ - Class clazz; - - try { -- clazz = Class.forName(className(opcode)); -- } catch (ClassNotFoundException cnfe){ -- // If a class by that name does not exist, the opcode is illegal. -- // Note that IMPDEP1, IMPDEP2, BREAKPOINT are also illegal in a sense. -- throw new ClassGenException("Illegal opcode detected."); -+ switch(opcode) { -+ case Constants.NOP: obj = new NOP(); break; -+ case Constants.ACONST_NULL: obj = new ACONST_NULL(); break; -+ case Constants.ICONST_M1: -+ case Constants.ICONST_0: -+ case Constants.ICONST_1: -+ case Constants.ICONST_2: -+ case Constants.ICONST_3: -+ case Constants.ICONST_4: -+ case Constants.ICONST_5: obj = new ICONST(); break; -+ case Constants.LCONST_0: -+ case Constants.LCONST_1: obj = new LCONST(); break; -+ case Constants.FCONST_0: -+ case Constants.FCONST_1: -+ case Constants.FCONST_2: obj = new FCONST(); break; -+ case Constants.DCONST_0: -+ case Constants.DCONST_1: obj = new DCONST(); break; -+ case Constants.BIPUSH : obj = new BIPUSH(); break; -+ case Constants.SIPUSH : obj = new SIPUSH(); break; -+ case Constants.LDC : obj = new LDC(); break; -+ case Constants.LDC_W: obj = new LDC_W(); break; -+ case Constants.LDC2_W: obj = new LDC2_W(); break; -+ case Constants.ILOAD : obj = new ILOAD(); break; -+ case Constants.LLOAD : obj = new LLOAD(); break; -+ case Constants.FLOAD : obj = new FLOAD(); break; -+ case Constants.DLOAD : obj = new DLOAD(); break; -+ case Constants.ALOAD : obj = new ALOAD(); break; -+ case Constants.ILOAD_0: -+ case Constants.ILOAD_1: -+ case Constants.ILOAD_2: -+ case Constants.ILOAD_3: obj = new ILOAD(); break; -+ case Constants.LLOAD_0: -+ case Constants.LLOAD_1: -+ case Constants.LLOAD_2: -+ case Constants.LLOAD_3: obj = new LLOAD(); break; -+ case Constants.FLOAD_0: -+ case Constants.FLOAD_1: -+ case Constants.FLOAD_2: -+ case Constants.FLOAD_3: obj = new FLOAD(); break; -+ case Constants.DLOAD_0: -+ case Constants.DLOAD_1: -+ case Constants.DLOAD_2: -+ case Constants.DLOAD_3: obj = new DLOAD(); break; -+ case Constants.ALOAD_0: -+ case Constants.ALOAD_1: -+ case Constants.ALOAD_2: -+ case Constants.ALOAD_3: obj = new ALOAD(); break; -+ case Constants.IALOAD : obj = new IALOAD(); break; -+ case Constants.LALOAD : obj = new LALOAD(); break; -+ case Constants.FALOAD : obj = new FALOAD(); break; -+ case Constants.DALOAD : obj = new DALOAD(); break; -+ case Constants.AALOAD : obj = new AALOAD(); break; -+ case Constants.BALOAD : obj = new BALOAD(); break; -+ case Constants.CALOAD : obj = new CALOAD(); break; -+ case Constants.SALOAD : obj = new SALOAD(); break; -+ case Constants.ISTORE : obj = new ISTORE(); break; -+ case Constants.LSTORE : obj = new LSTORE(); break; -+ case Constants.FSTORE : obj = new FSTORE(); break; -+ case Constants.DSTORE : obj = new DSTORE(); break; -+ case Constants.ASTORE : obj = new ASTORE(); break; -+ case Constants.ISTORE_0: -+ case Constants.ISTORE_1: -+ case Constants.ISTORE_2: -+ case Constants.ISTORE_3: obj = new ISTORE(); break; -+ case Constants.LSTORE_0: -+ case Constants.LSTORE_1: -+ case Constants.LSTORE_2: -+ case Constants.LSTORE_3: obj = new LSTORE(); break; -+ case Constants.FSTORE_0: -+ case Constants.FSTORE_1: -+ case Constants.FSTORE_2: -+ case Constants.FSTORE_3: obj = new FSTORE(); break; -+ case Constants.DSTORE_0: -+ case Constants.DSTORE_1: -+ case Constants.DSTORE_2: -+ case Constants.DSTORE_3: obj = new DSTORE(); break; -+ case Constants.ASTORE_0: -+ case Constants.ASTORE_1: -+ case Constants.ASTORE_2: -+ case Constants.ASTORE_3: obj = new ASTORE(); break; -+ case Constants.IASTORE : obj = new IASTORE(); break; -+ case Constants.LASTORE : obj = new LASTORE(); break; -+ case Constants.FASTORE : obj = new FASTORE(); break; -+ case Constants.DASTORE : obj = new DASTORE(); break; -+ case Constants.AASTORE : obj = new AASTORE(); break; -+ case Constants.BASTORE : obj = new BASTORE(); break; -+ case Constants.CASTORE : obj = new CASTORE(); break; -+ case Constants.SASTORE : obj = new SASTORE(); break; -+ case Constants.POP : obj = new POP(); break; -+ case Constants.POP2 : obj = new POP2(); break; -+ case Constants.DUP : obj = new DUP(); break; -+ case Constants.DUP_X1: obj = new DUP_X1(); break; -+ case Constants.DUP_X2: obj = new DUP_X2(); break; -+ case Constants.DUP2 : obj = new DUP2(); break; -+ case Constants.DUP2_X1: obj = new DUP2_X1(); break; -+ case Constants.DUP2_X2: obj = new DUP2_X2(); break; -+ case Constants.SWAP : obj = new SWAP(); break; -+ case Constants.IADD : obj = new IADD(); break; -+ case Constants.LADD : obj = new LADD(); break; -+ case Constants.FADD : obj = new FADD(); break; -+ case Constants.DADD : obj = new DADD(); break; -+ case Constants.ISUB : obj = new ISUB(); break; -+ case Constants.LSUB : obj = new LSUB(); break; -+ case Constants.FSUB : obj = new FSUB(); break; -+ case Constants.DSUB : obj = new DSUB(); break; -+ case Constants.IMUL : obj = new IMUL(); break; -+ case Constants.LMUL : obj = new LMUL(); break; -+ case Constants.FMUL : obj = new FMUL(); break; -+ case Constants.DMUL : obj = new DMUL(); break; -+ case Constants.IDIV : obj = new IDIV(); break; -+ case Constants.LDIV : obj = new LDIV(); break; -+ case Constants.FDIV : obj = new FDIV(); break; -+ case Constants.DDIV : obj = new DDIV(); break; -+ case Constants.IREM : obj = new IREM(); break; -+ case Constants.LREM : obj = new LREM(); break; -+ case Constants.FREM : obj = new FREM(); break; -+ case Constants.DREM : obj = new DREM(); break; -+ case Constants.INEG : obj = new INEG(); break; -+ case Constants.LNEG : obj = new LNEG(); break; -+ case Constants.FNEG : obj = new FNEG(); break; -+ case Constants.DNEG : obj = new DNEG(); break; -+ case Constants.ISHL : obj = new ISHL(); break; -+ case Constants.LSHL : obj = new LSHL(); break; -+ case Constants.ISHR : obj = new ISHR(); break; -+ case Constants.LSHR : obj = new LSHR(); break; -+ case Constants.IUSHR : obj = new IUSHR(); break; -+ case Constants.LUSHR : obj = new LUSHR(); break; -+ case Constants.IAND : obj = new IAND(); break; -+ case Constants.LAND : obj = new LAND(); break; -+ case Constants.IOR : obj = new IOR(); break; -+ case Constants.LOR : obj = new LOR(); break; -+ case Constants.IXOR : obj = new IXOR(); break; -+ case Constants.LXOR : obj = new LXOR(); break; -+ case Constants.IINC : obj = new IINC(); break; -+ case Constants.I2L : obj = new I2L(); break; -+ case Constants.I2F : obj = new I2F(); break; -+ case Constants.I2D : obj = new I2D(); break; -+ case Constants.L2I : obj = new L2I(); break; -+ case Constants.L2F : obj = new L2F(); break; -+ case Constants.L2D : obj = new L2D(); break; -+ case Constants.F2I : obj = new F2I(); break; -+ case Constants.F2L : obj = new F2L(); break; -+ case Constants.F2D : obj = new F2D(); break; -+ case Constants.D2I : obj = new D2I(); break; -+ case Constants.D2L : obj = new D2L(); break; -+ case Constants.D2F : obj = new D2F(); break; -+ case Constants.I2B : obj = new I2B(); break; -+ case Constants.I2C : obj = new I2C(); break; -+ case Constants.I2S : obj = new I2S(); break; -+ case Constants.LCMP : obj = new LCMP(); break; -+ case Constants.FCMPL : obj = new FCMPL(); break; -+ case Constants.FCMPG : obj = new FCMPG(); break; -+ case Constants.DCMPL : obj = new DCMPL(); break; -+ case Constants.DCMPG : obj = new DCMPG(); break; -+ case Constants.IFEQ : obj = new IFEQ(); break; -+ case Constants.IFNE : obj = new IFNE(); break; -+ case Constants.IFLT : obj = new IFLT(); break; -+ case Constants.IFGE : obj = new IFGE(); break; -+ case Constants.IFGT : obj = new IFGT(); break; -+ case Constants.IFLE : obj = new IFLE(); break; -+ case Constants.IF_ICMPEQ: obj = new IF_ICMPEQ(); break; -+ case Constants.IF_ICMPNE: obj = new IF_ICMPNE(); break; -+ case Constants.IF_ICMPLT: obj = new IF_ICMPLT(); break; -+ case Constants.IF_ICMPGE: obj = new IF_ICMPGE(); break; -+ case Constants.IF_ICMPGT: obj = new IF_ICMPGT(); break; -+ case Constants.IF_ICMPLE: obj = new IF_ICMPLE(); break; -+ case Constants.IF_ACMPEQ: obj = new IF_ACMPEQ(); break; -+ case Constants.IF_ACMPNE : obj = new IF_ACMPNE(); break; -+ case Constants.GOTO : obj = new GOTO(); break; -+ case Constants.JSR : obj = new JSR(); break; -+ case Constants.RET : obj = new RET(); break; -+ case Constants.TABLESWITCH : obj = new TABLESWITCH(); break; -+ case Constants.LOOKUPSWITCH : obj = new LOOKUPSWITCH(); break; -+ case Constants.IRETURN : obj = new IRETURN(); break; -+ case Constants.LRETURN : obj = new LRETURN(); break; -+ case Constants.FRETURN : obj = new FRETURN(); break; -+ case Constants.DRETURN : obj = new DRETURN(); break; -+ case Constants.ARETURN : obj = new ARETURN(); break; -+ case Constants.RETURN : obj = new RETURN(); break; -+ case Constants.GETSTATIC : obj = new GETSTATIC(); break; -+ case Constants.PUTSTATIC : obj = new PUTSTATIC(); break; -+ case Constants.GETFIELD : obj = new GETFIELD(); break; -+ case Constants.PUTFIELD : obj = new PUTFIELD(); break; -+ case Constants.INVOKEVIRTUAL : obj = new INVOKEVIRTUAL(); break; -+ case Constants.INVOKESPECIAL : obj = new INVOKESPECIAL(); break; -+ case Constants.INVOKESTATIC : obj = new INVOKESTATIC(); break; -+ case Constants.INVOKEINTERFACE : obj = new INVOKEINTERFACE(); break; -+ case Constants.NEW : obj = new NEW(); break; -+ case Constants.NEWARRAY : obj = new NEWARRAY(); break; -+ case Constants.ANEWARRAY : obj = new ANEWARRAY(); break; -+ case Constants.ARRAYLENGTH : obj = new ARRAYLENGTH(); break; -+ case Constants.ATHROW : obj = new ATHROW(); break; -+ case Constants.CHECKCAST : obj = new CHECKCAST(); break; -+ case Constants.INSTANCEOF : obj = new INSTANCEOF(); break; -+ case Constants.MONITORENTER : obj = new MONITORENTER(); break; -+ case Constants.MONITOREXIT : obj = new MONITOREXIT(); break; -+ case Constants.MULTIANEWARRAY : obj = new MULTIANEWARRAY(); break; -+ case Constants.IFNULL : obj = new IFNULL(); break; -+ case Constants.IFNONNULL : obj = new IFNONNULL(); break; -+ case Constants.GOTO_W : obj = new GOTO_W(); break; -+ case Constants.JSR_W : obj = new JSR_W(); break; -+ default: -+ throw new ClassGenException("Illegal opcode detected"); -+ } -+ } catch (ClassGenException e) { -+ throw e; -+ } catch (Exception e) { -+ throw new ClassGenException(e.toString()); - } -- -- try { -- obj = (Instruction)clazz.newInstance(); -- - if(wide && !((obj instanceof LocalVariableInstruction) || - (obj instanceof IINC) || - (obj instanceof RET))) -- throw new Exception("Illegal opcode after wide: " + opcode); -+ throw new ClassGenException("Illegal opcode after wide: " + opcode); - - obj.setOpcode(opcode); - obj.initFromFile(bytes, wide); // Do further initializations, if any - // Byte code offset set in InstructionList -- } catch(Exception e) { throw new ClassGenException(e.toString()); } -- - return obj; - } - -diff -N -a -u -r -b bcel-5.1/src/java/org/apache/bcel/generic/LDC_W.java bcel/src/java/org/apache/bcel/generic/LDC_W.java ---- bcel-5.1/src/java/org/apache/bcel/generic/LDC_W.java 2003-04-25 09:06:16.000000000 +0100 -+++ bcel/src/java/org/apache/bcel/generic/LDC_W.java 2004-08-11 21:28:47.160832000 +0100 -@@ -83,6 +83,6 @@ - { - setIndex(bytes.readUnsignedShort()); - // Override just in case it has been changed -- opcode = org.apache.bcel.Constants.LDC_W; -+ // opcode = org.apache.bcel.Constants.LDC_W; - } - } -diff -N -a -u -r -b bcel-5.1/src/java/org/apache/bcel/generic/MethodGen.java bcel/src/java/org/apache/bcel/generic/MethodGen.java ---- bcel-5.1/src/java/org/apache/bcel/generic/MethodGen.java 2003-04-25 09:06:16.000000000 +0100 -+++ bcel/src/java/org/apache/bcel/generic/MethodGen.java 2004-08-11 21:28:47.641523200 +0100 -@@ -133,9 +133,9 @@ - - /* Add local variables, namely the implicit `this' and the arguments - */ -- if(!isStatic() && (class_name != null)) { // Instance method -> `this' is local var 0 -- addLocalVariable("this", new ObjectType(class_name), start, end); -- } -+// if(!isStatic() && (class_name != null)) { // Instance method -> `this' is local var 0 -+// addLocalVariable("this", new ObjectType(class_name), start, end); -+// } - } - - if(arg_types != null) { -@@ -152,17 +152,17 @@ - throw new ClassGenException("Mismatch in argument array lengths: " + - size + " vs. " + arg_names.length); - } else { // Give them dummy names -- arg_names = new String[size]; -- -- for(int i=0; i < size; i++) -- arg_names[i] = "arg" + i; -- -- setArgumentNames(arg_names); -+// arg_names = new String[size]; -+// -+// for(int i=0; i < size; i++) -+// arg_names[i] = "arg" + i; -+// -+// setArgumentNames(arg_names); - } - - if(!abstract_) { - for(int i=0; i < size; i++) { -- addLocalVariable(arg_names[i], arg_types[i], start, end); -+// addLocalVariable(arg_names[i], arg_types[i], start, end); - } - } - } diff --git a/bcel-builder/readme.html b/bcel-builder/readme.html index 9a17e14bc..43f8f8c27 100644 --- a/bcel-builder/readme.html +++ b/bcel-builder/readme.html @@ -27,12 +27,6 @@ This module includes a modified form of BCEL - with some fixes in *and* support <li>The LocalVariableTypeTable attribute is supported (used for generics to tell you the original variable signature)</li> </ul> <p>All this is implemented without using any Java 5 APIs.</p> -<p>There are a number of new TODO type tags in the code that may prove useful:</p> -<ul> - <li>J5SUPPORT: Marks places where BCEL has been changed for 1.5 (might have missed a couple...)</li> - <li>BCELBUG: Marks things that might be BCEL problems that I came across</li> - <li>J5TODO: Marks either a missing bit of implementation (hopefully corner case) or an optimization we could make</li> -</ul> <hr> <p> The contents of this directory are: </p> @@ -40,6 +34,8 @@ This module includes a modified form of BCEL - with some fixes in *and* support <ul> <li>This file</li> <li>src -- contains the source for BCEL, a modified variant of BCEL 5.1 that includes bug fixes and Java 5 support</li> + <li>verifier-src -- contains the source for the bcel verifier package, something used by tests but not packaged + and distributed (at the moment). <li>testsrc -- JUnit test cases for the Java 5 support</li> <li>testdata -- Java5 testcode that can be built using the build.xml script in the testdata directory (see note on this below)</li> <li>build.xml -- an ant script for manipulating the src folder, possibly useful if ever merging a base BCEL version</li> @@ -66,83 +62,5 @@ then used by the testcases - so if you do change the testdata code then you shou to rebuild testcode.jar. <hr> -<h3>The old stuff...</h3> -Before the Java 5 support was added we maintained this module as basically a patch to apply against -a particular download of BCEL. Changes to BCEL are occurring more frequently than we integrate -a new version of BCEL so it made sense to make the patching process easier, so we have checked in -the modified source for BCEL. -The original instructions for patching BCEL in the old way are below... - -<p> And pretty much nothing else. Well, then, what do you do with -this directory? Well, the whole point is to generate bcel/bcel.jar in -the lib package. To do so, first stick -<strong>bcel-5.1-src.zip</strong> in this directory, then run ant. -(at one point, this was available at -<a href="http://archive.apache.org/dist/jakarta/bcel/source/bcel-5.1-src.zip"> -http://archive.apache.org/dist/jakarta/bcel/source/bcel-5.1-src.zip</a>) -After much unzipping, patching, and compiling, you should get an -appropriate bcel.jar file. Now put it in the appropriate place. </p> - -<p> If there's something <em>wrong</em> with the bcel.jar in the lib -project, well, then you've got some development to do. You'll need -to know some more ant targets. But before anything, get that -<strong>bcel-5.1-src.zip</strong> and stick it in this directory. -<b>NOTE: You should be working on BCEL when the package names are org.aspectj.apache.bcel, -and *not* when the package names are org.apache.bcel. If you run the extractAndPatch task -below, you will be left with a src folder in the correct state for further development.</b> -</p> - -<p> There are five top-level ant targets apart from the usual "clean":</p> - -<ul> - <li>ant extractAndPatchAndJar -- this is just the composition of the extract, - jar and srcjar targets, and is the default. It extracts the source from bcel-5.1-src.zip, - patches it, renames the files to start org.aspectj.apache rather than org.apache then - compiles the patched version into a jar and drops the new archives: - bcel.jar and bcel-src.zip, into the project root. This is the default task, mainly used - to sanity check the building and make sure we're generating something. - The bcel.jar and bcel-src.zip generated should be the same as that in ..\lib\bcel\. - </li> - - <li>ant extractAndPatch -- this extracts the source from bcel-5.1-src.zip, - patches it, renames the files to start org.aspectj.apache rather than org.apache then - copies the patched source into the project src directory, - there to be visible by eclipse for people to do development on it. - For the patch file to be applied you need to have a patch.exe on your path, - this bcel building process was tested with the version from cygwin. - </li> - - <li>ant jar -- this copies the edited source from the project source - directory and jars it up into bcel.jar, there to be tested. - </li> - - <li>ant srcjar -- this copies the edited source from the project source - directory and jars up the source code into bcel-src.zip. - </li> - - <li>ant push -- this pushes the new bcel.jar and bcel-src.zip into ..\lib\bcel\. - - ready to be used by the greater compiler.</li> - - <li>ant diff -- this creates the patch.txt file, composed of the differences - between the project src directory and the original bcel-5.1 source. - In order to create the patch, we transform the packages back to org.apache from - org.aspectj.apache. To continue working on BCEL once you have done this, you might - need to run the transformToAJ task to switch the packages back to the AJ prefix. - For the patch file to be built successfully you need to have a diff.exe on your path, - this bcel building process was tested with the version from cygwin. - </li> - - <li>ant transformToAJ - this changes the packages for the BCEL classes to - org.aspectj.apache from org.apache. This is used by the extractAndPatch task above. - </li> - - <li>ant transformFromAJ - this changes the packages for the BCEL classes to - org.apache from org.aspectj.apache. This is used by the diff task. - </li> -</ul> - -<p> All of the tasks are destructive, so don't do "ant extract", for example, -if you have anything in the project source directory you care about. -</p> </body> </html> diff --git a/bcel-builder/readme.refactored.txt b/bcel-builder/readme.refactored.txt deleted file mode 100644 index 1cde37c38..000000000 --- a/bcel-builder/readme.refactored.txt +++ /dev/null @@ -1,7 +0,0 @@ -15/2/07 - -There are problems with the 'refactoring' branch of the bcel-builder project. -For some reason if I commit things into the branch, they go into HEAD - whether -there was a problem creating the branch, I'm not sure. So as a temporary measure -I am committing the refactored form of the bcel-builder module in as a jar called -bcel-builder.refactored.jar.
\ No newline at end of file diff --git a/bcel-builder/src/org/aspectj/apache/bcel/Constants.java b/bcel-builder/src/org/aspectj/apache/bcel/Constants.java index 51c139901..3fd917f03 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/Constants.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/Constants.java @@ -1,5 +1,7 @@ package org.aspectj.apache.bcel; +import org.aspectj.apache.bcel.generic.Type; + /* ==================================================================== * The Apache Software License, Version 1.1 * @@ -57,12 +59,11 @@ package org.aspectj.apache.bcel; /** * Constants for the project, mostly defined in the JVM specification. * - * @version $Id: Constants.java,v 1.3 2006/05/04 11:28:26 aclement Exp $ + * @version $Id: Constants.java,v 1.4 2008/05/28 23:53:04 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public interface Constants { - /** Major and minor version of the code. - */ + // Major and minor version of the code public final static short MAJOR_1_1 = 45; public final static short MINOR_1_1 = 3; public final static short MAJOR_1_2 = 46; @@ -75,19 +76,17 @@ public interface Constants { public final static short MINOR_1_5 = 0; public final static short MAJOR_1_6 = 50; public final static short MINOR_1_6 = 0; - public final static short MAJOR = MAJOR_1_1; // Defaults + // Defaults + public final static short MAJOR = MAJOR_1_1; public final static short MINOR = MINOR_1_1; - /** Maximum value for an unsigned short. - */ + /** Maximum value for an unsigned short */ public final static int MAX_SHORT = 65535; // 2^16 - 1 - /** Maximum value for an unsigned byte. - */ + /** Maximum value for an unsigned byte */ public final static int MAX_BYTE = 255; // 2^8 - 1 - /** Access flags for classes, fields and methods. - */ + /** Access flags for classes, fields and methods */ public final static short ACC_PUBLIC = 0x0001; public final static short ACC_PRIVATE = 0x0002; public final static short ACC_PROTECTED = 0x0004; @@ -103,7 +102,6 @@ public interface Constants { public final static short ACC_ABSTRACT = 0x0400; public final static short ACC_STRICT = 0x0800; - // J5SUPPORT: public final static short ACC_ANNOTATION = 0x2000; public final static short ACC_ENUM = 0x4000; public final static short ACC_BRIDGE = 0x0040; @@ -119,8 +117,7 @@ public interface Constants { "volatile", "transient", "native", "interface", "abstract", "strictfp" }; - /** Tags in constant pool to denote type of constant. - */ + /** Tags in constant pool to denote type of constant */ public final static byte CONSTANT_Utf8 = 1; public final static byte CONSTANT_Integer = 3; public final static byte CONSTANT_Float = 4; @@ -410,8 +407,8 @@ public interface Constants { /** * Illegal codes */ - public static final short UNDEFINED = -1; - public static final short UNPREDICTABLE = -2; + public static final short UNDEFINED = '/'-'0'; //-1; + public static final short UNPREDICTABLE = '.'-'0';//-2; public static final short RESERVED = -3; public static final String ILLEGAL_OPCODE = "<illegal opcode>"; public static final String ILLEGAL_TYPE = "<illegal type>"; @@ -460,72 +457,246 @@ public interface Constants { "Z", "C", "F", "D", "B", "S", "I", "J", "V", ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE }; - - /** - * Number of byte code operands, i.e., number of bytes after the tag byte - * itself. - */ - public static final short[] NO_OF_OPERANDS = { - 0/*nop*/, 0/*aconst_null*/, 0/*iconst_m1*/, 0/*iconst_0*/, - 0/*iconst_1*/, 0/*iconst_2*/, 0/*iconst_3*/, 0/*iconst_4*/, - 0/*iconst_5*/, 0/*lconst_0*/, 0/*lconst_1*/, 0/*fconst_0*/, - 0/*fconst_1*/, 0/*fconst_2*/, 0/*dconst_0*/, 0/*dconst_1*/, - 1/*bipush*/, 2/*sipush*/, 1/*ldc*/, 2/*ldc_w*/, 2/*ldc2_w*/, - 1/*iload*/, 1/*lload*/, 1/*fload*/, 1/*dload*/, 1/*aload*/, - 0/*iload_0*/, 0/*iload_1*/, 0/*iload_2*/, 0/*iload_3*/, - 0/*lload_0*/, 0/*lload_1*/, 0/*lload_2*/, 0/*lload_3*/, - 0/*fload_0*/, 0/*fload_1*/, 0/*fload_2*/, 0/*fload_3*/, - 0/*dload_0*/, 0/*dload_1*/, 0/*dload_2*/, 0/*dload_3*/, - 0/*aload_0*/, 0/*aload_1*/, 0/*aload_2*/, 0/*aload_3*/, - 0/*iaload*/, 0/*laload*/, 0/*faload*/, 0/*daload*/, - 0/*aaload*/, 0/*baload*/, 0/*caload*/, 0/*saload*/, - 1/*istore*/, 1/*lstore*/, 1/*fstore*/, 1/*dstore*/, - 1/*astore*/, 0/*istore_0*/, 0/*istore_1*/, 0/*istore_2*/, - 0/*istore_3*/, 0/*lstore_0*/, 0/*lstore_1*/, 0/*lstore_2*/, - 0/*lstore_3*/, 0/*fstore_0*/, 0/*fstore_1*/, 0/*fstore_2*/, - 0/*fstore_3*/, 0/*dstore_0*/, 0/*dstore_1*/, 0/*dstore_2*/, - 0/*dstore_3*/, 0/*astore_0*/, 0/*astore_1*/, 0/*astore_2*/, - 0/*astore_3*/, 0/*iastore*/, 0/*lastore*/, 0/*fastore*/, - 0/*dastore*/, 0/*aastore*/, 0/*bastore*/, 0/*castore*/, - 0/*sastore*/, 0/*pop*/, 0/*pop2*/, 0/*dup*/, 0/*dup_x1*/, - 0/*dup_x2*/, 0/*dup2*/, 0/*dup2_x1*/, 0/*dup2_x2*/, 0/*swap*/, - 0/*iadd*/, 0/*ladd*/, 0/*fadd*/, 0/*dadd*/, 0/*isub*/, - 0/*lsub*/, 0/*fsub*/, 0/*dsub*/, 0/*imul*/, 0/*lmul*/, - 0/*fmul*/, 0/*dmul*/, 0/*idiv*/, 0/*ldiv*/, 0/*fdiv*/, - 0/*ddiv*/, 0/*irem*/, 0/*lrem*/, 0/*frem*/, 0/*drem*/, - 0/*ineg*/, 0/*lneg*/, 0/*fneg*/, 0/*dneg*/, 0/*ishl*/, - 0/*lshl*/, 0/*ishr*/, 0/*lshr*/, 0/*iushr*/, 0/*lushr*/, - 0/*iand*/, 0/*land*/, 0/*ior*/, 0/*lor*/, 0/*ixor*/, 0/*lxor*/, - 2/*iinc*/, 0/*i2l*/, 0/*i2f*/, 0/*i2d*/, 0/*l2i*/, 0/*l2f*/, - 0/*l2d*/, 0/*f2i*/, 0/*f2l*/, 0/*f2d*/, 0/*d2i*/, 0/*d2l*/, - 0/*d2f*/, 0/*i2b*/, 0/*i2c*/, 0/*i2s*/, 0/*lcmp*/, 0/*fcmpl*/, - 0/*fcmpg*/, 0/*dcmpl*/, 0/*dcmpg*/, 2/*ifeq*/, 2/*ifne*/, - 2/*iflt*/, 2/*ifge*/, 2/*ifgt*/, 2/*ifle*/, 2/*if_icmpeq*/, - 2/*if_icmpne*/, 2/*if_icmplt*/, 2/*if_icmpge*/, 2/*if_icmpgt*/, - 2/*if_icmple*/, 2/*if_acmpeq*/, 2/*if_acmpne*/, 2/*goto*/, - 2/*jsr*/, 1/*ret*/, UNPREDICTABLE/*tableswitch*/, UNPREDICTABLE/*lookupswitch*/, - 0/*ireturn*/, 0/*lreturn*/, 0/*freturn*/, - 0/*dreturn*/, 0/*areturn*/, 0/*return*/, - 2/*getstatic*/, 2/*putstatic*/, 2/*getfield*/, - 2/*putfield*/, 2/*invokevirtual*/, 2/*invokespecial*/, 2/*invokestatic*/, - 4/*invokeinterface*/, UNDEFINED, 2/*new*/, - 1/*newarray*/, 2/*anewarray*/, - 0/*arraylength*/, 0/*athrow*/, 2/*checkcast*/, - 2/*instanceof*/, 0/*monitorenter*/, - 0/*monitorexit*/, UNPREDICTABLE/*wide*/, 3/*multianewarray*/, - 2/*ifnull*/, 2/*ifnonnull*/, 4/*goto_w*/, - 4/*jsr_w*/, 0/*breakpoint*/, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, RESERVED/*impdep1*/, RESERVED/*impdep2*/ - }; - + + public static int PUSH_INST = 0x0001; + public static int CONSTANT_INST = 0x0002; + public static long LOADCLASS_INST = 0x0004; + public static int CP_INST = 0x0008; + public static int INDEXED = 0x0010; + public static int LOAD_INST = 0x0020; // load instruction + public static int LV_INST = 0x0040; // local variable instruction + public static int POP_INST = 0x0080; + public static int STORE_INST = 0x0100; + public static long STACK_INST =0x0200; + public static long BRANCH_INSTRUCTION =0x0400; + public static long TARGETER_INSTRUCTION =0x0800; + public static long NEGATABLE =0x1000; + public static long IF_INST =0x2000; + public static long JSR_INSTRUCTION =0x4000; + public static long RET_INST =0x8000; + public static long EXCEPTION_THROWER =0x10000; + + public static final byte[] iLen = new byte[256]; + public static final byte UNDEFINED_LENGTH = 'X'-'0'; + public static final byte VARIABLE_LENGTH = 'V'-'0'; + public static final byte[] stackEntriesProduced = new byte[256]; + public static final Type[] types = new Type[256]; + public static final long[] instFlags = new long[256]; + + public static final Class[][] instExcs = new Class[256][]; + + static final Clinit _unused = new Clinit(); + static class Clinit { + + static { + types[ILOAD] =Type.INT;types[ISTORE]=Type.INT;types[ILOAD_0]=Type.INT;types[ISTORE_0]=Type.INT; + types[ILOAD_1]=Type.INT;types[ISTORE_1]=Type.INT;types[ILOAD_2]=Type.INT;types[ISTORE_2]=Type.INT; + types[ILOAD_3]=Type.INT;types[ISTORE_3]=Type.INT; + types[LLOAD] =Type.LONG;types[LSTORE]=Type.LONG;types[LLOAD_0]=Type.LONG;types[LSTORE_0]=Type.LONG; + types[LLOAD_1]=Type.LONG;types[LSTORE_1]=Type.LONG;types[LLOAD_2]=Type.LONG;types[LSTORE_2]=Type.LONG; + types[LLOAD_3]=Type.LONG;types[LSTORE_3]=Type.LONG; + types[DLOAD] =Type.DOUBLE;types[DSTORE]=Type.DOUBLE;types[DLOAD_0]=Type.DOUBLE;types[DSTORE_0]=Type.DOUBLE; + types[DLOAD_1]=Type.DOUBLE;types[DSTORE_1]=Type.DOUBLE;types[DLOAD_2]=Type.DOUBLE;types[DSTORE_2]=Type.DOUBLE; + types[DLOAD_3]=Type.DOUBLE;types[DSTORE_3]=Type.DOUBLE; + types[FLOAD] =Type.FLOAT;types[FSTORE]=Type.FLOAT;types[FLOAD_0]=Type.FLOAT;types[FSTORE_0]=Type.FLOAT; + types[FLOAD_1]=Type.FLOAT;types[FSTORE_1]=Type.FLOAT;types[FLOAD_2]=Type.FLOAT;types[FSTORE_2]=Type.FLOAT; + types[FLOAD_3]=Type.FLOAT;types[FSTORE_3]=Type.FLOAT; + types[ALOAD] =Type.OBJECT;types[ASTORE]=Type.OBJECT;types[ALOAD_0]=Type.OBJECT;types[ASTORE_0]=Type.OBJECT; + types[ALOAD_1]=Type.OBJECT;types[ASTORE_1]=Type.OBJECT;types[ALOAD_2]=Type.OBJECT;types[ASTORE_2]=Type.OBJECT; + types[ALOAD_3]=Type.OBJECT;types[ASTORE_3]=Type.OBJECT; + + + // INSTRUCTION_FLAGS - set for all + instFlags[NOP] = 0; + instFlags[ACONST_NULL]=PUSH_INST; + instFlags[ICONST_M1]=PUSH_INST|CONSTANT_INST; + instFlags[ICONST_0]=PUSH_INST|CONSTANT_INST; + instFlags[ICONST_1]=PUSH_INST|CONSTANT_INST; + instFlags[ICONST_2]=PUSH_INST|CONSTANT_INST; + instFlags[ICONST_3]=PUSH_INST|CONSTANT_INST; + instFlags[ICONST_4]=PUSH_INST|CONSTANT_INST; + instFlags[ICONST_5]=PUSH_INST|CONSTANT_INST; + instFlags[LCONST_0]=PUSH_INST|CONSTANT_INST; + instFlags[LCONST_1]=PUSH_INST|CONSTANT_INST; + instFlags[FCONST_0]=PUSH_INST|CONSTANT_INST; + instFlags[FCONST_1]=PUSH_INST|CONSTANT_INST; + instFlags[FCONST_2]=PUSH_INST|CONSTANT_INST; + instFlags[DCONST_0]=PUSH_INST|CONSTANT_INST; + instFlags[DCONST_1]=PUSH_INST|CONSTANT_INST; + + instFlags[BIPUSH]=PUSH_INST|CONSTANT_INST; + instFlags[SIPUSH]=PUSH_INST|CONSTANT_INST; + + instFlags[LDC]=EXCEPTION_THROWER|PUSH_INST|CP_INST|INDEXED; + + instFlags[LDC_W]=EXCEPTION_THROWER|PUSH_INST|CP_INST|INDEXED; + + instFlags[LDC2_W]=EXCEPTION_THROWER|PUSH_INST|CP_INST|INDEXED; + + // the next five could be 'wide' prefixed and so have longer lengths + instFlags[ILOAD]=INDEXED|LOAD_INST|PUSH_INST|LV_INST; + instFlags[LLOAD]=INDEXED|LOAD_INST|PUSH_INST|LV_INST; + instFlags[FLOAD]=INDEXED|LOAD_INST|PUSH_INST|LV_INST; + instFlags[DLOAD]=INDEXED|LOAD_INST|PUSH_INST|LV_INST; + instFlags[ALOAD]=INDEXED|LOAD_INST|PUSH_INST|LV_INST; + for (int ii=ILOAD_0;ii<=ALOAD_3;ii++) { + instFlags[ii]=INDEXED|LOAD_INST|PUSH_INST|LV_INST; + } + + + // the next five could be 'wide' prefixed and so have longer lengths + instFlags[ISTORE]=INDEXED|STORE_INST|POP_INST|LV_INST; + instFlags[LSTORE]=INDEXED|STORE_INST|POP_INST|LV_INST; + instFlags[FSTORE]=INDEXED|STORE_INST|POP_INST|LV_INST; + instFlags[DSTORE]=INDEXED|STORE_INST|POP_INST|LV_INST; + instFlags[ASTORE]=INDEXED|STORE_INST|POP_INST|LV_INST; + for (int ii=ISTORE_0;ii<=ASTORE_3;ii++) { + instFlags[ii]=INDEXED|STORE_INST|POP_INST|LV_INST; + } + + instFlags[IDIV]=EXCEPTION_THROWER; + instExcs[IDIV] = new Class[]{org.aspectj.apache.bcel.ExceptionConstants.ARITHMETIC_EXCEPTION}; + instFlags[IREM]=EXCEPTION_THROWER; + instExcs[IREM] = new Class[]{org.aspectj.apache.bcel.ExceptionConstants.ARITHMETIC_EXCEPTION}; + instFlags[LDIV]=EXCEPTION_THROWER;instExcs[LDIV] = new Class[]{ org.aspectj.apache.bcel.ExceptionConstants.ARITHMETIC_EXCEPTION}; + instFlags[LREM]=EXCEPTION_THROWER;instExcs[LREM] = new Class[]{org.aspectj.apache.bcel.ExceptionConstants.ARITHMETIC_EXCEPTION}; + + + instFlags[ARRAYLENGTH]=EXCEPTION_THROWER; instExcs[ARRAYLENGTH]=new Class[]{org.aspectj.apache.bcel.ExceptionConstants.NULL_POINTER_EXCEPTION}; + instFlags[ATHROW]=EXCEPTION_THROWER;instExcs[ATHROW]=new Class[]{org.aspectj.apache.bcel.ExceptionConstants.THROWABLE}; + + instFlags[AALOAD]=EXCEPTION_THROWER;instExcs[AALOAD]=org.aspectj.apache.bcel.ExceptionConstants.EXCS_ARRAY_EXCEPTION; + instFlags[IALOAD]=EXCEPTION_THROWER;instExcs[IALOAD]=org.aspectj.apache.bcel.ExceptionConstants.EXCS_ARRAY_EXCEPTION; + instFlags[BALOAD]=EXCEPTION_THROWER;instExcs[BALOAD]=org.aspectj.apache.bcel.ExceptionConstants.EXCS_ARRAY_EXCEPTION; + instFlags[FALOAD]=EXCEPTION_THROWER;instExcs[FALOAD]=org.aspectj.apache.bcel.ExceptionConstants.EXCS_ARRAY_EXCEPTION; + instFlags[DALOAD]=EXCEPTION_THROWER;instExcs[DALOAD]=org.aspectj.apache.bcel.ExceptionConstants.EXCS_ARRAY_EXCEPTION; + instFlags[CALOAD]=EXCEPTION_THROWER;instExcs[CALOAD]=org.aspectj.apache.bcel.ExceptionConstants.EXCS_ARRAY_EXCEPTION; + instFlags[LALOAD]=EXCEPTION_THROWER;instExcs[LALOAD]=org.aspectj.apache.bcel.ExceptionConstants.EXCS_ARRAY_EXCEPTION; + instFlags[SALOAD]=EXCEPTION_THROWER;instExcs[SALOAD]=org.aspectj.apache.bcel.ExceptionConstants.EXCS_ARRAY_EXCEPTION; + + instFlags[AASTORE]=EXCEPTION_THROWER;instExcs[AASTORE]=org.aspectj.apache.bcel.ExceptionConstants.EXCS_ARRAY_EXCEPTION; + instFlags[IASTORE]=EXCEPTION_THROWER;instExcs[IASTORE]=org.aspectj.apache.bcel.ExceptionConstants.EXCS_ARRAY_EXCEPTION; + instFlags[BASTORE]=EXCEPTION_THROWER;instExcs[BASTORE]=org.aspectj.apache.bcel.ExceptionConstants.EXCS_ARRAY_EXCEPTION; + instFlags[FASTORE]=EXCEPTION_THROWER;instExcs[FASTORE]=org.aspectj.apache.bcel.ExceptionConstants.EXCS_ARRAY_EXCEPTION; + instFlags[DASTORE]=EXCEPTION_THROWER;instExcs[DASTORE]=org.aspectj.apache.bcel.ExceptionConstants.EXCS_ARRAY_EXCEPTION; + instFlags[CASTORE]=EXCEPTION_THROWER;instExcs[CASTORE]=org.aspectj.apache.bcel.ExceptionConstants.EXCS_ARRAY_EXCEPTION; + instFlags[LASTORE]=EXCEPTION_THROWER;instExcs[LASTORE]=org.aspectj.apache.bcel.ExceptionConstants.EXCS_ARRAY_EXCEPTION; + instFlags[SASTORE]=EXCEPTION_THROWER;instExcs[SASTORE]=org.aspectj.apache.bcel.ExceptionConstants.EXCS_ARRAY_EXCEPTION; + + // stack instructions + instFlags[DUP]=PUSH_INST|STACK_INST; + instFlags[DUP_X1]=STACK_INST; // TODO fixme - aren't these two push/stack producers? (although peculiar ones...) + instFlags[DUP_X2]=STACK_INST; + instFlags[DUP2]=PUSH_INST|STACK_INST; + instFlags[DUP2_X1]=STACK_INST; // TODO fixme - aren't these two push/stack producers? (although peculiar ones...) + instFlags[DUP2_X2]=STACK_INST; + instFlags[POP]=STACK_INST|POP_INST; + instFlags[POP2]=STACK_INST|POP_INST; + instFlags[SWAP]=STACK_INST; + + instFlags[MONITORENTER]=EXCEPTION_THROWER;instExcs[MONITORENTER]=new Class[] { org.aspectj.apache.bcel.ExceptionConstants.NULL_POINTER_EXCEPTION }; + instFlags[MONITOREXIT]=EXCEPTION_THROWER;instExcs[MONITOREXIT]=new Class[] { org.aspectj.apache.bcel.ExceptionConstants.NULL_POINTER_EXCEPTION }; + + + // branching instructions + instFlags[GOTO]=BRANCH_INSTRUCTION|TARGETER_INSTRUCTION; + instFlags[GOTO_W]=BRANCH_INSTRUCTION|TARGETER_INSTRUCTION; + instFlags[JSR]=BRANCH_INSTRUCTION|TARGETER_INSTRUCTION|JSR_INSTRUCTION; + instFlags[JSR_W]=BRANCH_INSTRUCTION|TARGETER_INSTRUCTION|JSR_INSTRUCTION; + + instFlags[IFGT]=BRANCH_INSTRUCTION|TARGETER_INSTRUCTION|NEGATABLE|IF_INST; + instFlags[IFLE]=BRANCH_INSTRUCTION|TARGETER_INSTRUCTION|NEGATABLE|IF_INST; + instFlags[IFNE]=BRANCH_INSTRUCTION|TARGETER_INSTRUCTION|NEGATABLE|IF_INST; + instFlags[IFEQ]=BRANCH_INSTRUCTION|TARGETER_INSTRUCTION|NEGATABLE|IF_INST; + instFlags[IFGE]=BRANCH_INSTRUCTION|TARGETER_INSTRUCTION|NEGATABLE|IF_INST; + instFlags[IFLT]=BRANCH_INSTRUCTION|TARGETER_INSTRUCTION|NEGATABLE|IF_INST; + instFlags[IFNULL]=BRANCH_INSTRUCTION|TARGETER_INSTRUCTION|NEGATABLE|IF_INST; + instFlags[IFNONNULL]=BRANCH_INSTRUCTION|TARGETER_INSTRUCTION|NEGATABLE|IF_INST; + instFlags[IF_ACMPEQ]=BRANCH_INSTRUCTION|TARGETER_INSTRUCTION|NEGATABLE|IF_INST; + instFlags[IF_ACMPNE]=BRANCH_INSTRUCTION|TARGETER_INSTRUCTION|NEGATABLE|IF_INST; + instFlags[IF_ICMPEQ]=BRANCH_INSTRUCTION|TARGETER_INSTRUCTION|NEGATABLE|IF_INST; + instFlags[IF_ICMPGE]=BRANCH_INSTRUCTION|TARGETER_INSTRUCTION|NEGATABLE|IF_INST; + instFlags[IF_ICMPGT]=BRANCH_INSTRUCTION|TARGETER_INSTRUCTION|NEGATABLE|IF_INST; + instFlags[IF_ICMPLE]=BRANCH_INSTRUCTION|TARGETER_INSTRUCTION|NEGATABLE|IF_INST; + instFlags[IF_ICMPLT]=BRANCH_INSTRUCTION|TARGETER_INSTRUCTION|NEGATABLE|IF_INST; + instFlags[IF_ICMPNE]=BRANCH_INSTRUCTION|TARGETER_INSTRUCTION|NEGATABLE|IF_INST; + + instFlags[LOOKUPSWITCH]=BRANCH_INSTRUCTION|TARGETER_INSTRUCTION; + instFlags[TABLESWITCH]=BRANCH_INSTRUCTION|TARGETER_INSTRUCTION; + + // fixme these class arrays should be constants + instFlags[ARETURN]=RET_INST|EXCEPTION_THROWER;instExcs[ARETURN]=new Class[] { ExceptionConstants.ILLEGAL_MONITOR_STATE }; + instFlags[DRETURN]=RET_INST|EXCEPTION_THROWER;instExcs[DRETURN]=new Class[] { ExceptionConstants.ILLEGAL_MONITOR_STATE }; + instFlags[FRETURN]=RET_INST|EXCEPTION_THROWER;instExcs[FRETURN]=new Class[] { ExceptionConstants.ILLEGAL_MONITOR_STATE }; + instFlags[IRETURN]=RET_INST|EXCEPTION_THROWER;instExcs[IRETURN]=new Class[] { ExceptionConstants.ILLEGAL_MONITOR_STATE }; + instFlags[LRETURN]=RET_INST|EXCEPTION_THROWER;instExcs[LRETURN]=new Class[] { ExceptionConstants.ILLEGAL_MONITOR_STATE }; + instFlags[RETURN]=RET_INST|EXCEPTION_THROWER;instExcs[RETURN]=new Class[] { ExceptionConstants.ILLEGAL_MONITOR_STATE }; + + + instFlags[NEW]=LOADCLASS_INST|EXCEPTION_THROWER|CP_INST|INDEXED;instExcs[NEW]=ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION_FOR_ALLOCATIONS; + instFlags[NEWARRAY]=EXCEPTION_THROWER;instExcs[NEWARRAY]=new Class[] { org.aspectj.apache.bcel.ExceptionConstants.NEGATIVE_ARRAY_SIZE_EXCEPTION }; + + types[IINC]=Type.INT;instFlags[IINC]=LV_INST|INDEXED; + instFlags[RET]=INDEXED; + + + instFlags[ANEWARRAY]=CP_INST|LOADCLASS_INST|EXCEPTION_THROWER|INDEXED;instExcs[ANEWARRAY]=ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION_ANEWARRAY; + instFlags[CHECKCAST]=CP_INST|LOADCLASS_INST|EXCEPTION_THROWER|INDEXED;instExcs[CHECKCAST]=ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION_CHECKCAST; + instFlags[INSTANCEOF]=CP_INST|LOADCLASS_INST|EXCEPTION_THROWER|INDEXED;instExcs[INSTANCEOF]=ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION; + instFlags[MULTIANEWARRAY]=CP_INST|LOADCLASS_INST|EXCEPTION_THROWER|INDEXED;instExcs[MULTIANEWARRAY]=ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION_ANEWARRAY; // fixme i think this is a stackproducer, old bcel says no... + + instFlags[GETFIELD]=EXCEPTION_THROWER|CP_INST|LOADCLASS_INST|INDEXED;instExcs[GETFIELD]=ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION_GETFIELD_PUTFIELD; + instFlags[GETSTATIC]=PUSH_INST|EXCEPTION_THROWER|LOADCLASS_INST|CP_INST|INDEXED;instExcs[GETSTATIC]=ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION_GETSTATIC_PUTSTATIC; + instFlags[PUTFIELD]=POP_INST|EXCEPTION_THROWER|LOADCLASS_INST|CP_INST|INDEXED;instExcs[PUTFIELD]=ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION_GETFIELD_PUTFIELD; + instFlags[PUTSTATIC]=EXCEPTION_THROWER|POP_INST|CP_INST|LOADCLASS_INST|INDEXED;instExcs[PUTSTATIC]=ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION_GETSTATIC_PUTSTATIC; + + instFlags[INVOKEINTERFACE]=EXCEPTION_THROWER|CP_INST|LOADCLASS_INST|INDEXED;instExcs[INVOKEINTERFACE]=ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION_INVOKEINTERFACE; + instFlags[INVOKESPECIAL]=EXCEPTION_THROWER|CP_INST|LOADCLASS_INST|INDEXED;instExcs[INVOKESPECIAL]=ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION_INVOKESPECIAL_INVOKEVIRTUAL; + instFlags[INVOKESTATIC]=EXCEPTION_THROWER|CP_INST|LOADCLASS_INST|INDEXED;instExcs[INVOKESTATIC]=ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION_INVOKESTATIC; + instFlags[INVOKEVIRTUAL]=EXCEPTION_THROWER|CP_INST|LOADCLASS_INST|INDEXED;instExcs[INVOKEVIRTUAL]=ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION_INVOKESPECIAL_INVOKEVIRTUAL; + + char[] lengths = // . = varies in length, / = undefined + ("1111111111111111"+ // nop > dconst_1 + "2323322222111111"+ // bipush > lload_1 + "1111111111111111"+ // lload_2 > laload + "1111112222211111"+ // faload > lstore_0 + "1111111111111111"+ // lstore_1 > iastore + "1111111111111111"+ // lastore > swap + "1111111111111111"+ // iadd > ddiv + "1111111111111111"+ // irem > land + "1111311111111111"+ // ior > d2l + "1111111113333333"+ // d2f > if_icmpeq + "3333333332..1111"+ // if_icmpne > dreturn + "1133333335/32311"+ // areturn > athrow + "3311.433551/////").toCharArray(); // checkcast > + int count=0; + for (;count<lengths.length;count++) iLen[count] = (byte)(lengths[count]-48); + while (count<256) { iLen[count]=UNDEFINED;count++;} + iLen[BREAKPOINT]=1; + iLen[IMPDEP1]=1; + iLen[IMPDEP2]=1; + + char[] producesOnStack = + ("0111111112211122"+ // nop > dconst_1 + "1111212121111122"+ // bipush > lload_1 + "2211112222111112"+ // lload_2 > laload + "1211110000000000"+ // faload > lstore_0 + "0000000000000000"+ // lstore_1 > iastore + "0000000002344562"+ // lastore > swap + "1212121212121212"+ // iadd > ddiv + "1212121212121212"+ // irem > land + "1212021211212212"+ // ior > d2l + "1111111110000000"+ // d2f > if_icmpeq + "0000000010000000"+ // if_icmpne > dreturn + "00.0.0..../11111"+ // areturn > athrow + "11000100010/").toCharArray(); // checkcast > + count=0; + for (;count<producesOnStack.length;count++) stackEntriesProduced[count] = (byte)(producesOnStack[count]-48); + while (count<256) { iLen[count]=UNDEFINED;count++;} + + } + } + /** * How the byte code operands are to be interpreted. */ @@ -699,62 +870,8 @@ public interface Constants { UNDEFINED, UNPREDICTABLE/*impdep1*/, UNPREDICTABLE/*impdep2*/ }; - /** - * Number of words produced onto operand stack by instructions. - */ - public static final int[] PRODUCE_STACK = { - 0/*nop*/, 1/*aconst_null*/, 1/*iconst_m1*/, 1/*iconst_0*/, 1/*iconst_1*/, - 1/*iconst_2*/, 1/*iconst_3*/, 1/*iconst_4*/, 1/*iconst_5*/, 2/*lconst_0*/, - 2/*lconst_1*/, 1/*fconst_0*/, 1/*fconst_1*/, 1/*fconst_2*/, 2/*dconst_0*/, - 2/*dconst_1*/, 1/*bipush*/, 1/*sipush*/, 1/*ldc*/, 1/*ldc_w*/, 2/*ldc2_w*/, 1/*iload*/, - 2/*lload*/, 1/*fload*/, 2/*dload*/, 1/*aload*/, 1/*iload_0*/, 1/*iload_1*/, 1/*iload_2*/, - 1/*iload_3*/, 2/*lload_0*/, 2/*lload_1*/, 2/*lload_2*/, 2/*lload_3*/, 1/*fload_0*/, - 1/*fload_1*/, 1/*fload_2*/, 1/*fload_3*/, 2/*dload_0*/, 2/*dload_1*/, 2/*dload_2*/, - 2/*dload_3*/, 1/*aload_0*/, 1/*aload_1*/, 1/*aload_2*/, 1/*aload_3*/, 1/*iaload*/, - 2/*laload*/, 1/*faload*/, 2/*daload*/, 1/*aaload*/, 1/*baload*/, 1/*caload*/, 1/*saload*/, - 0/*istore*/, 0/*lstore*/, 0/*fstore*/, 0/*dstore*/, 0/*astore*/, 0/*istore_0*/, - 0/*istore_1*/, 0/*istore_2*/, 0/*istore_3*/, 0/*lstore_0*/, 0/*lstore_1*/, - 0/*lstore_2*/, 0/*lstore_3*/, 0/*fstore_0*/, 0/*fstore_1*/, 0/*fstore_2*/, - 0/*fstore_3*/, 0/*dstore_0*/, 0/*dstore_1*/, 0/*dstore_2*/, 0/*dstore_3*/, - 0/*astore_0*/, 0/*astore_1*/, 0/*astore_2*/, 0/*astore_3*/, 0/*iastore*/, 0/*lastore*/, - 0/*fastore*/, 0/*dastore*/, 0/*aastore*/, 0/*bastore*/, 0/*castore*/, 0/*sastore*/, - 0/*pop*/, 0/*pop2*/, 2/*dup*/, 3/*dup_x1*/, 4/*dup_x2*/, 4/*dup2*/, 5/*dup2_x1*/, - 6/*dup2_x2*/, 2/*swap*/, 1/*iadd*/, 2/*ladd*/, 1/*fadd*/, 2/*dadd*/, 1/*isub*/, 2/*lsub*/, - 1/*fsub*/, 2/*dsub*/, 1/*imul*/, 2/*lmul*/, 1/*fmul*/, 2/*dmul*/, 1/*idiv*/, 2/*ldiv*/, - 1/*fdiv*/, 2/*ddiv*/, 1/*irem*/, 2/*lrem*/, 1/*frem*/, 2/*drem*/, 1/*ineg*/, 2/*lneg*/, - 1/*fneg*/, 2/*dneg*/, 1/*ishl*/, 2/*lshl*/, 1/*ishr*/, 2/*lshr*/, 1/*iushr*/, 2/*lushr*/, - 1/*iand*/, 2/*land*/, 1/*ior*/, 2/*lor*/, 1/*ixor*/, 2/*lxor*/, - 0/*iinc*/, 2/*i2l*/, 1/*i2f*/, 2/*i2d*/, 1/*l2i*/, 1/*l2f*/, 2/*l2d*/, 1/*f2i*/, - 2/*f2l*/, 2/*f2d*/, 1/*d2i*/, 2/*d2l*/, 1/*d2f*/, - 1/*i2b*/, 1/*i2c*/, 1/*i2s*/, 1/*lcmp*/, 1/*fcmpl*/, 1/*fcmpg*/, - 1/*dcmpl*/, 1/*dcmpg*/, 0/*ifeq*/, 0/*ifne*/, 0/*iflt*/, 0/*ifge*/, 0/*ifgt*/, 0/*ifle*/, - 0/*if_icmpeq*/, 0/*if_icmpne*/, 0/*if_icmplt*/, 0/*if_icmpge*/, 0/*if_icmpgt*/, - 0/*if_icmple*/, 0/*if_acmpeq*/, 0/*if_acmpne*/, 0/*goto*/, 1/*jsr*/, 0/*ret*/, - 0/*tableswitch*/, 0/*lookupswitch*/, 0/*ireturn*/, 0/*lreturn*/, 0/*freturn*/, - 0/*dreturn*/, 0/*areturn*/, 0/*return*/, UNPREDICTABLE/*getstatic*/, 0/*putstatic*/, - UNPREDICTABLE/*getfield*/, 0/*putfield*/, UNPREDICTABLE/*invokevirtual*/, - UNPREDICTABLE/*invokespecial*/, UNPREDICTABLE/*invokestatic*/, - UNPREDICTABLE/*invokeinterface*/, UNDEFINED, 1/*new*/, 1/*newarray*/, 1/*anewarray*/, - 1/*arraylength*/, 1/*athrow*/, 1/*checkcast*/, 1/*instanceof*/, 0/*monitorenter*/, - 0/*monitorexit*/, 0/*wide*/, 1/*multianewarray*/, 0/*ifnull*/, 0/*ifnonnull*/, - 0/*goto_w*/, 1/*jsr_w*/, 0/*breakpoint*/, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNPREDICTABLE/*impdep1*/, UNPREDICTABLE/*impdep2*/ - }; - /** Attributes and their corresponding names. - */ + // 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; @@ -766,10 +883,8 @@ public interface Constants { 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; //J5TODO: Is this the same as a Java5 signature attribute? + public static final byte ATTR_SIGNATURE = 10; public static final byte ATTR_STACK_MAP = 11; - - // J5SUPPORT: public static final byte ATTR_RUNTIME_VISIBLE_ANNOTATIONS = 12; public static final byte ATTR_RUNTIME_INVISIBLE_ANNOTATIONS = 13; public static final byte ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS = 14; @@ -785,7 +900,6 @@ public interface Constants { "LineNumberTable", "LocalVariableTable", "InnerClasses", "Synthetic", "Deprecated", "PMGClass", "Signature", "StackMap", - // J5SUPPORT: "RuntimeVisibleAnnotations","RuntimeInvisibleAnnotations", "RuntimeVisibleParameterAnnotations","RuntimeInvisibleParameterAnnotations", "LocalVariableTypeTable","EnclosingMethod","AnnotationDefault" diff --git a/bcel-builder/src/org/aspectj/apache/bcel/ExceptionConstants.java b/bcel-builder/src/org/aspectj/apache/bcel/ExceptionConstants.java index 27844e532..bbe3b4c26 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/ExceptionConstants.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/ExceptionConstants.java @@ -57,7 +57,7 @@ package org.aspectj.apache.bcel; /** * Exception constants. * - * @version $Id: ExceptionConstants.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: ExceptionConstants.java,v 1.3 2008/05/28 23:53:04 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase">E. Haase</A> */ public interface ExceptionConstants { @@ -107,11 +107,47 @@ public interface ExceptionConstants { NO_CLASS_DEF_FOUND_ERROR, CLASS_FORMAT_ERROR, VERIFY_ERROR, ABSTRACT_METHOD_ERROR, EXCEPTION_IN_INITIALIZER_ERROR, ILLEGAL_ACCESS_ERROR }; // Chapter 5.1 + public static final Class[] EXCS_CLASS_AND_INTERFACE_RESOLUTION_MULTIANEWARRAY = { + NO_CLASS_DEF_FOUND_ERROR, CLASS_FORMAT_ERROR, VERIFY_ERROR, ABSTRACT_METHOD_ERROR, + EXCEPTION_IN_INITIALIZER_ERROR, ILLEGAL_ACCESS_ERROR,NEGATIVE_ARRAY_SIZE_EXCEPTION,ILLEGAL_ACCESS_ERROR + }; + public static final Class[] EXCS_CLASS_AND_INTERFACE_RESOLUTION_ANEWARRAY = { + NO_CLASS_DEF_FOUND_ERROR, CLASS_FORMAT_ERROR, VERIFY_ERROR, ABSTRACT_METHOD_ERROR, + EXCEPTION_IN_INITIALIZER_ERROR, ILLEGAL_ACCESS_ERROR,NEGATIVE_ARRAY_SIZE_EXCEPTION + }; // Chapter 5.1 + public static final Class[] EXCS_CLASS_AND_INTERFACE_RESOLUTION_CHECKCAST = { + NO_CLASS_DEF_FOUND_ERROR, CLASS_FORMAT_ERROR, VERIFY_ERROR, ABSTRACT_METHOD_ERROR, + EXCEPTION_IN_INITIALIZER_ERROR, ILLEGAL_ACCESS_ERROR,CLASS_CAST_EXCEPTION + }; // Chapter 5.1 + public static final Class[] EXCS_CLASS_AND_INTERFACE_RESOLUTION_FOR_ALLOCATIONS= { + NO_CLASS_DEF_FOUND_ERROR, CLASS_FORMAT_ERROR, VERIFY_ERROR, ABSTRACT_METHOD_ERROR, + EXCEPTION_IN_INITIALIZER_ERROR, ILLEGAL_ACCESS_ERROR, INSTANTIATION_ERROR,ILLEGAL_ACCESS_ERROR + }; public static final Class[] EXCS_FIELD_AND_METHOD_RESOLUTION = { NO_SUCH_FIELD_ERROR, ILLEGAL_ACCESS_ERROR, NO_SUCH_METHOD_ERROR }; // Chapter 5.2 + public static final Class[] EXCS_FIELD_AND_METHOD_RESOLUTION_GETFIELD_PUTFIELD = { + NO_SUCH_FIELD_ERROR, ILLEGAL_ACCESS_ERROR, NO_SUCH_METHOD_ERROR,INCOMPATIBLE_CLASS_CHANGE_ERROR,NULL_POINTER_EXCEPTION + }; + + public static final Class[] EXCS_FIELD_AND_METHOD_RESOLUTION_GETSTATIC_PUTSTATIC = { + NO_SUCH_FIELD_ERROR, ILLEGAL_ACCESS_ERROR, NO_SUCH_METHOD_ERROR,INCOMPATIBLE_CLASS_CHANGE_ERROR + }; + + public static final Class[] EXCS_INTERFACE_METHOD_RESOLUTION_INVOKEINTERFACE = { + INCOMPATIBLE_CLASS_CHANGE_ERROR,ILLEGAL_ACCESS_ERROR,ABSTRACT_METHOD_ERROR,UNSATISFIED_LINK_ERROR + }; + public static final Class[] EXCS_INTERFACE_METHOD_RESOLUTION_INVOKESPECIAL_INVOKEVIRTUAL = { + INCOMPATIBLE_CLASS_CHANGE_ERROR,NULL_POINTER_EXCEPTION,ABSTRACT_METHOD_ERROR,UNSATISFIED_LINK_ERROR + }; + + public static final Class[] EXCS_INTERFACE_METHOD_RESOLUTION_INVOKESTATIC = { + INCOMPATIBLE_CLASS_CHANGE_ERROR,UNSATISFIED_LINK_ERROR + }; + + public static final Class[] EXCS_INTERFACE_METHOD_RESOLUTION = new Class[0]; // Chapter 5.3 (as below) public static final Class[] EXCS_STRING_RESOLUTION = new Class[0]; // Chapter 5.4 (no errors but the ones that _always_ could happen! How stupid.) diff --git a/bcel-builder/src/org/aspectj/apache/bcel/Repository.java b/bcel-builder/src/org/aspectj/apache/bcel/Repository.java index 658b57b98..ee1278ac9 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/Repository.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/Repository.java @@ -66,7 +66,7 @@ import java.io.*; * @see org.aspectj.apache.bcel.util.Repository * @see org.aspectj.apache.bcel.util.SyntheticRepository * - * @version $Id: Repository.java,v 1.3 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: Repository.java,v 1.4 2008/05/28 23:53:04 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public abstract class Repository { @@ -95,11 +95,9 @@ public abstract class Repository { try { JavaClass clazz = getRepository().findClass(class_name); - if(clazz == null) { - return getRepository().loadClass(class_name); - } else { - return clazz; - } + if(clazz != null) return clazz; + + return getRepository().loadClass(class_name); } catch(ClassNotFoundException ex) { return null; } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/AccessFlags.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/AccessFlags.java deleted file mode 100644 index cfcee2584..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/AccessFlags.java +++ /dev/null @@ -1,183 +0,0 @@ -package org.aspectj.apache.bcel.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -import org.aspectj.apache.bcel.Constants; - -/** - * Super class for all objects that have modifiers like private, final, ... - * I.e. classes, fields, and methods. - * - * @version $Id: AccessFlags.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public abstract class AccessFlags implements java.io.Serializable { - protected int access_flags; - - public AccessFlags() {} - - /** - * @param a inital access flags - */ - public AccessFlags(int a) { - access_flags = a; - } - - /** - * @return Access flags of the object aka. "modifiers". - */ - public final int getAccessFlags() { return access_flags; } - - /** - * @return Access flags of the object aka. "modifiers". - */ - public final int getModifiers() { return access_flags; } - - /** Set access flags aka "modifiers". - * @param access_flags Access flags of the object. - */ - public final void setAccessFlags(int access_flags) { - this.access_flags = access_flags; - } - - /** Set access flags aka "modifiers". - * @param access_flags Access flags of the object. - */ - public final void setModifiers(int access_flags) { - setAccessFlags(access_flags); - } - - private final void setFlag(int flag, boolean set) { - if((access_flags & flag) != 0) { // Flag is set already - if(!set) // Delete flag ? - access_flags ^= flag; - } else { // Flag not set - if(set) // Set flag ? - access_flags |= flag; - } - } - - public final void isPublic(boolean flag) { setFlag(Constants.ACC_PUBLIC, flag); } - public final boolean isPublic() { - return (access_flags & Constants.ACC_PUBLIC) != 0; - } - - public final void isPrivate(boolean flag) { setFlag(Constants.ACC_PRIVATE, flag); } - public final boolean isPrivate() { - return (access_flags & Constants.ACC_PRIVATE) != 0; - } - - public final void isProtected(boolean flag) { setFlag(Constants.ACC_PROTECTED, flag); } - public final boolean isProtected() { - return (access_flags & Constants.ACC_PROTECTED) != 0; - } - - public final void isStatic(boolean flag) { setFlag(Constants.ACC_STATIC, flag); } - public final boolean isStatic() { - return (access_flags & Constants.ACC_STATIC) != 0; - } - - public final void isFinal(boolean flag) { setFlag(Constants.ACC_FINAL, flag); } - public final boolean isFinal() { - return (access_flags & Constants.ACC_FINAL) != 0; - } - - public final void isSynchronized(boolean flag) { setFlag(Constants.ACC_SYNCHRONIZED, flag); } - public final boolean isSynchronized() { - return (access_flags & Constants.ACC_SYNCHRONIZED) != 0; - } - - public final void isVolatile(boolean flag) { setFlag(Constants.ACC_VOLATILE, flag); } - public final boolean isVolatile() { - return (access_flags & Constants.ACC_VOLATILE) != 0; - } - - public final void isTransient(boolean flag) { setFlag(Constants.ACC_TRANSIENT, flag); } - public final boolean isTransient() { - return (access_flags & Constants.ACC_TRANSIENT) != 0; - } - - public final void isNative(boolean flag) { setFlag(Constants.ACC_NATIVE, flag); } - public final boolean isNative() { - return (access_flags & Constants.ACC_NATIVE) != 0; - } - - public final void isInterface(boolean flag) { setFlag(Constants.ACC_INTERFACE, flag); } - public final boolean isInterface() { - return (access_flags & Constants.ACC_INTERFACE) != 0; - } - - public final void isAbstract(boolean flag) { setFlag(Constants.ACC_ABSTRACT, flag); } - public final boolean isAbstract() { - return (access_flags & Constants.ACC_ABSTRACT) != 0; - } - - public final void isStrictfp(boolean flag) { setFlag(Constants.ACC_STRICT, flag); } - public final boolean isStrictfp() { - return (access_flags & Constants.ACC_STRICT) != 0; - } - - public final void isVarargs(boolean flag) { setFlag(Constants.ACC_VARARGS, flag); } - /** J5SUPPORT: Called on methods to determine if they were written with varargs. */ - public final boolean isVarargs() { - return (access_flags & Constants.ACC_VARARGS) != 0; - } - - public final void isBridge(boolean flag) { setFlag(Constants.ACC_BRIDGE, flag); } - /** J5SUPPORT: Called on methods to determine if they are bridge methods */ - public final boolean isBridge() { - return (access_flags & Constants.ACC_BRIDGE) != 0; - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/AnnotationDefault.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/AnnotationDefault.java index c687758a8..53cf1c33d 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/AnnotationDefault.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/AnnotationDefault.java @@ -17,7 +17,7 @@ import java.io.DataOutputStream; import java.io.IOException; import org.aspectj.apache.bcel.Constants; -import org.aspectj.apache.bcel.classfile.annotation.ElementValue; +import org.aspectj.apache.bcel.classfile.annotation.ElementValueGen; /** * This attribute is attached to a method and indicates the default @@ -25,31 +25,31 @@ import org.aspectj.apache.bcel.classfile.annotation.ElementValue; */ public class AnnotationDefault extends Attribute { - private ElementValue value; + private ElementValueGen value; public AnnotationDefault(int nameIndex, int len, DataInputStream dis, ConstantPool cpool) throws IOException { - this(nameIndex, len, ElementValue.readElementValue(dis,cpool), cpool); + this(nameIndex, len, ElementValueGen.readElementValue(dis,cpool), cpool); } - private AnnotationDefault(int nameIndex, int len, ElementValue value, ConstantPool cpool) { + private AnnotationDefault(int nameIndex, int len, ElementValueGen value, ConstantPool cpool) { super(Constants.ATTR_ANNOTATION_DEFAULT, nameIndex, len, cpool); this.value = value; } - public void accept(Visitor v) { - v.visitAnnotationDefault(this); - } - public Attribute copy(ConstantPool constant_pool) { throw new RuntimeException("Not implemented yet!"); // is this next line sufficient? // return (EnclosingMethod)clone(); } - public final ElementValue getElementValue() { return value; } + public final ElementValueGen getElementValue() { return value; } public final void dump(DataOutputStream dos) throws IOException { super.dump(dos); value.dump(dos); } + + public void accept(ClassVisitor v) { + v.visitAnnotationDefault(this); + } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Attribute.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Attribute.java index 8d7deb62e..4833bbd64 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Attribute.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Attribute.java @@ -61,7 +61,6 @@ import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleAnnotations; import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleParameterAnnotations; import java.io.*; -import java.util.HashMap; /** * Abstract super class for <em>Attribute</em> objects. Currently the @@ -71,7 +70,7 @@ import java.util.HashMap; * <em>Synthetic</em> attributes are supported. The * <em>Unknown</em> attribute stands for non-standard-attributes. * - * @version $Id: Attribute.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: Attribute.java,v 1.3 2008/05/28 23:53:01 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see ConstantValue * @see SourceFile @@ -86,218 +85,86 @@ import java.util.HashMap; * @see Signature */ public abstract class Attribute implements Cloneable, Node, Serializable { - protected int name_index; // Points to attribute name in constant pool - protected int length; // Content length of attribute field - protected byte tag; // Tag to distiguish subclasses - protected ConstantPool constant_pool; + public static Attribute[] NoAttributes = new Attribute[0]; - protected Attribute(byte tag, int name_index, int length, - ConstantPool constant_pool) { - this.tag = tag; - this.name_index = name_index; - this.length = length; - this.constant_pool = constant_pool; - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public abstract void accept(Visitor v); - - /** - * Dump attribute to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public void dump(DataOutputStream file) throws IOException - { - file.writeShort(name_index); - file.writeInt(length); - } - - private static HashMap readers = new HashMap(); - - /** Add an Attribute reader capable of parsing (user-defined) attributes - * named "name". You should not add readers for the standard attributes - * such as "LineNumberTable", because those are handled internally. - * - * @param name the name of the attribute as stored in the class file - * @param r the reader object - */ - public static void addAttributeReader(String name, AttributeReader r) { - readers.put(name, r); - } - - /** Remove attribute reader - * - * @param name the name of the attribute as stored in the class file - */ - public static void removeAttributeReader(String name) { - readers.remove(name); - } + + protected byte tag; // Tag to distinguish subclasses + protected int nameIndex; // Points to attribute name in constant pool + protected int length; // Content length of attribute field + protected ConstantPool constantPool; + + + protected Attribute(byte tag, int nameIndex, int length, ConstantPool constantPool) { + this.tag = tag; + this.nameIndex = nameIndex; + this.length = length; + this.constantPool = constantPool; + } - /* Class method reads one attribute from the input data stream. - * This method must not be accessible from the outside. It is - * called by the Field and Method constructor methods. - * - * @see Field - * @see Method - * @param file Input stream - * @param constant_pool Array of constants - * @return Attribute - * @throws IOException - * @throws ClassFormatException - */ - public static final Attribute readAttribute(DataInputStream file, - ConstantPool constant_pool) - throws IOException, ClassFormatException - { - ConstantUtf8 c; - String name; - int name_index; - int length; - byte tag = Constants.ATTR_UNKNOWN; // Unknown attribute + + /** Dump attribute to file stream in binary format */ + public void dump(DataOutputStream file) throws IOException { + file.writeShort(nameIndex); + file.writeInt(length); + } - // Get class name from constant pool via 'name_index' indirection - name_index = (int)file.readUnsignedShort(); - c = (ConstantUtf8)constant_pool.getConstant(name_index, - Constants.CONSTANT_Utf8); - name = c.getBytes(); - // Length of data in bytes - length = file.readInt(); + public static final Attribute readAttribute(DataInputStream file, ConstantPool cpool) throws IOException { + byte tag = Constants.ATTR_UNKNOWN; // Unknown attribute + int idx = file.readUnsignedShort(); + String name = cpool.getConstantUtf8(idx).getBytes(); + int len = file.readInt(); // Compare strings to find known attribute - for(byte i=0; i < Constants.KNOWN_ATTRIBUTES; i++) { - if(name.equals(Constants.ATTRIBUTE_NAMES[i])) { - tag = i; // found! - break; - } + for (byte i=0; i < Constants.KNOWN_ATTRIBUTES; i++) { + if (name.equals(Constants.ATTRIBUTE_NAMES[i])) { tag = i; break; } } - - // Call proper constructor, depending on `tag' switch(tag) { - case Constants.ATTR_UNKNOWN: - AttributeReader r = (AttributeReader)readers.get(name); - - if(r != null) - return r.createAttribute(name_index, length, file, constant_pool); - else - return new Unknown(name_index, length, file, constant_pool); - - case Constants.ATTR_CONSTANT_VALUE: - return new ConstantValue(name_index, length, file, constant_pool); - - case Constants.ATTR_SOURCE_FILE: - return new SourceFile(name_index, length, file, constant_pool); - - case Constants.ATTR_CODE: - return new Code(name_index, length, file, constant_pool); - - case Constants.ATTR_EXCEPTIONS: - return new ExceptionTable(name_index, length, file, constant_pool); - - case Constants.ATTR_LINE_NUMBER_TABLE: - return new LineNumberTable(name_index, length, file, constant_pool); - - case Constants.ATTR_LOCAL_VARIABLE_TABLE: - return new LocalVariableTable(name_index, length, file, constant_pool); - - case Constants.ATTR_INNER_CLASSES: - return new InnerClasses(name_index, length, file, constant_pool); - - case Constants.ATTR_SYNTHETIC: - return new Synthetic(name_index, length, file, constant_pool); - - case Constants.ATTR_DEPRECATED: - return new Deprecated(name_index, length, file, constant_pool); - - case Constants.ATTR_PMG: - return new PMGClass(name_index, length, file, constant_pool); - - case Constants.ATTR_SIGNATURE: - return new Signature(name_index, length, file, constant_pool); - - case Constants.ATTR_STACK_MAP: - return new StackMap(name_index, length, file, constant_pool); - - // J5SUPPORT: - case Constants.ATTR_RUNTIME_VISIBLE_ANNOTATIONS: - return new RuntimeVisibleAnnotations(name_index,length,file,constant_pool); - case Constants.ATTR_RUNTIME_INVISIBLE_ANNOTATIONS: - return new RuntimeInvisibleAnnotations(name_index,length,file,constant_pool); - case Constants.ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS: - return new RuntimeVisibleParameterAnnotations(name_index,length,file,constant_pool); - case Constants.ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS: - return new RuntimeInvisibleParameterAnnotations(name_index,length,file,constant_pool); - case Constants.ATTR_ANNOTATION_DEFAULT: - return new AnnotationDefault(name_index,length,file,constant_pool); - case Constants.ATTR_LOCAL_VARIABLE_TYPE_TABLE: - return new LocalVariableTypeTable(name_index,length,file,constant_pool); - case Constants.ATTR_ENCLOSING_METHOD: - return new EnclosingMethod(name_index,length,file,constant_pool); - - default: // Never reached - throw new IllegalStateException("Ooops! default case reached."); - } + case Constants.ATTR_UNKNOWN: return new Unknown(idx, len, file, cpool); + case Constants.ATTR_CONSTANT_VALUE: return new ConstantValue(idx, len, file, cpool); + case Constants.ATTR_SOURCE_FILE: return new SourceFile(idx, len, file, cpool); + case Constants.ATTR_CODE: return new Code(idx, len, file, cpool); + case Constants.ATTR_EXCEPTIONS: return new ExceptionTable(idx, len, file, cpool); + case Constants.ATTR_LINE_NUMBER_TABLE: return new LineNumberTable(idx, len, file, cpool); + case Constants.ATTR_LOCAL_VARIABLE_TABLE: return new LocalVariableTable(idx, len, file, cpool); + case Constants.ATTR_INNER_CLASSES: return new InnerClasses(idx, len, file, cpool); + case Constants.ATTR_SYNTHETIC: return new Synthetic(idx, len, file, cpool); + case Constants.ATTR_DEPRECATED: return new Deprecated(idx, len, file, cpool); + case Constants.ATTR_PMG: return new PMGClass(idx, len, file, cpool); + case Constants.ATTR_SIGNATURE: return new Signature(idx, len, file, cpool); + case Constants.ATTR_STACK_MAP: return new StackMap(idx, len, file, cpool); + case Constants.ATTR_RUNTIME_VISIBLE_ANNOTATIONS: + return new RuntimeVisibleAnnotations(idx,len,file,cpool); + case Constants.ATTR_RUNTIME_INVISIBLE_ANNOTATIONS: + return new RuntimeInvisibleAnnotations(idx,len,file,cpool); + case Constants.ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS: + return new RuntimeVisibleParameterAnnotations(idx,len,file,cpool); + case Constants.ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS: + return new RuntimeInvisibleParameterAnnotations(idx,len,file,cpool); + case Constants.ATTR_ANNOTATION_DEFAULT: + return new AnnotationDefault(idx,len,file,cpool); + case Constants.ATTR_LOCAL_VARIABLE_TYPE_TABLE: + return new LocalVariableTypeTable(idx,len,file,cpool); + case Constants.ATTR_ENCLOSING_METHOD: + return new EnclosingMethod(idx,len,file,cpool); + default: throw new IllegalStateException(); + } } public String getName() { - ConstantUtf8 c = - (ConstantUtf8)constant_pool.getConstant(name_index,Constants.CONSTANT_Utf8); - return c.getBytes(); + return constantPool.getConstantUtf8(nameIndex).getBytes(); } - /** - * @return Length of attribute field in bytes. - */ - public final int getLength() { return length; } - - /** - * @param Attribute length in bytes. - */ - public final void setLength(int length) { - this.length = length; - } - - /** - * @param name_index of attribute. - */ - public final void setNameIndex(int name_index) { - this.name_index = name_index; - } - /** - * @return Name index in constant pool of attribute name. - */ - public final int getNameIndex() { return name_index; } - - /** - * @return Tag of attribute, i.e., its type. Value may not be altered, thus - * there is no setTag() method. - */ - public final byte getTag() { return tag; } + public final int getLength() { return length; } - /** - * @return Constant pool used by this object. - * @see ConstantPool - */ - public final ConstantPool getConstantPool() { return constant_pool; } + public final int getNameIndex() { return nameIndex; } + + public final byte getTag() { return tag; } - /** - * @param constant_pool Constant pool to be used for this object. - * @see ConstantPool - */ - public final void setConstantPool(ConstantPool constant_pool) { - this.constant_pool = constant_pool; - } + public final ConstantPool getConstantPool() { return constantPool; } /** - * Use copy() if you want to have a deep copy(), i.e., with all references + * Use copy() if you want to have a deep copy(), ie. with all references * copied correctly. * * @return shallow copy of this attribute @@ -319,10 +186,10 @@ public abstract class Attribute implements Cloneable, Node, Serializable { */ public abstract Attribute copy(ConstantPool constant_pool); - /** - * @return attribute name. - */ public String toString() { return Constants.ATTRIBUTE_NAMES[tag]; } + + public abstract void accept(ClassVisitor v); + } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/AttributeReader.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/AttributeReader.java deleted file mode 100644 index 1d3cdb3a5..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/AttributeReader.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.aspectj.apache.bcel.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Unknown (non-standard) attributes may be read via user-defined factory - * objects that can be registered with the Attribute.addAttributeReader - * method. These factory objects should implement this interface. - - * @see Attribute - * @version $Id: AttributeReader.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public interface AttributeReader { - /** - When this attribute reader is added via the static method - Attribute.addAttributeReader, an attribute name is associated with it. - As the class file parser parses attributes, it will call various - AttributeReaders based on the name of the attributes it is - constructing. - - @param name_index An index into the constant pool, indexing a - ConstantUtf8 that represents the name of the attribute. - - @param length The length of the data contained in the attribute. This - is written into the constant pool and should agree with what the - factory expects the length to be. - - @param file This is the data input stream that the factory needs to read - its data from. - - @param constant_pool This is the constant pool associated with the - Attribute that we are constructing. - - @return The user-defined AttributeReader should take this data and use - it to construct an attribute. In the case of errors, a null can be - returned which will cause the parsing of the class file to fail. - - @see Attribute#addAttributeReader( String, AttributeReader ) - */ - public Attribute createAttribute(int name_index, - int length, - java.io.DataInputStream file, - ConstantPool constant_pool); -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/AttributeUtils.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/AttributeUtils.java new file mode 100644 index 000000000..3c540e8c9 --- /dev/null +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/AttributeUtils.java @@ -0,0 +1,93 @@ +package org.aspectj.apache.bcel.classfile; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +import org.aspectj.apache.bcel.Constants; + +public class AttributeUtils { + + public static Attribute[] readAttributes(DataInputStream dataInputstream, ConstantPool cpool) { + try { + int length = dataInputstream.readUnsignedShort(); + if (length==0) return Attribute.NoAttributes; + Attribute[] attrs = new Attribute[length]; + for (int i=0; i < length; i++) + attrs[i] = Attribute.readAttribute(dataInputstream, cpool); + return attrs; + } catch (IOException e) { + throw new ClassFormatException("IOException whilst reading set of attributes: "+e.toString()); + } + } + + /** Write (serialize) a set of attributes into a specified output stream */ + public static void writeAttributes(Attribute[] attributes,DataOutputStream file) throws IOException { + if (attributes==null) { + file.writeShort(0); + } else { + file.writeShort(attributes.length); + for(int i=0; i < attributes.length; i++) + attributes[i].dump(file); + } + } + + public static Attribute[] copy(Attribute[] attributes, ConstantPool constant_pool) { + if (attributes==null || attributes.length==0) return Attribute.NoAttributes; + Attribute[] attrs = new Attribute[attributes.length]; + for (int i = 0; i < attributes.length; i++) { + attrs[i] = attributes[i].copy(constant_pool); + } + return attrs; + } + + public static Signature getSignatureAttribute(Attribute[] attributes) { + for(int i=0; i < attributes.length; i++) { + if (attributes[i].tag==Constants.ATTR_SIGNATURE) return ((Signature)attributes[i]); + } + return null; + } + + public static Code getCodeAttribute(Attribute[] attributes) { + for(int i=0; i < attributes.length; i++) { + if (attributes[i].tag==Constants.ATTR_CODE) { return ((Code)attributes[i]);} + } + return null; + } + + public static ExceptionTable getExceptionTableAttribute(Attribute[] attributes) { + for(int i=0; i < attributes.length; i++) { + if (attributes[i].tag==Constants.ATTR_EXCEPTIONS) { return ((ExceptionTable)attributes[i]);} + } + return null; + } + + public static ConstantValue getConstantValueAttribute(Attribute[] attributes) { + for(int i=0; i < attributes.length; i++) { + if(attributes[i].getTag() == Constants.ATTR_CONSTANT_VALUE) return (ConstantValue)attributes[i]; + } + return null; + } + + public static void accept(Attribute[] attributes,ClassVisitor visitor) { + for(int i=0; i < attributes.length; i++) + attributes[i].accept(visitor); + } + + public static boolean hasSyntheticAttribute(Attribute[] attributes) { + for (int i = 0; i < attributes.length; i++) { + if (attributes[i].tag==Constants.ATTR_SYNTHETIC) { + return true; + } + } + return false; + } + + public static SourceFile getSourceFileAttribute(Attribute[] attributes) { + for(int i=0; i < attributes.length; i++) { + if (attributes[i].tag==Constants.ATTR_SOURCE_FILE) { return ((SourceFile)attributes[i]);} + } + return null; + } + +} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassFormatException.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassFormatException.java index 8e374fc5b..a958329e5 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassFormatException.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassFormatException.java @@ -59,7 +59,7 @@ package org.aspectj.apache.bcel.classfile; * that the file is malformed or otherwise cannot be interpreted as a * class file. * - * @version $Id: ClassFormatException.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: ClassFormatException.java,v 1.3 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public class ClassFormatException extends RuntimeException { diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassParser.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassParser.java index ae7f8c92e..faa365357 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassParser.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassParser.java @@ -70,71 +70,40 @@ import java.util.zip.*; * JVM specification 1.0</a>. See this paper for * further details about the structure of a bytecode file. * - * @version $Id: ClassParser.java,v 1.4 2005/10/14 08:39:32 aclement Exp $ + * @version $Id: ClassParser.java,v 1.5 2008/05/28 23:53:01 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public final class ClassParser { private DataInputStream file; - private ZipFile zip; - private String file_name; - private int class_name_index, superclass_name_index; - private int major, minor; // Compiler version - private int access_flags; // Access rights of parsed class - private int[] interfaces; // Names of implemented interfaces - private ConstantPool constant_pool; // collection of constants - private Field[] fields; // class fields, i.e., its variables - private Method[] methods; // methods defined in the class - private Attribute[] attributes; // attributes defined in the class - private boolean is_zip; // Loaded from zip file + private String filename; + private int classnameIndex; + private int superclassnameIndex; + private int major, minor; + private int accessflags; + private int[] interfaceIndices; + private ConstantPool cpool; + private Field[] fields; + private Method[] methods; + private Attribute[] attributes; private static final int BUFSIZE = 8192; - /** - * Parse class from the given stream. - * - * @param file Input stream - * @param file_name File name - */ - public ClassParser(InputStream file, String file_name) { - this.file_name = file_name; - - String clazz = file.getClass().getName(); // Not a very clean solution ... - is_zip = clazz.startsWith("java.util.zip.") || clazz.startsWith("java.util.jar."); - - if(file instanceof DataInputStream) // Is already a data stream - this.file = (DataInputStream)file; - else - this.file = new DataInputStream(new BufferedInputStream(file, BUFSIZE)); + /** Parse class from the given stream */ + public ClassParser(InputStream file, String filename) { + this.filename = filename; + if (file instanceof DataInputStream) this.file = (DataInputStream)file; + else this.file = new DataInputStream(new BufferedInputStream(file,BUFSIZE)); } - /** Parse class from given .class file. - * - * @param file_name file name - * @throws IOException - */ - public ClassParser(String file_name) throws IOException - { - is_zip = false; - this.file_name = file_name; - file = new DataInputStream(new BufferedInputStream - (new FileInputStream(file_name), BUFSIZE)); + public ClassParser(ByteArrayInputStream baos, String filename) { + this.filename = filename; + this.file = new DataInputStream(baos); } - /** Parse class from given .class file in a ZIP-archive - * - * @param file_name file name - * @throws IOException - */ - public ClassParser(String zip_file, String file_name) throws IOException - { - is_zip = true; - zip = new ZipFile(zip_file); - ZipEntry entry = zip.getEntry(file_name); - - this.file_name = file_name; - - file = new DataInputStream(new BufferedInputStream(zip.getInputStream(entry), - BUFSIZE)); + /** Parse class from given .class file */ + public ClassParser(String file_name) throws IOException { + this.filename = file_name; + file = new DataInputStream(new BufferedInputStream(new FileInputStream(file_name),BUFSIZE)); } /** @@ -143,13 +112,8 @@ public final class ClassParser { * A <em>ClassFormatException</em> is raised, if the file is not a valid * .class file. (This does not include verification of the byte code as it * is performed by the java interpreter). - * - * @return Class object representing the parsed class file - * @throws IOException - * @throws ClassFormatException - */ - public JavaClass parse() throws IOException, ClassFormatException - { + */ + public JavaClass parse() throws IOException, ClassFormatException { /****************** Read headers ********************************/ // Check magic tag of class file readID(); @@ -160,7 +124,7 @@ public final class ClassParser { /****************** Read constant pool and related **************/ // Read constant pool entries readConstantPool(); - + // Get class information readClassInfo(); @@ -177,162 +141,105 @@ public final class ClassParser { // Read class attributes readAttributes(); - // Check for unknown variables - //Unknown[] u = Unknown.getUnknownAttributes(); - //for(int i=0; i < u.length; i++) - // System.err.println("WARNING: " + u[i]); - - // Everything should have been read now - // if(file.available() > 0) { - // int bytes = file.available(); - // byte[] buf = new byte[bytes]; - // file.read(buf); - - // if(!(is_zip && (buf.length == 1))) { - // System.err.println("WARNING: Trailing garbage at end of " + file_name); - // System.err.println(bytes + " extra bytes: " + Utility.toHexString(buf)); - // } - // } - // Read everything of interest, so close the file file.close(); - if(zip != null) - zip.close(); // Return the information we have gathered in a new object - return new JavaClass(class_name_index, superclass_name_index, - file_name, major, minor, access_flags, - constant_pool, interfaces, fields, - methods, attributes, is_zip? JavaClass.ZIP : JavaClass.FILE); + JavaClass jc= new JavaClass(classnameIndex, superclassnameIndex, + filename, major, minor, accessflags, + cpool, interfaceIndices, fields, + methods, attributes); + return jc; } - - /** - * Read information about the attributes of the class. - * @throws IOException - * @throws ClassFormatException - */ - private final void readAttributes() throws IOException, ClassFormatException - { - int attributes_count; - - attributes_count = file.readUnsignedShort(); - attributes = new Attribute[attributes_count]; - - for(int i=0; i < attributes_count; i++) - attributes[i] = Attribute.readAttribute(file, constant_pool); + + /** Read information about the attributes of the class */ + private final void readAttributes() { + attributes = AttributeUtils.readAttributes(file,cpool); } - /** - * Read information about the class and its super class. - * @throws IOException - * @throws ClassFormatException - */ - private final void readClassInfo() throws IOException, ClassFormatException - { - access_flags = file.readUnsignedShort(); + /** Read information about the class and its super class */ + private final void readClassInfo() throws IOException { + accessflags = file.readUnsignedShort(); /* Interfaces are implicitely abstract, the flag should be set - * according to the JVM specification. - */ - if((access_flags & Constants.ACC_INTERFACE) != 0) - access_flags |= Constants.ACC_ABSTRACT; + * according to the JVM specification */ + if((accessflags & Constants.ACC_INTERFACE) != 0) + accessflags |= Constants.ACC_ABSTRACT; // don't police it like this... leave higher level verification code to check it. // if(((access_flags & Constants.ACC_ABSTRACT) != 0) && // ((access_flags & Constants.ACC_FINAL) != 0 )) // throw new ClassFormatException("Class can't be both final and abstract"); - class_name_index = file.readUnsignedShort(); - superclass_name_index = file.readUnsignedShort(); - } - /** - * Read constant pool entries. - * @throws IOException - * @throws ClassFormatException - */ - private final void readConstantPool() throws IOException, ClassFormatException - { + classnameIndex = file.readUnsignedShort(); + superclassnameIndex = file.readUnsignedShort(); + } + + /** Read constant pool entries */ + private final void readConstantPool() throws IOException { try { - constant_pool = new ConstantPool(file); + cpool = new ConstantPool(file); } catch (ClassFormatException cfe) { // add some context if we can - if (file_name!=null) { - String newmessage = "File: '"+file_name+"': "+cfe.getMessage(); + cfe.printStackTrace(); + if (filename!=null) { + String newmessage = "File: '"+filename+"': "+cfe.getMessage(); throw new ClassFormatException(newmessage); // this loses the old stack trace but I dont think that matters! } throw cfe; } } - /** - * Read information about the fields of the class, i.e., its variables. - * @throws IOException - * @throws ClassFormatException - */ - private final void readFields() throws IOException, ClassFormatException - { - int fields_count; - - fields_count = file.readUnsignedShort(); - fields = new Field[fields_count]; - - for(int i=0; i < fields_count; i++) - fields[i] = new Field(file, constant_pool); + /** Read information about the fields of the class */ + private final void readFields() throws IOException, ClassFormatException { + int fieldCount = file.readUnsignedShort(); + if (fieldCount == 0) { + fields = Field.NoFields; + } else { + fields = new Field[fieldCount]; + for(int i=0; i < fieldCount; i++) + fields[i] = new Field(file, cpool); + } } - /******************** Private utility methods **********************/ - - /** - * Check whether the header of the file is ok. - * Of course, this has to be the first action on successive file reads. - * @throws IOException - * @throws ClassFormatException - */ - private final void readID() throws IOException, ClassFormatException - { + /** Check whether the header of the file is ok. Of course, this has + * to be the first action on successive file reads */ + private final void readID() throws IOException { int magic = 0xCAFEBABE; - - if(file.readInt() != magic) - throw new ClassFormatException(file_name + " is not a Java .class file"); - } - /** - * Read information about the interfaces implemented by this class. - * @throws IOException - * @throws ClassFormatException - */ - private final void readInterfaces() throws IOException, ClassFormatException - { - int interfaces_count; - - interfaces_count = file.readUnsignedShort(); - interfaces = new int[interfaces_count]; - - for(int i=0; i < interfaces_count; i++) - interfaces[i] = file.readUnsignedShort(); + if (file.readInt() != magic) + throw new ClassFormatException(filename + " is not a Java .class file"); + } + + private static final int[] NO_INTERFACES = new int[0]; + + /** Read information about the interfaces implemented by this class */ + private final void readInterfaces() throws IOException { + int interfacesCount = file.readUnsignedShort(); + if (interfacesCount==0) { + interfaceIndices = NO_INTERFACES; + } else { + interfaceIndices = new int[interfacesCount]; + for(int i=0; i < interfacesCount; i++) + interfaceIndices[i] = file.readUnsignedShort(); + } } - /** - * Read information about the methods of the class. - * @throws IOException - * @throws ClassFormatException - */ - private final void readMethods() throws IOException, ClassFormatException - { - int methods_count; - - methods_count = file.readUnsignedShort(); - methods = new Method[methods_count]; - - for(int i=0; i < methods_count; i++) - methods[i] = new Method(file, constant_pool); + + /** Read information about the methods of the class */ + private final void readMethods() throws IOException { + int methodsCount = file.readUnsignedShort(); + if (methodsCount==0) { + methods = Method.NoMethods; + } else { + methods = new Method[methodsCount]; + for(int i=0; i < methodsCount; i++) + methods[i] = new Method(file, cpool); + } } - /** - * Read major and minor version of compiler which created the file. - * @throws IOException - * @throws ClassFormatException - */ - private final void readVersion() throws IOException, ClassFormatException - { + + /** Read major and minor version of compiler which created the file */ + private final void readVersion() throws IOException { minor = file.readUnsignedShort(); major = file.readUnsignedShort(); } + } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Visitor.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassVisitor.java index 525512d31..f44b178ba 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Visitor.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassVisitor.java @@ -67,10 +67,10 @@ import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleParameterAnnot * Implemented by wish of * <A HREF="http://www.inf.fu-berlin.de/~bokowski">Boris Bokowski</A>. * - * @version $Id: Visitor.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: ClassVisitor.java,v 1.2 2008/05/28 23:53:01 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ -public interface Visitor { +public interface ClassVisitor { public void visitCode(Code obj); public void visitCodeException(CodeException obj); public void visitConstantClass(ConstantClass obj); diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Code.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Code.java index 235f73c1e..dc0c9c839 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Code.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Code.java @@ -69,23 +69,19 @@ import java.io.*; * is used for debugging purposes and <em>LocalVariableTable</em> which * contains information about the local variables. * - * @version $Id: Code.java,v 1.3 2006/09/22 10:50:17 aclement Exp $ + * @version $Id: Code.java,v 1.4 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Attribute * @see CodeException * @see LineNumberTable - * @see LocalVariableTable + * @see LocalVariableTable */ public final class Code extends Attribute { - private int max_stack; // Maximum size of stack used by this method - private int max_locals; // Number of local variables - private int code_length; // Length of code in bytes - private byte[] code; // Actual byte code - - private int exception_table_length; - private CodeException[] exception_table; // Table of handled exceptions - private int attributes_count; // Attributes of code: LineNumber - private Attribute[] attributes; // or LocalVariable + private int maxStack; // Maximum size of stack used by this method + private int maxLocals; // Number of local variables + private byte[] code; // Actual byte code + private CodeException[] exceptionTable; + private Attribute[] attributes; /** * Initialize from another object. Note that both objects use the same @@ -97,41 +93,28 @@ public final class Code extends Attribute { c.getConstantPool()); } - /** - * @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 - */ - Code(int name_index, int length, DataInputStream file, - ConstantPool constant_pool) throws IOException - { + + Code(int name_index, int length, DataInputStream file, ConstantPool constant_pool) throws IOException { // Initialize with some default values which will be overwritten later this(name_index, length, file.readUnsignedShort(), file.readUnsignedShort(), (byte[])null, (CodeException[])null, (Attribute[])null, constant_pool); - code_length = file.readInt(); - code = new byte[code_length]; // Read byte code + int len = file.readInt(); + code = new byte[len]; // Read byte code file.readFully(code); /* Read exception table that contains all regions where an exception * handler is active, i.e., a try { ... } catch() block. */ - exception_table_length = file.readUnsignedShort(); - exception_table = new CodeException[exception_table_length]; + len = file.readUnsignedShort(); + exceptionTable = new CodeException[len]; + for(int i=0; i < len; i++) + exceptionTable[i] = new CodeException(file); - for(int i=0; i < exception_table_length; i++) - exception_table[i] = new CodeException(file); - - /* Read all attributes, currently `LineNumberTable' and - * `LocalVariableTable' - */ - attributes_count = file.readUnsignedShort(); - attributes = new Attribute[attributes_count]; - for(int i=0; i < attributes_count; i++) - attributes[i] = Attribute.readAttribute(file, constant_pool); + // Read all attributes, eg: LineNumberTable, LocalVariableTable + attributes = AttributeUtils.readAttributes(file,constant_pool); /* Adjust length, because of setAttributes in this(), s.b. length * is incorrect, because it didn't take the internal attributes @@ -159,8 +142,8 @@ public final class Code extends Attribute { { super(Constants.ATTR_CODE, name_index, length, constant_pool); - this.max_stack = max_stack; - this.max_locals = max_locals; + this.maxStack = max_stack; + this.maxLocals = max_locals; setCode(code); setExceptionTable(exception_table); @@ -174,7 +157,7 @@ public final class Code extends Attribute { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitCode(this); } @@ -188,17 +171,20 @@ public final class Code extends Attribute { { super.dump(file); - file.writeShort(max_stack); - file.writeShort(max_locals); - file.writeInt(code_length); - file.write(code, 0, code_length); + file.writeShort(maxStack); + if (maxStack==3) { + int stop = 1; // fixme + } + file.writeShort(maxLocals); + file.writeInt(code.length); + file.write(code, 0, code.length); - file.writeShort(exception_table_length); - for(int i=0; i < exception_table_length; i++) - exception_table[i].dump(file); + file.writeShort(exceptionTable.length); + for(int i=0; i < exceptionTable.length; i++) + exceptionTable[i].dump(file); - file.writeShort(attributes_count); - for(int i=0; i < attributes_count; i++) + file.writeShort(attributes.length); + for(int i=0; i < attributes.length; i++) attributes[i].dump(file); } @@ -212,10 +198,8 @@ public final class Code extends Attribute { * @return LineNumberTable of Code, if it has one */ public LineNumberTable getLineNumberTable() { - for(int i=0; i < attributes_count; i++) - if(attributes[i] instanceof LineNumberTable) - return (LineNumberTable)attributes[i]; - + for (int i=0; i < attributes.length; i++) + if (attributes[i].tag==Constants.ATTR_LINE_NUMBER_TABLE) return (LineNumberTable)attributes[i]; return null; } @@ -223,10 +207,8 @@ public final class Code extends Attribute { * @return LocalVariableTable of Code, if it has one */ public LocalVariableTable getLocalVariableTable() { - for(int i=0; i < attributes_count; i++) - if(attributes[i] instanceof LocalVariableTable) - return (LocalVariableTable)attributes[i]; - + for(int i=0; i < attributes.length; i++) + if (attributes[i].tag==Constants.ATTR_LOCAL_VARIABLE_TABLE) return (LocalVariableTable)attributes[i]; return null; } @@ -239,18 +221,18 @@ public final class Code extends Attribute { * @return Table of handled exceptions. * @see CodeException */ - public final CodeException[] getExceptionTable() { return exception_table; } + public final CodeException[] getExceptionTable() { return exceptionTable; } /** * @return Number of local variables. */ - public final int getMaxLocals() { return max_locals; } + public final int getMaxLocals() { return maxLocals; } /** * @return Maximum size of stack used by this method. */ - public final int getMaxStack() { return max_stack; } + public final int getMaxStack() { return maxStack; } /** * @return the internal length of this code attribute (minus the first 6 bytes) @@ -258,9 +240,9 @@ public final class Code extends Attribute { */ private final int getInternalLength() { return 2 /*max_stack*/ + 2 /*max_locals*/ + 4 /*code length*/ - + code_length /*byte-code*/ + + (code==null?0:code.length) /*byte-code*/ + 2 /*exception-table length*/ - + 8 * exception_table_length /* exception table */ + + 8 * (exceptionTable==null?0:exceptionTable.length) /* exception table */ + 2 /* attributes count */; } @@ -270,10 +252,10 @@ public final class Code extends Attribute { */ private final int calculateLength() { int len = 0; - - for(int i=0; i < attributes_count; i++) - len += attributes[i].length + 6 /*attribute header size*/; - + if (attributes!=null) { + for(int i=0; i < attributes.length; i++) + len += attributes[i].length + 6 /*attribute header size*/; + } return len + getInternalLength(); } @@ -282,7 +264,6 @@ public final class Code extends Attribute { */ public final void setAttributes(Attribute[] attributes) { this.attributes = attributes; - attributes_count = (attributes == null)? 0 : attributes.length; length = calculateLength(); // Adjust length } @@ -291,30 +272,27 @@ public final class Code extends Attribute { */ public final void setCode(byte[] code) { this.code = code; - code_length = (code == null)? 0 : code.length; } /** * @param exception_table exception table */ public final void setExceptionTable(CodeException[] exception_table) { - this.exception_table = exception_table; - exception_table_length = (exception_table == null)? 0 : - exception_table.length; + this.exceptionTable = exception_table; } /** * @param max_locals maximum number of local variables */ public final void setMaxLocals(int max_locals) { - this.max_locals = max_locals; + this.maxLocals = max_locals; } /** * @param max_stack maximum stack size */ public final void setMaxStack(int max_stack) { - this.max_stack = max_stack; + this.maxStack = max_stack; } /** @@ -323,22 +301,22 @@ public final class Code extends Attribute { public final String toString(boolean verbose) { StringBuffer buf; - buf = new StringBuffer("Code(max_stack = " + max_stack + - ", max_locals = " + max_locals + - ", code_length = " + code_length + ")\n" + - Utility.codeToString(code, constant_pool, 0, -1, verbose)); + buf = new StringBuffer("Code(max_stack = " + maxStack + + ", max_locals = " + maxLocals + + ", code_length = " + code.length + ")\n" + + Utility.codeToString(code, constantPool, 0, -1, verbose)); - if(exception_table_length > 0) { + if(exceptionTable.length > 0) { buf.append("\nException handler(s) = \n" + "From\tTo\tHandler\tType\n"); - for(int i=0; i < exception_table_length; i++) - buf.append(exception_table[i].toString(constant_pool, verbose) + "\n"); + for(int i=0; i < exceptionTable.length; i++) + buf.append(exceptionTable[i].toString(constantPool, verbose) + "\n"); } - if(attributes_count > 0) { + if(attributes.length > 0) { buf.append("\nAttribute(s) = \n"); - for(int i=0; i < attributes_count; i++) + for(int i=0; i < attributes.length; i++) buf.append(attributes[i].toString() + "\n"); } @@ -358,14 +336,14 @@ public final class Code extends Attribute { public Attribute copy(ConstantPool constant_pool) { Code c = (Code)clone(); c.code = (byte[])code.clone(); - c.constant_pool = constant_pool; + c.constantPool = constant_pool; - c.exception_table = new CodeException[exception_table_length]; - for(int i=0; i < exception_table_length; i++) - c.exception_table[i] = exception_table[i].copy(); + c.exceptionTable = new CodeException[exceptionTable.length]; + for(int i=0; i < exceptionTable.length; i++) + c.exceptionTable[i] = exceptionTable[i].copy(); - c.attributes = new Attribute[attributes_count]; - for(int i=0; i < attributes_count; i++) + c.attributes = new Attribute[attributes.length]; + for(int i=0; i < attributes.length; i++) c.attributes[i] = attributes[i].copy(constant_pool); return c; @@ -378,17 +356,17 @@ public final class Code extends Attribute { */ public String getCodeString() { StringBuffer codeString = new StringBuffer(); - codeString.append("Code(max_stack = ").append(max_stack); - codeString.append(", max_locals = ").append(max_locals); - codeString.append(", code_length = ").append(code_length).append(")\n"); - codeString.append(Utility.codeToString(code, constant_pool, 0, -1,true)); - if (exception_table_length>0) { - codeString.append("\n").append("Exception entries = ").append(exception_table_length).append("\n"); - for (int i = 0; i < exception_table_length; i++) { - CodeException exc = exception_table[i]; + codeString.append("Code(max_stack = ").append(maxStack); + codeString.append(", max_locals = ").append(maxLocals); + codeString.append(", code_length = ").append(code.length).append(")\n"); + codeString.append(Utility.codeToString(code, constantPool, 0, -1,true)); + if (exceptionTable.length>0) { + codeString.append("\n").append("Exception entries = ").append(exceptionTable.length).append("\n"); + for (int i = 0; i < exceptionTable.length; i++) { + CodeException exc = exceptionTable[i]; int type = exc.getCatchType(); String name = "finally"; - if (type!=0) name = this.constant_pool.getConstantString(type,Constants.CONSTANT_Class); + if (type!=0) name = this.constantPool.getConstantString(type,Constants.CONSTANT_Class); codeString.append(name).append("["); codeString.append(exc.getStartPC()).append(">").append(exc.getEndPC()).append("]\n"); } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/CodeException.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/CodeException.java index b450186cb..72b4d539e 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/CodeException.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/CodeException.java @@ -62,77 +62,44 @@ import java.io.*; * attribute and is used only there. It contains a range in which a * particular exception handler is active. * - * @version $Id: CodeException.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: CodeException.java,v 1.3 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Code */ -public final class CodeException - implements Cloneable, Constants, Node, Serializable -{ +public final class CodeException implements Cloneable, Constants, Node, Serializable { private int start_pc; // Range in the code the exception handler is private int end_pc; // active. start_pc is inclusive, end_pc exclusive private int handler_pc; /* Starting address of exception handler, i.e., - * an offset from start of code. - */ + * an offset from start of code. + */ private int catch_type; /* If this is zero the handler catches any * exception, otherwise it points to the * exception class which is to be caught. */ - /** - * Initialize from another object. - */ + public CodeException(CodeException c) { this(c.getStartPC(), c.getEndPC(), c.getHandlerPC(), c.getCatchType()); } - /** - * Construct object from file stream. - * @param file Input stream - * @throws IOException - */ - CodeException(DataInputStream file) throws IOException - { - this(file.readUnsignedShort(), file.readUnsignedShort(), - file.readUnsignedShort(), file.readUnsignedShort()); + CodeException(DataInputStream file) throws IOException { + start_pc = file.readUnsignedShort(); + end_pc = file.readUnsignedShort(); + handler_pc = file.readUnsignedShort(); + catch_type = file.readUnsignedShort(); } - /** - * @param start_pc Range in the code the exception handler is active, - * start_pc is inclusive while - * @param end_pc is exclusive - * @param handler_pc Starting address of exception handler, i.e., - * an offset from start of code. - * @param catch_type If zero the handler catches any - * exception, otherwise it points to the exception class which is - * to be caught. - */ - public CodeException(int start_pc, int end_pc, int handler_pc, - int catch_type) - { + public CodeException(int start_pc, int end_pc, int handler_pc, int catch_type) { this.start_pc = start_pc; this.end_pc = end_pc; this.handler_pc = handler_pc; this.catch_type = catch_type; } - /** - * 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) { + public void accept(ClassVisitor v) { v.visitCodeException(this); } - /** - * Dump code exception to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { + + public final void dump(DataOutputStream file) throws IOException { file.writeShort(start_pc); file.writeShort(end_pc); file.writeShort(handler_pc); diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Constant.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Constant.java index 96ea2c603..32ee205ca 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Constant.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Constant.java @@ -62,7 +62,7 @@ import java.io.*; * in the constant pool of a class file. The classes keep closely to * the JVM specification. * - * @version $Id: Constant.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: Constant.java,v 1.3 2008/05/28 23:53:01 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public abstract class Constant implements Cloneable, Node, Serializable { @@ -85,7 +85,7 @@ public abstract class Constant implements Cloneable, Node, Serializable { * * @param v Visitor object */ - public abstract void accept(Visitor v); + public abstract void accept(ClassVisitor v); public abstract void dump(DataOutputStream file) throws IOException; @@ -117,32 +117,22 @@ public abstract class Constant implements Cloneable, Node, Serializable { return super.clone(); } - /** - * Read one constant from the given file, the type depends on a tag byte. - * - * @param file Input stream - * @return Constant object - */ - static final Constant readConstant(DataInputStream file) - throws IOException, ClassFormatException - { - byte b = file.readByte(); // Read tag byte - + static final Constant readConstant(DataInputStream file) throws IOException, ClassFormatException { + byte b = file.readByte(); switch(b) { - case Constants.CONSTANT_Class: return new ConstantClass(file); - case Constants.CONSTANT_Fieldref: return new ConstantFieldref(file); - case Constants.CONSTANT_Methodref: return new ConstantMethodref(file); - case Constants.CONSTANT_InterfaceMethodref: return new - ConstantInterfaceMethodref(file); - case Constants.CONSTANT_String: return new ConstantString(file); - case Constants.CONSTANT_Integer: return new ConstantInteger(file); - case Constants.CONSTANT_Float: return new ConstantFloat(file); - case Constants.CONSTANT_Long: return new ConstantLong(file); - case Constants.CONSTANT_Double: return new ConstantDouble(file); - case Constants.CONSTANT_NameAndType: return new ConstantNameAndType(file); - case Constants.CONSTANT_Utf8: return new ConstantUtf8(file); - default: - throw new ClassFormatException("Invalid byte tag in constant pool: " + b); + case Constants.CONSTANT_Class: return new ConstantClass(file); + case Constants.CONSTANT_NameAndType: return new ConstantNameAndType(file); + case Constants.CONSTANT_Utf8: return new ConstantUtf8(file); + case Constants.CONSTANT_Fieldref: return new ConstantFieldref(file); + case Constants.CONSTANT_Methodref: return new ConstantMethodref(file); + case Constants.CONSTANT_InterfaceMethodref: return new ConstantInterfaceMethodref(file); + case Constants.CONSTANT_String: return new ConstantString(file); + case Constants.CONSTANT_Integer: return new ConstantInteger(file); + case Constants.CONSTANT_Float: return new ConstantFloat(file); + case Constants.CONSTANT_Long: return new ConstantLong(file); + case Constants.CONSTANT_Double: return new ConstantDouble(file); + default: + throw new ClassFormatException("Invalid byte tag in constant pool: " + b); } } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantCP.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantCP.java index 7ee7e32dc..4cc882e3d 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantCP.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantCP.java @@ -59,7 +59,7 @@ import org.aspectj.apache.bcel.Constants; /** * Abstract super class for Fieldref and Methodref constants. * - * @version $Id: ConstantCP.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: ConstantCP.java,v 1.3 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see ConstantFieldref * @see ConstantMethodref diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantClass.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantClass.java index bd642e016..9c3b7d69c 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantClass.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantClass.java @@ -62,7 +62,7 @@ import java.io.*; * <A HREF="org.aspectj.apache.bcel.classfile.Constant.html">Constant</A> class * and represents a reference to a (external) class. * - * @version $Id: ConstantClass.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: ConstantClass.java,v 1.3 2008/05/28 23:53:01 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Constant */ @@ -84,7 +84,9 @@ public final class ConstantClass extends Constant implements ConstantObject { */ ConstantClass(DataInputStream file) throws IOException { - this(file.readUnsignedShort()); + super(Constants.CONSTANT_Class); + this.name_index = file.readUnsignedShort(); +// this(file.readUnsignedShort()); } /** @@ -103,7 +105,7 @@ public final class ConstantClass extends Constant implements ConstantObject { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitConstantClass(this); } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantDouble.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantDouble.java index ae7c63130..7c9c95732 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantDouble.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantDouble.java @@ -62,7 +62,7 @@ import java.io.*; * <A HREF="org.aspectj.apache.bcel.classfile.Constant.html">Constant</A> class * and represents a reference to a Double object. * - * @version $Id: ConstantDouble.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: ConstantDouble.java,v 1.3 2008/05/28 23:53:01 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Constant */ @@ -102,7 +102,7 @@ public final class ConstantDouble extends Constant implements ConstantObject { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitConstantDouble(this); } /** diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantFieldref.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantFieldref.java index 42cc8886f..ee248ea30 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantFieldref.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantFieldref.java @@ -60,7 +60,7 @@ import java.io.*; /** * This class represents a constant pool reference to a field. * - * @version $Id: ConstantFieldref.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: ConstantFieldref.java,v 1.3 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public final class ConstantFieldref extends ConstantCP { @@ -98,7 +98,7 @@ public final class ConstantFieldref extends ConstantCP { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitConstantFieldref(this); } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantFloat.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantFloat.java index 3e97c4dec..22f8ab910 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantFloat.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantFloat.java @@ -62,7 +62,7 @@ import java.io.*; * <A HREF="org.aspectj.apache.bcel.classfile.Constant.html">Constant</A> class * and represents a reference to a float object. * - * @version $Id: ConstantFloat.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: ConstantFloat.java,v 1.3 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Constant */ @@ -101,7 +101,7 @@ public final class ConstantFloat extends Constant implements ConstantObject { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitConstantFloat(this); } /** diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantInteger.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantInteger.java index ab6c44f72..3a35d4334 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantInteger.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantInteger.java @@ -64,7 +64,7 @@ import java.io.*; * <A HREF="org.aspectj.apache.bcel.classfile.Constant.html">Constant</A> class * and represents a reference to an int object. * - * @version $Id: ConstantInteger.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: ConstantInteger.java,v 1.3 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Constant */ @@ -105,7 +105,7 @@ public final class ConstantInteger extends Constant implements ConstantObject { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitConstantInteger(this); } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantInterfaceMethodref.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantInterfaceMethodref.java index c072a0e24..1598ce24f 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantInterfaceMethodref.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantInterfaceMethodref.java @@ -60,7 +60,7 @@ import java.io.*; /** * This class represents a constant pool reference to an interface method. * - * @version $Id: ConstantInterfaceMethodref.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: ConstantInterfaceMethodref.java,v 1.3 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public final class ConstantInterfaceMethodref extends ConstantCP { @@ -98,7 +98,7 @@ public final class ConstantInterfaceMethodref extends ConstantCP { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitConstantInterfaceMethodref(this); } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantLong.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantLong.java index 4080e700f..a850d248c 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantLong.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantLong.java @@ -62,7 +62,7 @@ import java.io.*; * <A HREF="org.aspectj.apache.bcel.classfile.Constant.html">Constant</A> class * and represents a reference to a long object. * - * @version $Id: ConstantLong.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: ConstantLong.java,v 1.3 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Constant */ @@ -100,7 +100,7 @@ public final class ConstantLong extends Constant implements ConstantObject { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitConstantLong(this); } /** diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantMethodref.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantMethodref.java index c7a1ec61d..bd22ee048 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantMethodref.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantMethodref.java @@ -60,7 +60,7 @@ import java.io.*; /** * This class represents a constant pool reference to a method. * - * @version $Id: ConstantMethodref.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: ConstantMethodref.java,v 1.3 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public final class ConstantMethodref extends ConstantCP { @@ -98,7 +98,7 @@ public final class ConstantMethodref extends ConstantCP { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitConstantMethodref(this); } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantNameAndType.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantNameAndType.java index f6fb51239..21a601534 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantNameAndType.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantNameAndType.java @@ -63,7 +63,7 @@ import java.io.*; * and represents a reference to the name and signature * of a field or method. * - * @version $Id: ConstantNameAndType.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: ConstantNameAndType.java,v 1.3 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Constant */ @@ -86,7 +86,7 @@ public final class ConstantNameAndType extends Constant { */ ConstantNameAndType(DataInputStream file) throws IOException { - this((int)file.readUnsignedShort(), (int)file.readUnsignedShort()); + this(file.readUnsignedShort(), file.readUnsignedShort()); } /** @@ -108,7 +108,7 @@ public final class ConstantNameAndType extends Constant { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitConstantNameAndType(this); } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantObject.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantObject.java index 6052ec152..1468b4ae8 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantObject.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantObject.java @@ -58,7 +58,7 @@ package org.aspectj.apache.bcel.classfile; * This interface denotes those constants that have a "natural" value, * such as ConstantLong, ConstantString, etc.. * - * @version $Id: ConstantObject.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: ConstantObject.java,v 1.3 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Constant */ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantPool.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantPool.java index 147b66fd6..7c31b213d 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantPool.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantPool.java @@ -1,372 +1,612 @@ package org.aspectj.apache.bcel.classfile; -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - import org.aspectj.apache.bcel.Constants; +import org.aspectj.apache.bcel.generic.*; + import java.io.*; /** * This class represents the constant pool, i.e., a table of constants, of * a parsed classfile. It may contain null references, due to the JVM * specification that skips an entry after an 8-byte constant (double, - * long) entry. Those interested in generating constant pools - * programatically should see <a href="../generic/ConstantPoolGen.html"> - * ConstantPoolGen</a>. - - * @version $Id: ConstantPool.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ - * @see Constant - * @see org.aspectj.apache.bcel.generic.ConstantPoolGen - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> + * long) entry. */ -public class ConstantPool implements Cloneable, Node, Serializable { - private int constant_pool_count; - private Constant[] constant_pool; - - /** - * @param constant_pool Array of constants - */ - public ConstantPool(Constant[] constant_pool) - { - setConstantPool(constant_pool); - } - - /** - * Read constants from given file stream. - * - * @param file Input stream - * @throws IOException - * @throws ClassFormatException - */ - ConstantPool(DataInputStream file) throws IOException, ClassFormatException - { - byte tag; - - constant_pool_count = file.readUnsignedShort(); - constant_pool = new Constant[constant_pool_count]; - - /* constant_pool[0] is unused by the compiler and may be used freely - * by the implementation. +public class ConstantPool implements Node { + private Constant[] pool; + private int poolSize; // number of entries in the pool (could be < pool.length as the array is resized in 'chunks') + + public int getSize() { return poolSize; } + + public ConstantPool() { + pool = new Constant[10]; + poolSize=0; + } + + public ConstantPool(Constant[] constants) { + pool = constants; + poolSize = (constants==null?0:constants.length); + } + + ConstantPool(DataInputStream file) throws IOException { + byte tag; + poolSize = file.readUnsignedShort(); + pool = new Constant[poolSize]; + // pool[0] is unused by the compiler and may be used freely by the implementation + for (int i=1; i<poolSize; i++) { + pool[i] = Constant.readConstant(file); + tag = pool[i].getTag(); + if ((tag == Constants.CONSTANT_Double) || (tag == Constants.CONSTANT_Long)) i++; + } + } + + public Constant getConstant(int index, byte tag) { + Constant c = getConstant(index); + //if (c == null) throw new ClassFormatException("Constant pool at index " + index + " is null."); + if(c.tag == tag) return c; + throw new ClassFormatException("Expected class '"+Constants.CONSTANT_NAMES[tag]+"' at index "+index+" and found "+c); + } + + public Constant getConstant(int index) { + if (index >= pool.length || index < 0) + throw new ClassFormatException("Invalid constant pool reference: " + + index + ". Constant pool size is: " + pool.length); + return pool[index]; + } + + /** + * @return deep copy of this constant pool + */ + public ConstantPool copy() { + ConstantPool c = null; + Constant[] newConstants = new Constant[poolSize]; // use the correct size + for (int i=1;i<poolSize;i++) { + if (pool[i]!=null) { + newConstants[i] = pool[i].copy(); + } + } + return new ConstantPool(newConstants); + } + + /** + * Get string from constant pool and bypass the indirection of + * `ConstantClass' and `ConstantString' objects. I.e. these classes have + * an index field that points to another entry of the constant pool of + * type `ConstantUtf8' which contains the real data. + * + * @param index Index in constant pool + * @param tag Tag of expected constant, either ConstantClass or ConstantString + * @return Contents of string reference + * @see ConstantClass + * @see ConstantString + * @throws ClassFormatException + */ + public String getConstantString(int index, byte tag) throws ClassFormatException { + Constant c = getConstant(index, tag); + int i; + /* This switch() is not that elegant, since the two classes have the + * same contents, they just differ in the name of the index + * field variable. + * But we want to stick to the JVM naming conventions closely though + * we could have solved these more elegantly by using the same + * variable name or by subclassing. + */ + // OPTIMIZE remove the difference - use the an interface and same index methods for string ref id + switch(tag) { + case Constants.CONSTANT_Class: i = ((ConstantClass)c).getNameIndex(); break; + case Constants.CONSTANT_String: i = ((ConstantString)c).getStringIndex(); break; + default: + throw new RuntimeException("getConstantString called with illegal tag " + tag); + } + // Finally get the string from the constant pool + c = getConstant(i, Constants.CONSTANT_Utf8); + return ((ConstantUtf8)c).getBytes(); + } + + /** + * Resolve constant to a string representation. */ - for(int i=1; i < constant_pool_count; i++) { - constant_pool[i] = Constant.readConstant(file); - - /* Quote from the JVM specification: - * "All eight byte constants take up two spots in the constant pool. - * If this is the n'th byte in the constant pool, then the next item - * will be numbered n+2" - * - * Thus we have to increment the index counter. - */ - tag = constant_pool[i].getTag(); - if((tag == Constants.CONSTANT_Double) || (tag == Constants.CONSTANT_Long)) - i++; - } + public String constantToString(Constant c) { + String str; + int i; + + switch (c.tag) { + case Constants.CONSTANT_Class: + i = ((ConstantClass)c).getNameIndex(); + c = getConstant(i, Constants.CONSTANT_Utf8); + str = Utility.compactClassName(((ConstantUtf8)c).getBytes(), false); + break; + + case Constants.CONSTANT_String: + i = ((ConstantString)c).getStringIndex(); + c = getConstant(i, Constants.CONSTANT_Utf8); + str = "\"" + escape(((ConstantUtf8)c).getBytes()) + "\""; + break; + + case Constants.CONSTANT_Utf8: str = ((ConstantUtf8)c).getBytes(); break; + case Constants.CONSTANT_Double: str = Double.toString(((ConstantDouble)c).getBytes()); break; + case Constants.CONSTANT_Float: str = Float.toString(((ConstantFloat)c).getBytes()); break; + case Constants.CONSTANT_Long: str = Long.toString(((ConstantLong)c).getBytes()); break; + case Constants.CONSTANT_Integer: str = Integer.toString(((ConstantInteger)c).getBytes()); break; + + case Constants.CONSTANT_NameAndType: + str = (constantToString(((ConstantNameAndType)c).getNameIndex(), + Constants.CONSTANT_Utf8) + " " + + constantToString(((ConstantNameAndType)c).getSignatureIndex(), + Constants.CONSTANT_Utf8)); + break; + + case Constants.CONSTANT_InterfaceMethodref: case Constants.CONSTANT_Methodref: + case Constants.CONSTANT_Fieldref: + str = (constantToString(((ConstantCP)c).getClassIndex(), + Constants.CONSTANT_Class) + "." + + constantToString(((ConstantCP)c).getNameAndTypeIndex(), + Constants.CONSTANT_NameAndType)); + break; + + default: // Never reached + throw new RuntimeException("Unknown constant type " + c.tag); + } + + return str; + } + + private static final String escape(String str) { + int len = str.length(); + StringBuffer buf = new StringBuffer(len + 5); + char[] ch = str.toCharArray(); + + for(int i=0; i < len; i++) { + switch(ch[i]) { + case '\n' : buf.append("\\n"); break; + case '\r' : buf.append("\\r"); break; + case '\t' : buf.append("\\t"); break; + case '\b' : buf.append("\\b"); break; + case '"' : buf.append("\\\""); break; + default: buf.append(ch[i]); + } + } + + return buf.toString(); } - - /** - * 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.visitConstantPool(this); - } - - /** - * Resolve constant to a string representation. - * - * @param constant Constant to be printed - * @return String representation - */ - public String constantToString(Constant c) - throws ClassFormatException - { - String str; - int i; - byte tag = c.getTag(); - - switch(tag) { - case Constants.CONSTANT_Class: - i = ((ConstantClass)c).getNameIndex(); - c = getConstant(i, Constants.CONSTANT_Utf8); - str = Utility.compactClassName(((ConstantUtf8)c).getBytes(), false); - break; - - case Constants.CONSTANT_String: - i = ((ConstantString)c).getStringIndex(); - c = getConstant(i, Constants.CONSTANT_Utf8); - str = "\"" + escape(((ConstantUtf8)c).getBytes()) + "\""; - break; - - case Constants.CONSTANT_Utf8: str = ((ConstantUtf8)c).getBytes(); break; - case Constants.CONSTANT_Double: str = "" + ((ConstantDouble)c).getBytes(); break; - case Constants.CONSTANT_Float: str = "" + ((ConstantFloat)c).getBytes(); break; - case Constants.CONSTANT_Long: str = "" + ((ConstantLong)c).getBytes(); break; - case Constants.CONSTANT_Integer: str = "" + ((ConstantInteger)c).getBytes(); break; - - case Constants.CONSTANT_NameAndType: - str = (constantToString(((ConstantNameAndType)c).getNameIndex(), - Constants.CONSTANT_Utf8) + " " + - constantToString(((ConstantNameAndType)c).getSignatureIndex(), - Constants.CONSTANT_Utf8)); - break; - - case Constants.CONSTANT_InterfaceMethodref: case Constants.CONSTANT_Methodref: - case Constants.CONSTANT_Fieldref: - str = (constantToString(((ConstantCP)c).getClassIndex(), - Constants.CONSTANT_Class) + "." + - constantToString(((ConstantCP)c).getNameAndTypeIndex(), - Constants.CONSTANT_NameAndType)); - break; - - default: // Never reached - throw new RuntimeException("Unknown constant type " + tag); + + public String constantToString(int index, byte tag) { + Constant c = getConstant(index, tag); + return constantToString(c); + } + + public void accept(ClassVisitor v) { + v.visitConstantPool(this); + } + + public Constant[] getConstantPool() { return pool; } // TEMPORARY, DONT LIKE PASSING THIS DATA OUT! + + public void dump(DataOutputStream file) throws IOException { + file.writeShort(poolSize); + for(int i=1; i < poolSize; i++) if (pool[i]!=null) pool[i].dump(file); } + + public ConstantUtf8 getConstantUtf8(int idx) { + try { + Constant c = pool[idx]; + if (c==null) + throw new ClassFormatException("Constant pool at index " + idx + " is null."); + if (c.tag!=Constants.CONSTANT_Utf8) + throw new ClassFormatException("Expected UTF8Constant "+ + " at index " + idx + " and got " + c); + return (ConstantUtf8)c; + } catch (ArrayIndexOutOfBoundsException aioobe) { + throw new ClassFormatException("Index "+idx+" into constant pool (size:"+poolSize+") is invalid"); + } + } - return str; - } + public String getConstantString_CONSTANTClass(int index) { + ConstantClass c = (ConstantClass)getConstant(index,Constants.CONSTANT_Class); + index = c.getNameIndex(); + return ((ConstantUtf8)getConstant(index,Constants.CONSTANT_Utf8)).getBytes(); + } + + public int getLength() { return poolSize; } - private static final String escape(String str) { - int len = str.length(); - StringBuffer buf = new StringBuffer(len + 5); - char[] ch = str.toCharArray(); - - for(int i=0; i < len; i++) { - switch(ch[i]) { - case '\n' : buf.append("\\n"); break; - case '\r' : buf.append("\\r"); break; - case '\t' : buf.append("\\t"); break; - case '\b' : buf.append("\\b"); break; - case '"' : buf.append("\\\""); break; - default: buf.append(ch[i]); + public String toString() { + StringBuffer buf = new StringBuffer(); + + for(int i=1; i < poolSize; i++) + buf.append(i + ")" + pool[i] + "\n"); + + return buf.toString(); + } + + public int lookupInteger(int n) { + for (int i=1; i < poolSize; i++) { + if (pool[i] instanceof ConstantInteger) { + ConstantInteger c = (ConstantInteger)pool[i]; + if (c.getBytes() == n) return i; + } } + return -1; + } + + + public int lookupUtf8(String string) { + for (int i=1;i<poolSize;i++) { + Constant c = pool[i]; + if (c!=null && c.tag==Constants.CONSTANT_Utf8) { + if (((ConstantUtf8)c).getBytes().equals(string)) return i; + } + } + return -1; + } + + public int lookupClass(String classname) { + for (int i=1;i<poolSize;i++) { + Constant c = pool[i]; + if (c!=null && c.tag==Constants.CONSTANT_Class) { + int cIndex = ((ConstantClass)c).getNameIndex(); + String cName = ((ConstantUtf8)pool[cIndex]).getBytes(); + if (cName.equals(classname)) return i; + } + } + return -1; + } + + public int addUtf8(String n) { + int ret = lookupUtf8(n); + if (ret != -1) return ret; + adjustSize(); + ret = poolSize; + pool[poolSize++] = new ConstantUtf8(n); + return ret; + } + + public int addInteger(int n) { + int ret = lookupInteger(n); + if (ret != -1) return ret; + adjustSize(); + ret = poolSize; + pool[poolSize++] = new ConstantInteger(n); + return ret; } - return buf.toString(); + public int addArrayClass(ArrayType type) { + return addClass(type.getSignature()); + } + + public int addClass(ObjectType type) { + return addClass(type.getClassName()); + } + + public int addClass(String classname) { + String toAdd = classname.replace('.','/'); + int ret = lookupClass(toAdd); + if(ret != -1) return ret; + adjustSize(); + ConstantClass c = new ConstantClass(addUtf8(toAdd)); + ret = poolSize; + pool[poolSize++] = c; + return ret; } + private void adjustSize() { + if(poolSize + 3 >= pool.length) { + Constant[] cs = pool; + pool = new Constant[cs.length+8]; + System.arraycopy(cs, 0, pool, 0, cs.length); + } + if (poolSize==0) poolSize = 1; // someone about to do something in here! + } + + public int addFieldref(String class_name, String field_name, String signature) { + int ret = lookupFieldref(class_name, field_name, signature); + int class_index, name_and_type_index; + + if (ret != -1) return ret; + + adjustSize(); + + class_index = addClass(class_name); + name_and_type_index = addNameAndType(field_name, signature); + ret = poolSize; + pool[poolSize++] = new ConstantFieldref(class_index, name_and_type_index); + + return ret; + } + + public int lookupFieldref(String searchClassname, String searchFieldname, String searchSignature) { + searchClassname = searchClassname.replace('.','/'); + for (int i=1;i<poolSize;i++) { + Constant c = pool[i]; + if (c!=null && c.tag==Constants.CONSTANT_Fieldref) { + ConstantFieldref cfr = (ConstantFieldref)c; + ConstantNameAndType cnat = (ConstantNameAndType)pool[cfr.getNameAndTypeIndex()]; + + // check the class + int cIndex = cfr.getClassIndex(); + ConstantClass cc = (ConstantClass)pool[cIndex]; + String cName = ((ConstantUtf8)pool[cc.getNameIndex()]).getBytes(); + if (!cName.equals(searchClassname)) continue; + + // check the name and type + String name = ((ConstantUtf8)pool[cnat.getNameIndex()]).getBytes(); + if (!name.equals(searchFieldname)) continue; // not this one + String typeSignature = ((ConstantUtf8)pool[cnat.getSignatureIndex()]).getBytes(); + if (!typeSignature.equals(searchSignature)) continue; + return i; + } + } + return -1; + } + + - /** - * Retrieve constant at `index' from constant pool and resolve it to - * a string representation. - * - * @param index of constant in constant pool - * @param tag expected type - * @return String representation - */ - public String constantToString(int index, byte tag) - throws ClassFormatException - { - Constant c = getConstant(index, tag); - return constantToString(c); + public int addNameAndType(String name, String signature) { + int ret = lookupNameAndType(name, signature); + if (ret != -1) return ret; + adjustSize(); + int name_index = addUtf8(name); + int signature_index = addUtf8(signature); + ret = poolSize; + pool[poolSize++] = new ConstantNameAndType(name_index, signature_index); + return ret; } - /** - * Dump constant pool to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public void dump(DataOutputStream file) throws IOException - { - file.writeShort(constant_pool_count); - - for(int i=1; i < constant_pool_count; i++) - if(constant_pool[i] != null) - constant_pool[i].dump(file); + public int lookupNameAndType(String searchName, String searchTypeSignature) { + for (int i=1;i<poolSize;i++) { + Constant c = pool[i]; + if (c!=null && c.tag==Constants.CONSTANT_NameAndType) { + ConstantNameAndType cnat = (ConstantNameAndType)c; + String name = ((ConstantUtf8)pool[cnat.getNameIndex()]).getBytes(); + if (!name.equals(searchName)) continue; // not this one + String typeSignature = ((ConstantUtf8)pool[cnat.getSignatureIndex()]).getBytes(); + if (!typeSignature.equals(searchTypeSignature)) continue; + return i; + } + } + return -1; } - - /** - * Get constant from constant pool. - * - * @param index Index in constant pool - * @return Constant value - * @see Constant - */ - public Constant getConstant(int index) { - if (index >= constant_pool.length || index < 0) - throw new ClassFormatException("Invalid constant pool reference: " + - index + ". Constant pool size is: " + - constant_pool.length); - return constant_pool[index]; + + public int addFloat(float f) { + int ret= lookupFloat(f); + if (ret != -1) return ret; + adjustSize(); + ret = poolSize; + pool[poolSize++] = new ConstantFloat(f); + return ret; + } + + + public int lookupFloat(float f) { + int bits = Float.floatToIntBits(f); + for (int i=1;i<poolSize;i++) { + Constant c = pool[i]; + if (c!=null && c.tag==Constants.CONSTANT_Float) { + ConstantFloat cf = (ConstantFloat)c; + if (Float.floatToIntBits(cf.getBytes())==bits) return i; + } + } + return -1; } + public int addDouble(double d) { + int ret= lookupDouble(d); + if (ret != -1) return ret; + adjustSize(); + ret = poolSize; + pool[poolSize] = new ConstantDouble(d); + poolSize+=2; + return ret; + } + + +public int lookupDouble(double d) { + long bits = Double.doubleToLongBits(d); + for (int i=1;i<poolSize;i++) { + Constant c = pool[i]; + if (c!=null && c.tag==Constants.CONSTANT_Double) { + ConstantDouble cf = (ConstantDouble)c; + if (Double.doubleToLongBits(cf.getBytes())==bits) return i; + } + } + return -1; +} - /** - * Get constant from constant pool and check whether it has the - * expected type. - * - * @param index Index in constant pool - * @param tag Tag of expected constant, i.e., its type - * @return Constant value - * @see Constant - * @throws ClassFormatException - */ - public Constant getConstant(int index, byte tag) - throws ClassFormatException - { - Constant c; - - c = getConstant(index); - - if(c == null) - throw new ClassFormatException("Constant pool at index " + index + " is null."); - - if(c.getTag() == tag) - return c; - else - throw new ClassFormatException("Expected class `" + Constants.CONSTANT_NAMES[tag] + - "' at index " + index + " and got " + c); - } +public int addLong(long l) { + int ret= lookupLong(l); + if (ret != -1) return ret; + adjustSize(); + ret = poolSize; + pool[poolSize] = new ConstantLong(l); + poolSize+=2; + return ret; + } + + +public int lookupString(String s) { + for (int i=1;i<poolSize;i++) { + Constant c = pool[i]; + if (c!=null && c.tag==Constants.CONSTANT_String) { + ConstantString cs = (ConstantString)c; + ConstantUtf8 cu8 = (ConstantUtf8)pool[cs.getStringIndex()]; + if (cu8.getBytes().equals(s)) return i; + } + } + return -1; +} - /** - * @return Array of constants. - * @see Constant - */ - public Constant[] getConstantPool() { return constant_pool; } - /** - * Get string from constant pool and bypass the indirection of - * `ConstantClass' and `ConstantString' objects. I.e. these classes have - * an index field that points to another entry of the constant pool of - * type `ConstantUtf8' which contains the real data. - * - * @param index Index in constant pool - * @param tag Tag of expected constant, either ConstantClass or ConstantString - * @return Contents of string reference - * @see ConstantClass - * @see ConstantString - * @throws ClassFormatException - */ - public String getConstantString(int index, byte tag) - throws ClassFormatException - { - Constant c; - int i; - - c = getConstant(index, tag); - - /* This switch() is not that elegant, since the two classes have the - * same contents, they just differ in the name of the index - * field variable. - * But we want to stick to the JVM naming conventions closely though - * we could have solved these more elegantly by using the same - * variable name or by subclassing. - */ - switch(tag) { - case Constants.CONSTANT_Class: i = ((ConstantClass)c).getNameIndex(); break; - case Constants.CONSTANT_String: i = ((ConstantString)c).getStringIndex(); break; - default: - throw new RuntimeException("getConstantString called with illegal tag " + tag); - } + public int addString(String str) { + int ret = lookupString(str); + if (ret!=-1) return ret; + int utf8 = addUtf8(str); + adjustSize(); + ConstantString s = new ConstantString(utf8); + ret = poolSize; + pool[poolSize++] = s; + return ret; + } + +public int lookupLong(long l) { + for (int i=1;i<poolSize;i++) { + Constant c = pool[i]; + if (c!=null && c.tag==Constants.CONSTANT_Long) { + ConstantLong cf = (ConstantLong)c; + if (cf.getBytes()==l) return i; + } + } + return -1; +} - // Finally get the string from the constant pool - c = getConstant(i, Constants.CONSTANT_Utf8); - return ((ConstantUtf8)c).getBytes(); - } - /** - * @return Length of constant pool. - */ - public int getLength() - { - return constant_pool_count; - } - - /** - * @param constant Constant to set - */ - public void setConstant(int index, Constant constant) { - constant_pool[index] = constant; - } - - /** - * @param constant_pool - */ - public void setConstantPool(Constant[] constant_pool) { - this.constant_pool = constant_pool; - constant_pool_count = (constant_pool == null)? 0 : constant_pool.length; - } - /** - * @return String representation. - */ - public String toString() { - StringBuffer buf = new StringBuffer(); - - for(int i=1; i < constant_pool_count; i++) - buf.append(i + ")" + constant_pool[i] + "\n"); - - return buf.toString(); - } + public int addConstant(Constant c, ConstantPool cp) { + Constant[] constants = cp.getConstantPool(); + switch(c.getTag()) { - /** - * @return deep copy of this constant pool - */ - public ConstantPool copy() { - ConstantPool c = null; + case Constants.CONSTANT_String: { + ConstantString s = (ConstantString)c; + ConstantUtf8 u8 = (ConstantUtf8)constants[s.getStringIndex()]; + + return addString(u8.getBytes()); + } - try { - c = (ConstantPool)clone(); - } catch(CloneNotSupportedException e) {} +case Constants.CONSTANT_Class: { + ConstantClass s = (ConstantClass)c; + ConstantUtf8 u8 = (ConstantUtf8)constants[s.getNameIndex()]; - c.constant_pool = new Constant[constant_pool_count]; + return addClass(u8.getBytes()); +} - for(int i=1; i < constant_pool_count; i++) { - if(constant_pool[i] != null) - c.constant_pool[i] = constant_pool[i].copy(); - } +case Constants.CONSTANT_NameAndType: { + ConstantNameAndType n = (ConstantNameAndType)c; + ConstantUtf8 u8 = (ConstantUtf8)constants[n.getNameIndex()]; + ConstantUtf8 u8_2 = (ConstantUtf8)constants[n.getSignatureIndex()]; + + return addNameAndType(u8.getBytes(), u8_2.getBytes()); +} + +case Constants.CONSTANT_Utf8: + return addUtf8(((ConstantUtf8)c).getBytes()); + +case Constants.CONSTANT_Double: + return addDouble(((ConstantDouble)c).getBytes()); + +case Constants.CONSTANT_Float: + return addFloat(((ConstantFloat)c).getBytes()); + +case Constants.CONSTANT_Long: + return addLong(((ConstantLong)c).getBytes()); - return c; +case Constants.CONSTANT_Integer: + return addInteger(((ConstantInteger)c).getBytes()); + +case Constants.CONSTANT_InterfaceMethodref: case Constants.CONSTANT_Methodref: +case Constants.CONSTANT_Fieldref: { + ConstantCP m = (ConstantCP)c; + ConstantClass clazz = (ConstantClass)constants[m.getClassIndex()]; + ConstantNameAndType n = (ConstantNameAndType)constants[m.getNameAndTypeIndex()]; + ConstantUtf8 u8 = (ConstantUtf8)constants[clazz.getNameIndex()]; + String class_name = u8.getBytes().replace('/', '.'); + + u8 = (ConstantUtf8)constants[n.getNameIndex()]; + String name = u8.getBytes(); + + u8 = (ConstantUtf8)constants[n.getSignatureIndex()]; + String signature = u8.getBytes(); + + switch(c.getTag()) { + case Constants.CONSTANT_InterfaceMethodref: +return addInterfaceMethodref(class_name, name, signature); + + case Constants.CONSTANT_Methodref: +return addMethodref(class_name, name, signature); + + case Constants.CONSTANT_Fieldref: +return addFieldref(class_name, name, signature); + + default: // Never reached +throw new RuntimeException("Unknown constant type " + c); } } + +default: // Never reached + throw new RuntimeException("Unknown constant type " + c); +} +} + + public int addMethodref(String class_name, String method_name, String signature) { + int ret, class_index, name_and_type_index; + if((ret = lookupMethodref(class_name, method_name, signature)) != -1) + return ret; // Already in CP + + adjustSize(); + + name_and_type_index = addNameAndType(method_name, signature); + class_index = addClass(class_name); + ret = poolSize; + pool[poolSize++] = new ConstantMethodref(class_index, name_and_type_index); + return ret; + } + + public int addInterfaceMethodref(String class_name, String method_name, String signature) { + int ret = lookupInterfaceMethodref(class_name, method_name, signature); + int class_index, name_and_type_index; + + if( ret != -1) return ret; + adjustSize(); + + class_index = addClass(class_name); + name_and_type_index = addNameAndType(method_name, signature); + ret = poolSize; + pool[poolSize++] = new ConstantInterfaceMethodref(class_index, name_and_type_index); + return ret; + } + + public int lookupInterfaceMethodref(String searchClassname, String searchMethodName, String searchSignature) { + searchClassname = searchClassname.replace('.','/'); + for (int i=1;i<poolSize;i++) { + Constant c = pool[i]; + if (c!=null && c.tag==Constants.CONSTANT_InterfaceMethodref) { + ConstantInterfaceMethodref cfr = (ConstantInterfaceMethodref)c; + + ConstantClass cc = (ConstantClass)pool[cfr.getClassIndex()]; + String cName = ((ConstantUtf8)pool[cc.getNameIndex()]).getBytes(); + if (!cName.equals(searchClassname)) continue; + + // check the name and type + ConstantNameAndType cnat = (ConstantNameAndType)pool[cfr.getNameAndTypeIndex()]; + String name = ((ConstantUtf8)pool[cnat.getNameIndex()]).getBytes(); + if (!name.equals(searchMethodName)) continue; // not this one + String typeSignature = ((ConstantUtf8)pool[cnat.getSignatureIndex()]).getBytes(); + if (!typeSignature.equals(searchSignature)) continue; + return i; + } + } + return -1; + } + + public int lookupMethodref(String searchClassname, String searchMethodName, String searchSignature) { + searchClassname = searchClassname.replace('.','/'); + for (int i=1;i<poolSize;i++) { + Constant c = pool[i]; + if (c!=null && c.tag==Constants.CONSTANT_Methodref) { + ConstantMethodref cfr = (ConstantMethodref)c; + ConstantNameAndType cnat = (ConstantNameAndType)pool[cfr.getNameAndTypeIndex()]; + + // check the class + int cIndex = cfr.getClassIndex(); + ConstantClass cc = (ConstantClass)pool[cIndex]; + String cName = ((ConstantUtf8)pool[cc.getNameIndex()]).getBytes(); + if (!cName.equals(searchClassname)) continue; + + // check the name and type + String name = ((ConstantUtf8)pool[cnat.getNameIndex()]).getBytes(); + if (!name.equals(searchMethodName)) continue; // not this one + String typeSignature = ((ConstantUtf8)pool[cnat.getSignatureIndex()]).getBytes(); + if (!typeSignature.equals(searchSignature)) continue; + return i; + } + } + return -1; + } + + public ConstantPool getFinalConstantPool() { + Constant[] cs = new Constant[poolSize]; // create it the exact size we need + System.arraycopy(pool, 0, cs, 0, poolSize); + return new ConstantPool(cs); + } +}
\ No newline at end of file diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantString.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantString.java index 8e8f51899..bd0807f00 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantString.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantString.java @@ -62,7 +62,7 @@ import java.io.*; * <A HREF="org.aspectj.apache.bcel.classfile.Constant.html">Constant</A> class * and represents a reference to a String object. * - * @version $Id: ConstantString.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: ConstantString.java,v 1.3 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Constant */ @@ -83,7 +83,7 @@ public final class ConstantString extends Constant implements ConstantObject { */ ConstantString(DataInputStream file) throws IOException { - this((int)file.readUnsignedShort()); + this(file.readUnsignedShort()); } /** * @param string_index Index of Constant_Utf8 in constant pool @@ -100,7 +100,7 @@ public final class ConstantString extends Constant implements ConstantObject { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitConstantString(this); } /** diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantUtf8.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantUtf8.java index fa7b1b2de..603199efc 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantUtf8.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantUtf8.java @@ -62,7 +62,7 @@ import java.io.*; * <A HREF="org.aspectj.apache.bcel.classfile.Constant.html">Constant</A> class * and represents a reference to a Utf8 encoded string. * - * @version $Id: ConstantUtf8.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: ConstantUtf8.java,v 1.3 2008/05/28 23:53:01 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Constant */ @@ -85,20 +85,15 @@ public final class ConstantUtf8 extends Constant { ConstantUtf8(DataInputStream file) throws IOException { super(Constants.CONSTANT_Utf8); - - bytes = file.readUTF(); + bytes=file.readUTF(); } - /** - * @param bytes Data - */ public ConstantUtf8(String bytes) { super(Constants.CONSTANT_Utf8); if(bytes == null) throw new IllegalArgumentException("bytes must not be null!"); - this.bytes = bytes; } @@ -109,7 +104,7 @@ public final class ConstantUtf8 extends Constant { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitConstantUtf8(this); } @@ -128,7 +123,9 @@ public final class ConstantUtf8 extends Constant { /** * @return Data converted to string. */ - public final String getBytes() { return bytes; } + public final String getBytes() { + return bytes; + } /** * @param bytes. diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantValue.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantValue.java index 386804824..c6a979318 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantValue.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantValue.java @@ -62,7 +62,7 @@ import java.io.*; * value, i.e., a default value for initializing a class field. * This class is instantiated by the <em>Attribute.readAttribute()</em> method. * - * @version $Id: ConstantValue.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: ConstantValue.java,v 1.3 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Attribute */ @@ -89,7 +89,7 @@ public final class ConstantValue extends Attribute { ConstantValue(int name_index, int length, DataInputStream file, ConstantPool constant_pool) throws IOException { - this(name_index, length, (int)file.readUnsignedShort(), constant_pool); + this(name_index, length, file.readUnsignedShort(), constant_pool); } /** @@ -113,7 +113,7 @@ public final class ConstantValue extends Attribute { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitConstantValue(this); } /** @@ -143,7 +143,7 @@ public final class ConstantValue extends Attribute { * @return String representation of constant value. */ public final String toString() { - Constant c = constant_pool.getConstant(constantvalue_index); + Constant c = constantPool.getConstant(constantvalue_index); String buf; int i; @@ -156,7 +156,7 @@ public final class ConstantValue extends Attribute { case Constants.CONSTANT_Integer: buf = "" + ((ConstantInteger)c).getBytes(); break; case Constants.CONSTANT_String: i = ((ConstantString)c).getStringIndex(); - c = constant_pool.getConstant(i, Constants.CONSTANT_Utf8); + c = constantPool.getConstant(i, Constants.CONSTANT_Utf8); buf = "\"" + Utility.convertString(((ConstantUtf8)c).getBytes()) + "\""; break; @@ -172,7 +172,7 @@ public final class ConstantValue extends Attribute { */ public Attribute copy(ConstantPool constant_pool) { ConstantValue c = (ConstantValue)clone(); - c.constant_pool = constant_pool; + c.constantPool = constant_pool; return c; } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Deprecated.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Deprecated.java index 2c7c9ab50..8df953096 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Deprecated.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Deprecated.java @@ -62,7 +62,7 @@ import java.io.*; * deprecated method. * It is instantiated from the <em>Attribute.readAttribute()</em> method. * - * @version $Id: Deprecated.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: Deprecated.java,v 1.3 2008/05/28 23:53:01 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Attribute */ @@ -117,7 +117,7 @@ public final class Deprecated extends Attribute { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitDeprecated(this); } @@ -163,7 +163,7 @@ public final class Deprecated extends Attribute { if(bytes != null) c.bytes = (byte[])bytes.clone(); - c.constant_pool = constant_pool; + c.constantPool = constant_pool; return c; } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/EnclosingMethod.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/EnclosingMethod.java index 4c92bca3b..6b01d23e5 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/EnclosingMethod.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/EnclosingMethod.java @@ -49,7 +49,7 @@ public class EnclosingMethod extends Attribute { methodIndex = methodIdx; } - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitEnclosingMethod(this); } @@ -68,14 +68,14 @@ public class EnclosingMethod extends Attribute { public final ConstantClass getEnclosingClass() { ConstantClass c = - (ConstantClass)constant_pool.getConstant(classIndex,Constants.CONSTANT_Class); + (ConstantClass)constantPool.getConstant(classIndex,Constants.CONSTANT_Class); return c; } public final ConstantNameAndType getEnclosingMethod() { if (methodIndex == 0) return null; ConstantNameAndType nat = - (ConstantNameAndType)constant_pool.getConstant(methodIndex,Constants.CONSTANT_NameAndType); + (ConstantNameAndType)constantPool.getConstant(methodIndex,Constants.CONSTANT_NameAndType); return nat; } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ExceptionTable.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ExceptionTable.java index 74577682a..3219cbae7 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ExceptionTable.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ExceptionTable.java @@ -65,7 +65,7 @@ import java.io.*; * attribute using the name <em>Exceptions</em> (which is inconsistent * with the other classes). * - * @version $Id: ExceptionTable.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: ExceptionTable.java,v 1.3 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Code */ @@ -123,7 +123,7 @@ public final class ExceptionTable extends Attribute { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitExceptionTable(this); } @@ -156,7 +156,7 @@ public final class ExceptionTable extends Attribute { public final String[] getExceptionNames() { String[] names = new String[number_of_exceptions]; for(int i=0; i < number_of_exceptions; i++) - names[i] = constant_pool.getConstantString(exception_index_table[i], + names[i] = constantPool.getConstantString(exception_index_table[i], Constants.CONSTANT_Class). replace('/', '.'); return names; @@ -179,7 +179,7 @@ public final class ExceptionTable extends Attribute { String str; for(int i=0; i < number_of_exceptions; i++) { - str = constant_pool.getConstantString(exception_index_table[i], + str = constantPool.getConstantString(exception_index_table[i], Constants.CONSTANT_Class); buf.append(Utility.compactClassName(str, false)); @@ -196,7 +196,7 @@ public final class ExceptionTable extends Attribute { public Attribute copy(ConstantPool constant_pool) { ExceptionTable c = (ExceptionTable)clone(); c.exception_index_table = (int[])exception_index_table.clone(); - c.constant_pool = constant_pool; + c.constantPool = constant_pool; return c; } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Field.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Field.java index 77b267fed..a2dfed81d 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Field.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Field.java @@ -53,18 +53,27 @@ package org.aspectj.apache.bcel.classfile; * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ -import org.aspectj.apache.bcel.Constants; +import java.io.DataInputStream; +import java.io.IOException; +import java.util.List; + import org.aspectj.apache.bcel.generic.Type; -import java.io.*; /** * This class represents the field info structure, i.e., the representation * for a variable in the class. See JVM specification for details. * - * @version $Id: Field.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: Field.java,v 1.3 2008/05/28 23:53:01 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public final class Field extends FieldOrMethod { + + public static final Field[] NoFields = new Field[0]; + + private Type fieldType = null; // lazily initialized + + private Field() {} + /** * Initialize from another object. Note that both objects use the same * references (shallow copy). Use clone() for a physical copy. @@ -73,37 +82,15 @@ public final class Field extends FieldOrMethod { super(c); } - /** - * Construct object from file stream. - * @param file Input stream - */ - Field(DataInputStream file, ConstantPool constant_pool) - throws IOException, ClassFormatException - { + Field(DataInputStream file, ConstantPool constant_pool) throws IOException { super(file, constant_pool); } - /** - * @param access_flags Access rights of field - * @param name_index Points to field name in constant pool - * @param signature_index Points to encoded signature - * @param attributes Collection of attributes - * @param constant_pool Array of constants - */ - public Field(int access_flags, int name_index, int signature_index, - Attribute[] attributes, ConstantPool constant_pool) - { - super(access_flags, name_index, signature_index, attributes, constant_pool); + public Field(int accessflags, int nameIndex, int signatureIndex,Attribute[] attributes, ConstantPool constant_pool) { + super(accessflags, nameIndex, signatureIndex, attributes, 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) { + public void accept(ClassVisitor v) { v.visitField(this); } @@ -111,55 +98,47 @@ public final class Field extends FieldOrMethod { * @return constant value associated with this field (may be null) */ public final ConstantValue getConstantValue() { - for(int i=0; i < attributes_count; i++) - if(attributes[i].getTag() == Constants.ATTR_CONSTANT_VALUE) - return (ConstantValue)attributes[i]; - - return null; + return AttributeUtils.getConstantValueAttribute(attributes); } /** - * Return string representation close to declaration format, - * `public static final short MAX = 100', e.g.. - * - * @return String representation of field, including the signature. + * Return string representation close to declaration format, eg: + * 'public static final short MAX = 100' */ public final String toString() { String name, signature, access; // Short cuts to constant pool // Get names from constant pool - access = Utility.accessToString(access_flags); + access = Utility.accessToString(modifiers); access = access.equals("")? "" : (access + " "); signature = Utility.signatureToString(getSignature()); name = getName(); - StringBuffer buf = new StringBuffer(access + signature + " " + name); + StringBuffer buf = new StringBuffer(access); + buf.append(signature).append(" ").append(name); ConstantValue cv = getConstantValue(); - if(cv != null) - buf.append(" = " + cv); + if (cv != null) buf.append(" = ").append(cv); - for(int i=0; i < attributes_count; i++) { + // append all attributes that are *not* "ConstantValue" + for(int i=0; i < attributes.length; i++) { Attribute a = attributes[i]; - - if(!(a instanceof ConstantValue)) - buf.append(" [" + a.toString() + "]"); + if(!(a instanceof ConstantValue)) buf.append(" [").append(a.toString()).append("]"); } return buf.toString(); } - /** - * @return deep copy of this field - */ + /** deep copy of this field */ public final Field copy(ConstantPool constant_pool) { return (Field)copy_(constant_pool); } - /** - * @return type of field - */ + /** return the type of the field */ public Type getType() { - return Type.getReturnType(getSignature()); + if (fieldType==null) { + fieldType = Type.getReturnType(getSignature()); + } + return fieldType; } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/FieldOrMethod.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/FieldOrMethod.java index 1222ef715..48b9fc2d5 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/FieldOrMethod.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/FieldOrMethod.java @@ -54,7 +54,7 @@ package org.aspectj.apache.bcel.classfile; * <http://www.apache.org/>. */ import org.aspectj.apache.bcel.Constants; -import org.aspectj.apache.bcel.classfile.annotation.Annotation; +import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; import org.aspectj.apache.bcel.classfile.annotation.RuntimeAnnotations; import java.io.*; @@ -64,94 +64,49 @@ import java.util.List; /** * Abstract super class for fields and methods. * - * @version $Id: FieldOrMethod.java,v 1.5 2005/06/26 20:27:23 acolyer Exp $ + * @version $Id: FieldOrMethod.java,v 1.6 2008/05/28 23:53:01 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ -public abstract class FieldOrMethod extends AccessFlags implements Cloneable, Node { - protected int name_index; // Points to field name in constant pool - protected int signature_index; // Points to encoded signature - protected int attributes_count;// No. of attributes - protected Attribute[] attributes; // Collection of attributes - private Annotation[] annotations; // annotations defined on the field or method - protected ConstantPool constant_pool; - - private String signatureAttributeString = null; +public abstract class FieldOrMethod extends Modifiers implements Cloneable, Node { + protected int nameIndex; + protected int signatureIndex; + protected Attribute[] attributes; + protected int attributes_count;// No. of attributes + + protected ConstantPool cpool; + private String name; // lazily initialized + private String signature; // lazily initialized + private AnnotationGen[] annotations; // lazily initialized + private String signatureAttributeString = null; private boolean searchedForSignatureAttribute = false; - - // Annotations are collected from certain attributes, don't do it more than necessary! - private boolean annotationsOutOfDate = true; - - FieldOrMethod() {} + + + protected FieldOrMethod() {} /** * Initialize from another object. Note that both objects use the same * references (shallow copy). Use clone() for a physical copy. */ protected FieldOrMethod(FieldOrMethod c) { - this(c.getAccessFlags(), c.getNameIndex(), c.getSignatureIndex(), - c.getAttributes(), c.getConstantPool()); + this(c.getModifiers(), c.getNameIndex(), c.getSignatureIndex(),c.getAttributes(), c.getConstantPool()); } - /** - * Construct object from file stream. - * @param file Input stream - * @throws IOException - * @throws ClassFormatException - */ - protected FieldOrMethod(DataInputStream file, ConstantPool constant_pool) - throws IOException, ClassFormatException - { - this(file.readUnsignedShort(), file.readUnsignedShort(), - file.readUnsignedShort(), null, constant_pool); - - attributes_count = file.readUnsignedShort(); - attributes = new Attribute[attributes_count]; - for(int i=0; i < attributes_count; i++) - attributes[i] = Attribute.readAttribute(file, constant_pool); - } - - /** - * @param access_flags Access rights of method - * @param name_index Points to field name in constant pool - * @param signature_index Points to encoded signature - * @param attributes Collection of attributes - * @param constant_pool Array of constants - */ - protected FieldOrMethod(int access_flags, int name_index, int signature_index, - Attribute[] attributes, ConstantPool constant_pool) - { - this.access_flags = access_flags; - this.name_index = name_index; - this.signature_index = signature_index; - this.constant_pool = constant_pool; - - setAttributes(attributes); + protected FieldOrMethod(DataInputStream file, ConstantPool cpool) throws IOException { + this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), null, cpool); + attributes = AttributeUtils.readAttributes(file,cpool); } - /** - * Dump object to file stream on binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - file.writeShort(access_flags); - file.writeShort(name_index); - file.writeShort(signature_index); - file.writeShort(attributes_count); - - for(int i=0; i < attributes_count; i++) - attributes[i].dump(file); + protected FieldOrMethod(int accessFlags, int nameIndex, int signatureIndex, Attribute[] attributes, ConstantPool cpool) { + this.modifiers = accessFlags; + this.nameIndex = nameIndex; + this.signatureIndex = signatureIndex; + this.cpool = cpool; + this.attributes = attributes; } - /** - * @return Collection of object attributes. - */ - public final Attribute[] getAttributes() { return attributes; } - - /** + + /** * @param attributes Collection of object attributes. */ public void setAttributes(Attribute[] attributes) { @@ -159,60 +114,34 @@ public abstract class FieldOrMethod extends AccessFlags implements Cloneable, No attributes_count = (attributes == null)? 0 : attributes.length; } - /** - * @return Constant pool used by this object. - */ - public final ConstantPool getConstantPool() { return constant_pool; } - - /** - * @param constant_pool Constant pool to be used for this object. - */ - public final void setConstantPool(ConstantPool constant_pool) { - this.constant_pool = constant_pool; - } - - /** - * @return Index in constant pool of object's name. - */ - public final int getNameIndex() { return name_index; } - - /** - * @param name_index Index in constant pool of object's name. - */ - public final void setNameIndex(int name_index) { - this.name_index = name_index; + + + public final void dump(DataOutputStream file) throws IOException { + file.writeShort(modifiers); + file.writeShort(nameIndex); + file.writeShort(signatureIndex); + AttributeUtils.writeAttributes(attributes,file); } - /** - * @return Index in constant pool of field signature. - */ - public final int getSignatureIndex() { return signature_index; } - - /** - * @param signature_index Index in constant pool of field signature. - */ - public final void setSignatureIndex(int signature_index) { - this.signature_index = signature_index; - } + public final Attribute[] getAttributes() { return attributes; } + public final ConstantPool getConstantPool() { return cpool; } + public final int getNameIndex() { return nameIndex; } + public final int getSignatureIndex() { return signatureIndex; } - /** - * @return Name of object, i.e., method name or field name - */ public final String getName() { - ConstantUtf8 c; - c = (ConstantUtf8)constant_pool.getConstant(name_index, - Constants.CONSTANT_Utf8); - return c.getBytes(); + if (name==null) { + ConstantUtf8 c = (ConstantUtf8)cpool.getConstant(nameIndex,Constants.CONSTANT_Utf8); + name = c.getBytes(); + } + return name; } - /** - * @return String representation of object's type signature (java style) - */ public final String getSignature() { - ConstantUtf8 c; - c = (ConstantUtf8)constant_pool.getConstant(signature_index, - Constants.CONSTANT_Utf8); - return c.getBytes(); + if (signature==null) { + ConstantUtf8 c = (ConstantUtf8)cpool.getConstant(signatureIndex,Constants.CONSTANT_Utf8); + signature = c.getBytes(); + } + return signature; } /** @@ -235,53 +164,34 @@ public abstract class FieldOrMethod extends AccessFlags implements Cloneable, No c = (FieldOrMethod)clone(); } catch(CloneNotSupportedException e) {} - c.constant_pool = constant_pool; - c.attributes = new Attribute[attributes_count]; - - for(int i=0; i < attributes_count; i++) - c.attributes[i] = attributes[i].copy(constant_pool); - + c.cpool = constant_pool; + c.attributes = AttributeUtils.copy(attributes,constant_pool); return c; } - - /** - * Ensure we have unpacked any attributes that contain annotations. - * We don't remove these annotation attributes from the attributes list, they - * remain there. - */ - private void ensureAnnotationsUpToDate() { - if (annotationsOutOfDate) { + public AnnotationGen[] getAnnotations() { + // Ensure we have unpacked any attributes that contain annotations. + // We don't remove these annotation attributes from the attributes list, they + // remain there. + if (annotations==null) { // Find attributes that contain annotation data - Attribute[] attrs = getAttributes(); List accumulatedAnnotations = new ArrayList(); - for (int i = 0; i < attrs.length; i++) { - Attribute attribute = attrs[i]; + for (int i = 0; i < attributes.length; i++) { + Attribute attribute = attributes[i]; if (attribute instanceof RuntimeAnnotations) { RuntimeAnnotations runtimeAnnotations = (RuntimeAnnotations)attribute; accumulatedAnnotations.addAll(runtimeAnnotations.getAnnotations()); } } - annotations = (Annotation[])accumulatedAnnotations.toArray(new Annotation[]{}); - annotationsOutOfDate = false; + if (accumulatedAnnotations.size()==0) { + annotations = AnnotationGen.NO_ANNOTATIONS; + } else { + annotations = (AnnotationGen[])accumulatedAnnotations.toArray(new AnnotationGen[]{}); + } } - } - - public Annotation[] getAnnotations() { - ensureAnnotationsUpToDate(); return annotations; } - public void addAnnotation(Annotation a) { - ensureAnnotationsUpToDate(); - int len = annotations.length; - Annotation[] newAnnotations = new Annotation[len+1]; - System.arraycopy(annotations, 0, newAnnotations, 0, len); - newAnnotations[len] = a; - annotations = newAnnotations; - } - - /** * Hunts for a signature attribute on the member and returns its contents. So where the 'regular' signature * may be (Ljava/util/Vector;)V the signature attribute may in fact say 'Ljava/lang/Vector<Ljava/lang/String>;' @@ -289,13 +199,8 @@ public abstract class FieldOrMethod extends AccessFlags implements Cloneable, No */ public final String getGenericSignature() { if (!searchedForSignatureAttribute) { - boolean found=false; - for(int i=0; !found && i < attributes_count; i++) { - if(attributes[i] instanceof Signature) { - signatureAttributeString = ((Signature)attributes[i]).getSignature(); - found=true; - } - } + Signature sig = AttributeUtils.getSignatureAttribute(attributes); + signatureAttributeString = (sig==null?null:sig.getSignature()); searchedForSignatureAttribute=true; } return signatureAttributeString; diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/InnerClass.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/InnerClass.java index cb57f71af..8ccbeb93a 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/InnerClass.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/InnerClass.java @@ -62,7 +62,7 @@ import java.io.*; * indices of the inner and outer classes, the name and the attributes * of the inner class. * - * @version $Id: InnerClass.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: InnerClass.java,v 1.3 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see InnerClasses */ @@ -113,7 +113,7 @@ public final class InnerClass implements Cloneable, Node { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitInnerClass(this); } /** diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/InnerClasses.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/InnerClasses.java index d51a9405c..7bc5b6e1c 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/InnerClasses.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/InnerClasses.java @@ -63,7 +63,7 @@ import java.io.*; * to the source file of this class. * It is instantiated from the <em>Attribute.readAttribute()</em> method. * - * @version $Id: InnerClasses.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: InnerClasses.java,v 1.3 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Attribute */ @@ -122,7 +122,7 @@ public final class InnerClasses extends Attribute { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitInnerClasses(this); } /** @@ -160,7 +160,7 @@ public final class InnerClasses extends Attribute { StringBuffer buf = new StringBuffer(); for(int i=0; i < number_of_classes; i++) - buf.append(inner_classes[i].toString(constant_pool) + "\n"); + buf.append(inner_classes[i].toString(constantPool) + "\n"); return buf.toString(); } @@ -175,7 +175,7 @@ public final class InnerClasses extends Attribute { for(int i=0; i < number_of_classes; i++) c.inner_classes[i] = inner_classes[i].copy(); - c.constant_pool = constant_pool; + c.constantPool = constant_pool; return c; } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/JavaClass.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/JavaClass.java index e019947f5..8083441f6 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/JavaClass.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/JavaClass.java @@ -58,7 +58,7 @@ import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.util.SyntheticRepository; import org.aspectj.apache.bcel.util.ClassVector; import org.aspectj.apache.bcel.util.ClassQueue; -import org.aspectj.apache.bcel.classfile.annotation.Annotation; +import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; import org.aspectj.apache.bcel.classfile.annotation.RuntimeAnnotations; import org.aspectj.apache.bcel.generic.Type; @@ -77,14 +77,14 @@ import java.util.StringTokenizer; * class file. Those interested in programatically generating classes * should see the <a href="../generic/ClassGen.html">ClassGen</a> class. - * @version $Id: JavaClass.java,v 1.9 2005/12/02 06:56:14 acolyer Exp $ + * @version $Id: JavaClass.java,v 1.10 2008/05/28 23:53:02 aclement Exp $ * @see org.aspectj.apache.bcel.generic.ClassGen * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ -public class JavaClass extends AccessFlags implements Cloneable, Node { +public class JavaClass extends Modifiers implements Cloneable, Node { private String file_name; private String package_name; - private String source_file_name = "<Unknown>"; + private String source_file_name; private int class_name_index; private int superclass_name_index; private String class_name; @@ -96,8 +96,7 @@ public class JavaClass extends AccessFlags implements Cloneable, Node { private Field[] fields; // Fields, i.e., variables of class private Method[] methods; // methods defined in the class private Attribute[] attributes; // attributes defined in the class - private Annotation[] annotations; // annotations defined on the class - private byte source = HEAP; // Generated in memory + private AnnotationGen[] annotations; // annotations defined on the class private boolean isGeneric = false; private boolean isAnonymous = false; private boolean isNested = false; @@ -154,39 +153,32 @@ public class JavaClass extends AccessFlags implements Cloneable, Node { int[] interfaces, Field[] fields, Method[] methods, - Attribute[] attributes, - byte source) + Attribute[] attributes) { if(interfaces == null) // Allowed for backward compatibility interfaces = new int[0]; - if(attributes == null) - this.attributes = new Attribute[0]; + if (attributes == null) this.attributes = Attribute.NoAttributes; if(fields == null) - fields = new Field[0]; + fields = new Field[0]; // TODO create a constant for no fields if(methods == null) - methods = new Method[0]; + methods = new Method[0]; // TODO create a constant for no methods this.class_name_index = class_name_index; this.superclass_name_index = superclass_name_index; this.file_name = file_name; this.major = major; this.minor = minor; - this.access_flags = access_flags; + this.modifiers = access_flags; this.constant_pool = constant_pool; this.interfaces = interfaces; this.fields = fields; this.methods = methods; this.attributes = attributes; annotationsOutOfDate = true; - this.source = source; // Get source file name if available - for(int i=0; i < attributes.length; i++) { - if(attributes[i] instanceof SourceFile) { - source_file_name = ((SourceFile)attributes[i]).getSourceFileName(); - break; - } - } + SourceFile sfAttribute = AttributeUtils.getSourceFileAttribute(attributes); + source_file_name = (sfAttribute==null?"<Unknown>":sfAttribute.getSourceFileName()); /* According to the specification the following entries must be of type * `ConstantClass' but we check that anyway via the @@ -217,36 +209,6 @@ public class JavaClass extends AccessFlags implements Cloneable, Node { } } - /** - * Constructor gets all contents as arguments. - * - * @param class_name_index Class name - * @param superclass_name_index Superclass name - * @param file_name File name - * @param major Major compiler version - * @param minor Minor compiler version - * @param access_flags Access rights defined by bit flags - * @param constant_pool Array of constants - * @param interfaces Implemented interfaces - * @param fields Class fields - * @param methods Class methods - * @param attributes Class attributes - */ - public JavaClass(int class_name_index, - int superclass_name_index, - String file_name, - int major, - int minor, - int access_flags, - ConstantPool constant_pool, - int[] interfaces, - Field[] fields, - Method[] methods, - Attribute[] attributes) { - this(class_name_index, superclass_name_index, file_name, major, minor, access_flags, - constant_pool, interfaces, fields, methods, attributes, HEAP); - } - /** * Called by objects that are traversing the nodes of the tree implicitely @@ -255,7 +217,7 @@ public class JavaClass extends AccessFlags implements Cloneable, Node { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitJavaClass(this); } @@ -339,7 +301,7 @@ public class JavaClass extends AccessFlags implements Cloneable, Node { constant_pool.dump(file); - file.writeShort(access_flags); + file.writeShort(modifiers); file.writeShort(class_name_index); file.writeShort(superclass_name_index); @@ -355,13 +317,7 @@ public class JavaClass extends AccessFlags implements Cloneable, Node { for(int i=0; i < methods.length; i++) methods[i].dump(file); - if(attributes != null) { - file.writeShort(attributes.length); - for(int i=0; i < attributes.length; i++) - attributes[i].dump(file); - } - else - file.writeShort(0); + AttributeUtils.writeAttributes(attributes,file); file.close(); } @@ -371,19 +327,18 @@ public class JavaClass extends AccessFlags implements Cloneable, Node { */ public Attribute[] getAttributes() { return attributes; } - public Annotation[] getAnnotations() { + public AnnotationGen[] getAnnotations() { if (annotationsOutOfDate) { // Find attributes that contain annotation data - Attribute[] attrs = getAttributes(); List accumulatedAnnotations = new ArrayList(); - for (int i = 0; i < attrs.length; i++) { - Attribute attribute = attrs[i]; + for (int i = 0; i < attributes.length; i++) { + Attribute attribute = attributes[i]; if (attribute instanceof RuntimeAnnotations) { RuntimeAnnotations runtimeAnnotations = (RuntimeAnnotations)attribute; accumulatedAnnotations.addAll(runtimeAnnotations.getAnnotations()); } } - annotations = (Annotation[])accumulatedAnnotations.toArray(new Annotation[]{}); + annotations = (AnnotationGen[])accumulatedAnnotations.toArray(new AnnotationGen[]{}); annotationsOutOfDate = false; } return annotations; @@ -618,11 +573,11 @@ public class JavaClass extends AccessFlags implements Cloneable, Node { * @return String representing class contents. */ public String toString() { - String access = Utility.accessToString(access_flags, true); + String access = Utility.accessToString(modifiers, true); access = access.equals("")? "" : (access + " "); StringBuffer buf = new StringBuffer(access + - Utility.classOrInterface(access_flags) + + Utility.classOrInterface(modifiers) + " " + class_name + " extends " + Utility.compactClassName(superclass_name, @@ -644,14 +599,13 @@ public class JavaClass extends AccessFlags implements Cloneable, Node { buf.append("filename\t\t" + file_name + '\n'); buf.append("compiled from\t\t" + source_file_name + '\n'); buf.append("compiler version\t" + major + "." + minor + '\n'); - buf.append("access flags\t\t" + access_flags + '\n'); + buf.append("access flags\t\t" + modifiers + '\n'); buf.append("constant pool\t\t" + constant_pool.getLength() + " entries\n"); buf.append("ACC_SUPER flag\t\t" + isSuper() + "\n"); if(attributes.length > 0) { buf.append("\nAttribute(s):\n"); - for(int i=0; i < attributes.length; i++) - buf.append(indent(attributes[i])); + for(int i=0; i < attributes.length; i++) buf.append(indent(attributes[i])); } if (annotations!=null && annotations.length>0) { @@ -707,9 +661,7 @@ public class JavaClass extends AccessFlags implements Cloneable, Node { for(int i=0; i < methods.length; i++) c.methods[i] = methods[i].copy(c.constant_pool); - c.attributes = new Attribute[attributes.length]; - for(int i=0; i < attributes.length; i++) - c.attributes[i] = attributes[i].copy(c.constant_pool); + c.attributes = AttributeUtils.copy(attributes,c.constant_pool); //J5SUPPORT: As the annotations exist as attributes against the class, copying // the attributes will copy the annotations across, so we don't have to @@ -719,11 +671,11 @@ public class JavaClass extends AccessFlags implements Cloneable, Node { } public final boolean isSuper() { - return (access_flags & Constants.ACC_SUPER) != 0; + return (modifiers & Constants.ACC_SUPER) != 0; } public final boolean isClass() { - return (access_flags & Constants.ACC_INTERFACE) == 0; + return (modifiers & Constants.ACC_INTERFACE) == 0; } public final boolean isAnonymous() { @@ -738,9 +690,10 @@ public class JavaClass extends AccessFlags implements Cloneable, Node { private final void computeNestedTypeStatus() { if (computedNestedTypeStatus) return; - for (int i = 0; i < this.attributes.length; i++) { - if (this.attributes[i] instanceof InnerClasses) { - InnerClass[] innerClasses = ((InnerClasses) this.attributes[i]).getInnerClasses(); + //Attribute[] attrs = attributes.getAttributes(); + for (int i = 0; i <attributes.length; i++) { + if (attributes[i] instanceof InnerClasses) { + InnerClass[] innerClasses = ((InnerClasses) attributes[i]).getInnerClasses(); for (int j = 0; j < innerClasses.length; j++) { boolean innerClassAttributeRefersToMe = false; String inner_class_name = constant_pool.getConstantString(innerClasses[j].getInnerClassIndex(), @@ -767,20 +720,14 @@ public class JavaClass extends AccessFlags implements Cloneable, Node { * 'public @interface blahblah' declaration */ public final boolean isAnnotation() { - return (access_flags & Constants.ACC_ANNOTATION) != 0; + return (modifiers & Constants.ACC_ANNOTATION) != 0; } /** * Returns true if this class represents an enum type */ public final boolean isEnum() { - return (access_flags & Constants.ACC_ENUM) != 0; - } - - /** @return returns either HEAP (generated), FILE, or ZIP - */ - public final byte getSource() { - return source; + return (modifiers & Constants.ACC_ENUM) != 0; } /********************* New repository functionality *********************/ @@ -904,6 +851,7 @@ public class JavaClass extends AccessFlags implements Cloneable, Node { /** * Get all interfaces implemented by this JavaClass (transitively). */ + // OPTIMIZE get rid of ClassQueue and ClassVector public JavaClass[] getAllInterfaces() { ClassQueue queue = new ClassQueue(); ClassVector vec = new ClassVector(); @@ -917,11 +865,11 @@ public class JavaClass extends AccessFlags implements Cloneable, Node { JavaClass[] interfaces = clazz.getInterfaces(); if(clazz.isInterface()) { - vec.addElement(clazz); - } else { - if(souper != null) { - queue.enqueue(souper); - } + vec.addElement(clazz); + } else { + if(souper != null) { + queue.enqueue(souper); + } } for(int i = 0; i < interfaces.length; i++) { @@ -951,15 +899,9 @@ public class JavaClass extends AccessFlags implements Cloneable, Node { private void loadGenericSignatureInfoIfNecessary() { if (!searchedForSignatureAttribute) { - boolean found=false; - for(int i=0; !found && i < attributes.length; i++) { - if(attributes[i] instanceof Signature) { - signatureAttribute = ((Signature)attributes[i]); - signatureAttributeString = signatureAttribute.getSignature(); - found=true; - } - } - isGeneric = found && signatureAttributeString.charAt(0)=='<'; + signatureAttribute = AttributeUtils.getSignatureAttribute(attributes); + signatureAttributeString = signatureAttribute==null?null:signatureAttribute.getSignature(); + isGeneric = signatureAttribute!=null && signatureAttributeString.charAt(0)=='<'; searchedForSignatureAttribute=true; } } @@ -971,9 +913,8 @@ public class JavaClass extends AccessFlags implements Cloneable, Node { loadGenericSignatureInfoIfNecessary(); if (signatureAttribute != null) { return signatureAttribute.asClassSignature(); - } else { - return null; } + return null; } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/LineNumber.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/LineNumber.java index 54c9fe330..81b3b4f49 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/LineNumber.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/LineNumber.java @@ -64,7 +64,7 @@ import java.io.Serializable; * the source that corresponds to a relative address in the byte code. This * is used for debugging purposes. * - * @version $Id: LineNumber.java,v 1.4 2007/02/28 13:10:32 aclement Exp $ + * @version $Id: LineNumber.java,v 1.5 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see LineNumberTable */ @@ -106,7 +106,7 @@ public final class LineNumber implements Cloneable, Node, Serializable { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitLineNumber(this); } @@ -150,7 +150,7 @@ public final class LineNumber implements Cloneable, Node, Serializable { * @return String representation */ public final String toString() { - return "LineNumber(pc=" + start_pc + ", line=" + line_number + ")"; + return "LineNumber(" + start_pc + ", " + line_number + ")"; } /** diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/LineNumberTable.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/LineNumberTable.java index ec6c3b197..1dc5183af 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/LineNumberTable.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/LineNumberTable.java @@ -62,7 +62,7 @@ import java.io.*; * purposes. This attribute is used by the <em>Code</em> attribute. It * contains pairs of PCs and line numbers. * - * @version $Id: LineNumberTable.java,v 1.3 2006/02/07 15:15:42 aclement Exp $ + * @version $Id: LineNumberTable.java,v 1.4 2008/05/28 23:53:01 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Code * @@ -144,7 +144,7 @@ public final class LineNumberTable extends Attribute { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { unpack(); v.visitLineNumberTable(this); } @@ -268,7 +268,7 @@ public final class LineNumberTable extends Attribute { for(int i=0; i < line_number_table_length; i++) c.line_number_table[i] = line_number_table[i].copy(); - c.constant_pool = constant_pool; + c.constantPool = constant_pool; return c; } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariable.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariable.java index 2c155149f..c97ec1485 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariable.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariable.java @@ -61,7 +61,7 @@ import java.io.*; * This class represents a local variable within a method. It contains its * scope, name, signature and index on the method's frame. * - * @version $Id: LocalVariable.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: LocalVariable.java,v 1.3 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see LocalVariableTable */ @@ -127,7 +127,7 @@ public final class LocalVariable * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitLocalVariable(this); } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTable.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTable.java index 476d4c66e..a85653e76 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTable.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTable.java @@ -61,7 +61,7 @@ import java.io.*; * This class represents collection of local variables in a * method. This attribute is contained in the <em>Code</em> attribute. * - * @version $Id: LocalVariableTable.java,v 1.3 2006/02/15 09:15:34 aclement Exp $ + * @version $Id: LocalVariableTable.java,v 1.4 2008/05/28 23:53:01 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Code * @see LocalVariable @@ -128,7 +128,7 @@ public class LocalVariableTable extends Attribute { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { unpack(); v.visitLocalVariableTable(this); } @@ -204,7 +204,7 @@ public class LocalVariableTable extends Attribute { for(int i=0; i < localVariableTableLength; i++) c.localVariableTable[i] = localVariableTable[i].copy(); - c.constant_pool = constant_pool; + c.constantPool = constant_pool; return c; } @@ -223,7 +223,7 @@ public class LocalVariableTable extends Attribute { localVariableTableLength = (dis.readUnsignedShort()); localVariableTable = new LocalVariable[localVariableTableLength]; for (int i=0; i < localVariableTableLength; i++) - localVariableTable[i] = new LocalVariable(dis,constant_pool); + localVariableTable[i] = new LocalVariable(dis,constantPool); dis.close(); data = null; // throw it away now } catch (IOException e) { diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTypeTable.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTypeTable.java index e54dda09b..81af0cc3a 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTypeTable.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTypeTable.java @@ -71,7 +71,7 @@ public class LocalVariableTypeTable extends Attribute { local_variable_type_table[i] = new LocalVariable(dis, cpool); } - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitLocalVariableTypeTable(this); } @@ -127,7 +127,7 @@ public class LocalVariableTypeTable extends Attribute { for(int i=0; i < local_variable_type_table_length; i++) c.local_variable_type_table[i] = local_variable_type_table[i].copy(); - c.constant_pool = constant_pool; + c.constantPool = constant_pool; return c; } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Method.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Method.java index 63db26e68..3f552e536 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Method.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Method.java @@ -55,38 +55,35 @@ package org.aspectj.apache.bcel.classfile; */ import java.io.DataInputStream; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; import org.aspectj.apache.bcel.Constants; -import org.aspectj.apache.bcel.classfile.annotation.Annotation; +import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisibleParameterAnnotations; import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleParameterAnnotations; import org.aspectj.apache.bcel.generic.Type; +import java.io.*; +import java.util.*; /** * This class represents the method info structure, i.e., the representation * for a method in the class. See JVM specification for details. * A method has access flags, a name, a signature and a number of attributes. * - * @version $Id: Method.java,v 1.4 2008/01/25 18:33:24 aclement Exp $ + * @version $Id: Method.java,v 1.5 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public final class Method extends FieldOrMethod { - - public static final Annotation[][] NO_PARAMETER_ANNOTATIONS = new Annotation[][]{}; - public static final Annotation[] NO_ANNOTATIONS = new Annotation[]{}; - private boolean parameterAnnotationsOutOfDate; - private Annotation[][] unpackedParameterAnnotations; + public static final AnnotationGen[][] NO_PARAMETER_ANNOTATIONS = new AnnotationGen[][]{}; + public static final AnnotationGen[] NO_ANNOTATIONS = new AnnotationGen[]{}; + + public static final Method[] NoMethods = new Method[0]; + private boolean parameterAnnotationsOutOfDate = true; + private AnnotationGen[][] unpackedParameterAnnotations; - /** - * Empty constructor, all attributes have to be defined via `setXXX' - * methods. Use at your own risk. - */ - public Method() { - parameterAnnotationsOutOfDate = true; + private Method() { + parameterAnnotationsOutOfDate = true; } /** @@ -98,44 +95,20 @@ public final class Method extends FieldOrMethod { parameterAnnotationsOutOfDate = true; } - /** - * Construct object from file stream. - * @param file Input stream - * @throws IOException - * @throws ClassFormatException - */ - Method(DataInputStream file, ConstantPool constant_pool) - throws IOException, ClassFormatException - { + Method(DataInputStream file, ConstantPool constant_pool) throws IOException { super(file, constant_pool); - parameterAnnotationsOutOfDate = true; } - /** - * @param access_flags Access rights of method - * @param name_index Points to field name in constant pool - * @param signature_index Points to encoded signature - * @param attributes Collection of attributes - * @param constant_pool Array of constants - */ - public Method(int access_flags, int name_index, int signature_index, - Attribute[] attributes, ConstantPool constant_pool) - { + public Method(int access_flags, int name_index, int signature_index, Attribute[] attributes, ConstantPool constant_pool) { super(access_flags, name_index, signature_index, attributes, constant_pool); parameterAnnotationsOutOfDate = true; } - /** - * 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) { + public void accept(ClassVisitor v) { v.visitMethod(this); } + // CUSTARD mutable or not? public void setAttributes(Attribute[] attributes) { parameterAnnotationsOutOfDate = true; super.setAttributes(attributes); @@ -145,79 +118,59 @@ public final class Method extends FieldOrMethod { * @return Code attribute of method, if any */ public final Code getCode() { - for(int i=0; i < attributes_count; i++) - if(attributes[i] instanceof Code) - return (Code)attributes[i]; - - return null; + return AttributeUtils.getCodeAttribute(attributes); } - /** - * @return ExceptionTable attribute of method, if any, i.e., list all - * exceptions the method may throw not exception handlers! - */ public final ExceptionTable getExceptionTable() { - for(int i=0; i < attributes_count; i++) - if(attributes[i] instanceof ExceptionTable) - return (ExceptionTable)attributes[i]; - - return null; + return AttributeUtils.getExceptionTableAttribute(attributes); } - /** @return LocalVariableTable of code attribute if any, i.e. the call is forwarded - * to the Code atribute. + /** + * Return LocalVariableTable of code attribute if any (the call is forwarded + * to the Code attribute) */ public final LocalVariableTable getLocalVariableTable() { Code code = getCode(); - - if(code != null) - return code.getLocalVariableTable(); - else - return null; + if (code != null) return code.getLocalVariableTable(); + return null; } - /** @return LineNumberTable of code attribute if any, i.e. the call is forwarded - * to the Code atribute. + /** + * Return LineNumberTable of code attribute if any (the call is forwarded + * to the Code attribute) */ public final LineNumberTable getLineNumberTable() { Code code = getCode(); - - if(code != null) - return code.getLineNumberTable(); - else - return null; + if (code != null) return code.getLineNumberTable(); + return null; } /** - * Return string representation close to declaration format, - * `public static void main(String[] args) throws IOException', e.g. - * - * @return String representation of the method. + * Return string representation close to declaration format, eg: + * 'public static void main(String[] args) throws IOException' */ public final String toString() { ConstantUtf8 c; String name, signature, access; // Short cuts to constant pool StringBuffer buf; - access = Utility.accessToString(access_flags); + access = Utility.accessToString(modifiers); // Get name and signature from constant pool - c = (ConstantUtf8)constant_pool.getConstant(signature_index, + c = (ConstantUtf8)cpool.getConstant(signatureIndex, Constants.CONSTANT_Utf8); signature = c.getBytes(); - c = (ConstantUtf8)constant_pool.getConstant(name_index, Constants.CONSTANT_Utf8); + c = (ConstantUtf8)cpool.getConstant(nameIndex, Constants.CONSTANT_Utf8); name = c.getBytes(); signature = Utility.methodSignatureToString(signature, name, access, true, getLocalVariableTable()); buf = new StringBuffer(signature); - for(int i=0; i < attributes_count; i++) { + for(int i=0; i < attributes.length; i++) { Attribute a = attributes[i]; - - if(!((a instanceof Code) || (a instanceof ExceptionTable))) - buf.append(" [" + a.toString() + "]"); + if(!((a instanceof Code) || (a instanceof ExceptionTable))) buf.append(" [" + a.toString() + "]"); } ExceptionTable e = getExceptionTable(); @@ -231,7 +184,7 @@ public final class Method extends FieldOrMethod { } /** - * @return deep copy of this method + * Return a deep copy of this method */ public final Method copy(ConstantPool constant_pool) { return (Method)copy_(constant_pool); @@ -250,7 +203,7 @@ public final class Method extends FieldOrMethod { public Type[] getArgumentTypes() { return Type.getArgumentTypes(getSignature()); } - + private void ensureParameterAnnotationsUnpacked() { if (!parameterAnnotationsOutOfDate) return; parameterAnnotationsOutOfDate = false; @@ -264,62 +217,64 @@ public final class Method extends FieldOrMethod { RuntimeVisibleParameterAnnotations parameterAnnotationsVis = null; RuntimeInvisibleParameterAnnotations parameterAnnotationsInvis = null; - // Find attributes that contain annotation data + // Find attributes that contain annotation data Attribute[] attrs = getAttributes(); List accumulatedAnnotations = new ArrayList(); - + for (int i = 0; i < attrs.length; i++) { Attribute attribute = attrs[i]; - if (attribute instanceof RuntimeVisibleParameterAnnotations) { - parameterAnnotationsVis = (RuntimeVisibleParameterAnnotations)attribute; + if (attribute instanceof RuntimeVisibleParameterAnnotations) { + parameterAnnotationsVis = (RuntimeVisibleParameterAnnotations)attribute; } else if (attribute instanceof RuntimeInvisibleParameterAnnotations) { - parameterAnnotationsInvis = (RuntimeInvisibleParameterAnnotations)attribute; + parameterAnnotationsInvis = (RuntimeInvisibleParameterAnnotations)attribute; + } } - } - // Build a list of annotation arrays, one per argument - List annotationsForEachParameter = new ArrayList(); - Annotation[] visibleOnes = null; - Annotation[] invisibleOnes = null; boolean foundSome = false; - for (int i=0; i<parameterCount; i++) { - int count = 0; - visibleOnes = new Annotation[0]; - invisibleOnes = new Annotation[0]; - if (parameterAnnotationsVis!=null) { - visibleOnes = parameterAnnotationsVis.getAnnotationsOnParameter(i); - count+=visibleOnes.length; - } - if (parameterAnnotationsInvis!=null){ - invisibleOnes = parameterAnnotationsInvis.getAnnotationsOnParameter(i); - count+=invisibleOnes.length; - } - - Annotation[] complete = NO_ANNOTATIONS; - if (count!=0) { - complete = new Annotation[visibleOnes.length+invisibleOnes.length]; - System.arraycopy(visibleOnes,0,complete,0,visibleOnes.length); - System.arraycopy(invisibleOnes,0,complete,visibleOnes.length,invisibleOnes.length); - foundSome = true; - } - annotationsForEachParameter.add(complete); - } - if (foundSome) { - unpackedParameterAnnotations = (Annotation[][])annotationsForEachParameter.toArray(new Annotation[][]{}); - } else { - unpackedParameterAnnotations=NO_PARAMETER_ANNOTATIONS; + // Build a list of annotation arrays, one per argument + if (parameterAnnotationsInvis!=null || parameterAnnotationsVis!=null) { + List annotationsForEachParameter = new ArrayList(); + AnnotationGen[] visibleOnes = null; + AnnotationGen[] invisibleOnes = null; + for (int i=0; i<parameterCount; i++) { + int count = 0; + visibleOnes = new AnnotationGen[0]; + invisibleOnes = new AnnotationGen[0]; + if (parameterAnnotationsVis!=null) { + visibleOnes = parameterAnnotationsVis.getAnnotationsOnParameter(i); + count+=visibleOnes.length; + } + if (parameterAnnotationsInvis!=null){ + invisibleOnes = parameterAnnotationsInvis.getAnnotationsOnParameter(i); + count+=invisibleOnes.length; + } + + AnnotationGen[] complete = NO_ANNOTATIONS; + if (count!=0) { + complete = new AnnotationGen[visibleOnes.length+invisibleOnes.length]; + System.arraycopy(visibleOnes,0,complete,0,visibleOnes.length); + System.arraycopy(invisibleOnes,0,complete,visibleOnes.length,invisibleOnes.length); + foundSome = true; + } + annotationsForEachParameter.add(complete); + } + if (foundSome) { + unpackedParameterAnnotations = (AnnotationGen[][])annotationsForEachParameter.toArray(new AnnotationGen[][]{}); + return; + } } + unpackedParameterAnnotations=NO_PARAMETER_ANNOTATIONS; } - public Annotation[] getAnnotationsOnParameter(int i) { + public AnnotationGen[] getAnnotationsOnParameter(int i) { ensureParameterAnnotationsUnpacked(); if (unpackedParameterAnnotations==NO_PARAMETER_ANNOTATIONS) return NO_ANNOTATIONS; return unpackedParameterAnnotations[i]; } - public Annotation[][] getParameterAnnotations() { + public AnnotationGen[][] getParameterAnnotations() { ensureParameterAnnotationsUnpacked(); return unpackedParameterAnnotations; } - + } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LoadInstruction.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Modifiers.java index 92fd9226a..63719913d 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LoadInstruction.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Modifiers.java @@ -1,4 +1,4 @@ -package org.aspectj.apache.bcel.generic; +package org.aspectj.apache.bcel.classfile; /* ==================================================================== * The Apache Software License, Version 1.1 @@ -54,48 +54,87 @@ package org.aspectj.apache.bcel.generic; * <http://www.apache.org/>. */ +import org.aspectj.apache.bcel.Constants; + /** - * Denotes an unparameterized instruction to load a value from a local - * variable, e.g. ILOAD. - * - * @version $Id: LoadInstruction.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ + * Super class for all objects that have modifiers like private, final, ... I.e. + * classes, fields, and methods. + * was AccessFlags + * + * @version $Id: Modifiers.java,v 1.2 2008/05/28 23:53:01 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ -public abstract class LoadInstruction extends LocalVariableInstruction - implements PushInstruction -{ - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - * tag and length are defined in readInstruction and initFromFile, respectively. - */ - LoadInstruction(short canon_tag, short c_tag) { - super(canon_tag, c_tag); - } - - /** - * @param opcode Instruction opcode - * @param c_tag Instruction number for compact version, ALOAD_0, e.g. - * @param n local variable index (unsigned short) - */ - protected LoadInstruction(short opcode, short c_tag, int n) { - super(opcode, c_tag, 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) { - v.visitStackProducer(this); - v.visitPushInstruction(this); - v.visitTypedInstruction(this); - v.visitLocalVariableInstruction(this); - v.visitLoadInstruction(this); - } -} +public abstract class Modifiers { + + protected int modifiers; + + public Modifiers() { } + + public Modifiers(int a) { + modifiers = a; + } + + public final int getModifiers() { + return modifiers; + } + + public final void setModifiers(int modifiers) { + this.modifiers = modifiers; + } + + public final boolean isPublic() { + return (modifiers & Constants.ACC_PUBLIC) != 0; + } + + public final boolean isPrivate() { + return (modifiers & Constants.ACC_PRIVATE) != 0; + } + + public final boolean isProtected() { + return (modifiers & Constants.ACC_PROTECTED) != 0; + } + + public final boolean isStatic() { + return (modifiers & Constants.ACC_STATIC) != 0; + } + public final boolean isFinal() { + return (modifiers & Constants.ACC_FINAL) != 0; + } + + public final boolean isSynchronized() { + return (modifiers & Constants.ACC_SYNCHRONIZED) != 0; + } + + public final boolean isVolatile() { + return (modifiers & Constants.ACC_VOLATILE) != 0; + } + + public final boolean isTransient() { + return (modifiers & Constants.ACC_TRANSIENT) != 0; + } + + public final boolean isNative() { + return (modifiers & Constants.ACC_NATIVE) != 0; + } + + public final boolean isInterface() { + return (modifiers & Constants.ACC_INTERFACE) != 0; + } + + public final boolean isAbstract() { + return (modifiers & Constants.ACC_ABSTRACT) != 0; + } + + public final boolean isStrictfp() { + return (modifiers & Constants.ACC_STRICT) != 0; + } + + public final boolean isVarargs() { + return (modifiers & Constants.ACC_VARARGS) != 0; + } + + public final boolean isBridge() { + return (modifiers & Constants.ACC_BRIDGE) != 0; + } +} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Node.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Node.java index 11ee287c2..5bef82979 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Node.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Node.java @@ -57,9 +57,9 @@ package org.aspectj.apache.bcel.classfile; /** * Denote class to have an accept method(); * - * @version $Id: Node.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: Node.java,v 1.3 2008/05/28 23:53:01 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public interface Node { - public void accept(Visitor obj); + public void accept(ClassVisitor obj); } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/PMGClass.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/PMGClass.java index 2587dfa53..004043852 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/PMGClass.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/PMGClass.java @@ -62,7 +62,7 @@ import java.io.*; * to a <a href="http://www.inf.fu-berlin.de/~bokowski/pmgjava/index.html">PMG</a> * attribute. * - * @version $Id: PMGClass.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: PMGClass.java,v 1.3 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Attribute */ @@ -114,7 +114,7 @@ public final class PMGClass extends Attribute { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { System.err.println("Visiting non-standard PMGClass object"); } @@ -159,7 +159,7 @@ public final class PMGClass extends Attribute { * @return PMG name. */ public final String getPMGName() { - ConstantUtf8 c = (ConstantUtf8)constant_pool.getConstant(pmg_index, + ConstantUtf8 c = (ConstantUtf8)constantPool.getConstant(pmg_index, Constants.CONSTANT_Utf8); return c.getBytes(); } @@ -168,7 +168,7 @@ public final class PMGClass extends Attribute { * @return PMG class name. */ public final String getPMGClassName() { - ConstantUtf8 c = (ConstantUtf8)constant_pool.getConstant(pmg_class_index, + ConstantUtf8 c = (ConstantUtf8)constantPool.getConstant(pmg_class_index, Constants.CONSTANT_Utf8); return c.getBytes(); } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Signature.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Signature.java index bb9673103..1c80d4a02 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Signature.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Signature.java @@ -69,7 +69,7 @@ import org.aspectj.apache.bcel.Constants; * This class is derived from <em>Attribute</em> and represents a reference * to a <href="http://wwwipd.ira.uka.de/~pizza/gj/">GJ</a> attribute. * - * @version $Id: Signature.java,v 1.6 2005/07/12 13:59:06 aclement Exp $ + * @version $Id: Signature.java,v 1.7 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Attribute */ @@ -118,7 +118,7 @@ public final class Signature extends Attribute { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { System.err.println("Visiting non-standard Signature object"); v.visitSignature(this); } @@ -151,7 +151,7 @@ public final class Signature extends Attribute { * @return GJ signature. */ public final String getSignature() { - ConstantUtf8 c = (ConstantUtf8)constant_pool.getConstant(signature_index, + ConstantUtf8 c = (ConstantUtf8)constantPool.getConstant(signature_index, Constants.CONSTANT_Utf8); return c.getBytes(); } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/SourceFile.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/SourceFile.java index ee93d6321..9858be71d 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/SourceFile.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/SourceFile.java @@ -63,7 +63,7 @@ import java.io.*; * should appear per classfile. The intention of this class is that it is * instantiated from the <em>Attribute.readAttribute()</em> method. * - * @version $Id: SourceFile.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: SourceFile.java,v 1.3 2008/05/28 23:53:01 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Attribute */ @@ -120,7 +120,7 @@ public final class SourceFile extends Attribute { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitSourceFile(this); } @@ -152,7 +152,7 @@ public final class SourceFile extends Attribute { * @return Source file name. */ public final String getSourceFileName() { - ConstantUtf8 c = (ConstantUtf8)constant_pool.getConstant(sourcefile_index, + ConstantUtf8 c = (ConstantUtf8)constantPool.getConstant(sourcefile_index, Constants.CONSTANT_Utf8); return c.getBytes(); } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMap.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMap.java index df976fc69..5878f1b2b 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMap.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMap.java @@ -66,7 +66,7 @@ import java.io.*; * within the Code attribute of a method. See CLDC specification * §5.3.1.2 * - * @version $Id: StackMap.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: StackMap.java,v 1.3 2008/05/28 23:53:01 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Code * @see StackMapEntry @@ -166,7 +166,7 @@ public final class StackMap extends Attribute implements Node { for(int i=0; i < map_length; i++) c.map[i] = map[i].copy(); - c.constant_pool = constant_pool; + c.constantPool = constant_pool; return c; } @@ -177,7 +177,7 @@ public final class StackMap extends Attribute implements Node { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitStackMap(this); } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMapEntry.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMapEntry.java index e20d11f5f..b369083fb 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMapEntry.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMapEntry.java @@ -63,7 +63,7 @@ import java.io.IOException; * local variables and the the of stack items at a given byte code offset. * See CLDC specification §5.3.1.2 * - * @version $Id: StackMapEntry.java,v 1.4 2004/11/22 08:31:27 aclement Exp $ + * @version $Id: StackMapEntry.java,v 1.5 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see StackMap * @see StackMapType @@ -192,7 +192,7 @@ public final class StackMapEntry implements Cloneable { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitStackMapEntry(this); } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMapType.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMapType.java index 0dd072d3b..b1116abbe 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMapType.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMapType.java @@ -61,7 +61,7 @@ import java.io.*; * This class represents the type of a local variable or item on stack * used in the StackMap entries. * - * @version $Id: StackMapType.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: StackMapType.java,v 1.3 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see StackMapEntry * @see StackMap diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Synthetic.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Synthetic.java index 235c4bb4a..91f53b40d 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Synthetic.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Synthetic.java @@ -55,6 +55,7 @@ package org.aspectj.apache.bcel.classfile; */ import org.aspectj.apache.bcel.Constants; + import java.io.*; /** @@ -66,7 +67,7 @@ import java.io.*; * is intended to be instantiated from the * <em>Attribute.readAttribute()</em> method. * - * @version $Id: Synthetic.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: Synthetic.java,v 1.3 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Attribute */ @@ -80,6 +81,13 @@ public final class Synthetic extends Attribute { public Synthetic(Synthetic c) { this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool()); } +// +// public Synthetic(ConstantPoolGen cpool) { +// super(Constants.ATTR_SYNTHETIC, cpool.addUtf8("Synthetic"), 0, cpool); +// ConstantPoolGen cpg = myGen.getConstantPool(); +// int index = ; +// Attribute synthetic = new Synthetic(index, 0, new byte[0], cpg.getConstantPool()); +// } /** * @param name_index Index in constant pool to CONSTANT_Utf8, which @@ -122,7 +130,7 @@ public final class Synthetic extends Attribute { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitSynthetic(this); } /** @@ -170,7 +178,7 @@ public final class Synthetic extends Attribute { if(bytes != null) c.bytes = (byte[])bytes.clone(); - c.constant_pool = constant_pool; + c.constantPool = constant_pool; return c; } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Unknown.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Unknown.java index 97fd6e8c8..279b1511d 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Unknown.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Unknown.java @@ -68,9 +68,8 @@ import java.io.*; * org.aspectj.apache.bcel.classfile.AttributeReader)">Attribute.addAttributeReader</a>. * - * @version $Id: Unknown.java,v 1.3 2006/03/04 10:43:17 aclement Exp $ + * @version $Id: Unknown.java,v 1.4 2008/05/28 23:53:01 aclement Exp $ * @see org.aspectj.apache.bcel.classfile.Attribute - * @see org.aspectj.apache.bcel.classfile.AttributeReader * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public final class Unknown extends Attribute { @@ -147,7 +146,7 @@ public final class Unknown extends Attribute { * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitUnknown(this); } /** @@ -207,7 +206,7 @@ public final class Unknown extends Attribute { if(bytes != null) c.bytes = (byte[])bytes.clone(); - c.constant_pool = constant_pool; + c.constantPool = constant_pool; return c; } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Utility.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Utility.java index 7e1d4affe..0e221ff1b 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Utility.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Utility.java @@ -73,27 +73,24 @@ import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; import org.aspectj.apache.bcel.Constants; -import org.aspectj.apache.bcel.classfile.annotation.Annotation; -import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePair; +import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisibleAnnotations; import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisibleParameterAnnotations; import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleAnnotations; import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleParameterAnnotations; -import org.aspectj.apache.bcel.generic.ConstantPoolGen; -import org.aspectj.apache.bcel.generic.annotation.AnnotationGen; import org.aspectj.apache.bcel.util.ByteSequence; /** * Utility functions that do not really belong to any class in particular. * - * @version $Id: Utility.java,v 1.5 2006/07/19 12:06:15 aclement Exp $ + * @version $Id: Utility.java,v 1.6 2008/05/28 23:53:01 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * * modified: Andy Clement 2-mar-05 Removed unnecessary static and optimized */ public abstract class Utility { - /* The `WIDE' instruction is used in the byte code to allow 16-bit wide indices for local + /* The 'WIDE' instruction is used in the byte code to allow 16-bit wide indices for local * variables. This opcode precedes an 'ILOAD', e.g.. The opcode immediately following takes * an extra byte which is combined with the following byte to form a 16-bit value. */ @@ -108,7 +105,6 @@ public abstract class Utility { public static final String accessToString(int access_flags) { return accessToString(access_flags, false); } - /** * Convert bit field of flags into string such as 'static final'. @@ -234,11 +230,14 @@ public abstract class Utility { str = str.replace('/', '.'); // Is '/' on all systems, even DOS if (chopit) { - // If string starts with 'prefix' and contains no further dots - if (str.startsWith(prefix) && (str.substring(len).indexOf('.') == -1)) - str = str.substring(len); + // If string starts with 'prefix' and contains no further dots + if (str.startsWith(prefix)) { + String result = str.substring(len); + if ( result.indexOf('.') == -1) { + str = result; + } + } } - return str; } @@ -257,144 +256,6 @@ public abstract class Utility { public static final String compactClassName(String str, boolean chopit) { return compactClassName(str, "java.lang.", chopit); } - - // bit modification - - /** - * @return 'flag' with bit 'i' set to 1 - */ - public static final int setBit(int flag, int i) { - return flag | pow2(i); - } - - /** - * @return 'flag' with bit 'i' set to 0 - */ - public static final int clearBit(int flag, int i) { - int bit = pow2(i); - return (flag & bit) == 0? flag : flag ^ bit; - } - - /** - * @return true, if bit 'i' in 'flag' is set - */ - public static final boolean isSet(int flag, int i) { - return (flag & pow2(i)) != 0; - } - - - - /** - * Converts string containing the method return and argument types - * to a byte code method signature. - * - * @param returnType Return type of method (e.g. "char" or "java.lang.String[]") - * @param methodArgs Types of method arguments - * @return Byte code representation of method signature - */ - public final static String methodTypeToSignature(String returnType, String[] methodArgs) throws ClassFormatException { - - StringBuffer buf = new StringBuffer("("); - - if (methodArgs != null) { - for (int i=0; i < methodArgs.length; i++) { - String str = getSignature(methodArgs[i]); - - if (str.equals("V")) // void can't be a method argument - throw new ClassFormatException("Invalid type: " + methodArgs[i]); - - buf.append(str); - } - } - - buf.append(")" + getSignature(returnType)); - - return buf.toString(); - } - - - - /** - * @param signature Method signature - * @return Array of argument types - * @throws ClassFormatException - */ - public static final String[] methodSignatureArgumentTypes(String signature) throws ClassFormatException { - return methodSignatureArgumentTypes(signature, true); - } - - - - - /** - * For some method signature (class file format) like '([Ljava/lang/String;Z)V' this returns an array - * of strings representing the arguments in their 'normal' form, e.g. '{java.lang.String[],boolean}' - * - * @param signature Method signature - * @param chopit Shorten class names - * @return Array of argument types - */ - public static final String[] methodSignatureArgumentTypes(String signature,boolean chopit) throws ClassFormatException { - ArrayList vec = new ArrayList(); - int index; - String[] types; - - try { // Read all declarations between for `(' and `)' - if (signature.charAt(0) != '(') - throw new ClassFormatException("Invalid method signature: " + signature); - - index = 1; // current string position - - while(signature.charAt(index) != ')') { - ResultHolder rh = signatureToStringInternal(signature.substring(index),chopit); - vec.add(rh.getResult()); - index += rh.getConsumedChars(); - } - } catch(StringIndexOutOfBoundsException e) { - throw new ClassFormatException("Invalid method signature: " + signature); - } - - types = new String[vec.size()]; - vec.toArray(types); - return types; - } - - - /** - * For some method signature (class file format) like '([Ljava/lang/String;)Z' this returns - * the string representing the return type its 'normal' form, e.g. 'boolean' - * - * @param signature Method signature - * @return return type of method - * @throws ClassFormatException - */ - public static final String methodSignatureReturnType(String signature) throws ClassFormatException { - return methodSignatureReturnType(signature, true); - } - - - /** - * For some method signature (class file format) like '([Ljava/lang/String;)Z' this returns - * the string representing the return type its 'normal' form, e.g. 'boolean' - * - * @param signature Method signature - * @param chopit Shorten class names - * @return return type of method - */ - public static final String methodSignatureReturnType(String signature,boolean chopit) throws ClassFormatException { - int index; - String type; - try { - // Read return type after `)' - index = signature.lastIndexOf(')') + 1; - type = signatureToString(signature.substring(index), chopit); - } catch (StringIndexOutOfBoundsException e) { - throw new ClassFormatException("Invalid method signature: " + signature); - } - return type; - } - - public static final String methodSignatureToString(String signature,String name,String access) { return methodSignatureToString(signature, name, access, true); @@ -622,64 +483,6 @@ public abstract class Utility { - /** - * Parse Java type such as "char", or "java.lang.String[]" and return the - * signature in byte code format, e.g. "C" or "[Ljava/lang/String;" respectively. - * - * @param type Java type - * @return byte code signature - */ - public static String getSignature(String type) { - StringBuffer buf = new StringBuffer(); - char[] chars = type.toCharArray(); - boolean char_found = false, delim = false; - int index = -1; - - loop: - for (int i=0; i < chars.length; i++) { - switch (chars[i]) { - case ' ': case '\t': case '\n': case '\r': case '\f': - if (char_found) delim = true; - break; - - case '[': - if (!char_found) throw new RuntimeException("Illegal type: " + type); - index = i; - break loop; - - default: - char_found = true; - if (!delim) buf.append(chars[i]); - } - } - - int brackets = 0; - - if(index > 0) brackets = countBrackets(type.substring(index)); - - type = buf.toString(); - buf.setLength(0); - - for (int i=0; i < brackets; i++) buf.append('['); - - boolean found = false; - - for(int i=Constants.T_BOOLEAN; (i <= Constants.T_VOID) && !found; i++) { - if (Constants.TYPE_NAMES[i].equals(type)) { - found = true; - buf.append(Constants.SHORT_TYPE_NAMES[i]); - } - } - - // Class name - if (!found) buf.append('L' + type.replace('.', '/') + ';'); - - return buf.toString(); - } - - - - /** * Return type of method signature as a byte value as defined in <em>Constants</em> * @@ -700,21 +503,6 @@ public abstract class Utility { } } - - - /** Map opcode names to opcode numbers. E.g., return Constants.ALOAD for "aload" - */ - public static short searchOpcode(String name) { - name = name.toLowerCase(); - - for (short i=0; i < Constants.OPCODE_NAMES.length; i++) { - if (Constants.OPCODE_NAMES[i].equals(name)) - return i; - } - - return -1; - } - /** * Convert (signed) byte to (unsigned) short value, i.e., all negative * values become positive. @@ -781,266 +569,7 @@ public abstract class Utility { else return new String(buf) + str; } - - static final boolean equals(byte[] a, byte[] b) { - int size; - - if((size=a.length) != b.length) - return false; - - for(int i=0; i < size; i++) - if(a[i] != b[i]) - return false; - - return true; - } - - public static final void printArray(PrintStream out, Object[] obj) { - out.println(printArray(obj, true)); - } - - public static final void printArray(PrintWriter out, Object[] obj) { - out.println(printArray(obj, true)); - } - - public static final String printArray(Object[] obj) { - return printArray(obj, true); - } - - public static final String printArray(Object[] obj, boolean braces) { - return printArray(obj, braces, false); - } - - public static final String printArray(Object[] obj, boolean braces, - boolean quote) { - if(obj == null) - return null; - - StringBuffer buf = new StringBuffer(); - if(braces) - buf.append('{'); - - for(int i=0; i < obj.length; i++) { - if(obj[i] != null) { - buf.append((quote? "\"" : "") + obj[i].toString() + (quote? "\"" : "")); - } else { - buf.append("null"); - } - - if(i < obj.length - 1) { - buf.append(", "); - } - } - - if(braces) - buf.append('}'); - - return buf.toString(); - } - - /** @return true, if character is one of (a, ... z, A, ... Z, 0, ... 9, _) - */ - public static boolean isJavaIdentifierPart(char ch) { - return ((ch >= 'a') && (ch <= 'z')) || - ((ch >= 'A') && (ch <= 'Z')) || - ((ch >= '0') && (ch <= '9')) || - (ch == '_'); - } - - /** - * Encode byte array it into Java identifier string, i.e., a string - * that only contains the following characters: (a, ... z, A, ... Z, - * 0, ... 9, _, $). The encoding algorithm itself is not too - * clever: if the current byte's ASCII value already is a valid Java - * identifier part, leave it as it is. Otherwise it writes the - * escape character($) followed by <p><ul><li> the ASCII value as a - * hexadecimal string, if the value is not in the range - * 200..247</li> <li>a Java identifier char not used in a lowercase - * hexadecimal string, if the value is in the range - * 200..247</li><ul></p> - * - * <p>This operation inflates the original byte array by roughly 40-50%</p> - * - * @param bytes the byte array to convert - * @param compress use gzip to minimize string - */ - public static String encode(byte[] bytes, boolean compress) throws IOException { - if(compress) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - GZIPOutputStream gos = new GZIPOutputStream(baos); - - gos.write(bytes, 0, bytes.length); - gos.close(); - baos.close(); - - bytes = baos.toByteArray(); - } - - CharArrayWriter caw = new CharArrayWriter(); - JavaWriter jw = new JavaWriter(caw); - - for(int i=0; i < bytes.length; i++) { - int in = bytes[i] & 0x000000ff; // Normalize to unsigned - jw.write(in); - } - - return caw.toString(); - } - - /** Decode a string back to a byte array. - * - * @param bytes the byte array to convert - * @param uncompress use gzip to uncompress the stream of bytes - */ - public static byte[] decode(String s, boolean uncompress) throws IOException { - char[] chars = s.toCharArray(); - - CharArrayReader car = new CharArrayReader(chars); - JavaReader jr = new JavaReader(car); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - - int ch; - - while((ch = jr.read()) >= 0) { - bos.write(ch); - } - - bos.close(); - car.close(); - jr.close(); - - byte[] bytes = bos.toByteArray(); - - if(uncompress) { - GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(bytes)); - - byte[] tmp = new byte[bytes.length * 3]; // Rough estimate - int count = 0; - int b; - - while((b = gis.read()) >= 0) - tmp[count++] = (byte)b; - - bytes = new byte[count]; - System.arraycopy(tmp, 0, bytes, 0, count); - } - - return bytes; - } - - // A-Z, g-z, _, $ - private static final int FREE_CHARS = 48; - private static int[] CHAR_MAP = new int[FREE_CHARS]; - private static int[] MAP_CHAR = new int[256]; // Reverse map - private static final char ESCAPE_CHAR = '$'; - - static { - int j = 0, k = 0; - for(int i='A'; i <= 'Z'; i++) { - CHAR_MAP[j] = i; - MAP_CHAR[i] = j; - j++; - } - - for(int i='g'; i <= 'z'; i++) { - CHAR_MAP[j] = i; - MAP_CHAR[i] = j; - j++; - } - - CHAR_MAP[j] = '$'; - MAP_CHAR['$'] = j; - j++; - - CHAR_MAP[j] = '_'; - MAP_CHAR['_'] = j; - } - - /** Decode characters into bytes. - * Used by <a href="Utility.html#decode(java.lang.String, boolean)">decode()</a> - */ - private static class JavaReader extends FilterReader { - public JavaReader(Reader in) { - super(in); - } - - public int read() throws IOException { - int b = in.read(); - - if(b != ESCAPE_CHAR) { - return b; - } else { - int i = in.read(); - - if(i < 0) - return -1; - - if(((i >= '0') && (i <= '9')) || ((i >= 'a') && (i <= 'f'))) { // Normal escape - int j = in.read(); - - if(j < 0) - return -1; - - char[] tmp = { (char)i, (char)j }; - int s = Integer.parseInt(new String(tmp), 16); - - return s; - } else { // Special escape - return MAP_CHAR[i]; - } - } - } - - public int read(char[] cbuf, int off, int len) throws IOException { - for(int i=0; i < len; i++) - cbuf[off + i] = (char)read(); - - return len; - } - } - - /** Encode bytes into valid java identifier characters. - * Used by <a href="Utility.html#encode(byte[], boolean)">encode()</a> - */ - private static class JavaWriter extends FilterWriter { - public JavaWriter(Writer out) { - super(out); - } - - public void write(int b) throws IOException { - if(isJavaIdentifierPart((char)b) && (b != ESCAPE_CHAR)) { - out.write(b); - } else { - out.write(ESCAPE_CHAR); // Escape character - - // Special escape - if(b >= 0 && b < FREE_CHARS) { - out.write(CHAR_MAP[b]); - } else { // Normal escape - char[] tmp = Integer.toHexString(b).toCharArray(); - - if(tmp.length == 1) { - out.write('0'); - out.write(tmp[0]); - } else { - out.write(tmp[0]); - out.write(tmp[1]); - } - } - } - } - - public void write(char[] cbuf, int off, int len) throws IOException { - for(int i=0; i < len; i++) - write(cbuf[off + i]); - } - - public void write(String str, int off, int len) throws IOException { - write(str.toCharArray(), off, len); - } - } - + /** * Escape all occurences of newline chars '\n', quotes \", etc. */ @@ -1068,17 +597,6 @@ public abstract class Utility { return buf.toString(); } - public static List getListOfAnnotationNames(Annotation a) { - List l = a.getValues(); - List names = new ArrayList(); - for (Iterator i = l.iterator(); i.hasNext();) { - ElementNameValuePair element = (ElementNameValuePair) i.next(); - names.add(element.getNameString()); - } - return names; - } - - /** * Converts a list of AnnotationGen objects into a set of attributes * that can be attached to the class file. @@ -1086,7 +604,7 @@ public abstract class Utility { * @param cp The constant pool gen where we can create the necessary name refs * @param vec A list of AnnotationGen objects */ - public static Attribute[] getAnnotationAttributes(ConstantPoolGen cp,List vec) { + public static Attribute[] getAnnotationAttributes(ConstantPool cp,List vec) { if (vec.size()==0) return null; @@ -1131,11 +649,11 @@ public abstract class Utility { List newAttributes = new ArrayList(); if (rvaData.length>2) { newAttributes.add( - new RuntimeVisibleAnnotations(rvaIndex,rvaData.length,rvaData,cp.getConstantPool())); + new RuntimeVisibleAnnotations(rvaIndex,rvaData.length,rvaData,cp)); } if (riaData.length>2) { newAttributes.add( - new RuntimeInvisibleAnnotations(riaIndex,riaData.length,riaData,cp.getConstantPool())); + new RuntimeInvisibleAnnotations(riaIndex,riaData.length,riaData,cp)); } return (Attribute[])newAttributes.toArray(new Attribute[]{}); @@ -1151,7 +669,8 @@ public abstract class Utility { * - RuntimeVisibleParameterAnnotations * - RuntimeInvisibleParameterAnnotations */ - public static Attribute[] getParameterAnnotationAttributes(ConstantPoolGen cp,List[] /*Array of lists, array size depends on #params */ vec) { + // OPTIMIZE looks heavyweight? + public static Attribute[] getParameterAnnotationAttributes(ConstantPool cp,List[] /*Array of lists, array size depends on #params */ vec) { int visCount[] = new int[vec.length]; int totalVisCount = 0; @@ -1217,13 +736,13 @@ public abstract class Utility { if (totalVisCount>0) { newAttributes.add( - new RuntimeVisibleParameterAnnotations(rvaIndex,rvaData.length,rvaData,cp.getConstantPool())); + new RuntimeVisibleParameterAnnotations(rvaIndex,rvaData.length,rvaData,cp)); } if (totalInvisCount>0) { newAttributes.add( - new RuntimeInvisibleParameterAnnotations(riaIndex,riaData.length,riaData,cp.getConstantPool())); + new RuntimeInvisibleParameterAnnotations(riaIndex,riaData.length,riaData,cp)); } return (Attribute[])newAttributes.toArray(new Attribute[]{}); @@ -1234,16 +753,7 @@ public abstract class Utility { return null; } - - private static final boolean is_digit(char ch) { - return (ch >= '0') && (ch <= '9'); - } - - private static final boolean is_space(char ch) { - return (ch == ' ') || (ch == '\t') || (ch == '\r') || (ch == '\n'); - } - - private static class ResultHolder { + public static class ResultHolder { private String result; private int consumed; @@ -1266,7 +776,6 @@ public abstract class Utility { public int getConsumedChars() { return consumed; } } - // code below here I am happy with .... /** * Return type of signature as a byte value as defined in <em>Constants</em> @@ -1315,122 +824,6 @@ public abstract class Utility { } } - public static final String readClassTypeSignatureFrom(String signature) { - StringBuffer sb = new StringBuffer(); - readClassTypeSignatureFrom(signature,0,sb,false); - return sb.toString(); - } - - /** - * Takes a string and consumes a single complete signature from it, returning - * how many chars it consumed. The chopit flag indicates whether to shorten - * type references ( java/lang/String => String ) - * - * FIXME asc this should also create some kind of object you can query for information about whether its parameterized, what the bounds are, etc... - */ - public static final int readClassTypeSignatureFrom(String signature, int posn, StringBuffer result, boolean chopit) { - int idx = posn; - try { - switch (signature.charAt(idx)) { - case 'B' : result.append("byte"); return 1; - case 'C' : result.append("char"); return 1; - case 'D' : result.append("double"); return 1; - case 'F' : result.append("float"); return 1; - case 'I' : result.append("int"); return 1; - case 'J' : result.append("long"); return 1; - case 'S' : result.append("short"); return 1; - case 'Z' : result.append("boolean");return 1; - case 'V' : result.append("void"); return 1; - - - //FIXME ASC Need a state machine to check we are parsing the right stuff here ! - case 'T' : - idx++; - int nextSemiIdx = signature.indexOf(';',idx); - result.append(signature.substring(idx,nextSemiIdx)); - return nextSemiIdx+1-posn; - - case '+' : - result.append("? extends "); - return readClassTypeSignatureFrom(signature,idx+1,result,chopit)+1; - - case '-' : - result.append("? super "); - return readClassTypeSignatureFrom(signature,idx+1,result,chopit)+1; - - case '*' : - result.append("?"); - return 1; - - case 'L' : // Full class name - boolean parameterized = false; - int idxSemicolon = signature.indexOf(';',idx); // Look for closing ';' or '<' - int idxAngly = signature.indexOf('<',idx); - int endOfSig = idxSemicolon; - if ((idxAngly!=-1) && idxAngly<endOfSig) { endOfSig = idxAngly; parameterized = true; } - - String p = signature.substring(idx+1,endOfSig); - String t = compactClassName(p,chopit); - - result.append(t); - idx=endOfSig; - // we might have finished now, depending on whether this is a parameterized type... - if (parameterized) { - idx++; - result.append("<"); - while (signature.charAt(idx)!='>') { - idx+=readClassTypeSignatureFrom(signature,idx,result,chopit); - if (signature.charAt(idx)!='>') result.append(","); - } - result.append(">");idx++; - } - if (signature.charAt(idx)!=';') throw new RuntimeException("Did not find ';' at end of signature, found "+signature.charAt(idx)); - idx++; - return idx-posn; - - - case '[' : // Array declaration - int dim = 0; - while (signature.charAt(idx)=='[') {dim++;idx++;} - idx+=readClassTypeSignatureFrom(signature,idx,result,chopit); - while (dim>0) {result.append("[]");dim--;} - return idx-posn; - - default : throw new ClassFormatException("Invalid signature: `" + - signature + "'"); - } - } catch(StringIndexOutOfBoundsException e) { // Should never occur - throw new ClassFormatException("Invalid signature: " + e + ":" + signature); - } - } - - private static int countBrackets(String brackets) { - char[] chars = brackets.toCharArray(); - int count = 0; - boolean open = false; - - for(int i=0; i<chars.length; i++) { - switch(chars[i]) { - case '[': - if (open) throw new RuntimeException("Illegally nested brackets:" + brackets); - open = true; - break; - - case ']': - if (!open) throw new RuntimeException("Illegally nested brackets:" + brackets); - open = false; - count++; - break; - - default: - } - } - - if (open) throw new RuntimeException("Illegally nested brackets:" + brackets); - - return count; - } - /** * Disassemble a stream of byte codes and return the string representation. * @@ -1629,7 +1022,7 @@ public abstract class Utility { break; default: - if (Constants.NO_OF_OPERANDS[opcode] > 0) { + if ((Constants.iLen[opcode]-1) > 0) { for (int i=0; i < Constants.TYPE_OF_OPERANDS[opcode].length; i++) { buf.append("\t\t"); switch(Constants.TYPE_OF_OPERANDS[opcode][i]) { diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/Annotation.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/Annotation.java deleted file mode 100644 index ac81ec805..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/Annotation.java +++ /dev/null @@ -1,155 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2004 IBM Corporation - * - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andy Clement initial implementation - * ******************************************************************/ -package org.aspectj.apache.bcel.classfile.annotation; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.aspectj.apache.bcel.Constants; -import org.aspectj.apache.bcel.classfile.ConstantPool; -import org.aspectj.apache.bcel.classfile.ConstantUtf8; -import org.aspectj.apache.bcel.classfile.Utility; - -/** - * An annotation is an immutable object (AnnotationGen is the mutable variant) - it basically contains a list - * of name-value pairs. - */ -public class Annotation { - private int typeIndex; - // OPTIMIZE don't need a new list instance for every annotation instance! - private List /* ElementNameValuePair */ evs = new ArrayList(); - private ConstantPool cpool; - private boolean isRuntimeVisible; - - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append("ANNOTATION ["+getTypeSignature()+"] ["+ - (isRuntimeVisible?"runtimeVisible":"runtimeInvisible")+"] ["); - for (Iterator iter = evs.iterator(); iter.hasNext();) { - ElementNameValuePair element = (ElementNameValuePair) iter.next(); - sb.append(element.toString()); - if (iter.hasNext()) sb.append(","); - } - sb.append("]"); - return sb.toString(); - } - - private Annotation(ConstantPool cpool) { - this.cpool = cpool; - } - - public Annotation(int index,ConstantPool cpool,boolean visible) { - this.cpool = cpool; - this.typeIndex = index; - this.isRuntimeVisible = visible; - } - - protected static Annotation read(DataInputStream dis,ConstantPool cpool,boolean isRuntimeVisible) throws IOException { - Annotation a = new Annotation(cpool); - a.typeIndex = dis.readUnsignedShort(); - int elemValuePairCount = dis.readUnsignedShort(); - for (int i=0;i<elemValuePairCount;i++) { - int nidx = dis.readUnsignedShort(); - a.addElementNameValuePair( - new ElementNameValuePair(nidx,ElementValue.readElementValue(dis,cpool),cpool)); - } - a.isRuntimeVisible(isRuntimeVisible); - return a; - } - - protected void dump(DataOutputStream dos) throws IOException { - dos.writeShort(typeIndex); // u2 index of type name in cpool - dos.writeShort(evs.size()); // u2 element_value pair count - for (int i = 0 ; i<evs.size();i++) { - ElementNameValuePair envp = (ElementNameValuePair) evs.get(i); - envp.dump(dos); - } - } - - public void addElementNameValuePair(ElementNameValuePair evp) { - evs.add(evp); - } - - - public int getTypeIndex() { - return typeIndex; - } - - public String getTypeSignature() { - ConstantUtf8 c = (ConstantUtf8)cpool.getConstant(typeIndex,Constants.CONSTANT_Utf8); - return c.getBytes(); - } - - public String getTypeName() { - ConstantUtf8 c = (ConstantUtf8)cpool.getConstant(typeIndex,Constants.CONSTANT_Utf8); - return Utility.signatureToString(c.getBytes()); - } - - /** - * Returns list of ElementNameValuePair objects - */ - public List getValues() { - return evs; - } - - protected void isRuntimeVisible(boolean b) { - isRuntimeVisible = b; - } - - public boolean isRuntimeVisible() { - return isRuntimeVisible; - } - - public String toShortString() { - StringBuffer result = new StringBuffer(); - result.append("@"); - result.append(getTypeName()); - if (getValues().size()>0) { - result.append("("); - for (Iterator iter = getValues().iterator(); iter.hasNext();) { - ElementNameValuePair element = (ElementNameValuePair) iter.next(); - result.append(element.toShortString()); - } - result.append(")"); - } - return result.toString(); - } - - /** - * Return true if the annotation has a value with the specified name (n) and value (v) - */ - public boolean hasNameValuePair(String n, String v) { - for (int i=0;i<evs.size();i++) { - ElementNameValuePair pair = (ElementNameValuePair)evs.get(i); - if (pair.getNameString().equals(n)) { - if (pair.getValue().stringifyValue().equals(v)) return true; - } - } - return false; - } - - /** - * Return true if the annotation has a value with the specified name (n) - */ - public boolean hasNamedValue(String n) { - for (int i=0;i<evs.size();i++) { - ElementNameValuePair pair = (ElementNameValuePair)evs.get(i); - if (pair.getNameString().equals(n)) return true; - } - return false; - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationElementValue.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationElementValue.java deleted file mode 100644 index 1959f20d8..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationElementValue.java +++ /dev/null @@ -1,51 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2004 IBM - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andy Clement - initial implementation {date} - * ******************************************************************/ -package org.aspectj.apache.bcel.classfile.annotation; - -import java.io.DataOutputStream; -import java.io.IOException; - -import org.aspectj.apache.bcel.classfile.ConstantPool; - -/** - * An element value that is an annotation. - */ -public class AnnotationElementValue extends ElementValue { - - // For annotation element values, this is the annotation - private Annotation a; - - public AnnotationElementValue(int type, Annotation annotation, ConstantPool cpool) { - super(type,cpool); - if (type != ANNOTATION) - throw new RuntimeException("Only element values of type annotation can be built with this ctor"); - this.a = annotation; - } - - public void dump(DataOutputStream dos) throws IOException { - dos.writeByte(type); // u1 type of value (ANNOTATION == '@') - a.dump(dos); - } - - public String stringifyValue() { - StringBuffer sb = new StringBuffer(); - sb.append(a.toString()); - return sb.toString(); - } - - public String toString() { - return stringifyValue(); - } - - public Annotation getAnnotation() { return a;} - -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/AnnotationElementValueGen.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationElementValueGen.java index 0ee425de9..e1b9f47d9 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/AnnotationElementValueGen.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationElementValueGen.java @@ -10,14 +10,12 @@ * Andy Clement - initial implementation {date} * ******************************************************************/ -package org.aspectj.apache.bcel.generic.annotation; +package org.aspectj.apache.bcel.classfile.annotation; import java.io.DataOutputStream; import java.io.IOException; -import org.aspectj.apache.bcel.classfile.annotation.AnnotationElementValue; -import org.aspectj.apache.bcel.classfile.annotation.ElementValue; -import org.aspectj.apache.bcel.generic.ConstantPoolGen; +import org.aspectj.apache.bcel.classfile.ConstantPool; public class AnnotationElementValueGen extends ElementValueGen { @@ -25,19 +23,19 @@ public class AnnotationElementValueGen extends ElementValueGen { // For annotation element values, this is the annotation private AnnotationGen a; - public AnnotationElementValueGen(AnnotationGen a,ConstantPoolGen cpool) { + public AnnotationElementValueGen(AnnotationGen a,ConstantPool cpool) { super(ANNOTATION,cpool); this.a = a; } - public AnnotationElementValueGen(int type, AnnotationGen annotation, ConstantPoolGen cpool) { + public AnnotationElementValueGen(int type, AnnotationGen annotation, ConstantPool cpool) { super(type,cpool); if (type != ANNOTATION) throw new RuntimeException("Only element values of type annotation can be built with this ctor"); this.a = annotation; } - public AnnotationElementValueGen(AnnotationElementValue value, ConstantPoolGen cpool,boolean copyPoolEntries) { + public AnnotationElementValueGen(AnnotationElementValueGen value, ConstantPool cpool,boolean copyPoolEntries) { super(ANNOTATION,cpool); a = new AnnotationGen(value.getAnnotation(),cpool,copyPoolEntries); } @@ -54,8 +52,8 @@ public class AnnotationElementValueGen extends ElementValueGen { /** * Return immutable variant of this AnnotationElementValueGen */ - public ElementValue getElementValue() { - return new AnnotationElementValue(this.type,a.getAnnotation(),cpGen.getConstantPool()); + public ElementValueGen getElementValue() { + return new AnnotationElementValueGen(this.type,a,cpGen); } public AnnotationGen getAnnotation() { return a;} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/AnnotationGen.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationGen.java index 7b758c17e..e845c8597 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/AnnotationGen.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationGen.java @@ -10,7 +10,7 @@ * Contributors: * Andy Clement initial implementation * ******************************************************************/ -package org.aspectj.apache.bcel.generic.annotation; +package org.aspectj.apache.bcel.classfile.annotation; import java.io.DataInputStream; import java.io.DataOutputStream; @@ -20,15 +20,16 @@ import java.util.Iterator; import java.util.List; import org.aspectj.apache.bcel.classfile.ConstantUtf8; -import org.aspectj.apache.bcel.classfile.annotation.Annotation; -import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePair; -import org.aspectj.apache.bcel.generic.ConstantPoolGen; +import org.aspectj.apache.bcel.classfile.ConstantPool; import org.aspectj.apache.bcel.generic.ObjectType; +import org.aspectj.apache.bcel.classfile.Utility; public class AnnotationGen { + public static final AnnotationGen[] NO_ANNOTATIONS = new AnnotationGen[0]; + private int typeIndex; private List /* ElementNameValuePairGen */ evs; - private ConstantPoolGen cpool; + private ConstantPool cpool; private boolean isRuntimeVisible = false; /** @@ -39,7 +40,7 @@ public class AnnotationGen { * across. * We need to copy the type and the element name value pairs and the visibility. */ - public AnnotationGen(Annotation a,ConstantPoolGen cpool,boolean copyPoolEntries) { + public AnnotationGen(AnnotationGen a,ConstantPool cpool,boolean copyPoolEntries) { this.cpool = cpool; if (copyPoolEntries) { @@ -53,39 +54,41 @@ public class AnnotationGen { evs = copyValues(a.getValues(),cpool,copyPoolEntries); } - private List copyValues(List in,ConstantPoolGen cpool,boolean copyPoolEntries) { + private List copyValues(List in,ConstantPool cpool,boolean copyPoolEntries) { List out = new ArrayList(); for (Iterator iter = in.iterator(); iter.hasNext();) { - ElementNameValuePair nvp = (ElementNameValuePair) iter.next(); + ElementNameValuePairGen nvp = (ElementNameValuePairGen) iter.next(); out.add(new ElementNameValuePairGen(nvp,cpool,copyPoolEntries)); } return out; } - private AnnotationGen(ConstantPoolGen cpool) { + private AnnotationGen(ConstantPool cpool) { this.cpool = cpool; + this.evs=new ArrayList(); } /** * Retrieve an immutable version of this AnnotationGen */ - public Annotation getAnnotation() { - Annotation a = new Annotation(typeIndex,cpool.getConstantPool(),isRuntimeVisible); - for (Iterator iter = evs.iterator(); iter.hasNext();) { - ElementNameValuePairGen element = (ElementNameValuePairGen) iter.next(); - a.addElementNameValuePair(element.getElementNameValuePair()); - } - return a; - } - - public AnnotationGen(ObjectType type,List /*ElementNameValuePairGen*/ elements,boolean vis,ConstantPoolGen cpool) { +// public AnnotationGen getAnnotation() { +// return this; +//// AnnotationGen a = new AnnotationGen(typeIndex,cpool,isRuntimeVisible); +//// for (Iterator iter = evs.iterator(); iter.hasNext();) { +//// ElementNameValuePairGen element = (ElementNameValuePairGen) iter.next(); +//// a.addElementNameValuePair(element.getElementNameValuePair()); +//// } +//// return a; +// } + + public AnnotationGen(ObjectType type,List /*ElementNameValuePairGen*/ elements,boolean vis,ConstantPool cpool) { this.cpool = cpool; - this.typeIndex = cpool.addUtf8(type.getSignature()); + if (type!=null) this.typeIndex = cpool.addUtf8(type.getSignature()); // Only null for funky *temporary* FakeAnnotation objects evs = elements; isRuntimeVisible = vis; } - public static AnnotationGen read(DataInputStream dis,ConstantPoolGen cpool,boolean b) throws IOException { + public static AnnotationGen read(DataInputStream dis,ConstantPool cpool,boolean b) throws IOException { AnnotationGen a = new AnnotationGen(cpool); a.typeIndex = dis.readUnsignedShort(); int elemValuePairCount = dis.readUnsignedShort(); @@ -117,14 +120,14 @@ public class AnnotationGen { return typeIndex; } - public final String getTypeSignature() { + public String getTypeSignature() { // ConstantClass c = (ConstantClass)cpool.getConstant(typeIndex); ConstantUtf8 utf8 = (ConstantUtf8)cpool.getConstant(typeIndex/*c.getNameIndex()*/); return utf8.getBytes(); } - public final String getTypeName() { - return getTypeSignature();// BCELBUG: Should I use this instead? Utility.signatureToString(getTypeSignature()); + public String getTypeName() { + return Utility.signatureToString(getTypeSignature()); } /** @@ -163,4 +166,28 @@ public class AnnotationGen { public boolean isRuntimeVisible() { return isRuntimeVisible; } + + /** + * Return true if the annotation has a value with the specified name (n) and value (v) + */ + public boolean hasNameValuePair(String n, String v) { + for (int i=0;i<evs.size();i++) { + ElementNameValuePairGen pair = (ElementNameValuePairGen)evs.get(i); + if (pair.getNameString().equals(n)) { + if (pair.getValue().stringifyValue().equals(v)) return true; + } + } + return false; + } + + /** + * Return true if the annotation has a value with the specified name (n) + */ + public boolean hasNamedValue(String n) { + for (int i=0;i<evs.size();i++) { + ElementNameValuePairGen pair = (ElementNameValuePairGen)evs.get(i); + if (pair.getNameString().equals(n)) return true; + } + return false; + } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ArrayElementValue.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ArrayElementValue.java deleted file mode 100644 index 6feeeddf4..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ArrayElementValue.java +++ /dev/null @@ -1,66 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2004 IBM - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andy Clement - initial implementation {date} - * ******************************************************************/ - -package org.aspectj.apache.bcel.classfile.annotation; - -import java.io.DataOutputStream; -import java.io.IOException; - -import org.aspectj.apache.bcel.classfile.ConstantPool; - - -public class ArrayElementValue extends ElementValue { - - // For array types, this is the array - private ElementValue[] evalues; - - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append("{"); - for (int i = 0; i < evalues.length; i++) { - sb.append(evalues[i].toString()); - if ((i+1)<evalues.length) sb.append(","); - } - sb.append("}"); - return sb.toString(); - } - - public ArrayElementValue(int type, ElementValue[] datums, ConstantPool cpool) { - super(type,cpool); - if (type != ARRAY) - throw new RuntimeException("Only element values of type array can be built with this ctor"); - this.evalues = datums; - } - - public void dump(DataOutputStream dos) throws IOException { - dos.writeByte(type); // u1 type of value (ARRAY == '[') - dos.writeShort(evalues.length); - for (int i=0; i<evalues.length; i++) { - evalues[i].dump(dos); - } - } - - public String stringifyValue() { - StringBuffer sb = new StringBuffer(); - sb.append("["); - for(int i=0; i<evalues.length; i++) { - sb.append(evalues[i].stringifyValue()); - if ((i+1)<evalues.length) sb.append(","); - } - sb.append("]"); - return sb.toString(); - } - - public ElementValue[] getElementValuesArray() { return evalues;} - public int getElementValuesArraySize() { return evalues.length;} - -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ArrayElementValueGen.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ArrayElementValueGen.java new file mode 100644 index 000000000..72235f3d6 --- /dev/null +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ArrayElementValueGen.java @@ -0,0 +1,93 @@ +/* ******************************************************************* + * Copyright (c) 2004 IBM + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement - initial implementation {date} + * ******************************************************************/ + +package org.aspectj.apache.bcel.classfile.annotation; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.aspectj.apache.bcel.classfile.ConstantPool; + + +public class ArrayElementValueGen extends ElementValueGen { + private static final ElementValueGen[] NO_VALUES = new ElementValueGen[0]; + + // J5TODO: Should we make this an array or a list? A list would be easier to modify ... + private ElementValueGen[] evalues = NO_VALUES; + + public ElementValueGen[] getElementValuesArray() { return evalues;} + public int getElementValuesArraySize() { return evalues.length;} + + public ArrayElementValueGen(ConstantPool cp) { + super(ARRAY,cp); + } + + public ArrayElementValueGen(int type, ElementValueGen[] datums, ConstantPool cpool) { + super(type,cpool); + if (type != ARRAY) + throw new RuntimeException("Only element values of type array can be built with this ctor"); + this.evalues = datums; + } + + /** + * Return immutable variant of this ArrayElementValueGen + */ + public ElementValueGen getElementValue() { + ElementValueGen[] immutableData = new ElementValueGen[evalues.length]; + for (int i = 0; i<evalues.length;i++) { + immutableData[i] = evalues[i]; + } + return new ArrayElementValueGen(type,immutableData,cpGen); + } + + /** + * @param value + * @param cpool + */ + public ArrayElementValueGen(ArrayElementValueGen value, ConstantPool cpool,boolean copyPoolEntries) { + super(ARRAY,cpool); + evalues = new ElementValueGen[value.getElementValuesArraySize()]; + ElementValueGen[] in = value.getElementValuesArray(); + for (int i = 0; i < in.length; i++) { + evalues[i]=ElementValueGen.copy(in[i],cpool,copyPoolEntries); + } + } + + public void dump(DataOutputStream dos) throws IOException { + dos.writeByte(type); // u1 type of value (ARRAY == '[') + dos.writeShort(evalues.length); + for (int i =0;i<evalues.length;i++) { + evalues[i].dump(dos); + } + } + + public String stringifyValue() { + StringBuffer sb = new StringBuffer(); + sb.append("["); + for (int i =0;i<evalues.length;i++) { + ElementValueGen element = (ElementValueGen) evalues[i]; + sb.append(element.stringifyValue()); + if ((i+1)<evalues.length) sb.append(","); + } + sb.append("]"); + return sb.toString(); + } + + + public void addElement(ElementValueGen gen) { + ElementValueGen[] old = evalues; + evalues = new ElementValueGen[evalues.length+1]; + System.arraycopy(old,0,evalues,0,old.length); + evalues[old.length]=gen; + } + +} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ClassElementValue.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ClassElementValue.java deleted file mode 100644 index ac934484f..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ClassElementValue.java +++ /dev/null @@ -1,53 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2004 IBM - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andy Clement - initial implementation {date} - * ******************************************************************/ - -package org.aspectj.apache.bcel.classfile.annotation; - -import java.io.DataOutputStream; -import java.io.IOException; - -import org.aspectj.apache.bcel.Constants; -import org.aspectj.apache.bcel.classfile.ConstantPool; -import org.aspectj.apache.bcel.classfile.ConstantUtf8; - - -public class ClassElementValue extends ElementValue { - - // For primitive types and string type, this points to the value entry in the cpool - // For 'class' this points to the class entry in the cpool - private int idx; - - public ClassElementValue(int type,int idx,ConstantPool cpool) { - super(type,cpool); - this.idx = idx; - } - - public int getIndex() { - return idx; - } - - public String getClassString() { - ConstantUtf8 c = (ConstantUtf8)cpool.getConstant(idx,Constants.CONSTANT_Utf8); - return c.getBytes(); - } - - public String stringifyValue() { - ConstantUtf8 cu8 = (ConstantUtf8)cpool.getConstant(idx,Constants.CONSTANT_Utf8); - return cu8.getBytes(); - } - - public void dump(DataOutputStream dos) throws IOException { - dos.writeByte(type); // u1 kind of value - dos.writeShort(idx); - } - -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/ClassElementValueGen.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ClassElementValueGen.java index 6fd5cfac7..333030ad7 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/ClassElementValueGen.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ClassElementValueGen.java @@ -10,15 +10,13 @@ * Andy Clement - initial implementation {date} * ******************************************************************/ -package org.aspectj.apache.bcel.generic.annotation; +package org.aspectj.apache.bcel.classfile.annotation; import java.io.DataOutputStream; import java.io.IOException; import org.aspectj.apache.bcel.classfile.ConstantUtf8; -import org.aspectj.apache.bcel.classfile.annotation.ClassElementValue; -import org.aspectj.apache.bcel.classfile.annotation.ElementValue; -import org.aspectj.apache.bcel.generic.ConstantPoolGen; +import org.aspectj.apache.bcel.classfile.ConstantPool; import org.aspectj.apache.bcel.generic.ObjectType; @@ -28,12 +26,12 @@ public class ClassElementValueGen extends ElementValueGen { // For 'class' this points to the class entry in the cpool private int idx; - protected ClassElementValueGen(int typeIdx,ConstantPoolGen cpool) { + protected ClassElementValueGen(int typeIdx,ConstantPool cpool) { super(ElementValueGen.CLASS,cpool); this.idx = typeIdx; } - public ClassElementValueGen(ObjectType t,ConstantPoolGen cpool) { + public ClassElementValueGen(ObjectType t,ConstantPool cpool) { super(ElementValueGen.CLASS,cpool); //this.idx = cpool.addClass(t); idx = cpool.addUtf8(t.getSignature()); @@ -42,11 +40,11 @@ public class ClassElementValueGen extends ElementValueGen { /** * Return immutable variant of this ClassElementValueGen */ - public ElementValue getElementValue() { - return new ClassElementValue(type,idx,cpGen.getConstantPool()); - } +// public ElementValueGen getElementValue() { +// return new ClassElementValueGen(type,idx,cpGen); +// } - public ClassElementValueGen(ClassElementValue value, ConstantPoolGen cpool,boolean copyPoolEntries) { + public ClassElementValueGen(ClassElementValueGen value, ConstantPool cpool,boolean copyPoolEntries) { super(CLASS,cpool); if (copyPoolEntries) { //idx = cpool.addClass(value.getClassString()); diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementNameValuePair.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementNameValuePair.java deleted file mode 100644 index 60dc5cd9f..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementNameValuePair.java +++ /dev/null @@ -1,62 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2004 IBM - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andy Clement - initial implementation {date} - * ******************************************************************/ - -package org.aspectj.apache.bcel.classfile.annotation; - -import java.io.DataOutputStream; -import java.io.IOException; - -import org.aspectj.apache.bcel.Constants; -import org.aspectj.apache.bcel.classfile.ConstantPool; -import org.aspectj.apache.bcel.classfile.ConstantUtf8; - - -public class ElementNameValuePair { - private int nameIdx; - private ElementValue value; - private ConstantPool cpool; - - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append(getNameString()+"="+value.toString()); - return sb.toString(); - } - public ElementNameValuePair(int idx,ElementValue value,ConstantPool cpool) { - this.nameIdx = idx; - this.value = value; - this.cpool = cpool; - } - - protected void dump(DataOutputStream dos) throws IOException { - dos.writeShort(nameIdx); // u2 name of the element - value.dump(dos); - } - - public int getNameIndex() { - return nameIdx; - } - - public final String getNameString() { - ConstantUtf8 c = (ConstantUtf8)cpool.getConstant(nameIdx,Constants.CONSTANT_Utf8); - return c.getBytes(); - } - - public final ElementValue getValue() { - return value; - } - - public String toShortString() { - StringBuffer result = new StringBuffer(); - result.append(getNameString()).append("=").append(getValue().toShortString()); - return result.toString(); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/ElementNameValuePairGen.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementNameValuePairGen.java index 9c68a83c1..451c504b8 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/ElementNameValuePairGen.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementNameValuePairGen.java @@ -10,23 +10,21 @@ * Andy Clement - initial implementation * ******************************************************************/ -package org.aspectj.apache.bcel.generic.annotation; +package org.aspectj.apache.bcel.classfile.annotation; import java.io.DataOutputStream; import java.io.IOException; import org.aspectj.apache.bcel.classfile.ConstantUtf8; -import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePair; -import org.aspectj.apache.bcel.classfile.annotation.ElementValue; -import org.aspectj.apache.bcel.generic.ConstantPoolGen; +import org.aspectj.apache.bcel.classfile.ConstantPool; public class ElementNameValuePairGen { private int nameIdx; private ElementValueGen value; - private ConstantPoolGen cpool; + private ConstantPool cpool; - public ElementNameValuePairGen(ElementNameValuePair nvp, ConstantPoolGen cpool, boolean copyPoolEntries) { + public ElementNameValuePairGen(ElementNameValuePairGen nvp, ConstantPool cpool, boolean copyPoolEntries) { this.cpool = cpool; // J5ASSERT: // Could assert nvp.getNameString() points to the same thing as cpool.getConstant(nvp.getNameIndex()) @@ -44,19 +42,19 @@ public class ElementNameValuePairGen { /** * Retrieve an immutable version of this ElementNameValuePairGen */ - public ElementNameValuePair getElementNameValuePair() { - ElementValue immutableValue = value.getElementValue(); - return new ElementNameValuePair(nameIdx,immutableValue,cpool.getConstantPool()); - } +// public ElementNameValuePairGen getElementNameValuePair() { +// ElementValueGen immutableValue = value.getElementValue(); +// return new ElementNameValuePairGen(nameIdx,immutableValue,cpool); +// } - protected ElementNameValuePairGen(int idx,ElementValueGen value,ConstantPoolGen cpool) { + protected ElementNameValuePairGen(int idx,ElementValueGen value,ConstantPool cpool) { this.nameIdx = idx; this.value = value; this.cpool = cpool; } - public ElementNameValuePairGen(String name,ElementValueGen value,ConstantPoolGen cpool) { + public ElementNameValuePairGen(String name,ElementValueGen value,ConstantPool cpool) { this.nameIdx = cpool.addUtf8(name); this.value = value; this.cpool = cpool; @@ -81,6 +79,8 @@ public class ElementNameValuePairGen { } public String toString() { - return "ElementNameValuePair:["+getNameString()+"="+value.stringifyValue()+"]"; + StringBuffer sb = new StringBuffer(); + sb.append(getNameString()+"="+value.stringifyValue()); + return sb.toString(); } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementValue.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementValue.java deleted file mode 100644 index 38e8ac11f..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementValue.java +++ /dev/null @@ -1,112 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2004 IBM - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andy Clement - initial implementation {date} - * ******************************************************************/ - -package org.aspectj.apache.bcel.classfile.annotation; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.aspectj.apache.bcel.classfile.ConstantPool; - -public abstract class ElementValue { - - protected int type; - protected ConstantPool cpool; - - public String toString() { - return stringifyValue(); - } - - protected ElementValue(int type,ConstantPool cpool) { - this.type = type; - this.cpool = cpool; - } - - public int getElementValueType() { - return type; - } - - public abstract String stringifyValue(); - public abstract void dump(DataOutputStream dos) throws IOException; - - public static final int STRING = 's'; - public static final int ENUM_CONSTANT = 'e'; - public static final int CLASS = 'c'; - public static final int ANNOTATION = '@'; - public static final int ARRAY = '['; - - public static final int PRIMITIVE_INT = 'I'; - public static final int PRIMITIVE_BYTE = 'B'; - public static final int PRIMITIVE_CHAR = 'C'; - public static final int PRIMITIVE_DOUBLE = 'D'; - public static final int PRIMITIVE_FLOAT = 'F'; - public static final int PRIMITIVE_LONG = 'J'; - public static final int PRIMITIVE_SHORT = 'S'; - public static final int PRIMITIVE_BOOLEAN= 'Z'; - - public static ElementValue readElementValue(DataInputStream dis,ConstantPool cpool) throws IOException { - int type= dis.readUnsignedByte(); - switch (type) { - case 'B': // byte - return new SimpleElementValue(PRIMITIVE_BYTE,dis.readUnsignedShort(),cpool); - case 'C': // char - return new SimpleElementValue(PRIMITIVE_CHAR,dis.readUnsignedShort(),cpool); - case 'D': // double - return new SimpleElementValue(PRIMITIVE_DOUBLE,dis.readUnsignedShort(),cpool); - case 'F': // float - return new SimpleElementValue(PRIMITIVE_FLOAT,dis.readUnsignedShort(),cpool); - case 'I': // int - return new SimpleElementValue(PRIMITIVE_INT,dis.readUnsignedShort(),cpool); - case 'J': // long - return new SimpleElementValue(PRIMITIVE_LONG,dis.readUnsignedShort(),cpool); - case 'S': // short - return new SimpleElementValue(PRIMITIVE_SHORT,dis.readUnsignedShort(),cpool); - case 'Z': // boolean - return new SimpleElementValue(PRIMITIVE_BOOLEAN,dis.readUnsignedShort(),cpool); - case 's': // String - return new SimpleElementValue(STRING,dis.readUnsignedShort(),cpool); - - case 'e': // Enum constant - return new EnumElementValue(ENUM_CONSTANT,dis.readUnsignedShort(),dis.readUnsignedShort(),cpool); - - case 'c': // Class - return new ClassElementValue(CLASS,dis.readUnsignedShort(),cpool); - - //J5TODO: Should it be 'true' in the next statement? What difference does it make? Should it be - // the same as the 'super annotation' in which we are contained? - case '@': // Annotation - return new AnnotationElementValue(ANNOTATION,Annotation.read(dis,cpool,true),cpool); - - case '[': // Array - int numArrayVals = dis.readUnsignedShort(); - List arrayVals = new ArrayList(); - ElementValue[] evalues = new ElementValue[numArrayVals]; - for (int j=0;j<numArrayVals;j++) { - evalues[j] = ElementValue.readElementValue(dis,cpool); - } - return new ArrayElementValue(ARRAY,evalues,cpool); - - default: - throw new RuntimeException("Unexpected element value kind in annotation: "+type); - } - } - - - public String toShortString() { - StringBuffer result = new StringBuffer(); - result.append(stringifyValue()); - return result.toString(); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/ElementValueGen.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementValueGen.java index 4537025f0..e575ff366 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/ElementValueGen.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementValueGen.java @@ -10,35 +10,29 @@ * Andy Clement - initial implementation {date} * ******************************************************************/ -package org.aspectj.apache.bcel.generic.annotation; +package org.aspectj.apache.bcel.classfile.annotation; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; -import org.aspectj.apache.bcel.classfile.annotation.AnnotationElementValue; -import org.aspectj.apache.bcel.classfile.annotation.ArrayElementValue; -import org.aspectj.apache.bcel.classfile.annotation.ClassElementValue; -import org.aspectj.apache.bcel.classfile.annotation.ElementValue; -import org.aspectj.apache.bcel.classfile.annotation.EnumElementValue; -import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValue; -import org.aspectj.apache.bcel.generic.ConstantPoolGen; +import org.aspectj.apache.bcel.classfile.ConstantPool; public abstract class ElementValueGen { protected int type; - protected ConstantPoolGen cpGen; + protected ConstantPool cpGen; - protected ElementValueGen(int type,ConstantPoolGen cpGen) { + protected ElementValueGen(int type,ConstantPool cpGen) { this.type = type; this.cpGen = cpGen; } - /** - * Subtypes return an immutable variant of the ElementValueGen - */ - public abstract ElementValue getElementValue(); +// /** +// * Subtypes return an immutable variant of the ElementValueGen +// */ +// public abstract ElementValueGen getElementValue(); public int getElementValueType() { return type; @@ -62,7 +56,7 @@ public abstract class ElementValueGen { public static final int PRIMITIVE_SHORT = 'S'; public static final int PRIMITIVE_BOOLEAN= 'Z'; - public static ElementValueGen readElementValue(DataInputStream dis,ConstantPoolGen cpGen) throws IOException { + public static ElementValueGen readElementValue(DataInputStream dis,ConstantPool cpGen) throws IOException { int type= dis.readUnsignedByte(); switch (type) { case 'B': // byte @@ -89,32 +83,32 @@ public abstract class ElementValueGen { case 'c': // Class return new ClassElementValueGen(dis.readUnsignedShort(),cpGen); -// -// case '@': // Annotation -// return new AnnotationElementValueGen(ANNOTATION,Annotation.read(dis,cpGen),cpGen); -// -// case '[': // Array -// int numArrayVals = dis.readUnsignedShort(); -// List arrayVals = new ArrayList(); -// ElementValue[] evalues = new ElementValue[numArrayVals]; -// for (int j=0;j<numArrayVals;j++) { -// evalues[j] = ElementValue.readElementValue(dis,cpGen); -// } -// return new ArrayElementValue(ARRAY,evalues,cpGen); + + // FIXME should this be true here? or should it be the value for the containing annotation? + case '@': // Annotation + return new AnnotationElementValueGen(ANNOTATION,AnnotationGen.read(dis,cpGen,true),cpGen); + + case '[': // Array + int numArrayVals = dis.readUnsignedShort(); + ElementValueGen[] evalues = new ElementValueGen[numArrayVals]; + for (int j=0;j<numArrayVals;j++) { + evalues[j] = ElementValueGen.readElementValue(dis,cpGen); + } + return new ArrayElementValueGen(ARRAY,evalues,cpGen); default: throw new RuntimeException("Unexpected element value kind in annotation: "+type); } } - protected ConstantPoolGen getConstantPool() { + protected ConstantPool getConstantPool() { return cpGen; } /** * Creates an (modifiable) ElementValueGen copy of an (immutable) ElementValue - constant pool is assumed correct. */ - public static ElementValueGen copy(ElementValue value,ConstantPoolGen cpool,boolean copyPoolEntries) { + public static ElementValueGen copy(ElementValueGen value,ConstantPool cpool,boolean copyPoolEntries) { switch (value.getElementValueType()) { case 'B': // byte case 'C': // char @@ -125,19 +119,19 @@ public abstract class ElementValueGen { case 'S': // short case 'Z': // boolean case 's': // String - return new SimpleElementValueGen((SimpleElementValue)value,cpool,copyPoolEntries); + return new SimpleElementValueGen((SimpleElementValueGen)value,cpool,copyPoolEntries); case 'e': // Enum constant - return new EnumElementValueGen((EnumElementValue)value,cpool,copyPoolEntries); + return new EnumElementValueGen((EnumElementValueGen)value,cpool,copyPoolEntries); case '@': // Annotation - return new AnnotationElementValueGen((AnnotationElementValue)value,cpool,copyPoolEntries); + return new AnnotationElementValueGen((AnnotationElementValueGen)value,cpool,copyPoolEntries); case '[': // Array - return new ArrayElementValueGen((ArrayElementValue)value,cpool,copyPoolEntries); + return new ArrayElementValueGen((ArrayElementValueGen)value,cpool,copyPoolEntries); case 'c': // Class - return new ClassElementValueGen((ClassElementValue)value,cpool,copyPoolEntries); + return new ClassElementValueGen((ClassElementValueGen)value,cpool,copyPoolEntries); default: throw new RuntimeException("Not implemented yet! ("+value.getElementValueType()+")"); diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/EnumElementValue.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/EnumElementValue.java deleted file mode 100644 index 4960949e5..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/EnumElementValue.java +++ /dev/null @@ -1,69 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2004 IBM - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andy Clement - initial implementation {date} - * ******************************************************************/ - -package org.aspectj.apache.bcel.classfile.annotation; - -import java.io.DataOutputStream; -import java.io.IOException; - -import org.aspectj.apache.bcel.Constants; -import org.aspectj.apache.bcel.classfile.ConstantPool; -import org.aspectj.apache.bcel.classfile.ConstantUtf8; - - -public class EnumElementValue extends ElementValue { - - // For enum types, these two indices point to the type and value - private int typeIdx; - private int valueIdx; - - public EnumElementValue(int type,int typeIdx,int valueIdx,ConstantPool cpool) { - super(type,cpool); - if (type != ENUM_CONSTANT) - throw new RuntimeException("Only element values of type enum can be built with this ctor"); - this.typeIdx = typeIdx; - this.valueIdx= valueIdx; - } - - public void dump(DataOutputStream dos) throws IOException { - dos.writeByte(type); // u1 type of value (ENUM_CONSTANT == 'e') - dos.writeShort(typeIdx); // u2 - dos.writeShort(valueIdx); // u2 - } - - /** - * return signature and value, something like Lp/Color;RED - */ - public String stringifyValue() { - StringBuffer sb = new StringBuffer(); - ConstantUtf8 cu8 = (ConstantUtf8)cpool.getConstant(typeIdx,Constants.CONSTANT_Utf8); - sb.append(cu8.getBytes()); - cu8 = (ConstantUtf8)cpool.getConstant(valueIdx,Constants.CONSTANT_Utf8); - sb.append(cu8.getBytes()); - return sb.toString(); - } - - public String getEnumTypeString() { - ConstantUtf8 cu8 = (ConstantUtf8)cpool.getConstant(typeIdx,Constants.CONSTANT_Utf8); - return cu8.getBytes();//Utility.signatureToString(cu8.getBytes()); - } - - public String getEnumValueString() { - ConstantUtf8 cu8 = (ConstantUtf8)cpool.getConstant(valueIdx,Constants.CONSTANT_Utf8); - return cu8.getBytes(); - } - - public int getValueIndex() { return valueIdx;} - public int getTypeIndex() { return typeIdx; } - - -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/EnumElementValueGen.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/EnumElementValueGen.java index c3b2f333f..1f3e796df 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/EnumElementValueGen.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/EnumElementValueGen.java @@ -10,15 +10,14 @@ * Andy Clement - initial implementation {date} * ******************************************************************/ -package org.aspectj.apache.bcel.generic.annotation; +package org.aspectj.apache.bcel.classfile.annotation; import java.io.DataOutputStream; import java.io.IOException; +import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.classfile.ConstantUtf8; -import org.aspectj.apache.bcel.classfile.annotation.ElementValue; -import org.aspectj.apache.bcel.classfile.annotation.EnumElementValue; -import org.aspectj.apache.bcel.generic.ConstantPoolGen; +import org.aspectj.apache.bcel.classfile.ConstantPool; import org.aspectj.apache.bcel.generic.ObjectType; @@ -32,7 +31,7 @@ public class EnumElementValueGen extends ElementValueGen { * This ctor assumes the constant pool already contains the right type and value - * as indicated by typeIdx and valueIdx. This ctor is used for deserialization */ - protected EnumElementValueGen(int typeIdx,int valueIdx,ConstantPoolGen cpool) { + protected EnumElementValueGen(int typeIdx,int valueIdx,ConstantPool cpool) { super(ElementValueGen.ENUM_CONSTANT,cpool); if (type != ENUM_CONSTANT) throw new RuntimeException("Only element values of type enum can be built with this ctor"); @@ -40,21 +39,21 @@ public class EnumElementValueGen extends ElementValueGen { this.valueIdx= valueIdx; } - /** - * Return immutable variant of this EnumElementValue - */ - public ElementValue getElementValue() { - System.err.println("Duplicating value: "+getEnumTypeString()+":"+getEnumValueString()); - return new EnumElementValue(type,typeIdx,valueIdx,cpGen.getConstantPool()); - } +// /** +// * Return immutable variant of this EnumElementValue +// */ +// public ElementValueGen getElementValue() { +// System.err.println("Duplicating value: "+getEnumTypeString()+":"+getEnumValueString()); +// return new EnumElementValueGen(type,typeIdx,valueIdx,cpGen); +// } - public EnumElementValueGen(ObjectType t,String value,ConstantPoolGen cpool) { + public EnumElementValueGen(ObjectType t,String value,ConstantPool cpool) { super(ElementValueGen.ENUM_CONSTANT,cpool); typeIdx = cpool.addUtf8(t.getSignature());// was addClass(t); valueIdx= cpool.addUtf8(value);// was addString(value); } - public EnumElementValueGen(EnumElementValue value, ConstantPoolGen cpool, boolean copyPoolEntries) { + public EnumElementValueGen(EnumElementValueGen value, ConstantPool cpool, boolean copyPoolEntries) { super(ENUM_CONSTANT,cpool); if (copyPoolEntries) { typeIdx = cpool.addUtf8(value.getEnumTypeString());// was addClass(value.getEnumTypeString()); @@ -71,12 +70,18 @@ public class EnumElementValueGen extends ElementValueGen { dos.writeShort(valueIdx); // u2 } + /** + * return signature and value, something like Lp/Color;RED + */ public String stringifyValue() { - ConstantUtf8 cu8 = (ConstantUtf8)getConstantPool().getConstant(valueIdx); - return cu8.getBytes(); -// ConstantString cu8 = (ConstantString)getConstantPool().getConstant(valueIdx); -// return ((ConstantUtf8)getConstantPool().getConstant(cu8.getStringIndex())).getBytes(); + StringBuffer sb = new StringBuffer(); + ConstantUtf8 cu8 = (ConstantUtf8)cpGen.getConstant(typeIdx,Constants.CONSTANT_Utf8); + sb.append(cu8.getBytes()); + cu8 = (ConstantUtf8)cpGen.getConstant(valueIdx,Constants.CONSTANT_Utf8); + sb.append(cu8.getBytes()); + return sb.toString(); } + // BCELBUG: Should we need to call utility.signatureToString() on the output here? diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeAnnotations.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeAnnotations.java index c0d06aa82..86254b93b 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeAnnotations.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeAnnotations.java @@ -11,6 +11,7 @@ import java.util.List; import org.aspectj.apache.bcel.classfile.Attribute; import org.aspectj.apache.bcel.classfile.ConstantPool; + public abstract class RuntimeAnnotations extends Attribute { private List /*Annotation*/ annotations; @@ -48,13 +49,25 @@ public abstract class RuntimeAnnotations extends Attribute { annotation_data = new byte[length]; dis.read(annotation_data,0,length); } + + protected void writeAnnotations(DataOutputStream dos) throws IOException { + if (!inflated) { + dos.write(annotation_data,0,length); + } else { + dos.writeShort(annotations.size()); + for (Iterator i = annotations.iterator(); i.hasNext();) { + AnnotationGen ann = (AnnotationGen) i.next(); + ann.dump(dos); + } + } + } private void inflate() { try { DataInputStream dis = new DataInputStream(new ByteArrayInputStream(annotation_data)); int numberOfAnnotations = dis.readUnsignedShort(); for (int i = 0 ;i<numberOfAnnotations;i++) { - annotations.add(Annotation.read(dis,getConstantPool(),visible)); + annotations.add(AnnotationGen.read(dis,getConstantPool(),visible)); } dis.close(); inflated = true; @@ -63,18 +76,6 @@ public abstract class RuntimeAnnotations extends Attribute { } } - protected void writeAnnotations(DataOutputStream dos) throws IOException { - if (!inflated) { - dos.write(annotation_data,0,length); - } else { - dos.writeShort(annotations.size()); - for (Iterator i = annotations.iterator(); i.hasNext();) { - Annotation ann = (Annotation) i.next(); - ann.dump(dos); - } - } - } - /** FOR TESTING ONLY: Tells you if the annotations have been inflated to an object graph */ public boolean isInflated() { return inflated; diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisibleAnnotations.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisibleAnnotations.java index ab638438e..cb372b2c9 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisibleAnnotations.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisibleAnnotations.java @@ -7,7 +7,7 @@ import java.io.IOException; import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.classfile.Attribute; import org.aspectj.apache.bcel.classfile.ConstantPool; -import org.aspectj.apache.bcel.classfile.Visitor; +import org.aspectj.apache.bcel.classfile.ClassVisitor; public class RuntimeInvisibleAnnotations extends RuntimeAnnotations { @@ -25,7 +25,7 @@ public class RuntimeInvisibleAnnotations extends RuntimeAnnotations { super(Constants.ATTR_RUNTIME_INVISIBLE_ANNOTATIONS,false,nameIndex,len,rvaData,cpool); } - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitRuntimeInvisibleAnnotations(this); } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisibleParameterAnnotations.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisibleParameterAnnotations.java index 9d5a2ff7b..4fb4bb7bd 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisibleParameterAnnotations.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisibleParameterAnnotations.java @@ -6,7 +6,7 @@ import java.io.IOException; import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.classfile.Attribute; import org.aspectj.apache.bcel.classfile.ConstantPool; -import org.aspectj.apache.bcel.classfile.Visitor; +import org.aspectj.apache.bcel.classfile.ClassVisitor; public class RuntimeInvisibleParameterAnnotations extends RuntimeParameterAnnotations { @@ -24,7 +24,7 @@ public class RuntimeInvisibleParameterAnnotations extends RuntimeParameterAnnota super(Constants.ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS,false,nameIndex,len,rvaData,cpool); } - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitRuntimeInvisibleParameterAnnotations(this); } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeParameterAnnotations.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeParameterAnnotations.java index 5a90fe07c..1b93f6a86 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeParameterAnnotations.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeParameterAnnotations.java @@ -50,9 +50,9 @@ public abstract class RuntimeParameterAnnotations extends Attribute { return parameterAnnotations; } - public Annotation[] getAnnotationsOnParameter(int parameterIndex) { + public AnnotationGen[] getAnnotationsOnParameter(int parameterIndex) { if (!inflated) inflate(); - return (Annotation[])parameterAnnotations.get(parameterIndex); + return (AnnotationGen[])parameterAnnotations.get(parameterIndex); } public boolean areVisible() { @@ -70,9 +70,9 @@ public abstract class RuntimeParameterAnnotations extends Attribute { int numParameters = dis.readUnsignedByte(); for (int i=0; i<numParameters; i++) { int numAnnotations = dis.readUnsignedShort(); - Annotation[] annotations = new Annotation[numAnnotations]; + AnnotationGen[] annotations = new AnnotationGen[numAnnotations]; for (int j=0; j<numAnnotations; j++) { - annotations[j] = Annotation.read(dis,getConstantPool(),visible); + annotations[j] = AnnotationGen.read(dis,getConstantPool(),visible); } parameterAnnotations.add(annotations); } @@ -89,7 +89,7 @@ public abstract class RuntimeParameterAnnotations extends Attribute { } else { dos.writeByte(parameterAnnotations.size()); for (int i=0; i<parameterAnnotations.size(); i++) { - Annotation[] annotations = (Annotation[])parameterAnnotations.get(i); + AnnotationGen[] annotations = (AnnotationGen[])parameterAnnotations.get(i); dos.writeShort(annotations.length); for (int j=0; j<annotations.length;j++) { annotations[j].dump(dos); diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisibleAnnotations.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisibleAnnotations.java index e43c55b92..5d6e427d4 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisibleAnnotations.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisibleAnnotations.java @@ -7,7 +7,7 @@ import java.io.IOException; import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.classfile.Attribute; import org.aspectj.apache.bcel.classfile.ConstantPool; -import org.aspectj.apache.bcel.classfile.Visitor; +import org.aspectj.apache.bcel.classfile.ClassVisitor; public class RuntimeVisibleAnnotations extends RuntimeAnnotations { @@ -25,7 +25,7 @@ public class RuntimeVisibleAnnotations extends RuntimeAnnotations { super(Constants.ATTR_RUNTIME_VISIBLE_ANNOTATIONS,true,nameIndex,len,rvaData,cpool); } - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitRuntimeVisibleAnnotations(this); } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisibleParameterAnnotations.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisibleParameterAnnotations.java index 2da812920..b0eeea8bc 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisibleParameterAnnotations.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisibleParameterAnnotations.java @@ -6,7 +6,7 @@ import java.io.IOException; import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.classfile.Attribute; import org.aspectj.apache.bcel.classfile.ConstantPool; -import org.aspectj.apache.bcel.classfile.Visitor; +import org.aspectj.apache.bcel.classfile.ClassVisitor; public class RuntimeVisibleParameterAnnotations extends RuntimeParameterAnnotations { @@ -24,7 +24,7 @@ public class RuntimeVisibleParameterAnnotations extends RuntimeParameterAnnotati readParameterAnnotations(dis,cpool); } - public void accept(Visitor v) { + public void accept(ClassVisitor v) { v.visitRuntimeVisibleParameterAnnotations(this); } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/SimpleElementValue.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/SimpleElementValue.java deleted file mode 100644 index 37c6deaf3..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/SimpleElementValue.java +++ /dev/null @@ -1,169 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2004 IBM - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andy Clement - initial implementation {date} - * ******************************************************************/ - -package org.aspectj.apache.bcel.classfile.annotation; - -import java.io.DataOutputStream; -import java.io.IOException; - -import org.aspectj.apache.bcel.Constants; -import org.aspectj.apache.bcel.classfile.ConstantDouble; -import org.aspectj.apache.bcel.classfile.ConstantFloat; -import org.aspectj.apache.bcel.classfile.ConstantInteger; -import org.aspectj.apache.bcel.classfile.ConstantLong; -import org.aspectj.apache.bcel.classfile.ConstantPool; -import org.aspectj.apache.bcel.classfile.ConstantUtf8; - -/** - * An element value representing a primitive or string value. - */ -public class SimpleElementValue extends ElementValue { - - // For primitive types and string type, this points to the value entry in the cpool - // For 'class' this points to the class entry in the cpool - private int idx; - - public SimpleElementValue(int type,int idx,ConstantPool cpool) { - super(type,cpool); - this.idx = idx; - } - - public int getIndex() { - return idx; - } - - - public String getValueString() { - if (type != STRING) - throw new RuntimeException("Dont call getValueString() on a non STRING ElementValue"); - ConstantUtf8 c = (ConstantUtf8)cpool.getConstant(idx,Constants.CONSTANT_Utf8); - return c.getBytes(); - } - - public int getValueInt() { - if (type != PRIMITIVE_INT) - throw new RuntimeException("Dont call getValueString() on a non STRING ElementValue"); - ConstantInteger c = (ConstantInteger)cpool.getConstant(idx,Constants.CONSTANT_Integer); - return c.getBytes(); - } - - public byte getValueByte() { - if (type != PRIMITIVE_BYTE) - throw new RuntimeException("Dont call getValueByte() on a non BYTE ElementValue"); - ConstantInteger c = (ConstantInteger)cpool.getConstant(idx,Constants.CONSTANT_Integer); - return (byte)c.getBytes(); - } - - public char getValueChar() { - if (type != PRIMITIVE_CHAR) - throw new RuntimeException("Dont call getValueChar() on a non CHAR ElementValue"); - ConstantInteger c = (ConstantInteger)cpool.getConstant(idx,Constants.CONSTANT_Integer); - return (char)c.getBytes(); - } - - public long getValueLong() { - if (type != PRIMITIVE_LONG) - throw new RuntimeException("Dont call getValueLong() on a non LONG ElementValue"); - ConstantLong j = (ConstantLong)cpool.getConstant(idx); - return j.getBytes(); - } - - public float getValueFloat() { - if (type != PRIMITIVE_FLOAT) - throw new RuntimeException("Dont call getValueFloat() on a non FLOAT ElementValue"); - ConstantFloat f = (ConstantFloat)cpool.getConstant(idx); - return f.getBytes(); - } - - - public double getValueDouble() { - if (type != PRIMITIVE_DOUBLE) - throw new RuntimeException("Dont call getValueDouble() on a non DOUBLE ElementValue"); - ConstantDouble d = (ConstantDouble)cpool.getConstant(idx); - return d.getBytes(); - } - - public boolean getValueBoolean() { - if (type != PRIMITIVE_BOOLEAN) - throw new RuntimeException("Dont call getValueBoolean() on a non BOOLEAN ElementValue"); - ConstantInteger bo = (ConstantInteger)cpool.getConstant(idx); - return (bo.getBytes()!=0); - } - - public short getValueShort() { - if (type != PRIMITIVE_SHORT) - throw new RuntimeException("Dont call getValueShort() on a non SHORT ElementValue"); - ConstantInteger s = (ConstantInteger)cpool.getConstant(idx); - return (short)s.getBytes(); - } - - public String toString() { - return stringifyValue(); - } - - // Whatever kind of value it is, return it as a string - public String stringifyValue() { - switch (type) { - case PRIMITIVE_INT: - ConstantInteger c = (ConstantInteger)cpool.getConstant(idx,Constants.CONSTANT_Integer); - return Integer.toString(c.getBytes()); - case PRIMITIVE_LONG: - ConstantLong j = (ConstantLong)cpool.getConstant(idx,Constants.CONSTANT_Long); - return Long.toString(j.getBytes()); - case PRIMITIVE_DOUBLE: - ConstantDouble d = (ConstantDouble)cpool.getConstant(idx,Constants.CONSTANT_Double); - return Double.toString(d.getBytes()); - case PRIMITIVE_FLOAT: - ConstantFloat f = (ConstantFloat)cpool.getConstant(idx,Constants.CONSTANT_Float); - return Float.toString(f.getBytes()); - case PRIMITIVE_SHORT: - ConstantInteger s = (ConstantInteger)cpool.getConstant(idx,Constants.CONSTANT_Integer); - return Integer.toString(s.getBytes()); - case PRIMITIVE_BYTE: - ConstantInteger b = (ConstantInteger)cpool.getConstant(idx,Constants.CONSTANT_Integer); - return Integer.toString(b.getBytes()); - case PRIMITIVE_CHAR: - ConstantInteger ch = (ConstantInteger)cpool.getConstant(idx,Constants.CONSTANT_Integer); - return new Character((char)ch.getBytes()).toString(); - case PRIMITIVE_BOOLEAN: - ConstantInteger bo = (ConstantInteger)cpool.getConstant(idx,Constants.CONSTANT_Integer); - if (bo.getBytes() == 0) return "false"; - if (bo.getBytes() != 0) return "true"; - case STRING: - ConstantUtf8 cu8 = (ConstantUtf8)cpool.getConstant(idx,Constants.CONSTANT_Utf8); - return cu8.getBytes(); - - default: - throw new RuntimeException("SimpleElementValue class does not know how to stringify type "+type); - } - } - - public void dump(DataOutputStream dos) throws IOException { - dos.writeByte(type); // u1 kind of value - switch (type) { - case PRIMITIVE_INT: - case PRIMITIVE_BYTE: - case PRIMITIVE_CHAR: - case PRIMITIVE_FLOAT: - case PRIMITIVE_LONG: - case PRIMITIVE_BOOLEAN: - case PRIMITIVE_SHORT: - case PRIMITIVE_DOUBLE: - case STRING: - dos.writeShort(idx); - break; - default: - throw new RuntimeException("SimpleElementValue doesnt know how to write out type "+type); - } - } - -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/SimpleElementValueGen.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/SimpleElementValueGen.java index d6c46483f..b2891f95a 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/SimpleElementValueGen.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/SimpleElementValueGen.java @@ -10,7 +10,7 @@ * Andy Clement - initial implementation {date} * ******************************************************************/ -package org.aspectj.apache.bcel.generic.annotation; +package org.aspectj.apache.bcel.classfile.annotation; import java.io.DataOutputStream; import java.io.IOException; @@ -20,10 +20,8 @@ import org.aspectj.apache.bcel.classfile.ConstantFloat; import org.aspectj.apache.bcel.classfile.ConstantInteger; import org.aspectj.apache.bcel.classfile.ConstantLong; import org.aspectj.apache.bcel.classfile.ConstantUtf8; -import org.aspectj.apache.bcel.classfile.annotation.ElementValue; -import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValue; -import org.aspectj.apache.bcel.generic.ConstantPoolGen; - +import org.aspectj.apache.bcel.classfile.ConstantPool; +import org.aspectj.apache.bcel.Constants; public class SimpleElementValueGen extends ElementValueGen { @@ -39,63 +37,113 @@ public class SimpleElementValueGen extends ElementValueGen { * Protected ctor used for deserialization, doesn't *put* an entry in the constant pool, * assumes the one at the supplied index is correct. */ - protected SimpleElementValueGen(int type,int idx,ConstantPoolGen cpGen) { + protected SimpleElementValueGen(int type,int idx,ConstantPool cpGen) { super(type,cpGen); this.idx = idx; } - public SimpleElementValueGen(int type,ConstantPoolGen cpGen,int value) { + public SimpleElementValueGen(int type,ConstantPool cpGen,int value) { super(type,cpGen); idx = cpGen.addInteger(value); } - public SimpleElementValueGen(int type,ConstantPoolGen cpGen,long value) { + public SimpleElementValueGen(int type,ConstantPool cpGen,long value) { super(type,cpGen); idx = cpGen.addLong(value); } - public SimpleElementValueGen(int type,ConstantPoolGen cpGen,double value) { + public SimpleElementValueGen(int type,ConstantPool cpGen,double value) { super(type,cpGen); idx = cpGen.addDouble(value); } - public SimpleElementValueGen(int type,ConstantPoolGen cpGen,float value) { + public SimpleElementValueGen(int type,ConstantPool cpGen,float value) { super(type,cpGen); idx = cpGen.addFloat(value); } - public SimpleElementValueGen(int type,ConstantPoolGen cpGen,short value) { + public SimpleElementValueGen(int type,ConstantPool cpGen,short value) { super(type,cpGen); idx = cpGen.addInteger(value); } - public SimpleElementValueGen(int type,ConstantPoolGen cpGen,byte value) { + public SimpleElementValueGen(int type,ConstantPool cpGen,byte value) { super(type,cpGen); idx = cpGen.addInteger(value); } - public SimpleElementValueGen(int type,ConstantPoolGen cpGen,char value) { + public SimpleElementValueGen(int type,ConstantPool cpGen,char value) { super(type,cpGen); idx = cpGen.addInteger(value); } - public SimpleElementValueGen(int type,ConstantPoolGen cpGen,boolean value) { + public SimpleElementValueGen(int type,ConstantPool cpGen,boolean value) { super(type,cpGen); if (value) idx = cpGen.addInteger(1); else idx = cpGen.addInteger(0); } - public SimpleElementValueGen(int type,ConstantPoolGen cpGen,String value) { + public SimpleElementValueGen(int type,ConstantPool cpGen,String value) { super(type,cpGen); idx = cpGen.addUtf8(value); } + + public byte getValueByte() { + if (type != PRIMITIVE_BYTE) + throw new RuntimeException("Dont call getValueByte() on a non BYTE ElementValue"); + ConstantInteger c = (ConstantInteger)cpGen.getConstant(idx,Constants.CONSTANT_Integer); + return (byte)c.getBytes(); + } + + public char getValueChar() { + if (type != PRIMITIVE_CHAR) + throw new RuntimeException("Dont call getValueChar() on a non CHAR ElementValue"); + ConstantInteger c = (ConstantInteger)cpGen.getConstant(idx,Constants.CONSTANT_Integer); + return (char)c.getBytes(); + } + + public long getValueLong() { + if (type != PRIMITIVE_LONG) + throw new RuntimeException("Dont call getValueLong() on a non LONG ElementValue"); + ConstantLong j = (ConstantLong)cpGen.getConstant(idx); + return j.getBytes(); + } + + public float getValueFloat() { + if (type != PRIMITIVE_FLOAT) + throw new RuntimeException("Dont call getValueFloat() on a non FLOAT ElementValue"); + ConstantFloat f = (ConstantFloat)cpGen.getConstant(idx); + return f.getBytes(); + } + + + public double getValueDouble() { + if (type != PRIMITIVE_DOUBLE) + throw new RuntimeException("Dont call getValueDouble() on a non DOUBLE ElementValue"); + ConstantDouble d = (ConstantDouble)cpGen.getConstant(idx); + return d.getBytes(); + } + + public boolean getValueBoolean() { + if (type != PRIMITIVE_BOOLEAN) + throw new RuntimeException("Dont call getValueBoolean() on a non BOOLEAN ElementValue"); + ConstantInteger bo = (ConstantInteger)cpGen.getConstant(idx); + return (bo.getBytes()!=0); + } + + public short getValueShort() { + if (type != PRIMITIVE_SHORT) + throw new RuntimeException("Dont call getValueShort() on a non SHORT ElementValue"); + ConstantInteger s = (ConstantInteger)cpGen.getConstant(idx); + return (short)s.getBytes(); + } /** * The boolean controls whether we copy info from the 'old' constant pool * to the 'new'. You need to use this ctor if the annotation is * being copied from one file to another. */ - public SimpleElementValueGen(SimpleElementValue value,ConstantPoolGen cpool,boolean copyPoolEntries) { + public SimpleElementValueGen(SimpleElementValueGen value,ConstantPool cpool,boolean copyPoolEntries) { super(value.getElementValueType(),cpool); if (!copyPoolEntries) { // J5ASSERT: Could assert value.stringifyValue() is the same as @@ -125,8 +173,8 @@ public class SimpleElementValueGen extends ElementValueGen { /** * Return immutable variant */ - public ElementValue getElementValue() { - return new SimpleElementValue(type,idx,cpGen.getConstantPool()); + public ElementValueGen getElementValue() { + return new SimpleElementValueGen(type,idx,cpGen); } public int getIndex() { @@ -170,7 +218,7 @@ public class SimpleElementValueGen extends ElementValueGen { return Integer.toString(b.getBytes()); case PRIMITIVE_CHAR: ConstantInteger ch = (ConstantInteger)cpGen.getConstant(idx); - return Integer.toString(ch.getBytes()); + return new Character((char)ch.getBytes()).toString(); case PRIMITIVE_BOOLEAN: ConstantInteger bo = (ConstantInteger)cpGen.getConstant(idx); if (bo.getBytes() == 0) return "false"; diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/package.html b/bcel-builder/src/org/aspectj/apache/bcel/classfile/package.html deleted file mode 100644 index 6a7a856fd..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/package.html +++ /dev/null @@ -1,14 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- -$Id: package.html,v 1.6 2008/04/25 17:58:22 aclement Exp $ ---> -</head> -<body bgcolor="white"> -<p> -This package contains the classes that describe the structure of a -Java class file and a class file parser. -</p> -</body> -</html> diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/AALOAD.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/AALOAD.java deleted file mode 100644 index e27a96b11..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/AALOAD.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * AALOAD - Load reference from array - * <PRE>Stack: ..., arrayref, index -> value</PRE> - * - * @version $Id: AALOAD.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class AALOAD extends ArrayInstruction implements StackProducer { - /** Load reference from array - */ - public AALOAD() { - super(org.aspectj.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); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/AASTORE.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/AASTORE.java deleted file mode 100644 index dd45cf14a..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/AASTORE.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * AASTORE - Store into reference array - * <PRE>Stack: ..., arrayref, index, value -> ...</PRE> - * - * @version $Id: AASTORE.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class AASTORE extends ArrayInstruction implements StackConsumer { - /** Store into reference array - */ - public AASTORE() { - super(org.aspectj.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); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ACONST_NULL.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ACONST_NULL.java deleted file mode 100644 index 8182e3ee7..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ACONST_NULL.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * ACONST_NULL - Push null reference - * <PRE>Stack: ... -> ..., null</PRE> - * - * @version $Id: ACONST_NULL.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class ACONST_NULL extends Instruction - implements PushInstruction, TypedInstruction { - /** - * Push null reference - */ - public ACONST_NULL() { - super(org.aspectj.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); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ALOAD.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ALOAD.java deleted file mode 100644 index 7532331a6..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ALOAD.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * ALOAD - Load reference from local variable - * <PRE>Stack: ... -> ..., objectref</PRE> - * - * @version $Id: ALOAD.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">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.aspectj.apache.bcel.Constants.ALOAD, org.aspectj.apache.bcel.Constants.ALOAD_0); - } - - /** Load reference from local variable - * @param n index of local variable - */ - public ALOAD(int n) { - super(org.aspectj.apache.bcel.Constants.ALOAD, org.aspectj.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); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ANEWARRAY.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ANEWARRAY.java deleted file mode 100644 index c6e671eb9..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ANEWARRAY.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ -import org.aspectj.apache.bcel.ExceptionConstants; - -/** - * ANEWARRAY - Create new array of references - * <PRE>Stack: ..., count -> ..., arrayref</PRE> - * - * @version $Id: ANEWARRAY.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class ANEWARRAY extends CPInstruction - implements LoadClass, AllocationInstruction, ExceptionThrower, StackProducer { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - ANEWARRAY() {} - - public ANEWARRAY(int index) { - super(org.aspectj.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; - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ARETURN.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ARETURN.java deleted file mode 100644 index 586779572..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ARETURN.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * ARETURN - Return reference from method - * <PRE>Stack: ..., objectref -> <empty></PRE> - * - * @version $Id: ARETURN.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class ARETURN extends ReturnInstruction { - /** - * Return reference from method - */ - public ARETURN() { - super(org.aspectj.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); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ARRAYLENGTH.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ARRAYLENGTH.java deleted file mode 100644 index 23b095ca5..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ARRAYLENGTH.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * ARRAYLENGTH - Get length of array - * <PRE>Stack: ..., arrayref -> ..., length</PRE> - * - * @version $Id: ARRAYLENGTH.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class ARRAYLENGTH extends Instruction - implements ExceptionThrower, StackProducer { - /** Get length of array - */ - public ARRAYLENGTH() { - super(org.aspectj.apache.bcel.Constants.ARRAYLENGTH, (short)1); - } - - /** @return exceptions this instruction may cause - */ - public Class[] getExceptions() { - return new Class[] { org.aspectj.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); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ASTORE.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ASTORE.java deleted file mode 100644 index fc6a578f1..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ASTORE.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * ASTORE - Store reference into local variable - * <PRE>Stack ..., objectref -> ... </PRE> - * - * @version $Id: ASTORE.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">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.aspectj.apache.bcel.Constants.ASTORE, org.aspectj.apache.bcel.Constants.ASTORE_0); - } - - /** Store reference into local variable - * @param n index of local variable - */ - public ASTORE(int n) { - super(org.aspectj.apache.bcel.Constants.ASTORE, org.aspectj.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); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ATHROW.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ATHROW.java deleted file mode 100644 index 1ad434b8e..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ATHROW.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * ATHROW - Throw exception - * <PRE>Stack: ..., objectref -> objectref</PRE> - * - * @version $Id: ATHROW.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class ATHROW extends Instruction implements UnconditionalBranch, ExceptionThrower { - /** - * Throw exception - */ - public ATHROW() { - super(org.aspectj.apache.bcel.Constants.ATHROW, (short)1); - } - - /** @return exceptions this instruction may cause - */ - public Class[] getExceptions() { - return new Class[] { org.aspectj.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); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/AllocationInstruction.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/AllocationInstruction.java deleted file mode 100644 index 6111ea5ae..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/AllocationInstruction.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Denote family of instructions that allocates space in the heap. - * - * @version $Id: AllocationInstruction.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public interface AllocationInstruction {} - diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ArithmeticInstruction.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ArithmeticInstruction.java deleted file mode 100644 index ff39fe850..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ArithmeticInstruction.java +++ /dev/null @@ -1,106 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ -import org.aspectj.apache.bcel.Constants; -/** - * Super class for the family of arithmetic instructions. - * - * @version $Id: ArithmeticInstruction.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">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; - - default: // Never reached - throw new ClassGenException("Unknown type " + opcode); - } - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ArrayInstruction.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ArrayInstruction.java deleted file mode 100644 index fc68fea79..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ArrayInstruction.java +++ /dev/null @@ -1,106 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Super class for instructions dealing with array access such as IALOAD. - * - * @version $Id: ArrayInstruction.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">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.aspectj.apache.bcel.ExceptionConstants.EXCS_ARRAY_EXCEPTION; - } - - /** @return type associated with the instruction - */ - public Type getType(ConstantPoolGen cp) { - switch(opcode) { - case org.aspectj.apache.bcel.Constants.IALOAD: case org.aspectj.apache.bcel.Constants.IASTORE: - return Type.INT; - case org.aspectj.apache.bcel.Constants.CALOAD: case org.aspectj.apache.bcel.Constants.CASTORE: - return Type.CHAR; - case org.aspectj.apache.bcel.Constants.BALOAD: case org.aspectj.apache.bcel.Constants.BASTORE: - return Type.BYTE; - case org.aspectj.apache.bcel.Constants.SALOAD: case org.aspectj.apache.bcel.Constants.SASTORE: - return Type.SHORT; - case org.aspectj.apache.bcel.Constants.LALOAD: case org.aspectj.apache.bcel.Constants.LASTORE: - return Type.LONG; - case org.aspectj.apache.bcel.Constants.DALOAD: case org.aspectj.apache.bcel.Constants.DASTORE: - return Type.DOUBLE; - case org.aspectj.apache.bcel.Constants.FALOAD: case org.aspectj.apache.bcel.Constants.FASTORE: - return Type.FLOAT; - case org.aspectj.apache.bcel.Constants.AALOAD: case org.aspectj.apache.bcel.Constants.AASTORE: - return Type.OBJECT; - - default: throw new ClassGenException("Oops: unknown case in switch" + opcode); - } - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ArrayType.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ArrayType.java index e937a7c1d..65cd88ded 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ArrayType.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/ArrayType.java @@ -58,7 +58,7 @@ import org.aspectj.apache.bcel.Constants; /** * Denotes array type, such as int[][] * - * @version $Id: ArrayType.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: ArrayType.java,v 1.3 2008/05/28 23:52:57 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public final class ArrayType extends ReferenceType { diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/BALOAD.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/BALOAD.java deleted file mode 100644 index fe48c3ae3..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/BALOAD.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * BALOAD - Load byte or boolean from array - * <PRE>Stack: ..., arrayref, index -> ..., value</PRE> - * - * @version $Id: BALOAD.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class BALOAD extends ArrayInstruction implements StackProducer { - /** Load byte or boolean from array - */ - public BALOAD() { - super(org.aspectj.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); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/BASTORE.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/BASTORE.java deleted file mode 100644 index 265f5e6ca..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/BASTORE.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * BASTORE - Store into byte or boolean array - * <PRE>Stack: ..., arrayref, index, value -> ...</PRE> - * - * @version $Id: BASTORE.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class BASTORE extends ArrayInstruction implements StackConsumer { - /** Store byte or boolean into array - */ - public BASTORE() { - super(org.aspectj.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); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/BIPUSH.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/BIPUSH.java deleted file mode 100644 index 12af9c85a..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/BIPUSH.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -import java.io.*; -import org.aspectj.apache.bcel.util.ByteSequence; - -/** - * BIPUSH - Push byte on stack - * - * <PRE>Stack: ... -> ..., value</PRE> - * - * @version $Id: BIPUSH.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">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.aspectj.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); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/BREAKPOINT.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/BREAKPOINT.java deleted file mode 100644 index a0c45f61c..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/BREAKPOINT.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * BREAKPOINT, JVM dependent, ignored by default - * - * @version $Id: BREAKPOINT.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class BREAKPOINT extends Instruction { - public BREAKPOINT() { - super(org.aspectj.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); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/BasicType.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/BasicType.java index d4a57a05f..1d2f4daa5 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/BasicType.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/BasicType.java @@ -58,7 +58,7 @@ import org.aspectj.apache.bcel.Constants; /** * Denotes basic type such as int. * - * @version $Id: BasicType.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: BasicType.java,v 1.3 2008/05/28 23:52:57 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public final class BasicType extends Type { diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/BranchHandle.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/BranchHandle.java index 74788f5ea..c735075a4 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/BranchHandle.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/BranchHandle.java @@ -63,21 +63,18 @@ package org.aspectj.apache.bcel.generic; * @see InstructionHandle * @see Instruction * @see InstructionList - * @version $Id: BranchHandle.java,v 1.3 2007/05/22 09:11:40 aclement Exp $ + * @version $Id: BranchHandle.java,v 1.4 2008/05/28 23:52:55 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public final class BranchHandle extends InstructionHandle { - private BranchInstruction bi; // An alias in fact, but saves lots of casts + private InstructionBranch bi; // An alias in fact, but saves lots of casts - private BranchHandle(BranchInstruction i) { + private BranchHandle(InstructionBranch i) { super(i); bi = i; } - /** Factory methods. - */ - - static final BranchHandle getBranchHandle(BranchInstruction i) { + static final BranchHandle getBranchHandle(InstructionBranch i) { return new BranchHandle(i); } @@ -85,15 +82,15 @@ public final class BranchHandle extends InstructionHandle { * Through this overriding all access to the private i_position field should * be prevented. */ - public int getPosition() { return bi.position; } + public int getPosition() { return bi.positionOfThisInstruction; } void setPosition(int pos) { - i_position = bi.position = pos; + i_position = bi.positionOfThisInstruction = pos; } protected int updatePosition(int offset, int max_offset) { int x = bi.updatePosition(offset, max_offset); - i_position = bi.position; + i_position = bi.positionOfThisInstruction; return x; } @@ -124,11 +121,11 @@ public final class BranchHandle extends InstructionHandle { public void setInstruction(Instruction i) { super.setInstruction(i); - if(!(i instanceof BranchInstruction)) + if(!(i instanceof InstructionBranch)) throw new ClassGenException("Assigning " + i + " to branch handle which is not a branch instruction"); - bi = (BranchInstruction)i; + bi = (InstructionBranch)i; } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/BranchInstruction.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/BranchInstruction.java deleted file mode 100644 index f6dc3608a..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/BranchInstruction.java +++ /dev/null @@ -1,246 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -import java.io.*; -import org.aspectj.apache.bcel.util.ByteSequence; - -/** - * Abstract super class for branching instructions like GOTO, IFEQ, etc.. - * Branch instructions may have a variable length, namely GOTO, JSR, - * LOOKUPSWITCH and TABLESWITCH. - * - * @see InstructionList - * @version $Id: BranchInstruction.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">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 opcodee 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; - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/CALOAD.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/CALOAD.java deleted file mode 100644 index ba05a2f5a..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/CALOAD.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * CALOAD - Load char from array - * <PRE>Stack: ..., arrayref, index -> ..., value</PRE> - * - * @version $Id: CALOAD.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class CALOAD extends ArrayInstruction implements StackProducer { - /** Load char from array - */ - public CALOAD() { - super(org.aspectj.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); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/CASTORE.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/CASTORE.java deleted file mode 100644 index 10014cdac..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/CASTORE.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * CASTORE - Store into char array - * <PRE>Stack: ..., arrayref, index, value -> ...</PRE> - * - * @version $Id: CASTORE.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class CASTORE extends ArrayInstruction implements StackConsumer { - /** Store char into array - */ - public CASTORE() { - super(org.aspectj.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); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/CHECKCAST.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/CHECKCAST.java deleted file mode 100644 index 2d2fa6574..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/CHECKCAST.java +++ /dev/null @@ -1,117 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ -import org.aspectj.apache.bcel.ExceptionConstants; -/** - * CHECKCAST - Check whether object is of given type - * <PRE>Stack: ..., objectref -> ..., objectref</PRE> - * - * @version $Id: CHECKCAST.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">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 n index to class in constant pool - */ - public CHECKCAST(int index) { - super(org.aspectj.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); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ClassGen.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ClassGen.java index ee0c7d1bc..4396c2d04 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ClassGen.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/ClassGen.java @@ -66,7 +66,7 @@ import java.util.Iterator; import java.util.List; import org.aspectj.apache.bcel.Constants; -import org.aspectj.apache.bcel.classfile.AccessFlags; +import org.aspectj.apache.bcel.classfile.Modifiers; import org.aspectj.apache.bcel.classfile.Attribute; import org.aspectj.apache.bcel.classfile.ConstantPool; import org.aspectj.apache.bcel.classfile.Field; @@ -74,34 +74,31 @@ import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.Method; import org.aspectj.apache.bcel.classfile.SourceFile; import org.aspectj.apache.bcel.classfile.Utility; -import org.aspectj.apache.bcel.classfile.annotation.Annotation; +import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisibleAnnotations; import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleAnnotations; -import org.aspectj.apache.bcel.generic.annotation.AnnotationGen; /** * Template class for building up a java class. May be initialized with an * existing java class (file). * * @see JavaClass - * @version $Id: ClassGen.java,v 1.8 2006/08/22 07:34:50 aclement Exp $ + * @version $Id: ClassGen.java,v 1.9 2008/05/28 23:52:58 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * * Upgraded, Andy Clement 9th Mar 06 - calculates SUID */ -public class ClassGen extends AccessFlags implements Cloneable { - /* Corresponds to the fields found in a JavaClass object. - */ +public class ClassGen extends Modifiers implements Cloneable { + private String class_name, super_class_name, file_name; private int class_name_index = -1, superclass_name_index = -1; private int major = Constants.MAJOR_1_1, minor = Constants.MINOR_1_1; - private ConstantPoolGen cp; // Template for building up constant pool + private ConstantPool cp; - // ArrayLists instead of arrays to gather fields, methods, etc. private ArrayList field_vec = new ArrayList(); private ArrayList method_vec = new ArrayList(); - private ArrayList attribute_vec = new ArrayList(); + private ArrayList attributesList = new ArrayList(); private ArrayList interface_vec = new ArrayList(); private ArrayList annotation_vec= new ArrayList(); private boolean unpackedAnnotations = false; @@ -116,24 +113,25 @@ public class ClassGen extends AccessFlags implements Cloneable { * @param cp constant pool to use */ public ClassGen(String class_name, String super_class_name, String file_name, - int access_flags, String[] interfaces, ConstantPoolGen cp) { + int access_flags, String[] interfaces, ConstantPool cp) { this.class_name = class_name; this.super_class_name = super_class_name; this.file_name = file_name; - this.access_flags = access_flags; + this.modifiers = access_flags; this.cp = cp; // Put everything needed by default into the constant pool and the vectors - if(file_name != null) - addAttribute(new SourceFile(cp.addUtf8("SourceFile"), 2, - cp.addUtf8(file_name), cp.getConstantPool())); + if (file_name != null) { + addAttribute(new SourceFile(cp.addUtf8("SourceFile"), 2, cp.addUtf8(file_name), cp)); + } class_name_index = cp.addClass(class_name); superclass_name_index = cp.addClass(super_class_name); - if(interfaces != null) + if (interfaces != null) { for(int i=0; i < interfaces.length; i++) - addInterface(interfaces[i]); + addInterface(interfaces[i]); + } } /** Convenience constructor to set up some important values initially. @@ -147,7 +145,7 @@ public class ClassGen extends AccessFlags implements Cloneable { public ClassGen(String class_name, String super_class_name, String file_name, int access_flags, String[] interfaces) { this(class_name, super_class_name, file_name, access_flags, interfaces, - new ConstantPoolGen()); + new ConstantPool()); } /** @@ -160,8 +158,8 @@ public class ClassGen extends AccessFlags implements Cloneable { class_name = clazz.getClassName(); super_class_name = clazz.getSuperclassName(); file_name = clazz.getSourceFileName(); - access_flags = clazz.getAccessFlags(); - cp = new ConstantPoolGen(clazz.getConstantPool()); + modifiers = clazz.getModifiers(); + cp = clazz.getConstantPool().copy(); major = clazz.getMajor(); minor = clazz.getMinor(); @@ -175,6 +173,7 @@ public class ClassGen extends AccessFlags implements Cloneable { for(int i=0; i < interfaces.length; i++) addInterface(interfaces[i]); + //Attribute[] attrs = attributes.getAttributes(); for(int i=0; i < attributes.length; i++) { // Dont add attributes for annotations as those will have been unpacked if (annotations.length==0) { @@ -207,14 +206,14 @@ public class ClassGen extends AccessFlags implements Cloneable { RuntimeVisibleAnnotations rva = (RuntimeVisibleAnnotations)attr; List annos = rva.getAnnotations(); for (Iterator iter = annos.iterator(); iter.hasNext();) { - Annotation a = (Annotation) iter.next(); + AnnotationGen a = (AnnotationGen) iter.next(); annotationGenObjs.add(new AnnotationGen(a,getConstantPool(),false)); } } else if (attr instanceof RuntimeInvisibleAnnotations) { RuntimeInvisibleAnnotations ria = (RuntimeInvisibleAnnotations)attr; List annos = ria.getAnnotations(); for (Iterator iter = annos.iterator(); iter.hasNext();) { - Annotation a = (Annotation) iter.next(); + AnnotationGen a = (AnnotationGen) iter.next(); annotationGenObjs.add(new AnnotationGen(a,getConstantPool(),false)); } } @@ -230,22 +229,23 @@ public class ClassGen extends AccessFlags implements Cloneable { Field[] fields = getFields(); Method[] methods = getMethods(); + // OPTIMIZE sort out this mangling of arrays and collections Attribute[] attributes = null; if (annotation_vec.size()==0) { attributes = getAttributes(); } else { // TODO: Sometime later, trash any attributes called 'RuntimeVisibleAnnotations' or 'RuntimeInvisibleAnnotations' Attribute[] annAttributes = Utility.getAnnotationAttributes(cp,annotation_vec); - attributes = new Attribute[attribute_vec.size()+annAttributes.length]; - attribute_vec.toArray(attributes); - System.arraycopy(annAttributes,0,attributes,attribute_vec.size(),annAttributes.length); + attributes = new Attribute[attributesList.size()+annAttributes.length]; + attributesList.toArray(attributes); + System.arraycopy(annAttributes,0,attributes,attributesList.size(),annAttributes.length); } // Must be last since the above calls may still add something to it ConstantPool cp = this.cp.getFinalConstantPool(); return new JavaClass(class_name_index, superclass_name_index, - file_name, major, minor, access_flags, + file_name, major, minor, modifiers, cp, interfaces, fields, methods, attributes); } @@ -293,7 +293,7 @@ public class ClassGen extends AccessFlags implements Cloneable { * Add an attribute to this class. * @param a attribute to add */ - public void addAttribute(Attribute a) { attribute_vec.add(a); } + public void addAttribute(Attribute a) { attributesList.add(a); } public void addAnnotation(AnnotationGen a) { annotation_vec.add(a); } /** @@ -311,8 +311,7 @@ public class ClassGen extends AccessFlags implements Cloneable { public void addEmptyConstructor(int access_flags) { InstructionList il = new InstructionList(); il.append(InstructionConstants.THIS); // Push `this' - il.append(new INVOKESPECIAL(cp.addMethodref(super_class_name, - "<init>", "()V"))); + il.append(new InvokeInstruction(Constants.INVOKESPECIAL,cp.addMethodref(super_class_name,"<init>", "()V"))); il.append(InstructionConstants.RETURN); MethodGen mg = new MethodGen(access_flags, Type.VOID, Type.NO_ARGS, null, @@ -358,7 +357,7 @@ public class ClassGen extends AccessFlags implements Cloneable { * Remove an attribute from this class. * @param a attribute to remove */ - public void removeAttribute(Attribute a) { attribute_vec.remove(a); } + public void removeAttribute(Attribute a) { attributesList.remove(a); } public void removeAnnotation(AnnotationGen a) {annotation_vec.remove(a);} /** @@ -376,7 +375,7 @@ public class ClassGen extends AccessFlags implements Cloneable { int i = method_vec.indexOf(old); - if(i < 0) + if (i < 0) method_vec.add(new_); else method_vec.set(i, new_); @@ -429,6 +428,12 @@ public class ClassGen extends AccessFlags implements Cloneable { addMethod(methods[m]); } + public void setFields(Field[] fs) { + field_vec.clear(); + for(int m=0; m<fs.length; m++) + addField(fs[m]); + } + public void setMethodAt(Method method, int pos) { method_vec.set(pos, method); } @@ -462,8 +467,8 @@ public class ClassGen extends AccessFlags implements Cloneable { } public Attribute[] getAttributes() { - Attribute[] attributes = new Attribute[attribute_vec.size()]; - attribute_vec.toArray(attributes); + Attribute[] attributes = new Attribute[attributesList.size()]; + attributesList.toArray(attributes); return attributes; } @@ -474,20 +479,20 @@ public class ClassGen extends AccessFlags implements Cloneable { return annotations; } - public ConstantPoolGen getConstantPool() { return cp; } - public void setConstantPool(ConstantPoolGen constant_pool) { + public ConstantPool getConstantPool() { return cp; } + public void setConstantPool(ConstantPool constant_pool) { cp = constant_pool; } public void setClassNameIndex(int class_name_index) { this.class_name_index = class_name_index; - class_name = cp.getConstantPool(). + class_name = cp. getConstantString(class_name_index, Constants.CONSTANT_Class).replace('/', '.'); } public void setSuperclassNameIndex(int superclass_name_index) { this.superclass_name_index = superclass_name_index; - super_class_name = cp.getConstantPool(). + super_class_name = cp. getConstantString(superclass_name_index, Constants.CONSTANT_Class).replace('/', '.'); } @@ -495,34 +500,6 @@ public class ClassGen extends AccessFlags implements Cloneable { public int getClassNameIndex() { return class_name_index; } - private ArrayList observers; - - /** Add observer for this object. - */ - public void addObserver(ClassObserver o) { - if(observers == null) - observers = new ArrayList(); - - observers.add(o); - } - - /** Remove observer for this object. - */ - public void removeObserver(ClassObserver o) { - if(observers != null) - observers.remove(o); - } - - /** Call notify() method on all observers. This method is not called - * automatically whenever the state has changed, but has to be - * called by the user after he has finished editing the object. - */ - public void update() { - if(observers != null) - for(Iterator e = observers.iterator(); e.hasNext(); ) - ((ClassObserver)e.next()).notify(this); - } - public Object clone() { try { return super.clone(); @@ -538,14 +515,14 @@ public class ClassGen extends AccessFlags implements Cloneable { * Returns true if this class represents an annotation type */ public final boolean isAnnotation() { - return (access_flags & Constants.ACC_ANNOTATION) != 0; + return (modifiers & Constants.ACC_ANNOTATION) != 0; } /** * Returns true if this class represents an enum type */ public final boolean isEnum() { - return (access_flags & Constants.ACC_ENUM) != 0; + return (modifiers & Constants.ACC_ENUM) != 0; } /** @@ -704,4 +681,20 @@ public class ClassGen extends AccessFlags implements Cloneable { return m1.getSignature().compareTo(m2.getSignature()); } } + + public boolean hasAttribute(String attributeName) { + for (Iterator iter = attributesList.iterator(); iter.hasNext();) { + Attribute attr = (Attribute) iter.next(); + if (attr.getName().equals(attributeName)) return true; + } + return false; + } + + public Attribute getAttribute(String attributeName) { + for (Iterator iter = attributesList.iterator(); iter.hasNext();) { + Attribute attr = (Attribute) iter.next(); + if (attr.getName().equals(attributeName)) return attr; + } + return null; + } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ClassGenException.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ClassGenException.java index 827da3080..b981dc8dc 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ClassGenException.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/ClassGenException.java @@ -58,7 +58,7 @@ package org.aspectj.apache.bcel.generic; * Thrown on internal errors. Extends RuntimeException so it hasn't to be declared * in the throws clause every time. * - * @version $Id: ClassGenException.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: ClassGenException.java,v 1.3 2008/05/28 23:52:57 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public class ClassGenException extends RuntimeException { diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ClassObserver.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ClassObserver.java deleted file mode 100644 index a52b5fc7a..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ClassObserver.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Implement this interface if you're interested in changes to a ClassGen object - * and register yourself with addObserver(). - * - * @version $Id: ClassObserver.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public interface ClassObserver { - public void notify(ClassGen clazz); -} - diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/CodeExceptionGen.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/CodeExceptionGen.java index 62c02ea49..01b839207 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/CodeExceptionGen.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/CodeExceptionGen.java @@ -55,6 +55,7 @@ package org.aspectj.apache.bcel.generic; */ import org.aspectj.apache.bcel.classfile.CodeException; +import org.aspectj.apache.bcel.classfile.ConstantPool; /** * This class represents an exception handler, i.e., specifies the region where @@ -65,7 +66,7 @@ import org.aspectj.apache.bcel.classfile.CodeException; * The end of the region is automatically mapped to be exclusive when calling * getCodeException(), i.e., there is no difference semantically. * - * @version $Id: CodeExceptionGen.java,v 1.4 2004/11/22 08:31:27 aclement Exp $ + * @version $Id: CodeExceptionGen.java,v 1.5 2008/05/28 23:52:56 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see MethodGen * @see CodeException @@ -104,7 +105,7 @@ public final class CodeExceptionGen * * @param cp constant pool */ - public CodeException getCodeException(ConstantPoolGen cp) { + public CodeException getCodeException(ConstantPool cp) { return new CodeException(start_pc.getPosition(), end_pc.getPosition() + end_pc.getInstruction().getLength(), handler_pc.getPosition(), @@ -115,7 +116,7 @@ public final class CodeExceptionGen * @param start_pc Start of handled region (inclusive) */ public void setStartPC(InstructionHandle start_pc) { - BranchInstruction.notifyTarget(this.start_pc, start_pc, this); + InstructionBranch.notifyTarget(this.start_pc, start_pc, this); this.start_pc = start_pc; } @@ -123,7 +124,7 @@ public final class CodeExceptionGen * @param end_pc End of handled region (inclusive) */ public void setEndPC(InstructionHandle end_pc) { - BranchInstruction.notifyTarget(this.end_pc, end_pc, this); + InstructionBranch.notifyTarget(this.end_pc, end_pc, this); this.end_pc = end_pc; } @@ -131,7 +132,7 @@ public final class CodeExceptionGen * @param handler_pc Start of handler */ public void setHandlerPC(InstructionHandle handler_pc) { - BranchInstruction.notifyTarget(this.handler_pc, handler_pc, this); + InstructionBranch.notifyTarget(this.handler_pc, handler_pc, this); this.handler_pc = handler_pc; } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/CompoundInstruction.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/CompoundInstruction.java deleted file mode 100644 index 243d87e42..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/CompoundInstruction.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Wrapper class for `compound' operations, virtual instructions that - * don't exist as byte code, but give a useful meaning. For example, - * the (virtual) PUSH instruction takes an arbitray argument and produces the - * appropiate code at dump time (ICONST, LDC, BIPUSH, ...). Also you can use the - * SWITCH instruction as a useful template for either LOOKUPSWITCH or - * TABLESWITCH. - * - * The interface provides the possibilty for the user to write - * `templates' or `macros' for such reuseable code patterns. - * - * @version $Id: CompoundInstruction.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - * @see PUSH - * @see SWITCH - */ -public interface CompoundInstruction { - public InstructionList getInstructionList(); -} - diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ConstantPoolGen.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ConstantPoolGen.java deleted file mode 100644 index a4b04e426..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ConstantPoolGen.java +++ /dev/null @@ -1,802 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -import java.util.HashMap; - -import org.aspectj.apache.bcel.Constants; -import org.aspectj.apache.bcel.classfile.Constant; -import org.aspectj.apache.bcel.classfile.ConstantCP; -import org.aspectj.apache.bcel.classfile.ConstantClass; -import org.aspectj.apache.bcel.classfile.ConstantDouble; -import org.aspectj.apache.bcel.classfile.ConstantFieldref; -import org.aspectj.apache.bcel.classfile.ConstantFloat; -import org.aspectj.apache.bcel.classfile.ConstantInteger; -import org.aspectj.apache.bcel.classfile.ConstantInterfaceMethodref; -import org.aspectj.apache.bcel.classfile.ConstantLong; -import org.aspectj.apache.bcel.classfile.ConstantMethodref; -import org.aspectj.apache.bcel.classfile.ConstantNameAndType; -import org.aspectj.apache.bcel.classfile.ConstantPool; -import org.aspectj.apache.bcel.classfile.ConstantString; -import org.aspectj.apache.bcel.classfile.ConstantUtf8; - -/** - * This class is used to build up a constant pool. The user adds - * constants via `addXXX' methods, `addString', `addClass', - * etc.. These methods return an index into the constant - * pool. Finally, `getFinalConstantPool()' returns the constant pool - * built up. Intermediate versions of the constant pool can be - * obtained with `getConstantPool()'. A constant pool has capacity for - * Constants.MAX_SHORT entries. Note that the first (0) is used by the - * JVM and that Double and Long constants need two slots. - * - * @version $Id: ConstantPoolGen.java,v 1.7 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - * @see Constant - */ -public class ConstantPoolGen implements java.io.Serializable { - protected int size = 1024; // Inital size, sufficient in most cases - protected Constant[] constants = new Constant[size]; - protected int index = 1; // First entry (0) used by JVM - - private static final String METHODREF_DELIM = ":"; - private static final String IMETHODREF_DELIM = "#"; - private static final String FIELDREF_DELIM = "&"; - private static final String NAT_DELIM = "%"; - - private static class Index implements java.io.Serializable { - int index; - Index(int i) { index = i; } - } - - /** - * Initialize with given array of constants. - * - * @param c array of given constants, new ones will be appended - */ - public ConstantPoolGen(Constant[] cs) { - if(cs.length > size) { - size = cs.length; - constants = new Constant[size]; - } - - System.arraycopy(cs, 0, constants, 0, cs.length); - - if(cs.length > 0) - index = cs.length; - - for(int i=1; i < index; i++) { - Constant c = constants[i]; - - if(c instanceof ConstantString) { - ConstantString s = (ConstantString)c; - ConstantUtf8 u8 = (ConstantUtf8)constants[s.getStringIndex()]; - - string_table.put(u8.getBytes(), new Index(i)); - } else if(c instanceof ConstantClass) { - ConstantClass s = (ConstantClass)c; - ConstantUtf8 u8 = (ConstantUtf8)constants[s.getNameIndex()]; - - class_table.put(u8.getBytes(), new Index(i)); - } else if(c instanceof ConstantNameAndType) { - ConstantNameAndType n = (ConstantNameAndType)c; - ConstantUtf8 u8 = (ConstantUtf8)constants[n.getNameIndex()]; - ConstantUtf8 u8_2 = (ConstantUtf8)constants[n.getSignatureIndex()]; - - n_a_t_table.put(u8.getBytes() + NAT_DELIM + u8_2.getBytes(), new Index(i)); - } else if(c instanceof ConstantUtf8) { - ConstantUtf8 u = (ConstantUtf8)c; - - utf8_table.put(u.getBytes(), new Index(i)); - } else if(c instanceof ConstantCP) { - ConstantCP m = (ConstantCP)c; - ConstantClass clazz = (ConstantClass)constants[m.getClassIndex()]; - ConstantNameAndType n = (ConstantNameAndType)constants[m.getNameAndTypeIndex()]; - - ConstantUtf8 u8 = (ConstantUtf8)constants[clazz.getNameIndex()]; - String class_name = u8.getBytes().replace('/', '.'); - - u8 = (ConstantUtf8)constants[n.getNameIndex()]; - String method_name = u8.getBytes(); - - u8 = (ConstantUtf8)constants[n.getSignatureIndex()]; - String signature = u8.getBytes(); - - String delim = METHODREF_DELIM; - - if(c instanceof ConstantInterfaceMethodref) - delim = IMETHODREF_DELIM; - else if(c instanceof ConstantFieldref) - delim = FIELDREF_DELIM; - - cp_table.put(class_name + delim + method_name + delim + signature, new Index(i)); - } - } - } - - /** - * Initialize with given constant pool. - */ - public ConstantPoolGen(ConstantPool cp) { - this(cp.getConstantPool()); - } - - /** - * Create empty constant pool. - */ - public ConstantPoolGen() {} - - /** Resize internal array of constants. - */ - protected void adjustSize() { - if(index + 3 >= size) { - Constant[] cs = constants; - - size *= 2; - constants = new Constant[size]; - System.arraycopy(cs, 0, constants, 0, index); - } - } - - private HashMap string_table = new HashMap(); - - /** - * Look for ConstantString in ConstantPool containing String `str'. - * - * @param str String to search for - * @return index on success, -1 otherwise - */ - public int lookupString(String str) { - Index index = (Index)string_table.get(str); - return (index != null)? index.index : -1; - } - - /** - * Add a new String constant to the ConstantPool, if it is not already in there. - * - * @param str String to add - * @return index of entry - */ - public int addString(String str) { - int ret; - - if((ret = lookupString(str)) != -1) - return ret; // Already in CP - - int utf8 = addUtf8(str); - - adjustSize(); - - ConstantString s = new ConstantString(utf8); - - ret = index; - constants[index++] = s; - - string_table.put(str, new Index(ret)); - - return ret; - } - - private HashMap class_table = new HashMap(); - - /** - * Look for ConstantClass in ConstantPool named `str'. - * - * @param str String to search for - * @return index on success, -1 otherwise - */ - public int lookupClass(String str) { - Index index = (Index)class_table.get(str.replace('.', '/')); - return (index != null)? index.index : -1; - } - - private int addClass_(String clazz) { - int ret; - - if((ret = lookupClass(clazz)) != -1) - return ret; // Already in CP - - adjustSize(); - - ConstantClass c = new ConstantClass(addUtf8(clazz)); - - ret = index; - constants[index++] = c; - - class_table.put(clazz, new Index(ret)); - - return ret; - } - - /** - * Add a new Class reference to the ConstantPool, if it is not already in there. - * - * @param str Class to add - * @return index of entry - */ - public int addClass(String str) { - return addClass_(str.replace('.', '/')); - } - - /** - * Add a new Class reference to the ConstantPool for a given type. - * - * @param str Class to add - * @return index of entry - */ - public int addClass(ObjectType type) { - //BCELBUG:? Should this we getClassName() - perhaps it should be getSignature() ?!? - return addClass(type.getClassName()); -// return addClass(type.getSignature()); - } - - /** - * Add a reference to an array class (e.g. String[][]) as needed by MULTIANEWARRAY - * instruction, e.g. to the ConstantPool. - * - * @param type type of array class - * @return index of entry - */ - public int addArrayClass(ArrayType type) { - return addClass_(type.getSignature()); - } - - /** - * Look for ConstantInteger in ConstantPool. - * - * @param n integer number to look for - * @return index on success, -1 otherwise - */ - public int lookupInteger(int n) { - for(int i=1; i < index; i++) { - if(constants[i] instanceof ConstantInteger) { - ConstantInteger c = (ConstantInteger)constants[i]; - - if(c.getBytes() == n) - return i; - } - } - - return -1; - } - - /** - * Add a new Integer constant to the ConstantPool, if it is not already in there. - * - * @param n integer number to add - * @return index of entry - */ - public int addInteger(int n) { - int ret; - - if((ret = lookupInteger(n)) != -1) - return ret; // Already in CP - - adjustSize(); - - ret = index; - constants[index++] = new ConstantInteger(n); - - return ret; - } - - /** - * Look for ConstantFloat in ConstantPool. - * - * @param n Float number to look for - * @return index on success, -1 otherwise - */ - public int lookupFloat(float n) { - int bits = Float.floatToIntBits(n); - - for(int i=1; i < index; i++) { - if(constants[i] instanceof ConstantFloat) { - ConstantFloat c = (ConstantFloat)constants[i]; - - if(Float.floatToIntBits(c.getBytes()) == bits) - return i; - } - } - - return -1; - } - - /** - * Add a new Float constant to the ConstantPool, if it is not already in there. - * - * @param n Float number to add - * @return index of entry - */ - public int addFloat(float n) { - int ret; - - if((ret = lookupFloat(n)) != -1) - return ret; // Already in CP - - adjustSize(); - - ret = index; - constants[index++] = new ConstantFloat(n); - - return ret; - } - - private HashMap utf8_table = new HashMap(); - - /** - * Look for ConstantUtf8 in ConstantPool. - * - * @param n Utf8 string to look for - * @return index on success, -1 otherwise - */ - public int lookupUtf8(String n) { - Index index = (Index)utf8_table.get(n); - - return (index != null)? index.index : -1; - } - - /** - * Add a new Utf8 constant to the ConstantPool, if it is not already in there. - * - * @param n Utf8 string to add - * @return index of entry - */ - public int addUtf8(String n) { - int ret; - - if((ret = lookupUtf8(n)) != -1) - return ret; // Already in CP - - adjustSize(); - - ret = index; - constants[index++] = new ConstantUtf8(n); - - utf8_table.put(n, new Index(ret)); - - return ret; - } - - /** - * Look for ConstantLong in ConstantPool. - * - * @param n Long number to look for - * @return index on success, -1 otherwise - */ - public int lookupLong(long n) { - for(int i=1; i < index; i++) { - if(constants[i] instanceof ConstantLong) { - ConstantLong c = (ConstantLong)constants[i]; - - if(c.getBytes() == n) - return i; - } - } - - return -1; - } - - /** - * Add a new long constant to the ConstantPool, if it is not already in there. - * - * @param n Long number to add - * @return index of entry - */ - public int addLong(long n) { - int ret; - - if((ret = lookupLong(n)) != -1) - return ret; // Already in CP - - adjustSize(); - - ret = index; - constants[index] = new ConstantLong(n); - index += 2; // Wastes one entry according to spec - - return ret; - } - - /** - * Look for ConstantDouble in ConstantPool. - * - * @param n Double number to look for - * @return index on success, -1 otherwise - */ - public int lookupDouble(double n) { - long bits = Double.doubleToLongBits(n); - - for(int i=1; i < index; i++) { - if(constants[i] instanceof ConstantDouble) { - ConstantDouble c = (ConstantDouble)constants[i]; - - if(Double.doubleToLongBits(c.getBytes()) == bits) - return i; - } - } - - return -1; - } - - /** - * Add a new double constant to the ConstantPool, if it is not already in there. - * - * @param n Double number to add - * @return index of entry - */ - public int addDouble(double n) { - int ret; - - if((ret = lookupDouble(n)) != -1) - return ret; // Already in CP - - adjustSize(); - - ret = index; - constants[index] = new ConstantDouble(n); - index += 2; // Wastes one entry according to spec - - return ret; - } - - private HashMap n_a_t_table = new HashMap(); - - /** - * Look for ConstantNameAndType in ConstantPool. - * - * @param name of variable/method - * @param signature of variable/method - * @return index on success, -1 otherwise - */ - public int lookupNameAndType(String name, String signature) { - Index index = (Index)n_a_t_table.get(name + NAT_DELIM + signature); - return (index != null)? index.index : -1; - } - - /** - * Add a new NameAndType constant to the ConstantPool if it is not already - * in there. - * - * @param n NameAndType string to add - * @return index of entry - */ - public int addNameAndType(String name, String signature) { - int ret; - int name_index, signature_index; - - if((ret = lookupNameAndType(name, signature)) != -1) - return ret; // Already in CP - - adjustSize(); - - name_index = addUtf8(name); - signature_index = addUtf8(signature); - ret = index; - constants[index++] = new ConstantNameAndType(name_index, signature_index); - - n_a_t_table.put(name + NAT_DELIM + signature, new Index(ret)); - return ret; - } - - private HashMap cp_table = new HashMap(); - - /** - * Look for ConstantMethodref in ConstantPool. - * - * @param class_name Where to find method - * @param method_name Guess what - * @param signature return and argument types - * @return index on success, -1 otherwise - */ - public int lookupMethodref(String class_name, String method_name, String signature) { - Index index = (Index)cp_table.get(class_name + METHODREF_DELIM + method_name + - METHODREF_DELIM + signature); - return (index != null)? index.index : -1; - } - - public int lookupMethodref(MethodGen method) { - return lookupMethodref(method.getClassName(), method.getName(), - method.getSignature()); - } - - /** - * Add a new Methodref constant to the ConstantPool, if it is not already - * in there. - * - * @param n Methodref string to add - * @return index of entry - */ - public int addMethodref(String class_name, String method_name, String signature) { - int ret, class_index, name_and_type_index; - - if((ret = lookupMethodref(class_name, method_name, signature)) != -1) - return ret; // Already in CP - - adjustSize(); - - name_and_type_index = addNameAndType(method_name, signature); - class_index = addClass(class_name); - ret = index; - constants[index++] = new ConstantMethodref(class_index, name_and_type_index); - - cp_table.put(class_name + METHODREF_DELIM + method_name + - METHODREF_DELIM + signature, new Index(ret)); - - return ret; - } - - public int addMethodref(MethodGen method) { - return addMethodref(method.getClassName(), method.getName(), - method.getSignature()); - } - - /** - * Look for ConstantInterfaceMethodref in ConstantPool. - * - * @param class_name Where to find method - * @param method_name Guess what - * @param signature return and argument types - * @return index on success, -1 otherwise - */ - public int lookupInterfaceMethodref(String class_name, String method_name, String signature) { - Index index = (Index)cp_table.get(class_name + IMETHODREF_DELIM + method_name + - IMETHODREF_DELIM + signature); - return (index != null)? index.index : -1; - } - - public int lookupInterfaceMethodref(MethodGen method) { - return lookupInterfaceMethodref(method.getClassName(), method.getName(), - method.getSignature()); - } - - /** - * Add a new InterfaceMethodref constant to the ConstantPool, if it is not already - * in there. - * - * @param n InterfaceMethodref string to add - * @return index of entry - */ - public int addInterfaceMethodref(String class_name, String method_name, String signature) { - int ret, class_index, name_and_type_index; - - if((ret = lookupInterfaceMethodref(class_name, method_name, signature)) != -1) - return ret; // Already in CP - - adjustSize(); - - class_index = addClass(class_name); - name_and_type_index = addNameAndType(method_name, signature); - ret = index; - constants[index++] = new ConstantInterfaceMethodref(class_index, name_and_type_index); - - cp_table.put(class_name + IMETHODREF_DELIM + method_name + - IMETHODREF_DELIM + signature, new Index(ret)); - - return ret; - } - - public int addInterfaceMethodref(MethodGen method) { - return addInterfaceMethodref(method.getClassName(), method.getName(), - method.getSignature()); - } - - /** - * Look for ConstantFieldref in ConstantPool. - * - * @param class_name Where to find method - * @param field_name Guess what - * @param signature return and argument types - * @return index on success, -1 otherwise - */ - public int lookupFieldref(String class_name, String field_name, String signature) { - Index index = (Index)cp_table.get(class_name + FIELDREF_DELIM + field_name + - FIELDREF_DELIM + signature); - return (index != null)? index.index : -1; - } - - /** - * Add a new Fieldref constant to the ConstantPool, if it is not already - * in there. - * - * @param n Fieldref string to add - * @return index of entry - */ - public int addFieldref(String class_name, String field_name, String signature) { - int ret; - int class_index, name_and_type_index; - - if((ret = lookupFieldref(class_name, field_name, signature)) != -1) - return ret; // Already in CP - - adjustSize(); - - class_index = addClass(class_name); - name_and_type_index = addNameAndType(field_name, signature); - ret = index; - constants[index++] = new ConstantFieldref(class_index, name_and_type_index); - - cp_table.put(class_name + FIELDREF_DELIM + field_name + FIELDREF_DELIM + signature, new Index(ret)); - - return ret; - } - - /** - * @param i index in constant pool - * @return constant pool entry at index i - */ - public Constant getConstant(int i) { return constants[i]; } - - /** - * Use with care! - * - * @param i index in constant pool - * @param c new constant pool entry at index i - */ - public void setConstant(int i, Constant c) { constants[i] = c; } - - /** - * @return intermediate constant pool - */ - public ConstantPool getConstantPool() { - return new ConstantPool(constants); - } - - /** - * @return current size of constant pool - */ - public int getSize() { - return index; - } - - /** - * @return constant pool with proper length - */ - public ConstantPool getFinalConstantPool() { - Constant[] cs = new Constant[index]; - - System.arraycopy(constants, 0, cs, 0, index); - - return new ConstantPool(cs); - } - - /** - * @return String representation. - */ - public String toString() { - StringBuffer buf = new StringBuffer(); - - for(int i=1; i < index; i++) - buf.append(i + ")" + constants[i] + "\n"); - - return buf.toString(); - } - - /** Import constant from another ConstantPool and return new index. - */ - public int addConstant(Constant c, ConstantPoolGen cp) { - Constant[] constants = cp.getConstantPool().getConstantPool(); - - switch(c.getTag()) { - case Constants.CONSTANT_String: { - ConstantString s = (ConstantString)c; - ConstantUtf8 u8 = (ConstantUtf8)constants[s.getStringIndex()]; - - return addString(u8.getBytes()); - } - - case Constants.CONSTANT_Class: { - ConstantClass s = (ConstantClass)c; - ConstantUtf8 u8 = (ConstantUtf8)constants[s.getNameIndex()]; - - return addClass(u8.getBytes()); - } - - case Constants.CONSTANT_NameAndType: { - ConstantNameAndType n = (ConstantNameAndType)c; - ConstantUtf8 u8 = (ConstantUtf8)constants[n.getNameIndex()]; - ConstantUtf8 u8_2 = (ConstantUtf8)constants[n.getSignatureIndex()]; - - return addNameAndType(u8.getBytes(), u8_2.getBytes()); - } - - case Constants.CONSTANT_Utf8: - return addUtf8(((ConstantUtf8)c).getBytes()); - - case Constants.CONSTANT_Double: - return addDouble(((ConstantDouble)c).getBytes()); - - case Constants.CONSTANT_Float: - return addFloat(((ConstantFloat)c).getBytes()); - - case Constants.CONSTANT_Long: - return addLong(((ConstantLong)c).getBytes()); - - case Constants.CONSTANT_Integer: - return addInteger(((ConstantInteger)c).getBytes()); - - case Constants.CONSTANT_InterfaceMethodref: case Constants.CONSTANT_Methodref: - case Constants.CONSTANT_Fieldref: { - ConstantCP m = (ConstantCP)c; - ConstantClass clazz = (ConstantClass)constants[m.getClassIndex()]; - ConstantNameAndType n = (ConstantNameAndType)constants[m.getNameAndTypeIndex()]; - ConstantUtf8 u8 = (ConstantUtf8)constants[clazz.getNameIndex()]; - String class_name = u8.getBytes().replace('/', '.'); - - u8 = (ConstantUtf8)constants[n.getNameIndex()]; - String name = u8.getBytes(); - - u8 = (ConstantUtf8)constants[n.getSignatureIndex()]; - String signature = u8.getBytes(); - - switch(c.getTag()) { - case Constants.CONSTANT_InterfaceMethodref: - return addInterfaceMethodref(class_name, name, signature); - - case Constants.CONSTANT_Methodref: - return addMethodref(class_name, name, signature); - - case Constants.CONSTANT_Fieldref: - return addFieldref(class_name, name, signature); - - default: // Never reached - throw new RuntimeException("Unknown constant type " + c); - } - } - - default: // Never reached - throw new RuntimeException("Unknown constant type " + c); - } - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ConstantPushInstruction.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ConstantPushInstruction.java deleted file mode 100644 index de0c600f5..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ConstantPushInstruction.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Denotes a push instruction that produces a literal on the stack - * such as SIPUSH, BIPUSH, ICONST, etc. - * - * @version $Id: ConstantPushInstruction.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - - * @see ICONST - * @see SIPUSH - */ -public interface ConstantPushInstruction extends PushInstruction, TypedInstruction { - public Number getValue(); -} - diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ConversionInstruction.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ConversionInstruction.java deleted file mode 100644 index c295bed95..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ConversionInstruction.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ -import org.aspectj.apache.bcel.Constants; -/** - * Super class for the x2y family of instructions. - * - * @version $Id: ConversionInstruction.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public abstract class ConversionInstruction extends Instruction - implements TypedInstruction, StackProducer, StackConsumer { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - ConversionInstruction() {} - - /** - * @param opcode opcode of instruction - */ - protected ConversionInstruction(short opcode) { - super(opcode, (short)1); - } - - /** @return type associated with the instruction - */ - public Type getType(ConstantPoolGen cp) { - switch(opcode) { - case Constants.D2I: case Constants.F2I: case Constants.L2I: - return Type.INT; - case Constants.D2F: case Constants.I2F: case Constants.L2F: - return Type.FLOAT; - case Constants.D2L: case Constants.F2L: case Constants.I2L: - return Type.LONG; - case Constants.F2D: case Constants.I2D: case Constants.L2D: - return Type.DOUBLE; - case Constants.I2B: - return Type.BYTE; - case Constants.I2C: - return Type.CHAR; - case Constants.I2S: - return Type.SHORT; - - default: // Never reached - throw new ClassGenException("Unknown type " + opcode); - } - } -} - diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/D2F.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/D2F.java deleted file mode 100644 index 5f57600a9..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/D2F.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * D2F - Convert double to float - * <PRE>Stack: ..., value.word1, value.word2 -> ..., result</PRE> - * - * @version $Id: D2F.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class D2F extends ConversionInstruction { - /** Convert double to float - */ - public D2F() { - super(org.aspectj.apache.bcel.Constants.D2F); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitConversionInstruction(this); - v.visitD2F(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/D2I.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/D2I.java deleted file mode 100644 index 823014972..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/D2I.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * D2I - Convert double to int - * <PRE>Stack: ..., value.word1, value.word2 -> ..., result</PRE> - * - * @version $Id: D2I.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class D2I extends ConversionInstruction { - /** Convert double to int - */ - public D2I() { - super(org.aspectj.apache.bcel.Constants.D2I); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitConversionInstruction(this); - v.visitD2I(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/D2L.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/D2L.java deleted file mode 100644 index c5c305841..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/D2L.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * D2L - Convert double to long - * <PRE>Stack: ..., value.word1, value.word2 -> ..., result.word1, result.word2</PRE> - * - * @version $Id: D2L.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class D2L extends ConversionInstruction { - /** Convert double to long - */ - public D2L() { - super(org.aspectj.apache.bcel.Constants.D2L); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitConversionInstruction(this); - v.visitD2L(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/DADD.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/DADD.java deleted file mode 100644 index 568ca46b2..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/DADD.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * DADD - Add doubles - * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -></PRE> - * ..., result.word1, result1.word2 - * - * @version $Id: DADD.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class DADD extends ArithmeticInstruction { - /** Add doubles - */ - public DADD() { - super(org.aspectj.apache.bcel.Constants.DADD); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitDADD(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/DALOAD.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/DALOAD.java deleted file mode 100644 index a7c0bd9af..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/DALOAD.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * DALOAD - Load double from array - * <PRE>Stack: ..., arrayref, index -> ..., result.word1, result.word2</PRE> - * - * @version $Id: DALOAD.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class DALOAD extends ArrayInstruction implements StackProducer { - /** Load double from array - */ - public DALOAD() { - super(org.aspectj.apache.bcel.Constants.DALOAD); - } - - - /** - * 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.visitDALOAD(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/DASTORE.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/DASTORE.java deleted file mode 100644 index 3c1cef331..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/DASTORE.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * DASTORE - Store into double array - * <PRE>Stack: ..., arrayref, index, value.word1, value.word2 -> ...</PRE> - * - * @version $Id: DASTORE.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class DASTORE extends ArrayInstruction implements StackConsumer { - /** Store double into array - */ - public DASTORE() { - super(org.aspectj.apache.bcel.Constants.DASTORE); - } - - - /** - * 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.visitDASTORE(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/DCMPG.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/DCMPG.java deleted file mode 100644 index 627ec726e..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/DCMPG.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * DCMPG - Compare doubles: value1 > value2 - * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -></PRE> - * ..., result - * - * @version $Id: DCMPG.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class DCMPG extends Instruction - implements TypedInstruction, StackProducer, StackConsumer { - - public DCMPG() { - super(org.aspectj.apache.bcel.Constants.DCMPG, (short)1); - } - - /** @return Type.DOUBLE - */ - public Type getType(ConstantPoolGen cp) { - return Type.DOUBLE; - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitDCMPG(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/DCMPL.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/DCMPL.java deleted file mode 100644 index 85d4f4ef5..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/DCMPL.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * DCMPL - Compare doubles: value1 < value2 - * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -></PRE> - * ..., result - * - * @version $Id: DCMPL.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class DCMPL extends Instruction - implements TypedInstruction, StackProducer, StackConsumer { - public DCMPL() { - super(org.aspectj.apache.bcel.Constants.DCMPL, (short)1); - } - - /** @return Type.DOUBLE - */ - public Type getType(ConstantPoolGen cp) { - return Type.DOUBLE; - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitDCMPL(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/DCONST.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/DCONST.java deleted file mode 100644 index 2a5f9bb4a..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/DCONST.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * DCONST - Push 0.0 or 1.0, other values cause an exception - * - * <PRE>Stack: ... -> ..., </PRE> - * - * @version $Id: DCONST.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class DCONST extends Instruction - implements ConstantPushInstruction, TypedInstruction { - private double value; - - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - DCONST() {} - - public DCONST(double f) { - super(org.aspectj.apache.bcel.Constants.DCONST_0, (short)1); - - if(f == 0.0) - opcode = org.aspectj.apache.bcel.Constants.DCONST_0; - else if(f == 1.0) - opcode = org.aspectj.apache.bcel.Constants.DCONST_1; - else - throw new ClassGenException("DCONST can be used only for 0.0 and 1.0: " + f); - - value = f; - } - - public Number getValue() { return new Double(value); } - - /** @return Type.DOUBLE - */ - public Type getType(ConstantPoolGen cp) { - return Type.DOUBLE; - } - - /** - * 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.visitDCONST(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/DDIV.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/DDIV.java deleted file mode 100644 index cba7c3b24..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/DDIV.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * DDIV - Divide doubles - * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -></PRE> - * ..., result.word1, result.word2 - * - * @version $Id: DDIV.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class DDIV extends ArithmeticInstruction { - /** Divide doubles - */ - public DDIV() { - super(org.aspectj.apache.bcel.Constants.DDIV); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitDDIV(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/DLOAD.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/DLOAD.java deleted file mode 100644 index 5a1b9e428..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/DLOAD.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * DLOAD - Load double from local variable - * <PRE>Stack ... -> ..., result.word1, result.word2</PRE> - * - * @version $Id: DLOAD.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class DLOAD extends LoadInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - DLOAD() { - super(org.aspectj.apache.bcel.Constants.DLOAD, org.aspectj.apache.bcel.Constants.DLOAD_0); - } - - /** Load double from local variable - * @param n index of local variable - */ - public DLOAD(int n) { - super(org.aspectj.apache.bcel.Constants.DLOAD, org.aspectj.apache.bcel.Constants.DLOAD_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.visitDLOAD(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/DMUL.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/DMUL.java deleted file mode 100644 index d8de4c631..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/DMUL.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * DMUL - Multiply doubles - * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -></PRE> - * ..., result.word1, result.word2 - * - * @version $Id: DMUL.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class DMUL extends ArithmeticInstruction { - /** Multiply doubles - */ - public DMUL() { - super(org.aspectj.apache.bcel.Constants.DMUL); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitDMUL(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/DNEG.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/DNEG.java deleted file mode 100644 index dbe39bd87..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/DNEG.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * DNEG - Negate double - * <PRE>Stack: ..., value.word1, value.word2 -> ..., result.word1, result.word2</PRE> - * - * @version $Id: DNEG.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class DNEG extends ArithmeticInstruction { - public DNEG() { - super(org.aspectj.apache.bcel.Constants.DNEG); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitDNEG(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/DREM.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/DREM.java deleted file mode 100644 index 1b364f43e..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/DREM.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * DREM - Remainder of doubles - * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -></PRE> - * ..., result.word1, result.word2 - * - * @version $Id: DREM.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class DREM extends ArithmeticInstruction { - /** Remainder of doubles - */ - public DREM() { - super(org.aspectj.apache.bcel.Constants.DREM); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitDREM(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/DRETURN.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/DRETURN.java deleted file mode 100644 index 4782efea4..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/DRETURN.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * DRETURN - Return double from method - * <PRE>Stack: ..., value.word1, value.word2 -> <empty></PRE> - * - * @version $Id: DRETURN.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class DRETURN extends ReturnInstruction { - /** Return double from method - */ - public DRETURN() { - super(org.aspectj.apache.bcel.Constants.DRETURN); - } - - - /** - * 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.visitDRETURN(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/DSTORE.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/DSTORE.java deleted file mode 100644 index faa280e6b..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/DSTORE.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * DSTORE - Store double into local variable - * <pre>Stack: ..., value.word1, value.word2 -> ... </PRE> - * - * @version $Id: DSTORE.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class DSTORE extends StoreInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - DSTORE() { - super(org.aspectj.apache.bcel.Constants.DSTORE, org.aspectj.apache.bcel.Constants.DSTORE_0); - } - - /** Store double into local variable - * @param n index of local variable - */ - public DSTORE(int n) { - super(org.aspectj.apache.bcel.Constants.DSTORE, org.aspectj.apache.bcel.Constants.DSTORE_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.visitDSTORE(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/DSUB.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/DSUB.java deleted file mode 100644 index 75fb97bef..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/DSUB.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * DSUB - Substract doubles - * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -></PRE> - * ..., result.word1, result.word2 - * - * @version $Id: DSUB.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class DSUB extends ArithmeticInstruction { - /** Substract doubles - */ - public DSUB() { - super(org.aspectj.apache.bcel.Constants.DSUB); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitDSUB(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/DUP.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/DUP.java deleted file mode 100644 index 2945d0ca7..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/DUP.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * DUP - Duplicate top operand stack word - * <PRE>Stack: ..., word -> ..., word, word</PRE> - * - * @version $Id: DUP.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class DUP extends StackInstruction implements PushInstruction { - public DUP() { - super(org.aspectj.apache.bcel.Constants.DUP); - } - - - /** - * 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.visitStackInstruction(this); - v.visitDUP(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/DUP2.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/DUP2.java deleted file mode 100644 index 6e061862e..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/DUP2.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * DUP2 - Duplicate two top operand stack words - * <PRE>Stack: ..., word2, word1 -> ..., word2, word1, word2, word1</PRE> - * - * @version $Id: DUP2.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class DUP2 extends StackInstruction implements PushInstruction { - public DUP2() { - super(org.aspectj.apache.bcel.Constants.DUP2); - } - - - /** - * 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.visitStackInstruction(this); - v.visitDUP2(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/DUP2_X1.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/DUP2_X1.java deleted file mode 100644 index beb0c4499..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/DUP2_X1.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * DUP2_X1 - Duplicate two top operand stack words and put three down - * <PRE>Stack: ..., word3, word2, word1 -> ..., word2, word1, word3, word2, word1</PRE> - * - * @version $Id: DUP2_X1.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class DUP2_X1 extends StackInstruction { - public DUP2_X1() { - super(org.aspectj.apache.bcel.Constants.DUP2_X1); - } - - - /** - * 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.visitStackInstruction(this); - v.visitDUP2_X1(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/DUP2_X2.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/DUP2_X2.java deleted file mode 100644 index e5bbeac05..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/DUP2_X2.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * DUP2_X2 - Duplicate two top operand stack words and put four down - * <PRE>Stack: ..., word4, word3, word2, word1 -> ..., word2, word1, word4, word3, word2, word1</PRE> - * - * @version $Id: DUP2_X2.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class DUP2_X2 extends StackInstruction { - public DUP2_X2() { - super(org.aspectj.apache.bcel.Constants.DUP2_X2); - } - - - /** - * 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.visitStackInstruction(this); - v.visitDUP2_X2(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/DUP_X1.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/DUP_X1.java deleted file mode 100644 index 8f967ef88..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/DUP_X1.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * DUP_X1 - Duplicate top operand stack word and put two down - * <PRE>Stack: ..., word2, word1 -> ..., word1, word2, word1</PRE> - * - * @version $Id: DUP_X1.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class DUP_X1 extends StackInstruction { - public DUP_X1() { - super(org.aspectj.apache.bcel.Constants.DUP_X1); - } - - - /** - * 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.visitStackInstruction(this); - v.visitDUP_X1(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/DUP_X2.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/DUP_X2.java deleted file mode 100644 index d395a7e70..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/DUP_X2.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * DUP_X2 - Duplicate top operand stack word and put three down - * <PRE>Stack: ..., word3, word2, word1 -> ..., word1, word3, word2, word1</PRE> - * - * @version $Id: DUP_X2.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class DUP_X2 extends StackInstruction { - public DUP_X2() { - super(org.aspectj.apache.bcel.Constants.DUP_X2); - } - - - /** - * 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.visitStackInstruction(this); - v.visitDUP_X2(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/EmptyVisitor.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/EmptyVisitor.java deleted file mode 100644 index ca983400b..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/EmptyVisitor.java +++ /dev/null @@ -1,244 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Supplies empty method bodies to be overridden by subclasses. - * - * @version $Id: EmptyVisitor.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public abstract class EmptyVisitor implements Visitor { - public void visitStackInstruction(StackInstruction obj) { } - public void visitLocalVariableInstruction(LocalVariableInstruction obj) { } - public void visitBranchInstruction(BranchInstruction obj) { } - public void visitLoadClass(LoadClass obj) { } - public void visitFieldInstruction(FieldInstruction obj) { } - public void visitIfInstruction(IfInstruction obj) { } - public void visitConversionInstruction(ConversionInstruction obj) { } - public void visitPopInstruction(PopInstruction obj) { } - public void visitJsrInstruction(JsrInstruction obj) { } - public void visitGotoInstruction(GotoInstruction obj) { } - public void visitStoreInstruction(StoreInstruction obj) { } - public void visitTypedInstruction(TypedInstruction obj) { } - public void visitSelect(Select obj) { } - public void visitUnconditionalBranch(UnconditionalBranch obj) { } - public void visitPushInstruction(PushInstruction obj) { } - public void visitArithmeticInstruction(ArithmeticInstruction obj) { } - public void visitCPInstruction(CPInstruction obj) { } - public void visitInvokeInstruction(InvokeInstruction obj) { } - public void visitArrayInstruction(ArrayInstruction obj) { } - public void visitAllocationInstruction(AllocationInstruction obj) { } - public void visitReturnInstruction(ReturnInstruction obj) { } - public void visitFieldOrMethod(FieldOrMethod obj) { } - public void visitConstantPushInstruction(ConstantPushInstruction obj) { } - public void visitExceptionThrower(ExceptionThrower obj) { } - public void visitLoadInstruction(LoadInstruction obj) { } - public void visitVariableLengthInstruction(VariableLengthInstruction obj) { } - public void visitStackProducer(StackProducer obj) { } - public void visitStackConsumer(StackConsumer obj) { } - public void visitACONST_NULL(ACONST_NULL obj) { } - public void visitGETSTATIC(GETSTATIC obj) { } - public void visitIF_ICMPLT(IF_ICMPLT obj) { } - public void visitMONITOREXIT(MONITOREXIT obj) { } - public void visitIFLT(IFLT obj) { } - public void visitLSTORE(LSTORE obj) { } - public void visitPOP2(POP2 obj) { } - public void visitBASTORE(BASTORE obj) { } - public void visitISTORE(ISTORE obj) { } - public void visitCHECKCAST(CHECKCAST obj) { } - public void visitFCMPG(FCMPG obj) { } - public void visitI2F(I2F obj) { } - public void visitATHROW(ATHROW obj) { } - public void visitDCMPL(DCMPL obj) { } - public void visitARRAYLENGTH(ARRAYLENGTH obj) { } - public void visitDUP(DUP obj) { } - public void visitINVOKESTATIC(INVOKESTATIC obj) { } - public void visitLCONST(LCONST obj) { } - public void visitDREM(DREM obj) { } - public void visitIFGE(IFGE obj) { } - public void visitCALOAD(CALOAD obj) { } - public void visitLASTORE(LASTORE obj) { } - public void visitI2D(I2D obj) { } - public void visitDADD(DADD obj) { } - public void visitINVOKESPECIAL(INVOKESPECIAL obj) { } - public void visitIAND(IAND obj) { } - public void visitPUTFIELD(PUTFIELD obj) { } - public void visitILOAD(ILOAD obj) { } - public void visitDLOAD(DLOAD obj) { } - public void visitDCONST(DCONST obj) { } - public void visitNEW(NEW obj) { } - public void visitIFNULL(IFNULL obj) { } - public void visitLSUB(LSUB obj) { } - public void visitL2I(L2I obj) { } - public void visitISHR(ISHR obj) { } - public void visitTABLESWITCH(TABLESWITCH obj) { } - public void visitIINC(IINC obj) { } - public void visitDRETURN(DRETURN obj) { } - public void visitFSTORE(FSTORE obj) { } - public void visitDASTORE(DASTORE obj) { } - public void visitIALOAD(IALOAD obj) { } - public void visitDDIV(DDIV obj) { } - public void visitIF_ICMPGE(IF_ICMPGE obj) { } - public void visitLAND(LAND obj) { } - public void visitIDIV(IDIV obj) { } - public void visitLOR(LOR obj) { } - public void visitCASTORE(CASTORE obj) { } - public void visitFREM(FREM obj) { } - public void visitLDC(LDC obj) { } - public void visitBIPUSH(BIPUSH obj) { } - public void visitDSTORE(DSTORE obj) { } - public void visitF2L(F2L obj) { } - public void visitFMUL(FMUL obj) { } - public void visitLLOAD(LLOAD obj) { } - public void visitJSR(JSR obj) { } - public void visitFSUB(FSUB obj) { } - public void visitSASTORE(SASTORE obj) { } - public void visitALOAD(ALOAD obj) { } - public void visitDUP2_X2(DUP2_X2 obj) { } - public void visitRETURN(RETURN obj) { } - public void visitDALOAD(DALOAD obj) { } - public void visitSIPUSH(SIPUSH obj) { } - public void visitDSUB(DSUB obj) { } - public void visitL2F(L2F obj) { } - public void visitIF_ICMPGT(IF_ICMPGT obj) { } - public void visitF2D(F2D obj) { } - public void visitI2L(I2L obj) { } - public void visitIF_ACMPNE(IF_ACMPNE obj) { } - public void visitPOP(POP obj) { } - public void visitI2S(I2S obj) { } - public void visitIFEQ(IFEQ obj) { } - public void visitSWAP(SWAP obj) { } - public void visitIOR(IOR obj) { } - public void visitIREM(IREM obj) { } - public void visitIASTORE(IASTORE obj) { } - public void visitNEWARRAY(NEWARRAY obj) { } - public void visitINVOKEINTERFACE(INVOKEINTERFACE obj) { } - public void visitINEG(INEG obj) { } - public void visitLCMP(LCMP obj) { } - public void visitJSR_W(JSR_W obj) { } - public void visitMULTIANEWARRAY(MULTIANEWARRAY obj) { } - public void visitDUP_X2(DUP_X2 obj) { } - public void visitSALOAD(SALOAD obj) { } - public void visitIFNONNULL(IFNONNULL obj) { } - public void visitDMUL(DMUL obj) { } - public void visitIFNE(IFNE obj) { } - public void visitIF_ICMPLE(IF_ICMPLE obj) { } - public void visitLDC2_W(LDC2_W obj) { } - public void visitGETFIELD(GETFIELD obj) { } - public void visitLADD(LADD obj) { } - public void visitNOP(NOP obj) { } - public void visitFALOAD(FALOAD obj) { } - public void visitINSTANCEOF(INSTANCEOF obj) { } - public void visitIFLE(IFLE obj) { } - public void visitLXOR(LXOR obj) { } - public void visitLRETURN(LRETURN obj) { } - public void visitFCONST(FCONST obj) { } - public void visitIUSHR(IUSHR obj) { } - public void visitBALOAD(BALOAD obj) { } - public void visitDUP2(DUP2 obj) { } - public void visitIF_ACMPEQ(IF_ACMPEQ obj) { } - public void visitIMPDEP1(IMPDEP1 obj) { } - public void visitMONITORENTER(MONITORENTER obj) { } - public void visitLSHL(LSHL obj) { } - public void visitDCMPG(DCMPG obj) { } - public void visitD2L(D2L obj) { } - public void visitIMPDEP2(IMPDEP2 obj) { } - public void visitL2D(L2D obj) { } - public void visitRET(RET obj) { } - public void visitIFGT(IFGT obj) { } - public void visitIXOR(IXOR obj) { } - public void visitINVOKEVIRTUAL(INVOKEVIRTUAL obj) { } - public void visitFASTORE(FASTORE obj) { } - public void visitIRETURN(IRETURN obj) { } - public void visitIF_ICMPNE(IF_ICMPNE obj) { } - public void visitFLOAD(FLOAD obj) { } - public void visitLDIV(LDIV obj) { } - public void visitPUTSTATIC(PUTSTATIC obj) { } - public void visitAALOAD(AALOAD obj) { } - public void visitD2I(D2I obj) { } - public void visitIF_ICMPEQ(IF_ICMPEQ obj) { } - public void visitAASTORE(AASTORE obj) { } - public void visitARETURN(ARETURN obj) { } - public void visitDUP2_X1(DUP2_X1 obj) { } - public void visitFNEG(FNEG obj) { } - public void visitGOTO_W(GOTO_W obj) { } - public void visitD2F(D2F obj) { } - public void visitGOTO(GOTO obj) { } - public void visitISUB(ISUB obj) { } - public void visitF2I(F2I obj) { } - public void visitDNEG(DNEG obj) { } - public void visitICONST(ICONST obj) { } - public void visitFDIV(FDIV obj) { } - public void visitI2B(I2B obj) { } - public void visitLNEG(LNEG obj) { } - public void visitLREM(LREM obj) { } - public void visitIMUL(IMUL obj) { } - public void visitIADD(IADD obj) { } - public void visitLSHR(LSHR obj) { } - public void visitLOOKUPSWITCH(LOOKUPSWITCH obj) { } - public void visitDUP_X1(DUP_X1 obj) { } - public void visitFCMPL(FCMPL obj) { } - public void visitI2C(I2C obj) { } - public void visitLMUL(LMUL obj) { } - public void visitLUSHR(LUSHR obj) { } - public void visitISHL(ISHL obj) { } - public void visitLALOAD(LALOAD obj) { } - public void visitASTORE(ASTORE obj) { } - public void visitANEWARRAY(ANEWARRAY obj) { } - public void visitFRETURN(FRETURN obj) { } - public void visitFADD(FADD obj) { } - public void visitBREAKPOINT(BREAKPOINT obj) { } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ExceptionThrower.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ExceptionThrower.java deleted file mode 100644 index e9db4a84d..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ExceptionThrower.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Denote an instruction that may throw a run-time or a linking - * exception (or both) during execution. This is not quite the truth - * as such; because all instructions may throw an - * java.lang.VirtualMachineError. These exceptions are omitted. - * - * The Lava Language Specification specifies exactly which - * <i>RUN-TIME</i> and which <i>LINKING</i> exceptions each - * instruction may throw which is reflected by the implementers. Due - * to the structure of the JVM specification, it may be possible that - * an Instruction implementing this interface returns a Class[] of - * size 0. - * - * Please note that we speak of an "exception" here when we mean any - * "Throwable" object; so this term is equally used for "Exception" - * and "Error" objects. - * - * @version $Id: ExceptionThrower.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase">Enver Haase</A> - */ -public interface ExceptionThrower { - public java.lang.Class[] getExceptions(); -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/F2D.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/F2D.java deleted file mode 100644 index cb09e5f9c..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/F2D.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * F2D - Convert float to double - * <PRE>Stack: ..., value -> ..., result.word1, result.word2</PRE> - * - * @version $Id: F2D.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class F2D extends ConversionInstruction { - /** Convert float to double - */ - public F2D() { - super(org.aspectj.apache.bcel.Constants.F2D); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitConversionInstruction(this); - v.visitF2D(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/F2I.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/F2I.java deleted file mode 100644 index 8f76a8c57..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/F2I.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * F2I - Convert float to int - * <PRE>Stack: ..., value -> ..., result</PRE> - * - * @version $Id: F2I.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class F2I extends ConversionInstruction { - /** Convert float to int - */ - public F2I() { - super(org.aspectj.apache.bcel.Constants.F2I); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitConversionInstruction(this); - v.visitF2I(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/F2L.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/F2L.java deleted file mode 100644 index e60da046a..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/F2L.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * F2L - Convert float to long - * <PRE>Stack: ..., value -> ..., result.word1, result.word2</PRE> - * - * @version $Id: F2L.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class F2L extends ConversionInstruction { - /** Convert float to long - */ - public F2L() { - super(org.aspectj.apache.bcel.Constants.F2L); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitConversionInstruction(this); - v.visitF2L(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/FADD.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/FADD.java deleted file mode 100644 index 5ec8d578e..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/FADD.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * FADD - Add floats - * <PRE>Stack: ..., value1, value2 -> result</PRE> - * - * @version $Id: FADD.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class FADD extends ArithmeticInstruction { - /** Add floats - */ - public FADD() { - super(org.aspectj.apache.bcel.Constants.FADD); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitFADD(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/FALOAD.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/FALOAD.java deleted file mode 100644 index 03ff7aeaf..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/FALOAD.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * FALOAD - Load float from array - * <PRE>Stack: ..., arrayref, index -> ..., value</PRE> - * - * @version $Id: FALOAD.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class FALOAD extends ArrayInstruction implements StackProducer { - /** Load float from array - */ - public FALOAD() { - super(org.aspectj.apache.bcel.Constants.FALOAD); - } - - - /** - * 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.visitFALOAD(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/FASTORE.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/FASTORE.java deleted file mode 100644 index c95eea1e7..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/FASTORE.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * FASTORE - Store into float array - * <PRE>Stack: ..., arrayref, index, value -> ...</PRE> - * - * @version $Id: FASTORE.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class FASTORE extends ArrayInstruction implements StackConsumer { - /** Store float into array - */ - public FASTORE() { - super(org.aspectj.apache.bcel.Constants.FASTORE); - } - - - /** - * 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.visitFASTORE(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/FCMPG.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/FCMPG.java deleted file mode 100644 index a9e41ba66..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/FCMPG.java +++ /dev/null @@ -1,91 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * FCMPG - Compare floats: value1 > value2 - * <PRE>Stack: ..., value1, value2 -> ..., result</PRE> - * - * @version $Id: FCMPG.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class FCMPG extends Instruction - implements TypedInstruction, StackProducer, StackConsumer { - public FCMPG() { - super(org.aspectj.apache.bcel.Constants.FCMPG, (short)1); - } - - /** @return Type.FLOAT - */ - public Type getType(ConstantPoolGen cp) { - return Type.FLOAT; - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitFCMPG(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/FCMPL.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/FCMPL.java deleted file mode 100644 index 5c995efe8..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/FCMPL.java +++ /dev/null @@ -1,91 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * FCMPL - Compare floats: value1 < value2 - * <PRE>Stack: ..., value1, value2 -> ..., result</PRE> - * - * @version $Id: FCMPL.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class FCMPL extends Instruction - implements TypedInstruction, StackProducer, StackConsumer { - public FCMPL() { - super(org.aspectj.apache.bcel.Constants.FCMPL, (short)1); - } - - /** @return Type.FLOAT - */ - public Type getType(ConstantPoolGen cp) { - return Type.FLOAT; - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitFCMPL(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/FCONST.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/FCONST.java deleted file mode 100644 index 61ae33caf..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/FCONST.java +++ /dev/null @@ -1,113 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * FCONST - Push 0.0, 1.0 or 2.0, other values cause an exception - * - * <PRE>Stack: ... -> ..., </PRE> - * - * @version $Id: FCONST.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class FCONST extends Instruction - implements ConstantPushInstruction, TypedInstruction { - private float value; - - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - FCONST() {} - - public FCONST(float f) { - super(org.aspectj.apache.bcel.Constants.FCONST_0, (short)1); - - if(f == 0.0) - opcode = org.aspectj.apache.bcel.Constants.FCONST_0; - else if(f == 1.0) - opcode = org.aspectj.apache.bcel.Constants.FCONST_1; - else if(f == 2.0) - opcode = org.aspectj.apache.bcel.Constants.FCONST_2; - else - throw new ClassGenException("FCONST can be used only for 0.0, 1.0 and 2.0: " + f); - - value = f; - } - - public Number getValue() { return new Float(value); } - - /** @return Type.FLOAT - */ - public Type getType(ConstantPoolGen cp) { - return Type.FLOAT; - } - - /** - * 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.visitFCONST(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/FDIV.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/FDIV.java deleted file mode 100644 index 1d006b3c0..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/FDIV.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * FDIV - Divide floats - * <PRE>Stack: ..., value1, value2 -> result</PRE> - * - * @version $Id: FDIV.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class FDIV extends ArithmeticInstruction { - /** Divide floats - */ - public FDIV() { - super(org.aspectj.apache.bcel.Constants.FDIV); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitFDIV(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/FLOAD.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/FLOAD.java deleted file mode 100644 index ca05f6354..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/FLOAD.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * FLOAD - Load float from local variable - * <PRE>Stack ... -> ..., result</PRE> - * - * @version $Id: FLOAD.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class FLOAD extends LoadInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - FLOAD() { - super(org.aspectj.apache.bcel.Constants.FLOAD, org.aspectj.apache.bcel.Constants.FLOAD_0); - } - - /** Load float from local variable - * @param n index of local variable - */ - public FLOAD(int n) { - super(org.aspectj.apache.bcel.Constants.FLOAD, org.aspectj.apache.bcel.Constants.FLOAD_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.visitFLOAD(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/FMUL.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/FMUL.java deleted file mode 100644 index f52ee3b1f..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/FMUL.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * FMUL - Multiply floats - * <PRE>Stack: ..., value1, value2 -> result</PRE> - * - * @version $Id: FMUL.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class FMUL extends ArithmeticInstruction { - /** Multiply floats - */ - public FMUL() { - super(org.aspectj.apache.bcel.Constants.FMUL); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitFMUL(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/FNEG.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/FNEG.java deleted file mode 100644 index 8457ae258..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/FNEG.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * FNEG - Negate float - * <PRE>Stack: ..., value -> ..., result</PRE> - * - * @version $Id: FNEG.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class FNEG extends ArithmeticInstruction { - public FNEG() { - super(org.aspectj.apache.bcel.Constants.FNEG); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitFNEG(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/FREM.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/FREM.java deleted file mode 100644 index 6a6c4bc82..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/FREM.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * FREM - Remainder of floats - * <PRE>Stack: ..., value1, value2 -> result</PRE> - * - * @version $Id: FREM.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class FREM extends ArithmeticInstruction { - /** Remainder of floats - */ - public FREM() { - super(org.aspectj.apache.bcel.Constants.FREM); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitFREM(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/FRETURN.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/FRETURN.java deleted file mode 100644 index 575610d35..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/FRETURN.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * FRETURN - Return float from method - * <PRE>Stack: ..., value -> <empty></PRE> - * - * @version $Id: FRETURN.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class FRETURN extends ReturnInstruction { - /** Return float from method - */ - public FRETURN() { - super(org.aspectj.apache.bcel.Constants.FRETURN); - } - - - /** - * 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.visitFRETURN(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/FSTORE.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/FSTORE.java deleted file mode 100644 index b1f031e7f..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/FSTORE.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * FSTORE - Store float into local variable - * <PRE>Stack: ..., value -> ... </PRE> - * - * @version $Id: FSTORE.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class FSTORE extends StoreInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - FSTORE() { - super(org.aspectj.apache.bcel.Constants.FSTORE, org.aspectj.apache.bcel.Constants.FSTORE_0); - } - - /** Store float into local variable - * @param n index of local variable - */ - public FSTORE(int n) { - super(org.aspectj.apache.bcel.Constants.FSTORE, org.aspectj.apache.bcel.Constants.FSTORE_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.visitFSTORE(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/FSUB.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/FSUB.java deleted file mode 100644 index dfc2f26d4..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/FSUB.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * FSUB - Substract floats - * <PRE>Stack: ..., value1, value2 -> result</PRE> - * - * @version $Id: FSUB.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class FSUB extends ArithmeticInstruction { - /** Substract floats - */ - public FSUB() { - super(org.aspectj.apache.bcel.Constants.FSUB); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitFSUB(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldGen.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldGen.java index 71e453dfd..e4d2d0917 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldGen.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldGen.java @@ -54,7 +54,6 @@ package org.aspectj.apache.bcel.generic; * <http://www.apache.org/>. */ -import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -66,16 +65,15 @@ import org.aspectj.apache.bcel.classfile.ConstantPool; import org.aspectj.apache.bcel.classfile.ConstantValue; import org.aspectj.apache.bcel.classfile.Field; import org.aspectj.apache.bcel.classfile.Utility; -import org.aspectj.apache.bcel.classfile.annotation.Annotation; +import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; import org.aspectj.apache.bcel.classfile.annotation.RuntimeAnnotations; -import org.aspectj.apache.bcel.generic.annotation.AnnotationGen; /** * Template class for building up a field. The only extraordinary thing * one can do is to add a constant value attribute to a field (which must of - * course be compatible with to the declared type). + * course be compatible with the declared type). * - * @version $Id: FieldGen.java,v 1.4 2005/03/10 12:15:04 aclement Exp $ + * @version $Id: FieldGen.java,v 1.5 2008/05/28 23:52:59 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Field */ @@ -92,8 +90,8 @@ public class FieldGen extends FieldGenOrMethodGen { * @param name field name * @param cp constant pool */ - public FieldGen(int access_flags, Type type, String name, ConstantPoolGen cp) { - setAccessFlags(access_flags); + public FieldGen(int access_flags, Type type, String name, ConstantPool cp) { + setModifiers(access_flags); setType(type); setName(name); setConstantPool(cp); @@ -105,8 +103,8 @@ public class FieldGen extends FieldGenOrMethodGen { * @param field Field object * @param cp constant pool (must contain the same entries as the field's constant pool) */ - public FieldGen(Field field, ConstantPoolGen cp) { - this(field.getAccessFlags(), Type.getType(field.getSignature()), field.getName(), cp); + public FieldGen(Field field, ConstantPool cp) { + this(field.getModifiers(), Type.getType(field.getSignature()), field.getName(), cp); Attribute[] attrs = field.getAttributes(); @@ -117,7 +115,7 @@ public class FieldGen extends FieldGenOrMethodGen { RuntimeAnnotations runtimeAnnotations = (RuntimeAnnotations)attrs[i]; List l = runtimeAnnotations.getAnnotations(); for (Iterator it = l.iterator(); it.hasNext();) { - Annotation element = (Annotation) it.next(); + AnnotationGen element = (AnnotationGen) it.next(); addAnnotation(new AnnotationGen(element,cp,false)); } } else { @@ -127,81 +125,13 @@ public class FieldGen extends FieldGenOrMethodGen { } private void setValue(int index) { - ConstantPool cp = this.cp.getConstantPool(); + ConstantPool cp = this.cp; Constant c = cp.getConstant(index); value = ((ConstantObject)c).getConstantValue(cp); } - /** - * Set (optional) initial value of field, otherwise it will be set to null/0/false - * by the JVM automatically. - */ - public void setInitValue(String str) { - checkType(new ObjectType("java.lang.String")); - - if(str != null) - value = str; - } - - public void setInitValue(long l) { - checkType(Type.LONG); - - if(l != 0L) - value = new Long(l); - } - - public void setInitValue(int i) { - checkType(Type.INT); - - if(i != 0) - value = new Integer(i); - } - - public void setInitValue(short s) { - checkType(Type.SHORT); - - if(s != 0) - value = new Integer(s); - } - - public void setInitValue(char c) { - checkType(Type.CHAR); - - if(c != 0) - value = new Integer(c); - } - - public void setInitValue(byte b) { - checkType(Type.BYTE); - - if(b != 0) - value = new Integer(b); - } - - public void setInitValue(boolean b) { - checkType(Type.BOOLEAN); - if(b) - value = new Integer(1); - } - - public void setInitValue(float f) { - checkType(Type.FLOAT); - - if(f != 0.0) - value = new Float(f); - } - - public void setInitValue(double d) { - checkType(Type.DOUBLE); - - if(d != 0.0) - value = new Double(d); - } - - /** Remove any initial value. - */ - public void cancelInitValue() { + public void wipeValue() { value = null; } @@ -228,22 +158,12 @@ public class FieldGen extends FieldGenOrMethodGen { checkType(type); int index = addConstant(); addAttribute(new ConstantValue(cp.addUtf8("ConstantValue"), - 2, index, cp.getConstantPool())); + 2, index, cp)); } addAnnotationsAsAttribute(cp); - return new Field(access_flags, name_index, signature_index, getAttributes(), - cp.getConstantPool()); - } - - private void addAnnotationsAsAttribute(ConstantPoolGen cp) { - Attribute[] attrs = Utility.getAnnotationAttributes(cp,annotation_vec); - if (attrs!=null) { - for (int i = 0; i < attrs.length; i++) { - addAttribute(attrs[i]); - } - } + return new Field(modifiers, name_index, signature_index, getAttributesImmutable(), cp); } private int addConstant() { @@ -271,35 +191,8 @@ public class FieldGen extends FieldGenOrMethodGen { public String getSignature() { return type.getSignature(); } - private ArrayList observers; - - /** Add observer for this object. - */ - public void addObserver(FieldObserver o) { - if(observers == null) - observers = new ArrayList(); - - observers.add(o); - } - - /** Remove observer for this object. - */ - public void removeObserver(FieldObserver o) { - if(observers != null) - observers.remove(o); - } - - /** Call notify() method on all observers. This method is not called - * automatically whenever the state has changed, but has to be - * called by the user after he has finished editing the object. - */ - public void update() { - if(observers != null) - for(Iterator e = observers.iterator(); e.hasNext(); ) - ((FieldObserver)e.next()).notify(this); - } - public String getInitValue() { + public String getInitialValue() { if(value != null) { return value.toString(); } else @@ -315,26 +208,26 @@ public class FieldGen extends FieldGenOrMethodGen { public final String toString() { String name, signature, access; // Short cuts to constant pool - access = Utility.accessToString(access_flags); + access = Utility.accessToString(modifiers); access = access.equals("")? "" : (access + " "); signature = type.toString(); name = getName(); StringBuffer buf = new StringBuffer(access + signature + " " + name); - String value = getInitValue(); + String value = getInitialValue(); if(value != null) buf.append(" = " + value); - // J5TODO: Add attributes and annotations to the string + // TODO: Add attributes and annotations to the string return buf.toString(); } /** @return deep copy of this field */ - public FieldGen copy(ConstantPoolGen cp) { + public FieldGen copy(ConstantPool cp) { FieldGen fg = (FieldGen)clone(); fg.setConstantPool(cp); diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldGenOrMethodGen.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldGenOrMethodGen.java index 12c995991..724c37ad8 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldGenOrMethodGen.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldGenOrMethodGen.java @@ -55,94 +55,114 @@ package org.aspectj.apache.bcel.generic; */ import java.util.ArrayList; +import java.util.List; -import org.aspectj.apache.bcel.Constants; -import org.aspectj.apache.bcel.classfile.AccessFlags; +import org.aspectj.apache.bcel.classfile.Modifiers; import org.aspectj.apache.bcel.classfile.Attribute; -import org.aspectj.apache.bcel.generic.annotation.AnnotationGen; +import org.aspectj.apache.bcel.classfile.ConstantPool; +import org.aspectj.apache.bcel.classfile.Utility; +import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; /** - * Super class for FieldGen and MethodGen objects, since they have - * some methods in common! - * - * @version $Id: FieldGenOrMethodGen.java,v 1.3 2004/11/22 08:31:27 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> + * Super class for FieldGen and MethodGen objects, since they have some methods + * in common! + * + * @version $Id: FieldGenOrMethodGen.java,v 1.4 2008/05/28 23:52:59 aclement Exp $ + * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ -public abstract class FieldGenOrMethodGen extends AccessFlags - implements NamedAndTyped, Cloneable -{ - protected String name; - protected Type type; - protected ConstantPoolGen cp; - private ArrayList attribute_vec = new ArrayList(); - protected ArrayList annotation_vec= new ArrayList(); - - protected FieldGenOrMethodGen() {} - - public void setType(Type type) { - if(type.getType() == Constants.T_ADDRESS) - throw new IllegalArgumentException("Type can not be " + type); - - this.type = type; - } - public Type getType() { return type; } - - /** @return name of method/field. - */ - public String getName() { return name; } - public void setName(String name) { this.name = name; } - - public ConstantPoolGen getConstantPool() { return cp; } - public void setConstantPool(ConstantPoolGen cp) { this.cp = cp; } - - /** - * Add an attribute to this method. Currently, the JVM knows about - * the `Code', `ConstantValue', `Synthetic' and `Exceptions' - * attributes. Other attributes will be ignored by the JVM but do no - * harm. - * - * @param a attribute to be added - */ - public void addAttribute(Attribute a) { attribute_vec.add(a); } - public void addAnnotation(AnnotationGen ag) { annotation_vec.add(ag);} - - /** - * Remove an attribute. - */ - public void removeAttribute(Attribute a) { attribute_vec.remove(a); } - public void removeAnnotation(AnnotationGen ag) { annotation_vec.remove(ag);} - - /** - * Remove all attributes. - */ - public void removeAttributes() { attribute_vec.clear(); } - public void removeAnnotations(){ annotation_vec.clear();} - - /** - * @return all attributes of this method. - */ - public Attribute[] getAttributes() { - Attribute[] attributes = new Attribute[attribute_vec.size()]; - attribute_vec.toArray(attributes); - return attributes; - } - - public AnnotationGen[] getAnnotations() { - AnnotationGen[] annotations = new AnnotationGen[annotation_vec.size()]; - annotation_vec.toArray(annotations); - return annotations; - } - - /** @return signature of method/field. - */ - public abstract String getSignature(); - - public Object clone() { - try { - return super.clone(); - } catch(CloneNotSupportedException e) { - System.err.println(e); - return null; - } - } +public abstract class FieldGenOrMethodGen extends Modifiers implements Cloneable { + + protected String name; + protected Type type; + protected ConstantPool cp; + private ArrayList/*<Attribute>*/ attributeList = new ArrayList(); + private ArrayList annotationList = new ArrayList(); + + protected FieldGenOrMethodGen() { + } + + public void setType(Type type) { + this.type = type; + } + + public Type getType() { + return type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ConstantPool getConstantPool() { + return cp; + } + + public void setConstantPool(ConstantPool cp) { + this.cp = cp; + } + + public void addAttribute(Attribute a) { + attributeList.add(a); + } + + public void removeAttribute(Attribute a) { + attributeList.remove(a); + } + + public void removeAttributes() { + attributeList.clear(); + } + + public void addAnnotation(AnnotationGen ag) { + annotationList.add(ag); + } + + public void removeAnnotation(AnnotationGen ag) { + annotationList.remove(ag); + } + + public void removeAnnotations() { + annotationList.clear(); + } + + public List/*<Attribute>*/ getAttributes() { + return attributeList; + } + + public Attribute[] getAttributesImmutable() { + Attribute[] attributes = new Attribute[attributeList.size()]; + attributeList.toArray(attributes); + return attributes; + } + + protected void addAnnotationsAsAttribute(ConstantPool cp) { + Attribute[] attrs = Utility.getAnnotationAttributes(cp,annotationList); + if (attrs!=null) { + for (int i = 0; i < attrs.length; i++) { + addAttribute(attrs[i]); + } + } + } + + public AnnotationGen[] getAnnotations() { + AnnotationGen[] annotations = new AnnotationGen[annotationList.size()]; + annotationList.toArray(annotations); + return annotations; + } + + public abstract String getSignature(); + + // OPTIMIZE clone any use??? + public Object clone() { + try { + return super.clone(); + } catch (CloneNotSupportedException e) { + System.err.println(e); + return null; + } + } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldInstruction.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldInstruction.java index c60419560..e7c67d2ef 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldInstruction.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldInstruction.java @@ -59,27 +59,15 @@ import org.aspectj.apache.bcel.classfile.ConstantPool; /** * Super class for the GET/PUTxxx family of instructions. * - * @version $Id: FieldInstruction.java,v 1.5 2006/07/19 12:06:16 aclement Exp $ + * @version $Id: FieldInstruction.java,v 1.6 2008/05/28 23:52:56 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ -public abstract class FieldInstruction extends FieldOrMethod - implements TypedInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - FieldInstruction() {} +public class FieldInstruction extends FieldOrMethod { - /** - * @param index to constant pool - */ - protected FieldInstruction(short opcode, int index) { + public FieldInstruction(short opcode, int index) { super(opcode, index); } - /** - * @return mnemonic for instruction with symbolic references resolved - */ public String toString(ConstantPool cp) { return org.aspectj.apache.bcel.Constants.OPCODE_NAMES[opcode] + " " + cp.constantToString(index, org.aspectj.apache.bcel.Constants.CONSTANT_Fieldref); @@ -87,26 +75,33 @@ public abstract class FieldInstruction extends FieldOrMethod /** @return size of field (1 or 2) */ - protected int getFieldSize(ConstantPoolGen cpg) { + protected int getFieldSize(ConstantPool cpg) { return Type.getTypeSize(getSignature(cpg)); } - /** @return return type of referenced field - */ - public Type getType(ConstantPoolGen cpg) { + public Type getType(ConstantPool cpg) { return getFieldType(cpg); } - /** @return type of field - */ - public Type getFieldType(ConstantPoolGen cpg) { + public Type getFieldType(ConstantPool cpg) { return Type.getType(getSignature(cpg)); } - /** @return name of referenced field. - */ - public String getFieldName(ConstantPoolGen cpg) { + + public String getFieldName(ConstantPool cpg) { return getName(cpg); } + + public int produceStack(ConstantPool cpg) { + if (!isStackProducer()) return 0; + + return getFieldSize(cpg); // SAME FOR GETFIELD/GETSTATIC + } + + public int consumeStack(ConstantPool cpg) { + if (!isStackConsumer()) return 0; + if (opcode==GETFIELD) return 1; + return getFieldSize(cpg)+(opcode==PUTFIELD?1:0); + } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldObserver.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldObserver.java deleted file mode 100644 index dfbf47970..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldObserver.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Imnplement this interface if you're interested in changes to a FieldGen object - * and register yourself with addObserver(). - * - * @version $Id: FieldObserver.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public interface FieldObserver { - public void notify(FieldGen field); -} - diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldOrMethod.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldOrMethod.java index 548be1f20..434ca757b 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldOrMethod.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldOrMethod.java @@ -62,23 +62,18 @@ import org.aspectj.apache.bcel.classfile.ConstantUtf8; * Super class for InvokeInstruction and FieldInstruction, since they have * some methods in common! * - * @version $Id: FieldOrMethod.java,v 1.5 2006/02/22 14:58:25 aclement Exp $ + * @version $Id: FieldOrMethod.java,v 1.6 2008/05/28 23:52:57 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ -public abstract class FieldOrMethod extends CPInstruction implements LoadClass { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - FieldOrMethod() {} +public abstract class FieldOrMethod extends InstructionCP { - private boolean dontKnowSignature=true; +// private boolean dontKnowSignature=true; private String signature; - private boolean dontKnowName =true; +// private boolean dontKnowName =true; private String name; - private boolean dontKnowClassname =true; +// private boolean dontKnowClassname =true; private String classname; /** @@ -90,54 +85,50 @@ public abstract class FieldOrMethod extends CPInstruction implements LoadClass { /** @return signature of referenced method/field. */ - public String getSignature(ConstantPoolGen cpg) { - if (dontKnowSignature) { - ConstantPool cp = cpg.getConstantPool(); + public String getSignature(ConstantPool cp) { + if (signature==null) { ConstantCP cmr = (ConstantCP)cp.getConstant(index); ConstantNameAndType cnat = (ConstantNameAndType)cp.getConstant(cmr.getNameAndTypeIndex()); signature = ((ConstantUtf8)cp.getConstant(cnat.getSignatureIndex())).getBytes(); - dontKnowSignature=false; +// dontKnowSignature=false; } return signature; } /** @return name of referenced method/field. */ - public String getName(ConstantPoolGen cpg) { - if (dontKnowName) { - ConstantPool cp = cpg.getConstantPool(); + public String getName(ConstantPool cp) { + if (name==null) { ConstantCP cmr = (ConstantCP)cp.getConstant(index); ConstantNameAndType cnat = (ConstantNameAndType)cp.getConstant(cmr.getNameAndTypeIndex()); name = ((ConstantUtf8)cp.getConstant(cnat.getNameIndex())).getBytes(); - dontKnowName = false; +// dontKnowName = false; } return name; } /** @return name of the referenced class/interface */ - public String getClassName(ConstantPoolGen cpg) { - if (dontKnowClassname) { - ConstantPool cp = cpg.getConstantPool(); + public String getClassName(ConstantPool cp) { + if (classname==null) { ConstantCP cmr = (ConstantCP)cp.getConstant(index); - String str = cp.getConstantString(cmr.getClassIndex(), org.aspectj.apache.bcel.Constants.CONSTANT_Class); - if (str.charAt(0)=='[') classname= str; - else classname= str.replace('/', '.'); - dontKnowClassname = false; + String str = cp.getConstantString(cmr.getClassIndex(), CONSTANT_Class); + if (str.charAt(0)=='[') classname= str; else classname= str.replace('/', '.'); +// dontKnowClassname = false; } return classname; } /** @return type of the referenced class/interface */ - public ObjectType getClassType(ConstantPoolGen cpg) { + public ObjectType getClassType(ConstantPool cpg) { return new ObjectType(getClassName(cpg)); } /** @return type of the referenced class/interface */ - public ObjectType getLoadClassType(ConstantPoolGen cpg) { + public ObjectType getLoadClassType(ConstantPool cpg) { return getClassType(cpg); } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/GETFIELD.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/GETFIELD.java deleted file mode 100644 index c49b393ba..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/GETFIELD.java +++ /dev/null @@ -1,117 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -import org.aspectj.apache.bcel.Constants; -import org.aspectj.apache.bcel.ExceptionConstants; - -/** - * GETFIELD - Fetch field from object - * <PRE>Stack: ..., objectref -> ..., value</PRE> - * OR - * <PRE>Stack: ..., objectref -> ..., value.word1, value.word2</PRE> - * - * @version $Id: GETFIELD.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class GETFIELD extends FieldInstruction - implements ExceptionThrower, StackConsumer, StackProducer { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - GETFIELD() {} - - public GETFIELD(int index) { - super(Constants.GETFIELD, index); - } - - public int produceStack(ConstantPoolGen cpg) { return getFieldSize(cpg); } - - public Class[] getExceptions() { - Class[] cs = new Class[2 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length]; - - System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0, - cs, 0, ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length); - - cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length+1] = - ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR; - cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] = - ExceptionConstants.NULL_POINTER_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.visitExceptionThrower(this); - v.visitStackConsumer(this); - v.visitStackProducer(this); - v.visitTypedInstruction(this); - v.visitLoadClass(this); - v.visitCPInstruction(this); - v.visitFieldOrMethod(this); - v.visitFieldInstruction(this); - v.visitGETFIELD(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/GETSTATIC.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/GETSTATIC.java deleted file mode 100644 index 214182096..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/GETSTATIC.java +++ /dev/null @@ -1,113 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -import org.aspectj.apache.bcel.Constants; -import org.aspectj.apache.bcel.ExceptionConstants; - -/** - * GETSTATIC - Fetch static field from class - * <PRE>Stack: ..., -> ..., value</PRE> - * OR - * <PRE>Stack: ..., -> ..., value.word1, value.word2</PRE> - * - * @version $Id: GETSTATIC.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class GETSTATIC extends FieldInstruction implements PushInstruction, ExceptionThrower { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - GETSTATIC() {} - - public GETSTATIC(int index) { - super(Constants.GETSTATIC, index); - } - - public int produceStack(ConstantPoolGen cpg) { return getFieldSize(cpg); } - - public Class[] getExceptions() { - Class[] cs = new Class[1 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length]; - - System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0, - cs, 0, ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length); - cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] = - ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR; - - 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.visitStackProducer(this); - v.visitPushInstruction(this); - v.visitExceptionThrower(this); - v.visitTypedInstruction(this); - v.visitLoadClass(this); - v.visitCPInstruction(this); - v.visitFieldOrMethod(this); - v.visitFieldInstruction(this); - v.visitGETSTATIC(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/GOTO.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/GOTO.java deleted file mode 100644 index d36a2f5a8..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/GOTO.java +++ /dev/null @@ -1,122 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ -import java.io.*; - -/** - * GOTO - Branch always (to relative offset, not absolute address) - * - * @version $Id: GOTO.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class GOTO extends GotoInstruction implements VariableLengthInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - GOTO() {} - - public GOTO(InstructionHandle target) { - super(org.aspectj.apache.bcel.Constants.GOTO, target); - } - - /** - * Dump instruction as byte code to stream out. - * @param out Output stream - */ - public void dump(DataOutputStream out) throws IOException { - index = getTargetOffset(); - if(opcode == org.aspectj.apache.bcel.Constants.GOTO) - super.dump(out); - else { // GOTO_W - index = getTargetOffset(); - out.writeByte(opcode); - out.writeInt(index); - } - } - - /** Called in pass 2 of InstructionList.setPositions() in order to update - * the branch target, that may shift due to variable length instructions. - */ - protected int updatePosition(int offset, int max_offset) { - int i = getTargetOffset(); // Depending on old position value - - position += offset; // Position may be shifted by preceding expansions - - if(Math.abs(i) >= (32767 - max_offset)) { // to large for short (estimate) - opcode = org.aspectj.apache.bcel.Constants.GOTO_W; - length = 5; - return 2; // 5 - 3 - } - - return 0; - } - - /** - * 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.visitVariableLengthInstruction(this); - v.visitUnconditionalBranch(this); - v.visitBranchInstruction(this); - v.visitGotoInstruction(this); - v.visitGOTO(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/GOTO_W.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/GOTO_W.java deleted file mode 100644 index 9212255b1..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/GOTO_W.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ -import java.io.*; -import org.aspectj.apache.bcel.util.ByteSequence; - -/** - * GOTO_W - Branch always (to relative offset, not absolute address) - * - * @version $Id: GOTO_W.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class GOTO_W extends GotoInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - GOTO_W() {} - - public GOTO_W(InstructionHandle target) { - super(org.aspectj.apache.bcel.Constants.GOTO_W, target); - length = 5; - } - - /** - * Dump instruction as byte code to stream out. - * @param out Output stream - */ - public void dump(DataOutputStream out) throws IOException { - index = getTargetOffset(); - out.writeByte(opcode); - out.writeInt(index); - } - - /** - * Read needed data (e.g. index) from file. - */ - protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException - { - index = bytes.readInt(); - length = 5; - } - - /** - * 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.visitBranchInstruction(this); - v.visitGotoInstruction(this); - v.visitGOTO_W(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/I2B.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/I2B.java deleted file mode 100644 index 11b456459..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/I2B.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * I2B - Convert int to byte - * <PRE>Stack: ..., value -> ..., result</PRE> - * - * @version $Id: I2B.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class I2B extends ConversionInstruction { - /** Convert int to byte - */ - public I2B() { - super(org.aspectj.apache.bcel.Constants.I2B); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitConversionInstruction(this); - v.visitI2B(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/I2C.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/I2C.java deleted file mode 100644 index 02cc1f1ab..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/I2C.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * I2C - Convert int to char - * <PRE>Stack: ..., value -> ..., result</PRE> - * - * @version $Id: I2C.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class I2C extends ConversionInstruction { - /** Convert int to char - */ - public I2C() { - super(org.aspectj.apache.bcel.Constants.I2C); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitConversionInstruction(this); - v.visitI2C(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/I2D.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/I2D.java deleted file mode 100644 index ae965dbcc..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/I2D.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * I2D - Convert int to double - * <PRE>Stack: ..., value -> ..., result.word1, result.word2</PRE> - * - * @version $Id: I2D.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class I2D extends ConversionInstruction { - /** Convert int to double - */ - public I2D() { - super(org.aspectj.apache.bcel.Constants.I2D); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitConversionInstruction(this); - v.visitI2D(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/I2F.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/I2F.java deleted file mode 100644 index 3e68badef..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/I2F.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * I2F - Convert int to float - * <PRE>Stack: ..., value -> ..., result</PRE> - * - * @version $Id: I2F.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class I2F extends ConversionInstruction { - /** Convert int to float - */ - public I2F() { - super(org.aspectj.apache.bcel.Constants.I2F); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitConversionInstruction(this); - v.visitI2F(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/I2L.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/I2L.java deleted file mode 100644 index ef5866280..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/I2L.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * I2L - Convert int to long - * <PRE>Stack: ..., value -> ..., result.word1, result.word2</PRE> - * - * @version $Id: I2L.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class I2L extends ConversionInstruction { - /** Convert int to long - */ - public I2L() { - super(org.aspectj.apache.bcel.Constants.I2L); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitConversionInstruction(this); - v.visitI2L(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/I2S.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/I2S.java deleted file mode 100644 index 83f991d6d..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/I2S.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * I2S - Convert int to short - * <PRE>Stack: ..., value -> ..., result</PRE> - * - * @version $Id: I2S.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class I2S extends ConversionInstruction { - public I2S() { - super(org.aspectj.apache.bcel.Constants.I2S); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitConversionInstruction(this); - v.visitI2S(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IADD.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IADD.java deleted file mode 100644 index 528b5158b..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IADD.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IADD - Add ints - * <PRE>Stack: ..., value1, value2 -> result</PRE> - * - * @version $Id: IADD.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IADD extends ArithmeticInstruction { - /** Add ints - */ - public IADD() { - super(org.aspectj.apache.bcel.Constants.IADD); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitIADD(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IALOAD.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IALOAD.java deleted file mode 100644 index 64ff778a2..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IALOAD.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IALOAD - Load int from array - * <PRE>Stack: ..., arrayref, index -> ..., value</PRE> - * - * @version $Id: IALOAD.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IALOAD extends ArrayInstruction implements StackProducer { - /** - * Load int from array - */ - public IALOAD() { - super(org.aspectj.apache.bcel.Constants.IALOAD); - } - - - /** - * 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.visitIALOAD(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IAND.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IAND.java deleted file mode 100644 index 3cddc41a7..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IAND.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IAND - Bitwise AND int - * <PRE>Stack: ..., value1, value2 -> ..., result</PRE> - * - * @version $Id: IAND.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IAND extends ArithmeticInstruction { - public IAND() { - super(org.aspectj.apache.bcel.Constants.IAND); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitIAND(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IASTORE.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IASTORE.java deleted file mode 100644 index 6cc20d5b7..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IASTORE.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IASTORE - Store into int array - * <PRE>Stack: ..., arrayref, index, value -> ...</PRE> - * - * @version $Id: IASTORE.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IASTORE extends ArrayInstruction implements StackConsumer { - /** - * Store into int array - */ - public IASTORE() { - super(org.aspectj.apache.bcel.Constants.IASTORE); - } - - - /** - * 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.visitIASTORE(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ICONST.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ICONST.java deleted file mode 100644 index d83418ca3..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ICONST.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * ICONST - Push value between -1, ..., 5, other values cause an exception - * - * <PRE>Stack: ... -> ..., </PRE> - * - * @version $Id: ICONST.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class ICONST extends Instruction - implements ConstantPushInstruction, TypedInstruction { - private int value; - - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - ICONST() {} - - public ICONST(int i) { - super(org.aspectj.apache.bcel.Constants.ICONST_0, (short)1); - - if((i >= -1) && (i <= 5)) - opcode = (short)(org.aspectj.apache.bcel.Constants.ICONST_0 + i); // Even works for i == -1 - else - throw new ClassGenException("ICONST can be used only for value between -1 and 5: " + - i); - value = i; - } - - public Number getValue() { return new Integer(value); } - - /** @return Type.INT - */ - public Type getType(ConstantPoolGen cp) { - return Type.INT; - } - - /** - * 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.visitICONST(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IDIV.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IDIV.java deleted file mode 100644 index a56e52636..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IDIV.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IDIV - Divide ints - * <PRE>Stack: ..., value1, value2 -> result</PRE> - * - * @version $Id: IDIV.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IDIV extends ArithmeticInstruction implements ExceptionThrower { - /** Divide ints - */ - public IDIV() { - super(org.aspectj.apache.bcel.Constants.IDIV); - } - - /** @return exceptions this instruction may cause - */ - public Class[] getExceptions() { - return new Class[] { org.aspectj.apache.bcel.ExceptionConstants.ARITHMETIC_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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitIDIV(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IFEQ.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IFEQ.java deleted file mode 100644 index 904956676..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IFEQ.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IFEQ - Branch if int comparison with zero succeeds - * - * <PRE>Stack: ..., value -> ...</PRE> - * - * @version $Id: IFEQ.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IFEQ extends IfInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - IFEQ() {} - - public IFEQ(InstructionHandle target) { - super(org.aspectj.apache.bcel.Constants.IFEQ, target); - } - - /** - * @return negation of instruction, e.g. IFEQ.negate() == IFNE - */ - public IfInstruction negate() { - return new IFNE(target); - } - - - /** - * 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.visitBranchInstruction(this); - v.visitIfInstruction(this); - v.visitIFEQ(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IFGE.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IFGE.java deleted file mode 100644 index 0eba8b050..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IFGE.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IFGE - Branch if int comparison with zero succeeds - * - * <PRE>Stack: ..., value -> ...</PRE> - * - * @version $Id: IFGE.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IFGE extends IfInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - IFGE() {} - - public IFGE(InstructionHandle target) { - super(org.aspectj.apache.bcel.Constants.IFGE, target); - } - - /** - * @return negation of instruction - */ - public IfInstruction negate() { - return new IFLT(target); - } - - - /** - * 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.visitBranchInstruction(this); - v.visitIfInstruction(this); - v.visitIFGE(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IFGT.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IFGT.java deleted file mode 100644 index e36493f79..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IFGT.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IFGT - Branch if int comparison with zero succeeds - * - * <PRE>Stack: ..., value -> ...</PRE> - * - * @version $Id: IFGT.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IFGT extends IfInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - IFGT() {} - - public IFGT(InstructionHandle target) { - super(org.aspectj.apache.bcel.Constants.IFGT, target); - } - - /** - * @return negation of instruction - */ - public IfInstruction negate() { - return new IFLE(target); - } - - - /** - * 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.visitBranchInstruction(this); - v.visitIfInstruction(this); - v.visitIFGT(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IFLE.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IFLE.java deleted file mode 100644 index 706095e39..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IFLE.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IFLE - Branch if int comparison with zero succeeds - * - * <PRE>Stack: ..., value -> ...</PRE> - * - * @version $Id: IFLE.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IFLE extends IfInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - IFLE() {} - - public IFLE(InstructionHandle target) { - super(org.aspectj.apache.bcel.Constants.IFLE, target); - } - - /** - * @return negation of instruction - */ - public IfInstruction negate() { - return new IFGT(target); - } - - - /** - * 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.visitBranchInstruction(this); - v.visitIfInstruction(this); - v.visitIFLE(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IFLT.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IFLT.java deleted file mode 100644 index c0ca3ebbb..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IFLT.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IFLT - Branch if int comparison with zero succeeds - * - * <PRE>Stack: ..., value -> ...</PRE> - * - * @version $Id: IFLT.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IFLT extends IfInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - IFLT() {} - - public IFLT(InstructionHandle target) { - super(org.aspectj.apache.bcel.Constants.IFLT, target); - } - - /** - * @return negation of instruction - */ - public IfInstruction negate() { - return new IFGE(target); - } - - - /** - * 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.visitBranchInstruction(this); - v.visitIfInstruction(this); - v.visitIFLT(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IFNE.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IFNE.java deleted file mode 100644 index 7a0770f4d..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IFNE.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IFNE - Branch if int comparison with zero succeeds - * - * <PRE>Stack: ..., value -> ...</PRE> - * - * @version $Id: IFNE.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IFNE extends IfInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - IFNE() {} - - public IFNE(InstructionHandle target) { - super(org.aspectj.apache.bcel.Constants.IFNE, target); - } - - /** - * @return negation of instruction - */ - public IfInstruction negate() { - return new IFEQ(target); - } - - - /** - * 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.visitBranchInstruction(this); - v.visitIfInstruction(this); - v.visitIFNE(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IFNONNULL.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IFNONNULL.java deleted file mode 100644 index 147f63062..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IFNONNULL.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IFNONNULL - Branch if reference is not null - * - * <PRE>Stack: ..., reference -> ...</PRE> - * - * @version $Id: IFNONNULL.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IFNONNULL extends IfInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - IFNONNULL() {} - - public IFNONNULL(InstructionHandle target) { - super(org.aspectj.apache.bcel.Constants.IFNONNULL, target); - } - - /** - * @return negation of instruction - */ - public IfInstruction negate() { - return new IFNULL(target); - } - - /** - * 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.visitBranchInstruction(this); - v.visitIfInstruction(this); - v.visitIFNONNULL(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IFNULL.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IFNULL.java deleted file mode 100644 index 6275c7692..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IFNULL.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IFNULL - Branch if reference is not null - * - * <PRE>Stack: ..., reference -> ...</PRE> - * - * @version $Id: IFNULL.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IFNULL extends IfInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - IFNULL() {} - - public IFNULL(InstructionHandle target) { - super(org.aspectj.apache.bcel.Constants.IFNULL, target); - } - - /** - * @return negation of instruction - */ - public IfInstruction negate() { - return new IFNONNULL(target); - } - - - /** - * 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.visitBranchInstruction(this); - v.visitIfInstruction(this); - v.visitIFNULL(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IF_ACMPEQ.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IF_ACMPEQ.java deleted file mode 100644 index eeb39fb29..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IF_ACMPEQ.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IF_ACMPEQ - Branch if reference comparison succeeds - * - * <PRE>Stack: ..., value1, value2 -> ...</PRE> - * - * @version $Id: IF_ACMPEQ.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IF_ACMPEQ extends IfInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - IF_ACMPEQ() {} - - public IF_ACMPEQ(InstructionHandle target) { - super(org.aspectj.apache.bcel.Constants.IF_ACMPEQ, target); - } - - /** - * @return negation of instruction - */ - public IfInstruction negate() { - return new IF_ACMPNE(target); - } - - /** - * 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.visitBranchInstruction(this); - v.visitIfInstruction(this); - v.visitIF_ACMPEQ(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IF_ACMPNE.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IF_ACMPNE.java deleted file mode 100644 index db74748ef..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IF_ACMPNE.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IF_ACMPNE - Branch if reference comparison doesn't succeed - * - * <PRE>Stack: ..., value1, value2 -> ...</PRE> - * - * @version $Id: IF_ACMPNE.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IF_ACMPNE extends IfInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - IF_ACMPNE() {} - - public IF_ACMPNE(InstructionHandle target) { - super(org.aspectj.apache.bcel.Constants.IF_ACMPNE, target); - } - - /** - * @return negation of instruction - */ - public IfInstruction negate() { - return new IF_ACMPEQ(target); - } - - - /** - * 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.visitBranchInstruction(this); - v.visitIfInstruction(this); - v.visitIF_ACMPNE(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IF_ICMPEQ.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IF_ICMPEQ.java deleted file mode 100644 index 26de9e2b1..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IF_ICMPEQ.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IF_ICMPEQ - Branch if int comparison succeeds - * - * <PRE>Stack: ..., value1, value2 -> ...</PRE> - * - * @version $Id: IF_ICMPEQ.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IF_ICMPEQ extends IfInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - IF_ICMPEQ() {} - - public IF_ICMPEQ(InstructionHandle target) { - super(org.aspectj.apache.bcel.Constants.IF_ICMPEQ, target); - } - - /** - * @return negation of instruction - */ - public IfInstruction negate() { - return new IF_ICMPNE(target); - } - - - /** - * 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.visitBranchInstruction(this); - v.visitIfInstruction(this); - v.visitIF_ICMPEQ(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IF_ICMPGE.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IF_ICMPGE.java deleted file mode 100644 index a679fae95..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IF_ICMPGE.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IF_ICMPGE - Branch if int comparison succeeds - * - * <PRE>Stack: ..., value1, value2 -> ...</PRE> - * - * @version $Id: IF_ICMPGE.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IF_ICMPGE extends IfInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - IF_ICMPGE() {} - - public IF_ICMPGE(InstructionHandle target) { - super(org.aspectj.apache.bcel.Constants.IF_ICMPGE, target); - } - - /** - * @return negation of instruction - */ - public IfInstruction negate() { - return new IF_ICMPLT(target); - } - - - /** - * 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.visitBranchInstruction(this); - v.visitIfInstruction(this); - v.visitIF_ICMPGE(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IF_ICMPGT.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IF_ICMPGT.java deleted file mode 100644 index 99cde3dd8..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IF_ICMPGT.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IF_ICMPGT - Branch if int comparison succeeds - * - * <PRE>Stack: ..., value1, value2 -> ...</PRE> - * - * @version $Id: IF_ICMPGT.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IF_ICMPGT extends IfInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - IF_ICMPGT() {} - - public IF_ICMPGT(InstructionHandle target) { - super(org.aspectj.apache.bcel.Constants.IF_ICMPGT, target); - } - - /** - * @return negation of instruction - */ - public IfInstruction negate() { - return new IF_ICMPLE(target); - } - - - /** - * 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.visitBranchInstruction(this); - v.visitIfInstruction(this); - v.visitIF_ICMPGT(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IF_ICMPLE.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IF_ICMPLE.java deleted file mode 100644 index 1149c0918..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IF_ICMPLE.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IF_ICMPLE - Branch if int comparison succeeds - * - * <PRE>Stack: ..., value1, value2 -> ...</PRE> - * - * @version $Id: IF_ICMPLE.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IF_ICMPLE extends IfInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - IF_ICMPLE() {} - - public IF_ICMPLE(InstructionHandle target) { - super(org.aspectj.apache.bcel.Constants.IF_ICMPLE, target); - } - - /** - * @return negation of instruction - */ - public IfInstruction negate() { - return new IF_ICMPGT(target); - } - - - /** - * 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.visitBranchInstruction(this); - v.visitIfInstruction(this); - v.visitIF_ICMPLE(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IF_ICMPLT.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IF_ICMPLT.java deleted file mode 100644 index 1ad059507..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IF_ICMPLT.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IF_ICMPLT - Branch if int comparison succeeds - * - * <PRE>Stack: ..., value1, value2 -> ...</PRE> - * - * @version $Id: IF_ICMPLT.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IF_ICMPLT extends IfInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - IF_ICMPLT() {} - - public IF_ICMPLT(InstructionHandle target) { - super(org.aspectj.apache.bcel.Constants.IF_ICMPLT, target); - } - - /** - * @return negation of instruction - */ - public IfInstruction negate() { - return new IF_ICMPGE(target); - } - - - /** - * 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.visitBranchInstruction(this); - v.visitIfInstruction(this); - v.visitIF_ICMPLT(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IF_ICMPNE.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IF_ICMPNE.java deleted file mode 100644 index 0fafcbd5a..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IF_ICMPNE.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IF_ICMPNE - Branch if int comparison doesn't succeed - * - * <PRE>Stack: ..., value1, value2 -> ...</PRE> - * - * @version $Id: IF_ICMPNE.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IF_ICMPNE extends IfInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - IF_ICMPNE() {} - - public IF_ICMPNE(InstructionHandle target) { - super(org.aspectj.apache.bcel.Constants.IF_ICMPNE, target); - } - - /** - * @return negation of instruction - */ - public IfInstruction negate() { - return new IF_ICMPEQ(target); - } - - - /** - * 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.visitBranchInstruction(this); - v.visitIfInstruction(this); - v.visitIF_ICMPNE(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IINC.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IINC.java index 7440221e5..6df506e44 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IINC.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/IINC.java @@ -54,130 +54,55 @@ package org.aspectj.apache.bcel.generic; * <http://www.apache.org/>. */ import java.io.*; -import org.aspectj.apache.bcel.util.ByteSequence; + +import org.aspectj.apache.bcel.Constants; /** * IINC - Increment local variable by constant * - * @version $Id: IINC.java,v 1.3 2005/08/12 15:58:50 acolyer Exp $ + * @version $Id: IINC.java,v 1.4 2008/05/28 23:52:57 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ -public class IINC extends LocalVariableInstruction { - private boolean wide; +public class IINC extends InstructionLV { private int c; - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - IINC() {} - - /** - * @param n index of local variable - * @param c increment factor - */ - public IINC(int n, int c) { - super(); // Default behaviour of LocalVariableInstruction causes error - - this.opcode = org.aspectj.apache.bcel.Constants.IINC; - this.length = (short)3; + public IINC(int n, int c,boolean w) { + super(Constants.IINC,n); + this.c=c; +// this.wide = w;//((n > org.aspectj.apache.bcel.Constants.MAX_BYTE) || (Math.abs(c) > Byte.MAX_VALUE)); + } - setIndex(n); // May set wide as side effect - setIncrement(c); + private boolean wide() { + return ((lvar > org.aspectj.apache.bcel.Constants.MAX_BYTE) || (Math.abs(c) > Byte.MAX_VALUE)); } - /** - * Dump instruction as byte code to stream out. - * @param out Output stream - */ public void dump(DataOutputStream out) throws IOException { - if(wide) // Need WIDE prefix ? - out.writeByte(org.aspectj.apache.bcel.Constants.WIDE); - - out.writeByte(opcode); - - if(wide) { - out.writeShort(n); - out.writeShort(c); - } else { - out.writeByte(n); - out.writeByte(c); - } + if (wide()) { + out.writeByte(WIDE); + out.writeByte(opcode); + out.writeShort(lvar); + out.writeShort(c); + } else { + out.writeByte(opcode); + out.writeByte(lvar); + out.writeByte(c); + } } - - private final void setWide() { - if(wide = ((n > org.aspectj.apache.bcel.Constants.MAX_BYTE) || - (Math.abs(c) > Byte.MAX_VALUE))) - length = 6; // wide byte included - else - length = 3; + + + public int getLength() { + if (wide()) return 6; else return 3; // includes wide byte } - /** - * Read needed data (e.g. index) from file. - */ - protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException - { - this.wide = wide; - - if(wide) { - length = 6; - n = bytes.readUnsignedShort(); - c = bytes.readShort(); - } else { - length = 3; - n = bytes.readUnsignedByte(); - c = bytes.readByte(); - } - } - - /** - * @return mnemonic for instruction - */ public String toString(boolean verbose) { return super.toString(verbose) + " " + c; } - /** - * Set index of local variable. - */ - public final void setIndex(int n) { - if(n < 0) - throw new ClassGenException("Negative index value: " + n); - - this.n = n; - setWide(); - } - - /** - * @return increment factor - */ public final int getIncrement() { return c; } - /** - * Set increment factor. - */ - public final void setIncrement(int c) { - this.c = c; - setWide(); - } - - /** @return int type - */ - public Type getType(ConstantPoolGen cp) { - return Type.INT; - } +// //fixme promote or stick in a table +// public Type getType(ConstantPoolGen cp) { +// return Type.INT; +// } - /** - * 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.visitLocalVariableInstruction(this); - v.visitIINC(this); - } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ILOAD.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ILOAD.java deleted file mode 100644 index 5c68bff3f..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ILOAD.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * ILOAD - Load int from local variable onto stack - * <PRE>Stack: ... -> ..., result</PRE> - * - * @version $Id: ILOAD.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class ILOAD extends LoadInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - ILOAD() { - super(org.aspectj.apache.bcel.Constants.ILOAD, org.aspectj.apache.bcel.Constants.ILOAD_0); - } - - /** Load int from local variable - * @param n index of local variable - */ - public ILOAD(int n) { - super(org.aspectj.apache.bcel.Constants.ILOAD, org.aspectj.apache.bcel.Constants.ILOAD_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.visitILOAD(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IMPDEP1.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IMPDEP1.java deleted file mode 100644 index 0084156a4..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IMPDEP1.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IMPDEP1 - Implementation dependent - * - * @version $Id: IMPDEP1.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IMPDEP1 extends Instruction { - public IMPDEP1() { - super(org.aspectj.apache.bcel.Constants.IMPDEP1, (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.visitIMPDEP1(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IMPDEP2.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IMPDEP2.java deleted file mode 100644 index 20cdc7758..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IMPDEP2.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IMPDEP2 - Implementation dependent - * - * @version $Id: IMPDEP2.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IMPDEP2 extends Instruction { - public IMPDEP2() { - super(org.aspectj.apache.bcel.Constants.IMPDEP2, (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.visitIMPDEP2(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IMUL.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IMUL.java deleted file mode 100644 index f435d8899..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IMUL.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IMUL - Multiply ints - * <PRE>Stack: ..., value1, value2 -> result</PRE> - * - * @version $Id: IMUL.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IMUL extends ArithmeticInstruction { - /** Multiply ints - */ - public IMUL() { - super(org.aspectj.apache.bcel.Constants.IMUL); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitIMUL(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/INEG.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/INEG.java deleted file mode 100644 index b5d72cb6b..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/INEG.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * INEG - Negate int - * <PRE>Stack: ..., value -> ..., result</PRE> - * - * @version $Id: INEG.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class INEG extends ArithmeticInstruction { - public INEG() { - super(org.aspectj.apache.bcel.Constants.INEG); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitINEG(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/INSTANCEOF.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/INSTANCEOF.java deleted file mode 100644 index ea6dbdf8a..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/INSTANCEOF.java +++ /dev/null @@ -1,106 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * INSTANCEOF - Determine if object is of given type - * <PRE>Stack: ..., objectref -> ..., result</PRE> - * - * @version $Id: INSTANCEOF.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class INSTANCEOF extends CPInstruction - implements LoadClass, ExceptionThrower, StackProducer, StackConsumer { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - INSTANCEOF() {} - - public INSTANCEOF(int index) { - super(org.aspectj.apache.bcel.Constants.INSTANCEOF, index); - } - - public Class[] getExceptions() { - return org.aspectj.apache.bcel.ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION; - } - - 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.visitINSTANCEOF(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/INVOKEINTERFACE.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/INVOKEINTERFACE.java index 2d49539fd..6f60afdac 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/INVOKEINTERFACE.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/INVOKEINTERFACE.java @@ -55,30 +55,22 @@ package org.aspectj.apache.bcel.generic; */ import org.aspectj.apache.bcel.classfile.ConstantPool; import org.aspectj.apache.bcel.Constants; -import org.aspectj.apache.bcel.ExceptionConstants; import java.io.*; -import org.aspectj.apache.bcel.util.ByteSequence; /** * INVOKEINTERFACE - Invoke interface method * <PRE>Stack: ..., objectref, [arg1, [arg2 ...]] -> ...</PRE> * - * @version $Id: INVOKEINTERFACE.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: INVOKEINTERFACE.java,v 1.3 2008/05/28 23:52:58 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public final class INVOKEINTERFACE extends InvokeInstruction { private int nargs; // Number of arguments on stack (number of stack slots), called "count" in vmspec2 - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - INVOKEINTERFACE() {} - public INVOKEINTERFACE(int index, int nargs) { + public INVOKEINTERFACE(int index, int nargs,int zerobyte) { super(Constants.INVOKEINTERFACE, index); - length = 5; if(nargs < 1) throw new ClassGenException("Number of arguments must be > 0 " + nargs); @@ -103,18 +95,6 @@ public final class INVOKEINTERFACE extends InvokeInstruction { */ public int getCount() { return nargs; } - /** - * Read needed data (i.e., index) from file. - */ - protected void initFromFile(ByteSequence bytes, boolean wide) - throws IOException - { - super.initFromFile(bytes, wide); - - length = 5; - nargs = bytes.readUnsignedByte(); - bytes.readByte(); // Skip 0 byte - } /** * @return mnemonic for instruction with symbolic references resolved @@ -123,41 +103,8 @@ public final class INVOKEINTERFACE extends InvokeInstruction { return super.toString(cp) + " " + nargs; } - public int consumeStack(ConstantPoolGen cpg) { // nargs is given in byte-code + public int consumeStack(ConstantPool cpg) { // nargs is given in byte-code return nargs; // nargs includes this reference } - public Class[] getExceptions() { - Class[] cs = new Class[4 + ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION.length]; - - System.arraycopy(ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION, 0, - cs, 0, ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION.length); - - cs[ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION.length+3] = ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR; - cs[ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION.length+2] = ExceptionConstants.ILLEGAL_ACCESS_ERROR; - cs[ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION.length+1] = ExceptionConstants.ABSTRACT_METHOD_ERROR; - cs[ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION.length] = ExceptionConstants.UNSATISFIED_LINK_ERROR; - - 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.visitExceptionThrower(this); - v.visitTypedInstruction(this); - v.visitStackConsumer(this); - v.visitStackProducer(this); - v.visitLoadClass(this); - v.visitCPInstruction(this); - v.visitFieldOrMethod(this); - v.visitInvokeInstruction(this); - v.visitINVOKEINTERFACE(this); - } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/INVOKESPECIAL.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/INVOKESPECIAL.java deleted file mode 100644 index 7cc32776b..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/INVOKESPECIAL.java +++ /dev/null @@ -1,113 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ -import org.aspectj.apache.bcel.Constants; -import org.aspectj.apache.bcel.ExceptionConstants; - -/** - * INVOKESPECIAL - Invoke instance method; special handling for superclass, private - * and instance initialization method invocations - * - * <PRE>Stack: ..., objectref, [arg1, [arg2 ...]] -> ...</PRE> - * - * @version $Id: INVOKESPECIAL.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class INVOKESPECIAL extends InvokeInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - INVOKESPECIAL() {} - - public INVOKESPECIAL(int index) { - super(Constants.INVOKESPECIAL, index); - } - - public Class[] getExceptions() { - Class[] cs = new Class[4 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length]; - - System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0, - cs, 0, ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length); - - cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length+3] = ExceptionConstants.UNSATISFIED_LINK_ERROR; - cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length+2] = ExceptionConstants.ABSTRACT_METHOD_ERROR; - cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length+1] = ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR; - cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] = ExceptionConstants.NULL_POINTER_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.visitExceptionThrower(this); - v.visitTypedInstruction(this); - v.visitStackConsumer(this); - v.visitStackProducer(this); - v.visitLoadClass(this); - v.visitCPInstruction(this); - v.visitFieldOrMethod(this); - v.visitInvokeInstruction(this); - v.visitINVOKESPECIAL(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/INVOKESTATIC.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/INVOKESTATIC.java deleted file mode 100644 index d905ae9c6..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/INVOKESTATIC.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ -import org.aspectj.apache.bcel.Constants; -import org.aspectj.apache.bcel.ExceptionConstants; - -/** - * INVOKESTATIC - Invoke a class (static) method - * - * <PRE>Stack: ..., [arg1, [arg2 ...]] -> ...</PRE> - * - * @version $Id: INVOKESTATIC.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class INVOKESTATIC extends InvokeInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - INVOKESTATIC() {} - - public INVOKESTATIC(int index) { - super(Constants.INVOKESTATIC, index); - } - - public Class[] getExceptions() { - Class[] cs = new Class[2 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length]; - - System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0, - cs, 0, ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length); - - cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] = ExceptionConstants.UNSATISFIED_LINK_ERROR; - cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length+1] = ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR; - - 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.visitExceptionThrower(this); - v.visitTypedInstruction(this); - v.visitStackConsumer(this); - v.visitStackProducer(this); - v.visitLoadClass(this); - v.visitCPInstruction(this); - v.visitFieldOrMethod(this); - v.visitInvokeInstruction(this); - v.visitINVOKESTATIC(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/INVOKEVIRTUAL.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/INVOKEVIRTUAL.java deleted file mode 100644 index 00c6531f2..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/INVOKEVIRTUAL.java +++ /dev/null @@ -1,112 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ -import org.aspectj.apache.bcel.Constants; -import org.aspectj.apache.bcel.ExceptionConstants; - -/** - * INVOKEVIRTUAL - Invoke instance method; dispatch based on class - * - * <PRE>Stack: ..., objectref, [arg1, [arg2 ...]] -> ...</PRE> - * - * @version $Id: INVOKEVIRTUAL.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class INVOKEVIRTUAL extends InvokeInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - INVOKEVIRTUAL() {} - - public INVOKEVIRTUAL(int index) { - super(Constants.INVOKEVIRTUAL, index); - } - - public Class[] getExceptions() { - Class[] cs = new Class[4 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length]; - - System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0, - cs, 0, ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length); - - cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length+3] = ExceptionConstants.UNSATISFIED_LINK_ERROR; - cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length+2] = ExceptionConstants.ABSTRACT_METHOD_ERROR; - cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length+1] = ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR; - cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] = ExceptionConstants.NULL_POINTER_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.visitExceptionThrower(this); - v.visitTypedInstruction(this); - v.visitStackConsumer(this); - v.visitStackProducer(this); - v.visitLoadClass(this); - v.visitCPInstruction(this); - v.visitFieldOrMethod(this); - v.visitInvokeInstruction(this); - v.visitINVOKEVIRTUAL(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IOR.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IOR.java deleted file mode 100644 index c0e0e503a..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IOR.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IOR - Bitwise OR int - * <PRE>Stack: ..., value1, value2 -> ..., result</PRE> - * - * @version $Id: IOR.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IOR extends ArithmeticInstruction { - public IOR() { - super(org.aspectj.apache.bcel.Constants.IOR); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitIOR(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IREM.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IREM.java deleted file mode 100644 index 5c43ec9a9..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IREM.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IREM - Remainder of int - * <PRE>Stack: ..., value1, value2 -> result</PRE> - * - * @version $Id: IREM.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IREM extends ArithmeticInstruction implements ExceptionThrower { - /** Remainder of ints - */ - public IREM() { - super(org.aspectj.apache.bcel.Constants.IREM); - } - - /** @return exceptions this instruction may cause - */ - public Class[] getExceptions() { - return new Class[] { org.aspectj.apache.bcel.ExceptionConstants.ARITHMETIC_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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitIREM(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IRETURN.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IRETURN.java deleted file mode 100644 index dea659568..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IRETURN.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IRETURN - Return int from method - * <PRE>Stack: ..., value -> <empty></PRE> - * - * @version $Id: IRETURN.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IRETURN extends ReturnInstruction { - /** Return int from method - */ - public IRETURN() { - super(org.aspectj.apache.bcel.Constants.IRETURN); - } - - - /** - * 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.visitIRETURN(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ISHL.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ISHL.java deleted file mode 100644 index d976045e4..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ISHL.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * ISHL - Arithmetic shift left int - * <PRE>Stack: ..., value1, value2 -> ..., result</PRE> - * - * @version $Id: ISHL.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class ISHL extends ArithmeticInstruction { - public ISHL() { - super(org.aspectj.apache.bcel.Constants.ISHL); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitISHL(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ISHR.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ISHR.java deleted file mode 100644 index 2cf6213a6..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ISHR.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * ISHR - Arithmetic shift right int - * <PRE>Stack: ..., value1, value2 -> ..., result</PRE> - * - * @version $Id: ISHR.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class ISHR extends ArithmeticInstruction { - public ISHR() { - super(org.aspectj.apache.bcel.Constants.ISHR); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitISHR(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ISTORE.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ISTORE.java deleted file mode 100644 index 9e2e685bf..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ISTORE.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * ISTORE - Store int from stack into local variable - * <PRE>Stack: ..., value -> ... </PRE> - * - * @version $Id: ISTORE.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class ISTORE extends StoreInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - ISTORE() { - super(org.aspectj.apache.bcel.Constants.ISTORE, org.aspectj.apache.bcel.Constants.ISTORE_0); - } - - /** Store int into local variable - * @param n index of local variable - */ - public ISTORE(int n) { - super(org.aspectj.apache.bcel.Constants.ISTORE, org.aspectj.apache.bcel.Constants.ISTORE_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.visitISTORE(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ISUB.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ISUB.java deleted file mode 100644 index a6e4722e1..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ISUB.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * ISUB - Substract ints - * <PRE>Stack: ..., value1, value2 -> result</PRE> - * - * @version $Id: ISUB.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class ISUB extends ArithmeticInstruction { - /** Substract ints - */ - public ISUB() { - super(org.aspectj.apache.bcel.Constants.ISUB); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitISUB(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IUSHR.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IUSHR.java deleted file mode 100644 index c0d53c436..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IUSHR.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IUSHR - Logical shift right int - * <PRE>Stack: ..., value1, value2 -> ..., result</PRE> - * - * @version $Id: IUSHR.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IUSHR extends ArithmeticInstruction { - public IUSHR() { - super(org.aspectj.apache.bcel.Constants.IUSHR); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitIUSHR(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IXOR.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IXOR.java deleted file mode 100644 index 8fdcecb19..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IXOR.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * IXOR - Bitwise XOR int - * <PRE>Stack: ..., value1, value2 -> ..., result</PRE> - * - * @version $Id: IXOR.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class IXOR extends ArithmeticInstruction { - public IXOR() { - super(org.aspectj.apache.bcel.Constants.IXOR); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitIXOR(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IfInstruction.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IfInstruction.java deleted file mode 100644 index 8465879cf..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IfInstruction.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Super class for the IFxxx family of instructions. - * - * @version $Id: IfInstruction.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public abstract class IfInstruction extends BranchInstruction implements StackConsumer { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - IfInstruction() {} - - /** - * @param instruction Target instruction to branch to - */ - protected IfInstruction(short opcode, InstructionHandle target) { - super(opcode, target); - } - - /** - * @return negation of instruction, e.g. IFEQ.negate() == IFNE - */ - public abstract IfInstruction negate(); -} - diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/IndexedInstruction.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/IndexedInstruction.java deleted file mode 100644 index 7fb4cd4de..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/IndexedInstruction.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Denote entity that refers to an index, e.g. local variable instructions, - * RET, CPInstruction, etc. - * - * @version $Id: IndexedInstruction.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public interface IndexedInstruction { - public int getIndex(); - public void setIndex(int index); -} - diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/InstVisitor.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstVisitor.java new file mode 100644 index 000000000..424ff4a66 --- /dev/null +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstVisitor.java @@ -0,0 +1,247 @@ +package org.aspectj.apache.bcel.generic; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache BCEL" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache BCEL", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/** + * Interface implementing the Visitor pattern programming style. + * I.e., a class that implements this interface can handle all types of + * instructions with the properly typed methods just by calling the accept() + * method. + * + * @version $Id: InstVisitor.java,v 1.2 2008/05/28 23:52:59 aclement Exp $ + * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> + */ +public interface InstVisitor { + public void visitStackInstruction(Instruction obj); + public void visitLocalVariableInstruction(InstructionLV obj); + public void visitBranchInstruction(InstructionBranch obj); + public void visitLoadClass(Instruction obj); + public void visitFieldInstruction(Instruction obj); + public void visitIfInstruction(Instruction obj); + public void visitConversionInstruction(Instruction obj); + public void visitPopInstruction(Instruction obj); + public void visitStoreInstruction(Instruction obj); + public void visitTypedInstruction(Instruction obj); + public void visitSelect(InstructionSelect obj); + public void visitJsrInstruction(InstructionBranch obj); + public void visitGotoInstruction(Instruction obj); + public void visitUnconditionalBranch(Instruction obj); + public void visitPushInstruction(Instruction obj); + public void visitArithmeticInstruction(Instruction obj); + public void visitCPInstruction(Instruction obj); + public void visitInvokeInstruction(InvokeInstruction obj); + public void visitArrayInstruction(Instruction obj); + public void visitAllocationInstruction(Instruction obj); + public void visitReturnInstruction(Instruction obj); + public void visitFieldOrMethod(Instruction obj); + public void visitConstantPushInstruction(Instruction obj); + public void visitExceptionThrower(Instruction obj); + public void visitLoadInstruction(Instruction obj); + public void visitVariableLengthInstruction(Instruction obj); + public void visitStackProducer(Instruction obj); + public void visitStackConsumer(Instruction obj); + public void visitACONST_NULL(Instruction obj); + public void visitGETSTATIC(FieldInstruction obj); + public void visitIF_ICMPLT(Instruction obj); + public void visitMONITOREXIT(Instruction obj); + public void visitIFLT(Instruction obj); + public void visitLSTORE(Instruction obj); + public void visitPOP2(Instruction obj); + public void visitBASTORE(Instruction obj); + public void visitISTORE(Instruction obj); + public void visitCHECKCAST(Instruction obj); + public void visitFCMPG(Instruction obj); + public void visitI2F(Instruction obj); + public void visitATHROW(Instruction obj); + public void visitDCMPL(Instruction obj); + public void visitARRAYLENGTH(Instruction obj); + public void visitDUP(Instruction obj); + public void visitINVOKESTATIC(InvokeInstruction obj); + public void visitLCONST(Instruction obj); + public void visitDREM(Instruction obj); + public void visitIFGE(Instruction obj); + public void visitCALOAD(Instruction obj); + public void visitLASTORE(Instruction obj); + public void visitI2D(Instruction obj); + public void visitDADD(Instruction obj); + public void visitINVOKESPECIAL(InvokeInstruction obj); + public void visitIAND(Instruction obj); + public void visitPUTFIELD(FieldInstruction obj); + public void visitILOAD(Instruction obj); + public void visitDLOAD(Instruction obj); + public void visitDCONST(Instruction obj); + public void visitNEW(Instruction obj); + public void visitIFNULL(Instruction obj); + public void visitLSUB(Instruction obj); + public void visitL2I(Instruction obj); + public void visitISHR(Instruction obj); + public void visitTABLESWITCH(TABLESWITCH obj); + public void visitIINC(IINC obj); + public void visitDRETURN(Instruction obj); + public void visitFSTORE(Instruction obj); + public void visitDASTORE(Instruction obj); + public void visitIALOAD(Instruction obj); + public void visitDDIV(Instruction obj); + public void visitIF_ICMPGE(Instruction obj); + public void visitLAND(Instruction obj); + public void visitIDIV(Instruction obj); + public void visitLOR(Instruction obj); + public void visitCASTORE(Instruction obj); + public void visitFREM(Instruction obj); + public void visitLDC(Instruction obj); + public void visitBIPUSH(Instruction obj); + public void visitDSTORE(Instruction obj); + public void visitF2L(Instruction obj); + public void visitFMUL(Instruction obj); + public void visitLLOAD(Instruction obj); + public void visitJSR(InstructionBranch obj); + public void visitFSUB(Instruction obj); + public void visitSASTORE(Instruction obj); + public void visitALOAD(Instruction obj); + public void visitDUP2_X2(Instruction obj); + public void visitRETURN(Instruction obj); + public void visitDALOAD(Instruction obj); + public void visitSIPUSH(Instruction obj); + public void visitDSUB(Instruction obj); + public void visitL2F(Instruction obj); + public void visitIF_ICMPGT(Instruction obj); + public void visitF2D(Instruction obj); + public void visitI2L(Instruction obj); + public void visitIF_ACMPNE(Instruction obj); + public void visitPOP(Instruction obj); + public void visitI2S(Instruction obj); + public void visitIFEQ(Instruction obj); + public void visitSWAP(Instruction obj); + public void visitIOR(Instruction obj); + public void visitIREM(Instruction obj); + public void visitIASTORE(Instruction obj); + public void visitNEWARRAY(Instruction obj); + public void visitINVOKEINTERFACE(INVOKEINTERFACE obj); + public void visitINEG(Instruction obj); + public void visitLCMP(Instruction obj); + public void visitJSR_W(InstructionBranch obj); + public void visitMULTIANEWARRAY(MULTIANEWARRAY obj); + public void visitDUP_X2(Instruction obj); + public void visitSALOAD(Instruction obj); + public void visitIFNONNULL(Instruction obj); + public void visitDMUL(Instruction obj); + public void visitIFNE(Instruction obj); + public void visitIF_ICMPLE(Instruction obj); + public void visitLDC2_W(Instruction obj); + public void visitGETFIELD(FieldInstruction obj); + public void visitLADD(Instruction obj); + public void visitNOP(Instruction obj); + public void visitFALOAD(Instruction obj); + public void visitINSTANCEOF(Instruction obj); + public void visitIFLE(Instruction obj); + public void visitLXOR(Instruction obj); + public void visitLRETURN(Instruction obj); + public void visitFCONST(Instruction obj); + public void visitIUSHR(Instruction obj); + public void visitBALOAD(Instruction obj); + public void visitDUP2(Instruction obj); + public void visitIF_ACMPEQ(Instruction obj); + public void visitIMPDEP1(Instruction obj); + public void visitMONITORENTER(Instruction obj); + public void visitLSHL(Instruction obj); + public void visitDCMPG(Instruction obj); + public void visitD2L(Instruction obj); + public void visitIMPDEP2(Instruction obj); + public void visitL2D(Instruction obj); + public void visitRET(RET obj); + public void visitIFGT(Instruction obj); + public void visitIXOR(Instruction obj); + public void visitINVOKEVIRTUAL(InvokeInstruction obj); + public void visitFASTORE(Instruction obj); + public void visitIRETURN(Instruction obj); + public void visitIF_ICMPNE(Instruction obj); + public void visitFLOAD(Instruction obj); + public void visitLDIV(Instruction obj); + public void visitPUTSTATIC(FieldInstruction obj); + public void visitAALOAD(Instruction obj); + public void visitD2I(Instruction obj); + public void visitIF_ICMPEQ(Instruction obj); + public void visitAASTORE(Instruction obj); + public void visitARETURN(Instruction obj); + public void visitDUP2_X1(Instruction obj); + public void visitFNEG(Instruction obj); + public void visitGOTO_W(Instruction obj); + public void visitD2F(Instruction obj); + public void visitGOTO(Instruction obj); + public void visitISUB(Instruction obj); + public void visitF2I(Instruction obj); + public void visitDNEG(Instruction obj); + public void visitICONST(Instruction obj); + public void visitFDIV(Instruction obj); + public void visitI2B(Instruction obj); + public void visitLNEG(Instruction obj); + public void visitLREM(Instruction obj); + public void visitIMUL(Instruction obj); + public void visitIADD(Instruction obj); + public void visitLSHR(Instruction obj); + public void visitLOOKUPSWITCH(LOOKUPSWITCH obj); + public void visitDUP_X1(Instruction obj); + public void visitFCMPL(Instruction obj); + public void visitI2C(Instruction obj); + public void visitLMUL(Instruction obj); + public void visitLUSHR(Instruction obj); + public void visitISHL(Instruction obj); + public void visitLALOAD(Instruction obj); + public void visitASTORE(Instruction obj); + public void visitANEWARRAY(Instruction obj); + public void visitFRETURN(Instruction obj); + public void visitFADD(Instruction obj); + public void visitBREAKPOINT(Instruction obj); +} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/Instruction.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/Instruction.java index 69de15199..1470c3637 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/Instruction.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/Instruction.java @@ -62,72 +62,43 @@ import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.classfile.ConstantPool; import org.aspectj.apache.bcel.util.ByteSequence; + /** * Abstract super class for all Java byte codes. * - * @version $Id: Instruction.java,v 1.4 2004/11/22 08:31:27 aclement Exp $ + * @version $Id: Instruction.java,v 1.5 2008/05/28 23:52:58 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ -public abstract class Instruction implements Cloneable, Serializable { - protected short length = 1; // Length of instruction in bytes - protected short opcode = -1; // Opcode number +public class Instruction implements Cloneable, Serializable, Constants { + public short opcode = -1; private static InstructionComparator cmp = InstructionComparator.DEFAULT; - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ Instruction() {} - public Instruction(short opcode, short length) { - this.length = length; - this.opcode = opcode; - } - - /** - * Dump instruction as byte code to stream out. - * @param out Output stream - */ - public void dump(DataOutputStream out) throws IOException { - out.writeByte(opcode); // Common for all instructions - } + public Instruction(short opcode) { this.opcode = opcode; } + + public void dump(DataOutputStream out) throws IOException { out.writeByte(opcode); } - /** @return name of instruction, i.e., opcode name - */ - public String getName() { - return Constants.OPCODE_NAMES[opcode]; - } + public String getName() { return Constants.OPCODE_NAMES[opcode]; } /** * Long output format: - * - * <name of opcode> "["<opcode number>"]" - * "("<length of instruction>")" - * - * @param verbose long/short format switch - * @return mnemonic for instruction + * 'name of opcode' "[" 'opcode number' "]" "(" 'length of instruction' ")" */ public String toString(boolean verbose) { - if(verbose) - return getName() + "[" + opcode + "](" + length + ")"; - else + if (verbose) { + StringBuffer sb = new StringBuffer(); + sb.append(getName()).append("[").append(opcode).append("](size").append(Constants.iLen[opcode]).append(")"); + return sb.toString(); + } else { return getName(); + } } - /** - * @return mnemonic for instruction in verbose format - */ - public String toString() { - return toString(true); - } + public String toString() { return toString(true); } - /** - * @return mnemonic for instruction with sumbolic references resolved - */ - public String toString(ConstantPool cp) { - return toString(false); - } + public String toString(ConstantPool cp) { return toString(false); } /** * Use with caution, since `BranchInstruction's have a `target' reference which @@ -137,32 +108,20 @@ public abstract class Instruction implements Cloneable, Serializable { * @see BranchInstruction * @return (shallow) copy of an instruction */ - public Instruction copy() { - Instruction i = null; - - // "Constant" instruction, no need to duplicate - if(InstructionConstants.INSTRUCTIONS[this.getOpcode()] != null) - i = this; - else { - try { - i = (Instruction)clone(); + final public Instruction copy() { + if (InstructionConstants.INSTRUCTIONS[opcode] != null) { // immutable instructions do not need copying + return this; + } else { + Instruction i = null; + try {//OPTIMIZE is clone the right thing to do here? it is horrible + i = (Instruction)clone(); } catch(CloneNotSupportedException e) { - System.err.println(e); + System.err.println(e); } + return i; } - - return i; } - /** - * Read needed data (e.g. index) from file. - * - * @param bytes byte sequence to read from - * @param wide "wide" instruction flag - */ - protected void initFromFile(ByteSequence bytes, boolean wide) - throws IOException - {} /** * Read an instruction from (byte code) input stream and return the @@ -171,265 +130,179 @@ public abstract class Instruction implements Cloneable, Serializable { * @param file file to read from * @return instruction object being read */ - public static final Instruction readInstruction(ByteSequence bytes) - throws IOException - { + public static final Instruction readInstruction(ByteSequence bytes) throws IOException { boolean wide = false; short opcode = (short)bytes.readUnsignedByte(); Instruction obj = null; - if(opcode == Constants.WIDE) { // Read next opcode after wide byte + if (opcode == Constants.WIDE) { wide = true; opcode = (short)bytes.readUnsignedByte(); } - if(InstructionConstants.INSTRUCTIONS[opcode] != null) - return InstructionConstants.INSTRUCTIONS[opcode]; // Used predefined immutable object, if available - - /* Find appropiate class, instantiate an (empty) instruction object - * and initialize it by hand. - */ - Class clazz; + Instruction constantInstruction = InstructionConstants.INSTRUCTIONS[opcode]; + if (constantInstruction != null) return constantInstruction; try { - switch(opcode) { - case Constants.NOP: obj = new NOP(); break; - case Constants.ACONST_NULL: obj = new ACONST_NULL(); break; - case Constants.ICONST_M1: - case Constants.ICONST_0: - case Constants.ICONST_1: - case Constants.ICONST_2: - case Constants.ICONST_3: - case Constants.ICONST_4: - case Constants.ICONST_5: obj = new ICONST(); break; - case Constants.LCONST_0: - case Constants.LCONST_1: obj = new LCONST(); break; - case Constants.FCONST_0: - case Constants.FCONST_1: - case Constants.FCONST_2: obj = new FCONST(); break; - case Constants.DCONST_0: - case Constants.DCONST_1: obj = new DCONST(); break; - case Constants.BIPUSH : obj = new BIPUSH(); break; - case Constants.SIPUSH : obj = new SIPUSH(); break; - case Constants.LDC : obj = new LDC(); break; - case Constants.LDC_W: obj = new LDC_W(); break; - case Constants.LDC2_W: obj = new LDC2_W(); break; - case Constants.ILOAD : obj = new ILOAD(); break; - case Constants.LLOAD : obj = new LLOAD(); break; - case Constants.FLOAD : obj = new FLOAD(); break; - case Constants.DLOAD : obj = new DLOAD(); break; - case Constants.ALOAD : obj = new ALOAD(); break; - case Constants.ILOAD_0: - case Constants.ILOAD_1: - case Constants.ILOAD_2: - case Constants.ILOAD_3: obj = new ILOAD(); break; - case Constants.LLOAD_0: - case Constants.LLOAD_1: - case Constants.LLOAD_2: - case Constants.LLOAD_3: obj = new LLOAD(); break; - case Constants.FLOAD_0: - case Constants.FLOAD_1: - case Constants.FLOAD_2: - case Constants.FLOAD_3: obj = new FLOAD(); break; - case Constants.DLOAD_0: - case Constants.DLOAD_1: - case Constants.DLOAD_2: - case Constants.DLOAD_3: obj = new DLOAD(); break; - case Constants.ALOAD_0: - case Constants.ALOAD_1: - case Constants.ALOAD_2: - case Constants.ALOAD_3: obj = new ALOAD(); break; - case Constants.IALOAD : obj = new IALOAD(); break; - case Constants.LALOAD : obj = new LALOAD(); break; - case Constants.FALOAD : obj = new FALOAD(); break; - case Constants.DALOAD : obj = new DALOAD(); break; - case Constants.AALOAD : obj = new AALOAD(); break; - case Constants.BALOAD : obj = new BALOAD(); break; - case Constants.CALOAD : obj = new CALOAD(); break; - case Constants.SALOAD : obj = new SALOAD(); break; - case Constants.ISTORE : obj = new ISTORE(); break; - case Constants.LSTORE : obj = new LSTORE(); break; - case Constants.FSTORE : obj = new FSTORE(); break; - case Constants.DSTORE : obj = new DSTORE(); break; - case Constants.ASTORE : obj = new ASTORE(); break; - case Constants.ISTORE_0: - case Constants.ISTORE_1: - case Constants.ISTORE_2: - case Constants.ISTORE_3: obj = new ISTORE(); break; - case Constants.LSTORE_0: - case Constants.LSTORE_1: - case Constants.LSTORE_2: - case Constants.LSTORE_3: obj = new LSTORE(); break; - case Constants.FSTORE_0: - case Constants.FSTORE_1: - case Constants.FSTORE_2: - case Constants.FSTORE_3: obj = new FSTORE(); break; - case Constants.DSTORE_0: - case Constants.DSTORE_1: - case Constants.DSTORE_2: - case Constants.DSTORE_3: obj = new DSTORE(); break; - case Constants.ASTORE_0: - case Constants.ASTORE_1: - case Constants.ASTORE_2: - case Constants.ASTORE_3: obj = new ASTORE(); break; - case Constants.IASTORE : obj = new IASTORE(); break; - case Constants.LASTORE : obj = new LASTORE(); break; - case Constants.FASTORE : obj = new FASTORE(); break; - case Constants.DASTORE : obj = new DASTORE(); break; - case Constants.AASTORE : obj = new AASTORE(); break; - case Constants.BASTORE : obj = new BASTORE(); break; - case Constants.CASTORE : obj = new CASTORE(); break; - case Constants.SASTORE : obj = new SASTORE(); break; - case Constants.POP : obj = new POP(); break; - case Constants.POP2 : obj = new POP2(); break; - case Constants.DUP : obj = new DUP(); break; - case Constants.DUP_X1: obj = new DUP_X1(); break; - case Constants.DUP_X2: obj = new DUP_X2(); break; - case Constants.DUP2 : obj = new DUP2(); break; - case Constants.DUP2_X1: obj = new DUP2_X1(); break; - case Constants.DUP2_X2: obj = new DUP2_X2(); break; - case Constants.SWAP : obj = new SWAP(); break; - case Constants.IADD : obj = new IADD(); break; - case Constants.LADD : obj = new LADD(); break; - case Constants.FADD : obj = new FADD(); break; - case Constants.DADD : obj = new DADD(); break; - case Constants.ISUB : obj = new ISUB(); break; - case Constants.LSUB : obj = new LSUB(); break; - case Constants.FSUB : obj = new FSUB(); break; - case Constants.DSUB : obj = new DSUB(); break; - case Constants.IMUL : obj = new IMUL(); break; - case Constants.LMUL : obj = new LMUL(); break; - case Constants.FMUL : obj = new FMUL(); break; - case Constants.DMUL : obj = new DMUL(); break; - case Constants.IDIV : obj = new IDIV(); break; - case Constants.LDIV : obj = new LDIV(); break; - case Constants.FDIV : obj = new FDIV(); break; - case Constants.DDIV : obj = new DDIV(); break; - case Constants.IREM : obj = new IREM(); break; - case Constants.LREM : obj = new LREM(); break; - case Constants.FREM : obj = new FREM(); break; - case Constants.DREM : obj = new DREM(); break; - case Constants.INEG : obj = new INEG(); break; - case Constants.LNEG : obj = new LNEG(); break; - case Constants.FNEG : obj = new FNEG(); break; - case Constants.DNEG : obj = new DNEG(); break; - case Constants.ISHL : obj = new ISHL(); break; - case Constants.LSHL : obj = new LSHL(); break; - case Constants.ISHR : obj = new ISHR(); break; - case Constants.LSHR : obj = new LSHR(); break; - case Constants.IUSHR : obj = new IUSHR(); break; - case Constants.LUSHR : obj = new LUSHR(); break; - case Constants.IAND : obj = new IAND(); break; - case Constants.LAND : obj = new LAND(); break; - case Constants.IOR : obj = new IOR(); break; - case Constants.LOR : obj = new LOR(); break; - case Constants.IXOR : obj = new IXOR(); break; - case Constants.LXOR : obj = new LXOR(); break; - case Constants.IINC : obj = new IINC(); break; - case Constants.I2L : obj = new I2L(); break; - case Constants.I2F : obj = new I2F(); break; - case Constants.I2D : obj = new I2D(); break; - case Constants.L2I : obj = new L2I(); break; - case Constants.L2F : obj = new L2F(); break; - case Constants.L2D : obj = new L2D(); break; - case Constants.F2I : obj = new F2I(); break; - case Constants.F2L : obj = new F2L(); break; - case Constants.F2D : obj = new F2D(); break; - case Constants.D2I : obj = new D2I(); break; - case Constants.D2L : obj = new D2L(); break; - case Constants.D2F : obj = new D2F(); break; - case Constants.I2B : obj = new I2B(); break; - case Constants.I2C : obj = new I2C(); break; - case Constants.I2S : obj = new I2S(); break; - case Constants.LCMP : obj = new LCMP(); break; - case Constants.FCMPL : obj = new FCMPL(); break; - case Constants.FCMPG : obj = new FCMPG(); break; - case Constants.DCMPL : obj = new DCMPL(); break; - case Constants.DCMPG : obj = new DCMPG(); break; - case Constants.IFEQ : obj = new IFEQ(); break; - case Constants.IFNE : obj = new IFNE(); break; - case Constants.IFLT : obj = new IFLT(); break; - case Constants.IFGE : obj = new IFGE(); break; - case Constants.IFGT : obj = new IFGT(); break; - case Constants.IFLE : obj = new IFLE(); break; - case Constants.IF_ICMPEQ: obj = new IF_ICMPEQ(); break; - case Constants.IF_ICMPNE: obj = new IF_ICMPNE(); break; - case Constants.IF_ICMPLT: obj = new IF_ICMPLT(); break; - case Constants.IF_ICMPGE: obj = new IF_ICMPGE(); break; - case Constants.IF_ICMPGT: obj = new IF_ICMPGT(); break; - case Constants.IF_ICMPLE: obj = new IF_ICMPLE(); break; - case Constants.IF_ACMPEQ: obj = new IF_ACMPEQ(); break; - case Constants.IF_ACMPNE : obj = new IF_ACMPNE(); break; - case Constants.GOTO : obj = new GOTO(); break; - case Constants.JSR : obj = new JSR(); break; - case Constants.RET : obj = new RET(); break; - case Constants.TABLESWITCH : obj = new TABLESWITCH(); break; - case Constants.LOOKUPSWITCH : obj = new LOOKUPSWITCH(); break; - case Constants.IRETURN : obj = new IRETURN(); break; - case Constants.LRETURN : obj = new LRETURN(); break; - case Constants.FRETURN : obj = new FRETURN(); break; - case Constants.DRETURN : obj = new DRETURN(); break; - case Constants.ARETURN : obj = new ARETURN(); break; - case Constants.RETURN : obj = new RETURN(); break; - case Constants.GETSTATIC : obj = new GETSTATIC(); break; - case Constants.PUTSTATIC : obj = new PUTSTATIC(); break; - case Constants.GETFIELD : obj = new GETFIELD(); break; - case Constants.PUTFIELD : obj = new PUTFIELD(); break; - case Constants.INVOKEVIRTUAL : obj = new INVOKEVIRTUAL(); break; - case Constants.INVOKESPECIAL : obj = new INVOKESPECIAL(); break; - case Constants.INVOKESTATIC : obj = new INVOKESTATIC(); break; - case Constants.INVOKEINTERFACE : obj = new INVOKEINTERFACE(); break; - case Constants.NEW : obj = new NEW(); break; - case Constants.NEWARRAY : obj = new NEWARRAY(); break; - case Constants.ANEWARRAY : obj = new ANEWARRAY(); break; - case Constants.ARRAYLENGTH : obj = new ARRAYLENGTH(); break; - case Constants.ATHROW : obj = new ATHROW(); break; - case Constants.CHECKCAST : obj = new CHECKCAST(); break; - case Constants.INSTANCEOF : obj = new INSTANCEOF(); break; - case Constants.MONITORENTER : obj = new MONITORENTER(); break; - case Constants.MONITOREXIT : obj = new MONITOREXIT(); break; - case Constants.MULTIANEWARRAY : obj = new MULTIANEWARRAY(); break; - case Constants.IFNULL : obj = new IFNULL(); break; - case Constants.IFNONNULL : obj = new IFNONNULL(); break; - case Constants.GOTO_W : obj = new GOTO_W(); break; - case Constants.JSR_W : obj = new JSR_W(); break; + switch (opcode) { + case Constants.BIPUSH : obj = new InstructionByte(Constants.BIPUSH,bytes.readByte()); break; + case Constants.SIPUSH : obj = new InstructionShort(Constants.SIPUSH,bytes.readShort()); break; + case Constants.LDC : obj = new InstructionCP(Constants.LDC,bytes.readUnsignedByte()); break; + case Constants.LDC_W : obj = new InstructionCP(Constants.LDC_W,bytes.readUnsignedShort()); break; + case Constants.LDC2_W: obj = new InstructionCP(Constants.LDC2_W,bytes.readUnsignedShort()); break; + case Constants.ILOAD : obj = new InstructionLV(Constants.ILOAD,wide?bytes.readUnsignedShort():bytes.readUnsignedByte()); break; + case Constants.LLOAD : obj = new InstructionLV(Constants.LLOAD,wide?bytes.readUnsignedShort():bytes.readUnsignedByte()); break; + case Constants.FLOAD : obj = new InstructionLV(Constants.FLOAD,wide?bytes.readUnsignedShort():bytes.readUnsignedByte()); break; + case Constants.DLOAD : obj = new InstructionLV(Constants.DLOAD,wide?bytes.readUnsignedShort():bytes.readUnsignedByte()); break; + case Constants.ALOAD : obj = new InstructionLV(Constants.ALOAD,wide?bytes.readUnsignedShort():bytes.readUnsignedByte()); break; + + // move these to InstructionConstants + case Constants.ILOAD_0: obj = new InstructionLV(Constants.ILOAD_0);break; + case Constants.ILOAD_1: obj = new InstructionLV(Constants.ILOAD_1);break; + case Constants.ILOAD_2: obj = new InstructionLV(Constants.ILOAD_2);break; + case Constants.ILOAD_3: obj = new InstructionLV(Constants.ILOAD_3);break; + case Constants.LLOAD_0: obj = new InstructionLV(Constants.LLOAD_0);break; + case Constants.LLOAD_1: obj = new InstructionLV(Constants.LLOAD_1);break; + case Constants.LLOAD_2: obj = new InstructionLV(Constants.LLOAD_2);break; + case Constants.LLOAD_3: obj = new InstructionLV(Constants.LLOAD_3);break; + case Constants.FLOAD_0: obj = new InstructionLV(Constants.FLOAD_0);break; + case Constants.FLOAD_1: obj = new InstructionLV(Constants.FLOAD_1);break; + case Constants.FLOAD_2: obj = new InstructionLV(Constants.FLOAD_2);break; + case Constants.FLOAD_3: obj = new InstructionLV(Constants.FLOAD_3);break; + case Constants.DLOAD_0: obj = new InstructionLV(Constants.DLOAD_0);break; + case Constants.DLOAD_1: obj = new InstructionLV(Constants.DLOAD_1);break; + case Constants.DLOAD_2: obj = new InstructionLV(Constants.DLOAD_2);break; + case Constants.DLOAD_3: obj = new InstructionLV(Constants.DLOAD_3);break; + case Constants.ALOAD_0: obj = new InstructionLV(Constants.ALOAD_0);break; + case Constants.ALOAD_1: obj = new InstructionLV(Constants.ALOAD_1);break; + case Constants.ALOAD_2: obj = new InstructionLV(Constants.ALOAD_2);break; + case Constants.ALOAD_3: obj = new InstructionLV(Constants.ALOAD_3);break; + + // move to constants? + case Constants.ISTORE_0: obj = new InstructionLV(Constants.ISTORE_0);break; + case Constants.ISTORE_1: obj = new InstructionLV(Constants.ISTORE_1);break; + case Constants.ISTORE_2: obj = new InstructionLV(Constants.ISTORE_2);break; + case Constants.ISTORE_3: obj = new InstructionLV(Constants.ISTORE_3);break; + case Constants.LSTORE_0: obj = new InstructionLV(Constants.LSTORE_0);break; + case Constants.LSTORE_1: obj = new InstructionLV(Constants.LSTORE_1);break; + case Constants.LSTORE_2: obj = new InstructionLV(Constants.LSTORE_2);break; + case Constants.LSTORE_3: obj = new InstructionLV(Constants.LSTORE_3);break; + case Constants.FSTORE_0: obj = new InstructionLV(Constants.FSTORE_0);break; + case Constants.FSTORE_1: obj = new InstructionLV(Constants.FSTORE_1);break; + case Constants.FSTORE_2: obj = new InstructionLV(Constants.FSTORE_2);break; + case Constants.FSTORE_3: obj = new InstructionLV(Constants.FSTORE_3);break; + case Constants.DSTORE_0: obj = new InstructionLV(Constants.DSTORE_0);break; + case Constants.DSTORE_1: obj = new InstructionLV(Constants.DSTORE_1);break; + case Constants.DSTORE_2: obj = new InstructionLV(Constants.DSTORE_2);break; + case Constants.DSTORE_3: obj = new InstructionLV(Constants.DSTORE_3);break; + case Constants.ASTORE_0: obj = new InstructionLV(Constants.ASTORE_0);break; + case Constants.ASTORE_1: obj = new InstructionLV(Constants.ASTORE_1);break; + case Constants.ASTORE_2: obj = new InstructionLV(Constants.ASTORE_2);break; + case Constants.ASTORE_3: obj = new InstructionLV(Constants.ASTORE_3);break; +// case Constants.IALOAD : obj = new IALOAD(); break; +// case Constants.LALOAD : obj = new LALOAD(); break; +// case Constants.FALOAD : obj = new FALOAD(); break; +// case Constants.DALOAD : obj = new DALOAD(); break; +// case Constants.AALOAD : obj = new AALOAD(); break; +// case Constants.BALOAD : obj = new BALOAD(); break; +// case Constants.CALOAD : obj = new CALOAD(); break; +// case Constants.SALOAD : obj = new SALOAD(); break; + + case Constants.ISTORE : obj = new InstructionLV(Constants.ISTORE,wide?bytes.readUnsignedShort():bytes.readUnsignedByte()); break; + case Constants.LSTORE : obj = new InstructionLV(Constants.LSTORE,wide?bytes.readUnsignedShort():bytes.readUnsignedByte()); break; + case Constants.FSTORE : obj = new InstructionLV(Constants.FSTORE,wide?bytes.readUnsignedShort():bytes.readUnsignedByte()); break; + case Constants.DSTORE : obj = new InstructionLV(Constants.DSTORE,wide?bytes.readUnsignedShort():bytes.readUnsignedByte()); break; + case Constants.ASTORE : obj = new InstructionLV(Constants.ASTORE,wide?bytes.readUnsignedShort():bytes.readUnsignedByte()); break; + + +// case Constants.IASTORE : obj = new IASTORE(); break; +// case Constants.LASTORE : obj = new LASTORE(); break; +// case Constants.FASTORE : obj = new FASTORE(); break; +// case Constants.DASTORE : obj = new DASTORE(); break; +// case Constants.AASTORE : obj = new AASTORE(); break; +// case Constants.BASTORE : obj = new BASTORE(); break; +// case Constants.CASTORE : obj = new CASTORE(); break; +// case Constants.SASTORE : obj = new SASTORE(); break; + +// case Constants.POP : obj = new POP(); break; +// case Constants.POP2 : obj = new POP2(); break; +// case Constants.DUP : obj = new DUP(); break; +// case Constants.DUP_X1: obj = new DUP_X1(); break; +// case Constants.DUP_X2: obj = new DUP_X2(); break; +// case Constants.DUP2 : obj = new DUP2(); break; +// case Constants.DUP2_X1: obj = new DUP2_X1(); break; +// case Constants.DUP2_X2: obj = new DUP2_X2(); break; +// case Constants.SWAP : obj = new SWAP(); break; + + case Constants.IINC : obj = new IINC(wide?bytes.readUnsignedShort():bytes.readUnsignedByte(), + wide?bytes.readShort():bytes.readByte(),wide); break; + +// case Constants.LCMP : obj = new LCMP(); break; +// case Constants.FCMPL : obj = new FCMPL(); break; +// case Constants.FCMPG : obj = new FCMPG(); break; +// case Constants.DCMPL : obj = new DCMPL(); break; +// case Constants.DCMPG : obj = new DCMPG(); break; +// case Constants.ARRAYLENGTH : obj = new Instruction(Constants.ARRAYLENGTH); break; +// case Constants.ATHROW : obj = new ATHROW(); break; +// case Constants.MONITORENTER : obj = new MONITORENTER(); break; +// case Constants.MONITOREXIT : obj = new MONITOREXIT(); break; + case Constants.IFNULL : obj = new InstructionBranch(Constants.IFNULL,bytes.readShort()); break; + case Constants.IFNONNULL : obj = new InstructionBranch(Constants.IFNONNULL,bytes.readShort()); break; + case Constants.IFEQ : obj = new InstructionBranch(Constants.IFEQ,bytes.readShort()); break; + case Constants.IFNE : obj = new InstructionBranch(Constants.IFNE,bytes.readShort()); break; + case Constants.IFLT : obj = new InstructionBranch(Constants.IFLT,bytes.readShort()); break; + case Constants.IFGE : obj = new InstructionBranch(Constants.IFGE,bytes.readShort()); break; + case Constants.IFGT : obj = new InstructionBranch(Constants.IFGT,bytes.readShort()); break; + case Constants.IFLE : obj = new InstructionBranch(Constants.IFLE,bytes.readShort()); break; + case Constants.IF_ICMPEQ: obj = new InstructionBranch(Constants.IF_ICMPEQ,bytes.readShort()); break; + case Constants.IF_ICMPNE: obj = new InstructionBranch(Constants.IF_ICMPNE,bytes.readShort()); break; + case Constants.IF_ICMPLT: obj = new InstructionBranch(Constants.IF_ICMPLT,bytes.readShort()); break; + case Constants.IF_ICMPGE: obj = new InstructionBranch(Constants.IF_ICMPGE,bytes.readShort()); break; + case Constants.IF_ICMPGT: obj = new InstructionBranch(Constants.IF_ICMPGT,bytes.readShort()); break; + case Constants.IF_ICMPLE: obj = new InstructionBranch(Constants.IF_ICMPLE,bytes.readShort()); break; + case Constants.IF_ACMPEQ: obj = new InstructionBranch(Constants.IF_ACMPEQ,bytes.readShort()); break; + case Constants.IF_ACMPNE : obj = new InstructionBranch(Constants.IF_ACMPNE,bytes.readShort()); break; + case Constants.GOTO : obj = new InstructionBranch(Constants.GOTO,bytes.readShort()); break; + case Constants.GOTO_W : obj = new InstructionBranch(Constants.GOTO_W,bytes.readInt()); break; + case Constants.JSR : obj = new InstructionBranch(Constants.JSR,bytes.readShort()); break; + case Constants.JSR_W : obj = new InstructionBranch(Constants.JSR_W,bytes.readInt()); break; + + case Constants.TABLESWITCH : obj = new TABLESWITCH(bytes); break; + case Constants.LOOKUPSWITCH : obj = new LOOKUPSWITCH(bytes); break; + + case Constants.RET : obj = new RET(wide?bytes.readUnsignedShort():bytes.readUnsignedByte(),wide); break; + +// case Constants.IRETURN : obj = new IRETURN(); break; +// case Constants.LRETURN : obj = new LRETURN(); break; +// case Constants.FRETURN : obj = new FRETURN(); break; +// case Constants.DRETURN : obj = new DRETURN(); break; +// case Constants.ARETURN : obj = new ARETURN(); break; +// case Constants.RETURN : obj = new RETURN(); break; + case Constants.NEW : obj = new InstructionCP(Constants.NEW,bytes.readUnsignedShort()); break; + + case Constants.GETSTATIC : obj = new FieldInstruction(Constants.GETSTATIC,bytes.readUnsignedShort()); break; + case Constants.PUTSTATIC : obj = new FieldInstruction(Constants.PUTSTATIC,bytes.readUnsignedShort()); break; + case Constants.GETFIELD : obj = new FieldInstruction(Constants.GETFIELD,bytes.readUnsignedShort()); break; + case Constants.PUTFIELD : obj = new FieldInstruction(Constants.PUTFIELD,bytes.readUnsignedShort()); break; + case Constants.INVOKEVIRTUAL : obj = new InvokeInstruction(Constants.INVOKEVIRTUAL,bytes.readUnsignedShort()); break; + case Constants.INVOKESPECIAL : obj = new InvokeInstruction(Constants.INVOKESPECIAL,bytes.readUnsignedShort()); break; + case Constants.INVOKESTATIC : obj = new InvokeInstruction(Constants.INVOKESTATIC,bytes.readUnsignedShort()); break; + case Constants.INVOKEINTERFACE : obj = new INVOKEINTERFACE(bytes.readUnsignedShort(),bytes.readUnsignedByte(),bytes.readByte());break; + case Constants.NEWARRAY : obj = new InstructionByte(Constants.NEWARRAY,bytes.readByte()); break; + case Constants.ANEWARRAY : obj = new InstructionCP(Constants.ANEWARRAY,bytes.readUnsignedShort()); break; + case Constants.CHECKCAST : obj = new InstructionCP(Constants.CHECKCAST,bytes.readUnsignedShort()); break; + case Constants.INSTANCEOF : obj = new InstructionCP(Constants.INSTANCEOF,bytes.readUnsignedShort()); break; + case Constants.MULTIANEWARRAY : obj = new MULTIANEWARRAY(bytes.readUnsignedShort(),bytes.readByte()); break; default: throw new ClassGenException("Illegal opcode detected"); } } catch (ClassGenException e) { - throw e; + throw e; } catch (Exception e) { - throw new ClassGenException(e.toString()); + throw new ClassGenException(e.toString()); } - if(wide && !((obj instanceof LocalVariableInstruction) || - (obj instanceof IINC) || - (obj instanceof RET))) - throw new ClassGenException("Illegal opcode after wide: " + opcode); - - obj.setOpcode(opcode); - obj.initFromFile(bytes, wide); // Do further initializations, if any - // Byte code offset set in InstructionList - return obj; - } - - private static final String className(short opcode) { - String name = Constants.OPCODE_NAMES[opcode].toUpperCase(); - - /* ICONST_0, etc. will be shortened to ICONST, etc., since ICONST_0 and the like - * are not implemented (directly). - */ - try { - int len = name.length(); - char ch1 = name.charAt(len - 2), ch2 = name.charAt(len - 1); - - if((ch1 == '_') && (ch2 >= '0') && (ch2 <= '5')) - name = name.substring(0, len - 2); - if(name.equals("ICONST_M1")) // Special case - name = "ICONST"; - } catch(StringIndexOutOfBoundsException e) { System.err.println(e); } - - return "org.aspectj.apache.bcel.generic." + name; + return obj; } /** @@ -439,7 +312,7 @@ public abstract class Instruction implements Cloneable, Serializable { * @return Number of words consumed from stack by this instruction, * or Constants.UNPREDICTABLE, if this can not be computed statically */ - public int consumeStack(ConstantPoolGen cpg) { + public int consumeStack(ConstantPool cpg) { return Constants.CONSUME_STACK[opcode]; } @@ -450,8 +323,8 @@ public abstract class Instruction implements Cloneable, Serializable { * @return Number of words produced onto stack by this instruction, * or Constants.UNPREDICTABLE, if this can not be computed statically */ - public int produceStack(ConstantPoolGen cpg) { - return Constants.PRODUCE_STACK[opcode]; + public int produceStack(ConstantPool cpg) { + return Constants.stackEntriesProduced[opcode]; } /** @@ -459,18 +332,14 @@ public abstract class Instruction implements Cloneable, Serializable { */ public short getOpcode() { return opcode; } - /** - * @return length (in bytes) of instruction - */ - public int getLength() { return length; } - - /** - * Needed in readInstruction. - */ - private void setOpcode(short opcode) { this.opcode = opcode; } + public int getLength() { + // if it is zero, it should have been provided by an overriding implementation of getLength() + int len = Constants.iLen[opcode]; + if (len==0) throw new IllegalStateException("Length not right for "+getName().toUpperCase()); + return len; + } - /** Some instructions may be reused, so don't do anything by default. - */ + /** Some instructions may be reused, so don't do anything by default */ void dispose() {} /** @@ -481,18 +350,369 @@ public abstract class Instruction implements Cloneable, Serializable { * * @param v Visitor object */ - public abstract void accept(Visitor v); - - /** Get Comparator object used in the equals() method to determine - * equality of instructions. - * - * @return currently used comparator for equals() - */ - public static InstructionComparator getComparator() { return cmp; } - - /** Set comparator to be used for equals(). - */ - public static void setComparator(InstructionComparator c) { cmp = c; } + public void accept(InstVisitor v) { + switch (opcode) { + case IMPDEP1:v.visitIMPDEP1(this);break; + case IMPDEP2:v.visitIMPDEP2(this);break; + case MONITORENTER: + v.visitExceptionThrower(this); + v.visitStackConsumer(this); + v.visitMONITORENTER(this); + break; + case MONITOREXIT: + v.visitExceptionThrower(this); + v.visitStackConsumer(this); + v.visitMONITOREXIT(this); + break; + case LCMP: + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitLCMP(this); + break; + case FCMPL: + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitFCMPL(this); + break; + case FCMPG: + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitFCMPG(this); + break; + case DCMPL: + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitDCMPL(this); + break; + case DCMPG: + v.visitTypedInstruction(this); + v.visitStackProducer(this); + v.visitStackConsumer(this); + v.visitDCMPG(this); + break; + case NOP: + v.visitNOP(this); + break; + case BREAKPOINT: + v.visitBREAKPOINT(this); + break; + case SWAP: + v.visitStackConsumer(this); + v.visitStackProducer(this); + v.visitStackInstruction(this); + v.visitSWAP(this); + break; + case POP: + v.visitStackConsumer(this); + v.visitPopInstruction(this); + v.visitStackInstruction(this); + v.visitPOP(this); + break; + case POP2: + v.visitStackConsumer(this); + v.visitPopInstruction(this); + v.visitStackInstruction(this); + v.visitPOP2(this); + break; + case DUP2_X1: + v.visitStackInstruction(this); + v.visitDUP2_X1(this); + break; + case DUP2_X2: + v.visitStackInstruction(this); + v.visitDUP2_X2(this); + break; + case DUP2: + v.visitStackProducer(this); + v.visitPushInstruction(this); + v.visitStackInstruction(this); + v.visitDUP2(this); + break; + case DUP_X1: + v.visitStackInstruction(this); + v.visitDUP_X1(this); + break; + case DUP_X2: + v.visitStackInstruction(this); + v.visitDUP_X2(this); + break; + case DUP: + v.visitStackProducer(this); + v.visitPushInstruction(this); + v.visitStackInstruction(this); + v.visitDUP(this); + break; + case BASTORE: + v.visitStackConsumer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitBASTORE(this); + break; + case CASTORE: + v.visitStackConsumer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitCASTORE(this); + break; + case SASTORE: + v.visitStackConsumer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitSASTORE(this); + break; + case DASTORE: + v.visitStackConsumer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitDASTORE(this); + break; + case FASTORE: + v.visitStackConsumer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitFASTORE(this); + break; + case LASTORE: + v.visitStackConsumer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitLASTORE(this); + break; + case IASTORE: + v.visitStackConsumer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitIASTORE(this); + break; + case AASTORE: + v.visitStackConsumer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitAASTORE(this); + break; + case SALOAD: + v.visitStackProducer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitSALOAD(this); + break; + case CALOAD: + v.visitStackProducer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitCALOAD(this); + break; + case DALOAD: + v.visitStackProducer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitDALOAD(this); + break; + case FALOAD: + v.visitStackProducer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitFALOAD(this); + break; + case LALOAD: + v.visitStackProducer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitLALOAD(this); + break; + case AALOAD: + v.visitStackProducer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitAALOAD(this); + break; + case ATHROW: + v.visitUnconditionalBranch(this); + v.visitExceptionThrower(this); + v.visitATHROW(this); + break; + case ACONST_NULL: + v.visitStackProducer(this); + v.visitPushInstruction(this); + v.visitTypedInstruction(this); + v.visitACONST_NULL(this); + break; + case ICONST_M1:case ICONST_0:case ICONST_1:case ICONST_2:case ICONST_3:case ICONST_4:case ICONST_5: + v.visitPushInstruction(this); + v.visitStackProducer(this); + v.visitTypedInstruction(this); + v.visitConstantPushInstruction(this); + v.visitICONST(this); + break; + case LCONST_0:case LCONST_1: + v.visitPushInstruction(this); + v.visitStackProducer(this); + v.visitTypedInstruction(this); + v.visitConstantPushInstruction(this); + v.visitLCONST(this); + break; + case FCONST_0:case FCONST_1:case FCONST_2: + v.visitPushInstruction(this); + v.visitStackProducer(this); + v.visitTypedInstruction(this); + v.visitConstantPushInstruction(this); + v.visitFCONST(this); + break; + case DCONST_0:case DCONST_1: + v.visitPushInstruction(this); + v.visitStackProducer(this); + v.visitTypedInstruction(this); + v.visitConstantPushInstruction(this); + v.visitDCONST(this); + case BALOAD: + v.visitStackProducer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitBALOAD(this); + break; + case IALOAD: + v.visitStackProducer(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitArrayInstruction(this); + v.visitIALOAD(this); + case BIPUSH: + v.visitPushInstruction(this); + v.visitStackProducer(this); + v.visitTypedInstruction(this); + v.visitConstantPushInstruction(this); + v.visitBIPUSH(this); + break; + case SIPUSH: + v.visitPushInstruction(this); + v.visitStackProducer(this); + v.visitTypedInstruction(this); + v.visitConstantPushInstruction(this); + v.visitSIPUSH(this); + break; + case LDC:case LDC_W: + v.visitStackProducer(this); + v.visitPushInstruction(this); + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitCPInstruction(this); + v.visitLDC(this); + break; + case LDC2_W: + v.visitStackProducer(this); + v.visitPushInstruction(this); + v.visitTypedInstruction(this); + v.visitCPInstruction(this); + v.visitLDC2_W(this); + break; + case ARRAYLENGTH: + v.visitExceptionThrower(this); + v.visitStackProducer(this); + v.visitARRAYLENGTH(this); + break; + case ASTORE_0: + v.visitStackConsumer(this); + v.visitPopInstruction(this); + v.visitStoreInstruction(this); + v.visitTypedInstruction(this); + v.visitLocalVariableInstruction((InstructionLV)this); + v.visitStoreInstruction(this); + v.visitASTORE(this); + break; + case ALOAD_0: + v.visitStackConsumer(this); + v.visitPopInstruction(this); + v.visitStoreInstruction(this); + v.visitTypedInstruction(this); + v.visitLocalVariableInstruction((InstructionLV)this); + v.visitStoreInstruction(this); + v.visitALOAD(this); + break; + // for store instructions: ISTORE > ASTORE_3 - needs to visit the instruction too +// v.visitStackConsumer(this); +// v.visitPopInstruction(this); +// v.visitStoreInstruction(this); +// v.visitTypedInstruction(this); +// v.visitLocalVariableInstruction(this); +// v.visitStoreInstruction(this); + // for load instructions: ILOAD > ALOAD_3 - needs to visit the instruction too +// v.visitStackProducer(this); +// v.visitPushInstruction(this); +// v.visitTypedInstruction(this); +// v.visitLocalVariableInstruction(this); +// v.visitLoadInstruction(this); + + // for conversion instructions: (all 15 of them) - needs to visit conversion instruction too +// v.visitTypedInstruction(this); +// v.visitStackProducer(this); +// v.visitStackConsumer(this); +// v.visitConversionInstruction(this); + + // arithmetic instructions - need to visit the instructions too (iadd etc) +// v.visitTypedInstruction(this); +// v.visitStackProducer(this); +// v.visitStackConsumer(this); +// v.visitArithmeticInstruction(this); + + case INVOKESTATIC: + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackConsumer(this); + v.visitStackProducer(this); + v.visitLoadClass(this); + v.visitCPInstruction(this); + v.visitFieldOrMethod(this); + v.visitInvokeInstruction((InvokeInstruction)this); + v.visitINVOKESTATIC((InvokeInstruction)this); + break; + + case GOTO: + v.visitVariableLengthInstruction(this); + v.visitUnconditionalBranch(this); + v.visitBranchInstruction((InstructionBranch)this); + v.visitGotoInstruction(this); + v.visitGOTO(this); + break; + case PUTSTATIC: + v.visitExceptionThrower(this); + v.visitStackConsumer(this); + v.visitPopInstruction(this); + v.visitTypedInstruction(this); + v.visitLoadClass(this); + v.visitCPInstruction(this); + v.visitFieldOrMethod(this); + v.visitFieldInstruction(this); + v.visitPUTSTATIC((FieldInstruction)this); + break; + case RETURN: + v.visitExceptionThrower(this); + v.visitTypedInstruction(this); + v.visitStackConsumer(this); + v.visitReturnInstruction(this); + v.visitRETURN(this); + break; + default: throw new IllegalStateException("visiting not yet implemented for "+getName().toUpperCase()); + } + } /** Check for equality, delegated to comparator * @return true if that is an Instruction and has the same opcode @@ -501,4 +721,176 @@ public abstract class Instruction implements Cloneable, Serializable { return (that instanceof Instruction)? cmp.equals(this, (Instruction)that) : false; } + + public Type getType() { return getType(null); } + + public Type getType(ConstantPool cp) { + // if (types[opcode]==null) throw new RuntimeException(getName()+" is not a typed instruction"); + Type t = Constants.types[opcode]; + if (t!=null) return t; + switch (opcode) { + case Constants.IRETURN: return Type.INT; + case Constants.LRETURN: return Type.LONG; + case Constants.FRETURN: return Type.FLOAT; + case Constants.DRETURN: return Type.DOUBLE; + case Constants.ARETURN: return Type.OBJECT; + case Constants.RETURN: return Type.VOID; + case LCMP: return Type.LONG; + case DCMPG: case DCMPL: return Type.DOUBLE; + case FCMPG: case FCMPL: return Type.FLOAT; + case ACONST_NULL: + return Type.NULL; + case ICONST_M1:case ICONST_0:case ICONST_1:case ICONST_2:case ICONST_3:case ICONST_4:case ICONST_5: + return Type.INT; + case IALOAD: case IASTORE: + return Type.INT; + case CALOAD: case CASTORE: + return Type.CHAR; + case BALOAD: case BASTORE: + return Type.BYTE; + case SALOAD: case SASTORE: + return Type.SHORT; + case LALOAD: case LASTORE: + return Type.LONG; + case DALOAD: case DASTORE: + return Type.DOUBLE; + case FALOAD: case FASTORE: + return Type.FLOAT; + case AALOAD: case AASTORE: + return Type.OBJECT; + + case ASTORE: + case ALOAD: + return Type.OBJECT; + + case Constants.D2I: case Constants.F2I: case Constants.L2I: + return Type.INT; + case Constants.D2F: case Constants.I2F: case Constants.L2F: + return Type.FLOAT; + case Constants.D2L: case Constants.F2L: case Constants.I2L: + return Type.LONG; + case Constants.F2D: case Constants.I2D: case Constants.L2D: + return Type.DOUBLE; + case Constants.I2B: + return Type.BYTE; + case Constants.I2C: + return Type.CHAR; + case Constants.I2S: + return Type.SHORT; + + // arithmetic instructions + 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.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.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: + throw new IllegalStateException("Not implemented yet for "+getName().toUpperCase()); + } + } + + public Number getValue() { + if ((instFlags[opcode]&CONSTANT_INST)==0) throw new RuntimeException(getName()+" is not a constant instruction"); + switch (opcode) { + case ICONST_M1:case ICONST_0:case ICONST_1:case ICONST_2:case ICONST_3:case ICONST_4:case ICONST_5: + return new Integer(opcode-ICONST_0); + default: + throw new IllegalStateException("Not implemented yet for "+getName()); + } + } + + public int getIndex() { return -1; } + public void setIndex(int i) { + throw new IllegalStateException("Shouldnt be asking "+getName().toUpperCase()); + } + + public Object getValue(ConstantPool cpg) { + throw new IllegalStateException("Shouldnt be asking "+getName().toUpperCase()); + } + + public boolean isLoadInstruction() { + return (Constants.instFlags[opcode]&LOAD_INST)!=0; + } + + public boolean isALOAD() { + return false; + } + + public boolean isStoreInstruction() { + return (Constants.instFlags[opcode]&STORE_INST)!=0; + } + + public boolean isASTORE() { + return false; + } + public java.lang.Class[] getExceptions() { + // fixme + return Constants.instExcs[opcode]; + } + + public boolean containsTarget(InstructionHandle ih) { throw new IllegalStateException("Dont ask!!");} + public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) { throw new IllegalStateException("Dont ask!!");} + + public boolean isJsrInstruction() { + return (Constants.instFlags[opcode]&JSR_INSTRUCTION)!=0; + } + + public boolean isConstantInstruction() { + return (Constants.instFlags[opcode]&CONSTANT_INST)!=0; + } + + public boolean isConstantPoolInstruction() { + return (Constants.instFlags[opcode]&CP_INST)!=0; + } + public boolean isStackProducer() { + return (Constants.stackEntriesProduced[opcode]!=0); +// return ((Constants.instFlags[opcode]&STACK_PRODUCER)!=0); + } + public boolean isStackConsumer() { + return (Constants.CONSUME_STACK[opcode]!=0); +// return ((Constants.instFlags[opcode]&STACK_CONSUMER)!=0); + } + + public boolean isIndexedInstruction() { + return (Constants.instFlags[opcode]&INDEXED)!=0; + } + public boolean isArrayCreationInstruction() { + return (opcode==NEWARRAY || opcode==ANEWARRAY || opcode==MULTIANEWARRAY); + } + + // Asserts a property of an instruction - can be commented out after a lot of testing ;) + public void assertSomething(long flag) { + if ((Constants.instFlags[opcode]&flag)==0) throw new IllegalStateException("This opcode "+opcode+" does not have the property "+Long.toHexString(flag)); + } + + public ObjectType getLoadClassType(ConstantPool cpg) { + assertSomething(Constants.LOADCLASS_INST); + Type t = getType(cpg); + if (t instanceof ArrayType) t = ((ArrayType)t).getBasicType(); + return (t instanceof ObjectType)?(ObjectType)t:null; + } + + public boolean isReturnInstruction() { + return (Constants.instFlags[opcode]&RET_INST)!=0; + } + public boolean isGoto() { + return opcode==GOTO || opcode==GOTO_W; + } + public boolean isLocalVariableInstruction() { + return (Constants.instFlags[opcode]&LV_INST)!=0; + } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionBranch.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionBranch.java new file mode 100644 index 000000000..3fd9b4c75 --- /dev/null +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionBranch.java @@ -0,0 +1,340 @@ +package org.aspectj.apache.bcel.generic; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache BCEL" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache BCEL", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +import java.io.*; + +import org.aspectj.apache.bcel.Constants; +import org.aspectj.apache.bcel.classfile.ConstantPool; + +/** + * Abstract super class for branching instructions like GOTO, IFEQ, etc.. + * Branch instructions may have a variable length, namely GOTO, JSR, + * LOOKUPSWITCH and TABLESWITCH. + * + * @see InstructionList + * @version $Id: InstructionBranch.java,v 1.2 2008/05/28 23:53:00 aclement Exp $ + * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> + */ +/** + * A branch instruction may be talking in terms of absolute destination (targetIndex) or about an instruction it + * doesnt yet know the position if (targetInstruction). targetInstruction (if set) overrides targetIndex + */ +public class InstructionBranch extends Instruction implements InstructionTargeter { + private static final int UNSET = -1; + + protected int targetIndex = UNSET; // Branch target relative to this instruction + protected InstructionHandle targetInstruction; // Target object in instruction list + protected int positionOfThisInstruction; // for calculating relative branch destinations! + + /** + * Constructor if building an instruction branch that targets a handle (ie. we don't need to actual targetIndex in the bytecode yet) + */ + public InstructionBranch(short opcode, InstructionHandle target) { +// if (opcode == GOTO ) System.err.println("building GOTO"); + this.opcode = opcode; + setTarget(target); + } + + public InstructionBranch(short opcode, int index) { +// if (opcode == GOTO ) System.err.println("targetIndex set to "+index); + this.opcode = opcode; + this.targetIndex = index; + } + + // used when we know nothing + public InstructionBranch(short opcode) { + this.opcode = opcode; + } + + public void dump(DataOutputStream out) throws IOException { + out.writeByte(opcode); + int target = getTargetOffset(); +// System.err.println("Writing out target for branch instruction "+getName()); + switch (opcode) { + case GOTO: +// System.err.println("Writing out target "+target); + out.writeShort(target); + break; + case GOTO_W: +// System.err.println("Writing out target "+target); + out.writeInt(target); + break; + + case IF_ACMPEQ: + case IF_ACMPNE: + case IF_ICMPEQ: + case IF_ICMPGE: + case IF_ICMPGT: + case IF_ICMPLE: + case IF_ICMPLT: + case IF_ICMPNE: + case IFEQ: + case IFLE: + case IFLT: + case IFGT: + case IFNE: + case IFGE: + case IFNULL: + case IFNONNULL: + out.writeShort(target); + break; + + case JSR: + out.writeShort(target); + break; + case JSR_W: + out.writeInt(target); + break; + + default: + throw new IllegalStateException("Don't know how to write out "+getName().toUpperCase()); + } + + if(Math.abs(target) >= 32767) // too large for short + throw new ClassGenException("Branch target offset too large for short"); + } + + protected int getTargetOffset() { + if(targetInstruction == null && targetIndex==UNSET) + throw new ClassGenException("Target of " + super.toString(true) + " is unknown"); + + if (targetInstruction==null) { + return targetIndex; + } else { + return targetInstruction.getPosition()-positionOfThisInstruction; + } + } + + + /** + * 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) { + int i = getTargetOffset(); + + positionOfThisInstruction += offset; + + if (Math.abs(i)>=(32767-max_offset)) { // too larget for short (we think) + throw new IllegalStateException("Argh!"); + } + + 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(targetInstruction != null) { + if(targetInstruction.getInstruction() == this) + t = "<points to itself>"; + else if(targetInstruction.getInstruction() == null) + t = "<null instruction!!!?>"; + else + t = targetInstruction.getInstruction().toString(false); // Avoid circles + } + } else { + if(targetInstruction != null) { + targetIndex = getTargetOffset(); + t = "" + (targetIndex + positionOfThisInstruction); + } + } + + return s + " -> " + t; + } + + + /** + * @return target offset in byte code + */ + public final int getIndex() { return targetIndex; } + + /** + * @return target of branch instruction + */ + public InstructionHandle getTarget() { return targetInstruction; } + + /** + * Set branch target + * @param target branch target + */ + public void setTarget(InstructionHandle target) { +// if (opcode==GOTO) System.err.println("Set target to "+target); + notifyTarget(this.targetInstruction, target, this); + this.targetInstruction = 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(targetInstruction == old_ih) + setTarget(new_ih); + else + throw new ClassGenException("Not targeting " + old_ih + ", but " + targetInstruction); + } + + /** + * @return true, if ih is target of this instruction + */ + public boolean containsTarget(InstructionHandle ih) { + return (targetInstruction == ih); + } + + /** + * Inform target that it's not targeted anymore. + */ + void dispose() { + setTarget(null); + targetIndex=-1; + positionOfThisInstruction=-1; + } + + // OPTIMIZE why bother with this? +// public InstructionBranch negate() { +// if ((Constants.instFlags[opcode]&Constants.NEGATABLE)==0) throw new IllegalStateException("Operation is not negatable"); +// switch (opcode) { +// case IFGT: return copy(Constants.IFNE); +// case IFLE: return copy(Constants.IFGT); +// default: +// throw new IllegalStateException("Dunno:"+opcode); +// } +// } +// +// private InstructionBranch copy(short opcode) { +// InstructionBranch ib = null; +// if (targetInstruction!=null) { +// ib = new InstructionBranch(opcode,targetInstruction); +// } else { +// ib = new InstructionBranch(opcode,targetIndex); +// } +// ib.positionOfThisInstruction = positionOfThisInstruction; +// return ib; +// } + public Type getType(ConstantPool cp) { + if ((Constants.instFlags[opcode]&Constants.JSR_INSTRUCTION)!=0) return new ReturnaddressType(physicalSuccessor()); + return super.getType(cp); + } + + /** + * Returns an InstructionHandle to the physical successor + * of this JsrInstruction. <B>For this method to work, + * this JsrInstruction object must not be shared between + * multiple InstructionHandle objects!</B> + * Formally, there must not be InstructionHandle objects + * i, j where i != j and i.getInstruction() == this == + * j.getInstruction(). + * @return an InstructionHandle to the "next" instruction that + * will be executed when RETurned from a subroutine. + */ + public InstructionHandle physicalSuccessor(){ + InstructionHandle ih = this.targetInstruction; + + // Rewind! + while(ih.getPrev() != null) + ih = ih.getPrev(); + + // Find the handle for "this" JsrInstruction object. + while(ih.getInstruction() != this) + ih = ih.getNext(); + + InstructionHandle toThis = ih; + + while(ih != null){ + ih = ih.getNext(); + if ((ih != null) && (ih.getInstruction() == this)) + throw new RuntimeException("physicalSuccessor() called on a shared JsrInstruction."); + } + + // Return the physical successor + return toThis.getNext(); + } + + public boolean isIfInstruction() { + return ((Constants.instFlags[opcode]&Constants.IF_INST)!=0); + } +} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/GotoInstruction.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionByte.java index 291834fbd..d0611306c 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/GotoInstruction.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionByte.java @@ -54,22 +54,33 @@ package org.aspectj.apache.bcel.generic; * <http://www.apache.org/>. */ +import java.io.*; + + /** - * Super class for GOTO - * - * @version $Id: GotoInstruction.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> + * Instruction that needs one byte */ -public abstract class GotoInstruction extends BranchInstruction - implements UnconditionalBranch -{ - GotoInstruction(short opcode, InstructionHandle target) { - super(opcode, target); +public class InstructionByte extends Instruction { + private byte b; + + public InstructionByte(short opcode, byte b) { + this.opcode = opcode; + this.b = b; + } + + public void dump(DataOutputStream out) throws IOException { + out.writeByte(opcode); + out.writeByte(b); + } + + public String toString(boolean verbose) { + return super.toString(verbose) + " " + b; } + + public final byte getTypecode() { return b; } // NEWARRAY - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - GotoInstruction(){} + // NEWARRAY + public final Type getType() { + return new ArrayType(BasicType.getType(b), 1); + } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionCLV.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionCLV.java new file mode 100644 index 000000000..21e504c73 --- /dev/null +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionCLV.java @@ -0,0 +1,22 @@ +package org.aspectj.apache.bcel.generic; + +/** + * A small subclass of the local variable accessing instruction class InstructionLV - this subclass does + * not allow the index to be altered. + */ +public class InstructionCLV extends InstructionLV { + + public InstructionCLV(short opcode) { + super(opcode); + } + + public InstructionCLV(short opcode,int localVariableIndex) { + super(opcode,localVariableIndex); + } + + public void setIndex(int localVariableIndex) { + if (localVariableIndex!=getIndex())//allow this, shouldnt really... + throw new ClassGenException("Do not attempt to modify the index for this constant instruction: "+this); + } + +} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/CPInstruction.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionCP.java index ff7ee1c3e..175f89914 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/CPInstruction.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionCP.java @@ -60,45 +60,45 @@ import java.io.IOException; import org.aspectj.apache.bcel.classfile.Constant; import org.aspectj.apache.bcel.classfile.ConstantClass; import org.aspectj.apache.bcel.classfile.ConstantPool; -import org.aspectj.apache.bcel.util.ByteSequence; +import org.aspectj.apache.bcel.Constants; /** - * Abstract super class for instructions that use an index into the + * Slass for instructions that use an index into the * constant pool such as LDC, INVOKEVIRTUAL, etc. * * @see ConstantPoolGen * @see LDC * @see INVOKEVIRTUAL * - * @version $Id: CPInstruction.java,v 1.8 2008/04/25 17:58:20 aclement Exp $ + * @version $Id: InstructionCP.java,v 1.2 2008/05/28 23:52:57 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ -public abstract class CPInstruction extends Instruction - implements TypedInstruction, IndexedInstruction -{ +public class InstructionCP extends Instruction { protected int index; // index to constant pool - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - CPInstruction() {} - - /** - * @param index to constant pool - */ - protected CPInstruction(short opcode, int index) { - super(opcode, (short)3); - setIndex(index); + public InstructionCP(short opcode, int index) { + this.opcode = opcode; + this.index = index; } - /** - * Dump instruction as byte code to stream out. - * @param out Output stream - */ public void dump(DataOutputStream out) throws IOException { - out.writeByte(opcode); - out.writeShort(index); + if (opcode==LDC_W && index<256) { + out.writeByte(LDC); + out.writeByte(index); + } else { + out.writeByte(opcode); + if(Constants.iLen[opcode] == 2) { + if (index>255) { + throw new IllegalStateException(); + } + out.writeByte(index); + } else + out.writeShort(index); + } + } + + public int getLength() { + if (opcode==LDC_W && index<256) return 2; else return super.getLength(); } /** @@ -128,42 +128,69 @@ public abstract class CPInstruction extends Instruction } /** - * Read needed data (i.e., index) from file. - * @param bytes input stream - * @param wide wide prefix? - */ - protected void initFromFile(ByteSequence bytes, boolean wide) - throws IOException - { - setIndex(bytes.readUnsignedShort()); - length = 3; - } - - /** * @return index in constant pool referred by this instruction. */ public final int getIndex() { return index; } - /** - * Set the index to constant pool. - * @param index in constant pool. - */ - public void setIndex(int index) { - if(index < 0) - throw new ClassGenException("Negative index value: " + index); - - this.index = index; + public void setIndex(int index) { + this.index = index; + if (this.index>255 && opcode==LDC) { + // promote it + opcode = LDC_W; + } } - /** @return type related with this instruction. - */ - public Type getType(ConstantPoolGen cpg) { - ConstantPool cp = cpg.getConstantPool(); - String name = cp.getConstantString(index, org.aspectj.apache.bcel.Constants.CONSTANT_Class); - - if(!name.startsWith("[")) - name = "L" + name + ";"; - - return Type.getType(name); + public Type getType(ConstantPool cpg) { + switch (cpg.getConstant(index).getTag()) { + case CONSTANT_String: return Type.STRING; + case CONSTANT_Float: return Type.FLOAT; + case CONSTANT_Integer: return Type.INT; + case CONSTANT_Long: return Type.LONG; + case CONSTANT_Double: return Type.DOUBLE; + case CONSTANT_Class: + String name = cpg.getConstantString_CONSTANTClass(index); +// ConstantPool cp = cpg.getConstantPool(); +// String name = cp.getConstantString(index, CONSTANT_Class); + if(!name.startsWith("[")) { + StringBuffer sb = new StringBuffer(); + sb.append("L").append(name).append(";"); + return Type.getType(sb.toString()); + } else { + return Type.getType(name); + } + default: // Never reached + throw new RuntimeException("Unknown or invalid constant type at " + index); + } } + + public Object getValue(ConstantPool cpg) { + org.aspectj.apache.bcel.classfile.Constant c = cpg.getConstant(index); + + switch(c.getTag()) { + case org.aspectj.apache.bcel.Constants.CONSTANT_String: + int i = ((org.aspectj.apache.bcel.classfile.ConstantString)c).getStringIndex(); + c = cpg.getConstant(i); + return ((org.aspectj.apache.bcel.classfile.ConstantUtf8)c).getBytes(); + + case org.aspectj.apache.bcel.Constants.CONSTANT_Float: + return new Float(((org.aspectj.apache.bcel.classfile.ConstantFloat)c).getBytes()); + + case org.aspectj.apache.bcel.Constants.CONSTANT_Integer: + return new Integer(((org.aspectj.apache.bcel.classfile.ConstantInteger)c).getBytes()); + + // from ldc2_w: + case org.aspectj.apache.bcel.Constants.CONSTANT_Long: + return new Long(((org.aspectj.apache.bcel.classfile.ConstantLong)c).getBytes()); + + case org.aspectj.apache.bcel.Constants.CONSTANT_Double: + return new Double(((org.aspectj.apache.bcel.classfile.ConstantDouble)c).getBytes()); + default: // Never reached + throw new RuntimeException("Unknown or invalid constant type at " + index); + } + } + + + public Class[] getExceptions() { + return org.aspectj.apache.bcel.ExceptionConstants.EXCS_STRING_RESOLUTION; + } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionComparator.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionComparator.java index 029952887..1c8b5ec3e 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionComparator.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionComparator.java @@ -1,5 +1,7 @@ package org.aspectj.apache.bcel.generic; +import org.aspectj.apache.bcel.Constants; + /* ==================================================================== * The Apache Software License, Version 1.1 * @@ -64,16 +66,16 @@ package org.aspectj.apache.bcel.generic; * instructions must have the same target. * * @see Instruction - * @version $Id: InstructionComparator.java,v 1.3 2005/09/21 16:28:36 acolyer Exp $ + * @version $Id: InstructionComparator.java,v 1.4 2008/05/28 23:52:56 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public interface InstructionComparator { public static final InstructionComparator DEFAULT = new InstructionComparator() { public boolean equals(Instruction i1, Instruction i2) { if (i1.opcode == i2.opcode) { - if (i1 instanceof Select) { - InstructionHandle[] t1 = ((Select) i1).getTargets(); - InstructionHandle[] t2 = ((Select) i2).getTargets(); + if (i1 instanceof InstructionSelect) { + InstructionHandle[] t1 = ((InstructionSelect) i1).getTargets(); + InstructionHandle[] t2 = ((InstructionSelect) i2).getTargets(); // See AspectJ bug 104957 if (t1 == null && t2 == null) return true; @@ -88,16 +90,14 @@ public interface InstructionComparator { return true; } - } else if (i1 instanceof BranchInstruction) { - return ((BranchInstruction) i1).target == ((BranchInstruction) i2).target; - } else if (i1 instanceof ConstantPushInstruction) { - return ((ConstantPushInstruction) i1).getValue().equals( - ((ConstantPushInstruction) i2).getValue()); - } else if (i1 instanceof IndexedInstruction) { - return ((IndexedInstruction) i1).getIndex() == ((IndexedInstruction) i2) - .getIndex(); - } else if (i1 instanceof NEWARRAY) { - return ((NEWARRAY) i1).getTypecode() == ((NEWARRAY) i2) + } else if (i1 instanceof InstructionBranch) { + return ((InstructionBranch) i1).targetInstruction == ((InstructionBranch) i2).targetInstruction; + } else if (i1.isConstantInstruction()) { + return i1.getValue().equals(i2.getValue()); + } else if (i1.isIndexedInstruction()) { + return i1.getIndex() == i2.getIndex(); + } else if (i1.opcode==Constants.NEWARRAY) { + return ((InstructionByte) i1).getTypecode() == ((InstructionByte) i2) .getTypecode(); } else { return true; diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionConstants.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionConstants.java index cf1a390e5..553b67986 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionConstants.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionConstants.java @@ -70,136 +70,165 @@ import org.aspectj.apache.bcel.Constants; * The Instructions can also accessed directly under their names, so * it's possible to write il.append(Instruction.ICONST_0); * - * @version $Id: InstructionConstants.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: InstructionConstants.java,v 1.3 2008/05/28 23:52:55 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public interface InstructionConstants { /** Predefined instruction objects */ - public static final Instruction NOP = new NOP(); - public static final Instruction ACONST_NULL = new ACONST_NULL(); - public static final Instruction ICONST_M1 = new ICONST(-1); - public static final Instruction ICONST_0 = new ICONST(0); - public static final Instruction ICONST_1 = new ICONST(1); - public static final Instruction ICONST_2 = new ICONST(2); - public static final Instruction ICONST_3 = new ICONST(3); - public static final Instruction ICONST_4 = new ICONST(4); - public static final Instruction ICONST_5 = new ICONST(5); - public static final Instruction LCONST_0 = new LCONST(0); - public static final Instruction LCONST_1 = new LCONST(1); - public static final Instruction FCONST_0 = new FCONST(0); - public static final Instruction FCONST_1 = new FCONST(1); - public static final Instruction FCONST_2 = new FCONST(2); - public static final Instruction DCONST_0 = new DCONST(0); - public static final Instruction DCONST_1 = new DCONST(1); - public static final ArrayInstruction IALOAD = new IALOAD(); - public static final ArrayInstruction LALOAD = new LALOAD(); - public static final ArrayInstruction FALOAD = new FALOAD(); - public static final ArrayInstruction DALOAD = new DALOAD(); - public static final ArrayInstruction AALOAD = new AALOAD(); - public static final ArrayInstruction BALOAD = new BALOAD(); - public static final ArrayInstruction CALOAD = new CALOAD(); - public static final ArrayInstruction SALOAD = new SALOAD(); - public static final ArrayInstruction IASTORE = new IASTORE(); - public static final ArrayInstruction LASTORE = new LASTORE(); - public static final ArrayInstruction FASTORE = new FASTORE(); - public static final ArrayInstruction DASTORE = new DASTORE(); - public static final ArrayInstruction AASTORE = new AASTORE(); - public static final ArrayInstruction BASTORE = new BASTORE(); - public static final ArrayInstruction CASTORE = new CASTORE(); - public static final ArrayInstruction SASTORE = new SASTORE(); - public static final StackInstruction POP = new POP(); - public static final StackInstruction POP2 = new POP2(); - public static final StackInstruction DUP = new DUP(); - public static final StackInstruction DUP_X1 = new DUP_X1(); - public static final StackInstruction DUP_X2 = new DUP_X2(); - public static final StackInstruction DUP2 = new DUP2(); - public static final StackInstruction DUP2_X1 = new DUP2_X1(); - public static final StackInstruction DUP2_X2 = new DUP2_X2(); - public static final StackInstruction SWAP = new SWAP(); - public static final ArithmeticInstruction IADD = new IADD(); - public static final ArithmeticInstruction LADD = new LADD(); - public static final ArithmeticInstruction FADD = new FADD(); - public static final ArithmeticInstruction DADD = new DADD(); - public static final ArithmeticInstruction ISUB = new ISUB(); - public static final ArithmeticInstruction LSUB = new LSUB(); - public static final ArithmeticInstruction FSUB = new FSUB(); - public static final ArithmeticInstruction DSUB = new DSUB(); - public static final ArithmeticInstruction IMUL = new IMUL(); - public static final ArithmeticInstruction LMUL = new LMUL(); - public static final ArithmeticInstruction FMUL = new FMUL(); - public static final ArithmeticInstruction DMUL = new DMUL(); - public static final ArithmeticInstruction IDIV = new IDIV(); - public static final ArithmeticInstruction LDIV = new LDIV(); - public static final ArithmeticInstruction FDIV = new FDIV(); - public static final ArithmeticInstruction DDIV = new DDIV(); - public static final ArithmeticInstruction IREM = new IREM(); - public static final ArithmeticInstruction LREM = new LREM(); - public static final ArithmeticInstruction FREM = new FREM(); - public static final ArithmeticInstruction DREM = new DREM(); - public static final ArithmeticInstruction INEG = new INEG(); - public static final ArithmeticInstruction LNEG = new LNEG(); - public static final ArithmeticInstruction FNEG = new FNEG(); - public static final ArithmeticInstruction DNEG = new DNEG(); - public static final ArithmeticInstruction ISHL = new ISHL(); - public static final ArithmeticInstruction LSHL = new LSHL(); - public static final ArithmeticInstruction ISHR = new ISHR(); - public static final ArithmeticInstruction LSHR = new LSHR(); - public static final ArithmeticInstruction IUSHR = new IUSHR(); - public static final ArithmeticInstruction LUSHR = new LUSHR(); - public static final ArithmeticInstruction IAND = new IAND(); - public static final ArithmeticInstruction LAND = new LAND(); - public static final ArithmeticInstruction IOR = new IOR(); - public static final ArithmeticInstruction LOR = new LOR(); - public static final ArithmeticInstruction IXOR = new IXOR(); - public static final ArithmeticInstruction LXOR = new LXOR(); - public static final ConversionInstruction I2L = new I2L(); - public static final ConversionInstruction I2F = new I2F(); - public static final ConversionInstruction I2D = new I2D(); - public static final ConversionInstruction L2I = new L2I(); - public static final ConversionInstruction L2F = new L2F(); - public static final ConversionInstruction L2D = new L2D(); - public static final ConversionInstruction F2I = new F2I(); - public static final ConversionInstruction F2L = new F2L(); - public static final ConversionInstruction F2D = new F2D(); - public static final ConversionInstruction D2I = new D2I(); - public static final ConversionInstruction D2L = new D2L(); - public static final ConversionInstruction D2F = new D2F(); - public static final ConversionInstruction I2B = new I2B(); - public static final ConversionInstruction I2C = new I2C(); - public static final ConversionInstruction I2S = new I2S(); - public static final Instruction LCMP = new LCMP(); - public static final Instruction FCMPL = new FCMPL(); - public static final Instruction FCMPG = new FCMPG(); - public static final Instruction DCMPL = new DCMPL(); - public static final Instruction DCMPG = new DCMPG(); - public static final ReturnInstruction IRETURN = new IRETURN(); - public static final ReturnInstruction LRETURN = new LRETURN(); - public static final ReturnInstruction FRETURN = new FRETURN(); - public static final ReturnInstruction DRETURN = new DRETURN(); - public static final ReturnInstruction ARETURN = new ARETURN(); - public static final ReturnInstruction RETURN = new RETURN(); - public static final Instruction ARRAYLENGTH = new ARRAYLENGTH(); - public static final Instruction ATHROW = new ATHROW(); - public static final Instruction MONITORENTER = new MONITORENTER(); - public static final Instruction MONITOREXIT = new MONITOREXIT(); + public static final Instruction NOP = new Instruction(Constants.NOP); + public static final Instruction ACONST_NULL = new Instruction(Constants.ACONST_NULL); + public static final Instruction ICONST_M1 = new Instruction(Constants.ICONST_M1); + public static final Instruction ICONST_0 = new Instruction(Constants.ICONST_0); + public static final Instruction ICONST_1 = new Instruction(Constants.ICONST_1); + public static final Instruction ICONST_2 = new Instruction(Constants.ICONST_2); + public static final Instruction ICONST_3 = new Instruction(Constants.ICONST_3); + public static final Instruction ICONST_4 = new Instruction(Constants.ICONST_4); + public static final Instruction ICONST_5 = new Instruction(Constants.ICONST_5); + public static final Instruction LCONST_0 = new Instruction(Constants.LCONST_0); + public static final Instruction LCONST_1 = new Instruction(Constants.LCONST_1); + public static final Instruction FCONST_0 = new Instruction(Constants.FCONST_0); + public static final Instruction FCONST_1 = new Instruction(Constants.FCONST_1); + public static final Instruction FCONST_2 = new Instruction(Constants.FCONST_2); + public static final Instruction DCONST_0 = new Instruction(Constants.DCONST_0); + public static final Instruction DCONST_1 = new Instruction(Constants.DCONST_1); + public static final Instruction IALOAD = new Instruction(Constants.IALOAD); + public static final Instruction LALOAD = new Instruction(Constants.LALOAD); + public static final Instruction FALOAD = new Instruction(Constants.FALOAD); + public static final Instruction DALOAD = new Instruction(Constants.DALOAD); + public static final Instruction AALOAD = new Instruction(Constants.AALOAD); + public static final Instruction BALOAD = new Instruction(Constants.BALOAD); + public static final Instruction CALOAD = new Instruction(Constants.CALOAD); + public static final Instruction SALOAD = new Instruction(Constants.SALOAD); + public static final Instruction IASTORE = new Instruction(Constants.IASTORE); + public static final Instruction LASTORE = new Instruction(Constants.LASTORE); + public static final Instruction FASTORE = new Instruction(Constants.FASTORE); + public static final Instruction DASTORE = new Instruction(Constants.DASTORE); + public static final Instruction AASTORE = new Instruction(Constants.AASTORE); + public static final Instruction BASTORE = new Instruction(Constants.BASTORE); + public static final Instruction CASTORE = new Instruction(Constants.CASTORE); + public static final Instruction SASTORE = new Instruction(Constants.SASTORE); + public static final Instruction POP = new Instruction(Constants.POP); + public static final Instruction POP2 = new Instruction(Constants.POP2); + public static final Instruction DUP = new Instruction(Constants.DUP); + public static final Instruction DUP_X1 = new Instruction(Constants.DUP_X1); + public static final Instruction DUP_X2 = new Instruction(Constants.DUP_X2); + public static final Instruction DUP2 = new Instruction(Constants.DUP2); + public static final Instruction DUP2_X1 = new Instruction(Constants.DUP2_X1); + public static final Instruction DUP2_X2 = new Instruction(Constants.DUP2_X2); + public static final Instruction SWAP = new Instruction(Constants.SWAP); + public static final Instruction IADD = new Instruction(Constants.IADD); + public static final Instruction LADD = new Instruction(Constants.LADD); + public static final Instruction FADD = new Instruction(Constants.FADD); + public static final Instruction DADD = new Instruction(Constants.DADD); + public static final Instruction ISUB = new Instruction(Constants.ISUB); + public static final Instruction LSUB = new Instruction(Constants.LSUB); + public static final Instruction FSUB = new Instruction(Constants.FSUB); + public static final Instruction DSUB = new Instruction(Constants.DSUB); + public static final Instruction IMUL = new Instruction(Constants.IMUL); + public static final Instruction LMUL = new Instruction(Constants.LMUL); + public static final Instruction FMUL = new Instruction(Constants.FMUL); + public static final Instruction DMUL = new Instruction(Constants.DMUL); + public static final Instruction IDIV = new Instruction(Constants.IDIV); + public static final Instruction LDIV = new Instruction(Constants.LDIV); + public static final Instruction FDIV = new Instruction(Constants.FDIV); + public static final Instruction DDIV = new Instruction(Constants.DDIV); + public static final Instruction IREM = new Instruction(Constants.IREM); + public static final Instruction LREM = new Instruction(Constants.LREM); + public static final Instruction FREM = new Instruction(Constants.FREM); + public static final Instruction DREM = new Instruction(Constants.DREM); + public static final Instruction INEG = new Instruction(Constants.INEG); + public static final Instruction LNEG = new Instruction(Constants.LNEG); + public static final Instruction FNEG = new Instruction(Constants.FNEG); + public static final Instruction DNEG = new Instruction(Constants.DNEG); + public static final Instruction ISHL = new Instruction(Constants.ISHL); + public static final Instruction LSHL = new Instruction(Constants.LSHL); + public static final Instruction ISHR = new Instruction(Constants.ISHR); + public static final Instruction LSHR = new Instruction(Constants.LSHR); + public static final Instruction IUSHR = new Instruction(Constants.IUSHR); + public static final Instruction LUSHR = new Instruction(Constants.LUSHR); + public static final Instruction IAND = new Instruction(Constants.IAND); + public static final Instruction LAND = new Instruction(Constants.LAND); + public static final Instruction IOR = new Instruction(Constants.IOR); + public static final Instruction LOR = new Instruction(Constants.LOR); + public static final Instruction IXOR = new Instruction(Constants.IXOR); + public static final Instruction LXOR = new Instruction(Constants.LXOR); + public static final Instruction I2L = new Instruction(Constants.I2L); + public static final Instruction I2F = new Instruction(Constants.I2F); + public static final Instruction I2D = new Instruction(Constants.I2D); + public static final Instruction L2I = new Instruction(Constants.L2I); + public static final Instruction L2F = new Instruction(Constants.L2F); + public static final Instruction L2D = new Instruction(Constants.L2D); + public static final Instruction F2I = new Instruction(Constants.F2I); + public static final Instruction F2L = new Instruction(Constants.F2L); + public static final Instruction F2D = new Instruction(Constants.F2D); + public static final Instruction D2I = new Instruction(Constants.D2I); + public static final Instruction D2L = new Instruction(Constants.D2L); + public static final Instruction D2F = new Instruction(Constants.D2F); + public static final Instruction I2B = new Instruction(Constants.I2B); + public static final Instruction I2C = new Instruction(Constants.I2C); + public static final Instruction I2S = new Instruction(Constants.I2S); + public static final Instruction LCMP = new Instruction(Constants.LCMP); + public static final Instruction FCMPL = new Instruction(Constants.FCMPL); + public static final Instruction FCMPG = new Instruction(Constants.FCMPG); + public static final Instruction DCMPL = new Instruction(Constants.DCMPL); + public static final Instruction DCMPG = new Instruction(Constants.DCMPG); + public static final Instruction IRETURN = new Instruction(Constants.IRETURN); + public static final Instruction LRETURN = new Instruction(Constants.LRETURN); + public static final Instruction FRETURN = new Instruction(Constants.FRETURN); + public static final Instruction DRETURN = new Instruction(Constants.DRETURN); + public static final Instruction ARETURN = new Instruction(Constants.ARETURN); + public static final Instruction RETURN = new Instruction(Constants.RETURN); + public static final Instruction ARRAYLENGTH = new Instruction(Constants.ARRAYLENGTH); + public static final Instruction ATHROW = new Instruction(Constants.ATHROW); + public static final Instruction MONITORENTER = new Instruction(Constants.MONITORENTER); + public static final Instruction MONITOREXIT = new Instruction(Constants.MONITOREXIT); + public static final Instruction IMPDEP1 = new Instruction(Constants.IMPDEP1); + public static final Instruction IMPDEP2 = new Instruction(Constants.IMPDEP2); - /** You can use these constants in multiple places safely, if you can guarantee - * that you will never alter their internal values, e.g. call setIndex(). - */ - public static final LocalVariableInstruction THIS = new ALOAD(0); - public static final LocalVariableInstruction ALOAD_0 = THIS; - public static final LocalVariableInstruction ALOAD_1 = new ALOAD(1); - public static final LocalVariableInstruction ALOAD_2 = new ALOAD(2); - public static final LocalVariableInstruction ILOAD_0 = new ILOAD(0); - public static final LocalVariableInstruction ILOAD_1 = new ILOAD(1); - public static final LocalVariableInstruction ILOAD_2 = new ILOAD(2); - public static final LocalVariableInstruction ASTORE_0 = new ASTORE(0); - public static final LocalVariableInstruction ASTORE_1 = new ASTORE(1); - public static final LocalVariableInstruction ASTORE_2 = new ASTORE(2); - public static final LocalVariableInstruction ISTORE_0 = new ISTORE(0); - public static final LocalVariableInstruction ISTORE_1 = new ISTORE(1); - public static final LocalVariableInstruction ISTORE_2 = new ISTORE(2); + // You can use these constants in multiple places safely, any attempt to change the index + // for these constants will cause an exception + public static final InstructionLV THIS = new InstructionCLV(Constants.ALOAD,0); + public static final InstructionLV ALOAD_0 = new InstructionCLV(Constants.ALOAD_0); + public static final InstructionLV ALOAD_1 = new InstructionCLV(Constants.ALOAD_1); + public static final InstructionLV ALOAD_2 = new InstructionCLV(Constants.ALOAD_2); + public static final InstructionLV ALOAD_3 = new InstructionCLV(Constants.ALOAD_3); + public static final InstructionLV ILOAD_0 = new InstructionCLV(Constants.ILOAD_0); + public static final InstructionLV ILOAD_1 = new InstructionCLV(Constants.ILOAD_1); + public static final InstructionLV ILOAD_2 = new InstructionCLV(Constants.ILOAD_2); + public static final InstructionLV ILOAD_3 = new InstructionCLV(Constants.ILOAD_3); + public static final InstructionLV DLOAD_0 = new InstructionCLV(Constants.DLOAD_0); + public static final InstructionLV DLOAD_1 = new InstructionCLV(Constants.DLOAD_1); + public static final InstructionLV DLOAD_2 = new InstructionCLV(Constants.DLOAD_2); + public static final InstructionLV DLOAD_3 = new InstructionCLV(Constants.DLOAD_3); + public static final InstructionLV FLOAD_0 = new InstructionCLV(Constants.FLOAD_0); + public static final InstructionLV FLOAD_1 = new InstructionCLV(Constants.FLOAD_1); + public static final InstructionLV FLOAD_2 = new InstructionCLV(Constants.FLOAD_2); + public static final InstructionLV FLOAD_3 = new InstructionCLV(Constants.FLOAD_3); + public static final InstructionLV LLOAD_0 = new InstructionCLV(Constants.LLOAD_0); + public static final InstructionLV LLOAD_1 = new InstructionCLV(Constants.LLOAD_1); + public static final InstructionLV LLOAD_2 = new InstructionCLV(Constants.LLOAD_2); + public static final InstructionLV LLOAD_3 = new InstructionCLV(Constants.LLOAD_3); + public static final InstructionLV ASTORE_0 = new InstructionCLV(Constants.ASTORE_0); + public static final InstructionLV ASTORE_1 = new InstructionCLV(Constants.ASTORE_1); + public static final InstructionLV ASTORE_2 = new InstructionCLV(Constants.ASTORE_2); + public static final InstructionLV ASTORE_3 = new InstructionCLV(Constants.ASTORE_3); + public static final InstructionLV ISTORE_0 = new InstructionCLV(Constants.ISTORE_0); + public static final InstructionLV ISTORE_1 = new InstructionCLV(Constants.ISTORE_1); + public static final InstructionLV ISTORE_2 = new InstructionCLV(Constants.ISTORE_2); + public static final InstructionLV ISTORE_3 = new InstructionCLV(Constants.ISTORE_3); + public static final InstructionLV LSTORE_0 = new InstructionCLV(Constants.LSTORE_0); + public static final InstructionLV LSTORE_1 = new InstructionCLV(Constants.LSTORE_1); + public static final InstructionLV LSTORE_2 = new InstructionCLV(Constants.LSTORE_2); + public static final InstructionLV LSTORE_3 = new InstructionCLV(Constants.LSTORE_3); + public static final InstructionLV FSTORE_0 = new InstructionCLV(Constants.FSTORE_0); + public static final InstructionLV FSTORE_1 = new InstructionCLV(Constants.FSTORE_1); + public static final InstructionLV FSTORE_2 = new InstructionCLV(Constants.FSTORE_2); + public static final InstructionLV FSTORE_3 = new InstructionCLV(Constants.FSTORE_3); + public static final InstructionLV DSTORE_0 = new InstructionCLV(Constants.DSTORE_0); + public static final InstructionLV DSTORE_1 = new InstructionCLV(Constants.DSTORE_1); + public static final InstructionLV DSTORE_2 = new InstructionCLV(Constants.DSTORE_2); + public static final InstructionLV DSTORE_3 = new InstructionCLV(Constants.DSTORE_3); /** Get object via its opcode, for immutable instructions like @@ -321,6 +350,18 @@ public interface InstructionConstants { INSTRUCTIONS[Constants.ATHROW] = ATHROW; INSTRUCTIONS[Constants.MONITORENTER] = MONITORENTER; INSTRUCTIONS[Constants.MONITOREXIT] = MONITOREXIT; + INSTRUCTIONS[Constants.IMPDEP1] = IMPDEP1; + INSTRUCTIONS[Constants.IMPDEP2] = IMPDEP2; +// INSTRUCTIONS[Constants.ALOAD_0] = ALOAD_0;INSTRUCTIONS[Constants.ALOAD_1] = ALOAD_1; +// INSTRUCTIONS[Constants.ALOAD_2] = ALOAD_2;INSTRUCTIONS[Constants.ALOAD_3] = ALOAD_3; +// INSTRUCTIONS[Constants.LLOAD_0] = LLOAD_0;INSTRUCTIONS[Constants.LLOAD_1] = LLOAD_1; +// INSTRUCTIONS[Constants.LLOAD_2] = LLOAD_2;INSTRUCTIONS[Constants.LLOAD_3] = LLOAD_3; +// INSTRUCTIONS[Constants.DLOAD_0] = DLOAD_0;INSTRUCTIONS[Constants.DLOAD_1] = DLOAD_1; +// INSTRUCTIONS[Constants.DLOAD_2] = DLOAD_2;INSTRUCTIONS[Constants.DLOAD_3] = DLOAD_3; +// INSTRUCTIONS[Constants.FLOAD_0] = FLOAD_0;INSTRUCTIONS[Constants.FLOAD_1] = FLOAD_1; +// INSTRUCTIONS[Constants.FLOAD_2] = FLOAD_2;INSTRUCTIONS[Constants.FLOAD_3] = FLOAD_3; +// INSTRUCTIONS[Constants.ILOAD_0] = ILOAD_0;INSTRUCTIONS[Constants.ILOAD_1] = ILOAD_1; +// INSTRUCTIONS[Constants.ILOAD_2] = ILOAD_2;INSTRUCTIONS[Constants.ILOAD_3] = ILOAD_3; } } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionFactory.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionFactory.java index 9943e0949..07aed8852 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionFactory.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionFactory.java @@ -54,6 +54,7 @@ package org.aspectj.apache.bcel.generic; * <http://www.apache.org/>. */ import org.aspectj.apache.bcel.Constants; +import org.aspectj.apache.bcel.classfile.ConstantPool; /** * Instances of this class may be used, e.g., to generate typed @@ -61,35 +62,28 @@ import org.aspectj.apache.bcel.Constants; * byte code generating backend of a compiler. You can subclass it to * add your own create methods. * - * @version $Id: InstructionFactory.java,v 1.3 2005/01/31 11:32:21 aclement Exp $ + * @version $Id: InstructionFactory.java,v 1.4 2008/05/28 23:52:59 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Constants */ -public class InstructionFactory - implements InstructionConstants, java.io.Serializable -{ +public class InstructionFactory implements InstructionConstants, java.io.Serializable { protected ClassGen cg; - protected ConstantPoolGen cp; + protected ConstantPool cp; - public InstructionFactory(ClassGen cg, ConstantPoolGen cp) { + public InstructionFactory(ClassGen cg, ConstantPool cp) { this.cg = cg; this.cp = cp; } - /** Initialize with ClassGen object - */ public InstructionFactory(ClassGen cg) { this(cg, cg.getConstantPool()); } - /** Initialize just with ConstantPoolGen object - */ - public InstructionFactory(ConstantPoolGen cp) { + public InstructionFactory(ConstantPool cp) { this(null, cp); } /** Create an invoke instruction. - * * @param class_name name of the called class * @param name name of the called method * @param ret_type return type of method @@ -100,66 +94,89 @@ public class InstructionFactory */ public InvokeInstruction createInvoke(String class_name, String name, Type ret_type, Type[] arg_types, short kind) { - int index; - int nargs = 0; + String signature = Type.getMethodSignature(ret_type, arg_types); - - for(int i=0; i < arg_types.length; i++) // Count size of arguments - nargs += arg_types[i].getSize(); - - if(kind == Constants.INVOKEINTERFACE) + + int index; + if (kind == Constants.INVOKEINTERFACE) index = cp.addInterfaceMethodref(class_name, name, signature); else index = cp.addMethodref(class_name, name, signature); switch(kind) { - case Constants.INVOKESPECIAL: return new INVOKESPECIAL(index); - case Constants.INVOKEVIRTUAL: return new INVOKEVIRTUAL(index); - case Constants.INVOKESTATIC: return new INVOKESTATIC(index); - case Constants.INVOKEINTERFACE: return new INVOKEINTERFACE(index, nargs + 1); + case Constants.INVOKESPECIAL: return new InvokeInstruction(Constants.INVOKESPECIAL,index); + case Constants.INVOKEVIRTUAL: return new InvokeInstruction(Constants.INVOKEVIRTUAL,index); + case Constants.INVOKESTATIC: return new InvokeInstruction(Constants.INVOKESTATIC,index); + case Constants.INVOKEINTERFACE: + int nargs = 0; + for(int i=0; i < arg_types.length; i++) // Count size of arguments + nargs += arg_types[i].getSize(); + return new INVOKEINTERFACE(index, nargs + 1,0); default: throw new RuntimeException("Oops: Unknown invoke kind:" + kind); } } - /** Create a call to the most popular System.out.println() method. - * - * @param s the string to print - */ - public InstructionList createPrintln(String s) { - InstructionList il = new InstructionList(); - int out = cp.addFieldref("java.lang.System", "out", - "Ljava/io/PrintStream;"); - int println = cp.addMethodref("java.io.PrintStream", "println", - "(Ljava/lang/String;)V"); - - il.append(new GETSTATIC(out)); - il.append(new PUSH(cp, s)); - il.append(new INVOKEVIRTUAL(println)); - - return il; + public InvokeInstruction createInvoke(String class_name, String name, String signature, short kind) { + int index; + if(kind == Constants.INVOKEINTERFACE) { + index = cp.addInterfaceMethodref(class_name, name, signature); + } else { + index = cp.addMethodref(class_name, name, signature); + } + + switch(kind) { + case Constants.INVOKESPECIAL: return new InvokeInstruction(Constants.INVOKESPECIAL,index); + case Constants.INVOKEVIRTUAL: return new InvokeInstruction(Constants.INVOKEVIRTUAL,index); + case Constants.INVOKESTATIC: return new InvokeInstruction(Constants.INVOKESTATIC,index); + case Constants.INVOKEINTERFACE: + Type[] argumentTypes = Type.getArgumentTypes(signature); + int nargs = 0; + for(int i=0; i < argumentTypes.length; i++) {// Count size of arguments + nargs += argumentTypes[i].getSize(); + } + return new INVOKEINTERFACE(index, nargs + 1,0); + default: + throw new RuntimeException("Oops: Unknown invoke kind:" + kind); + } + } + + public static Instruction createALOAD(int n) { + if (n<4) { + return new InstructionLV((short)(Constants.ALOAD_0+n)); + } + return new InstructionLV(Constants.ALOAD,n); + } + + public static Instruction createASTORE(int n) { + if (n<4) { + return new InstructionLV((short)(Constants.ASTORE_0+n)); + } + return new InstructionLV(Constants.ASTORE,n); } + /** Uses PUSH to push a constant value onto the stack. * @param value must be of type Number, Boolean, Character or String */ + // OPTIMIZE callers should use the PUSH methods where possible if they know the types public Instruction createConstant(Object value) { - PUSH push; + Instruction instruction; if(value instanceof Number) - push = new PUSH(cp, (Number)value); + instruction = InstructionFactory.PUSH(cp, (Number)value); else if(value instanceof String) - push = new PUSH(cp, (String)value); + instruction = InstructionFactory.PUSH(cp, (String)value); else if(value instanceof Boolean) - push = new PUSH(cp, (Boolean)value); + instruction = InstructionFactory.PUSH(cp, (Boolean)value); else if(value instanceof Character) - push = new PUSH(cp, (Character)value); + instruction = InstructionFactory.PUSH(cp, (Character)value); else if (value instanceof ObjectType) - push = new PUSH(cp, (ObjectType)value); + instruction = InstructionFactory.PUSH(cp, (ObjectType)value); else throw new ClassGenException("Illegal type: " + value.getClass()); - return push.getInstruction(); + return instruction; } private static class MethodObject { @@ -183,58 +200,6 @@ public class InstructionFactory return createInvoke(m.class_name, m.name, m.result_type, m.arg_types, kind); } - private static MethodObject[] append_mos = { - new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, - new Type[] { Type.STRING }, Constants.ACC_PUBLIC), - new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, - new Type[] { Type.OBJECT }, Constants.ACC_PUBLIC), - null, null, // indices 2, 3 - new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, - new Type[] { Type.BOOLEAN }, Constants.ACC_PUBLIC), - new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, - new Type[] { Type.CHAR }, Constants.ACC_PUBLIC), - new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, - new Type[] { Type.FLOAT }, Constants.ACC_PUBLIC), - new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, - new Type[] { Type.DOUBLE }, Constants.ACC_PUBLIC), - new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, - new Type[] { Type.INT }, Constants.ACC_PUBLIC), - new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, // No append(byte) - new Type[] { Type.INT }, Constants.ACC_PUBLIC), - new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, // No append(short) - new Type[] { Type.INT }, Constants.ACC_PUBLIC), - new MethodObject("java.lang.StringBuffer", "append", Type.STRINGBUFFER, - new Type[] { Type.LONG }, Constants.ACC_PUBLIC) - }; - - private static final boolean isString(Type type) { - return ((type instanceof ObjectType) && - ((ObjectType)type).getClassName().equals("java.lang.String")); - } - - public Instruction createAppend(Type type) { - byte t = type.getType(); - - if(isString(type)) - return createInvoke(append_mos[0], Constants.INVOKEVIRTUAL); - - switch(t) { - case Constants.T_BOOLEAN: - case Constants.T_CHAR: - case Constants.T_FLOAT: - case Constants.T_DOUBLE: - case Constants.T_BYTE: - case Constants.T_SHORT: - case Constants.T_INT: - case Constants.T_LONG - : return createInvoke(append_mos[t], Constants.INVOKEVIRTUAL); - case Constants.T_ARRAY: - case Constants.T_OBJECT: - return createInvoke(append_mos[1], Constants.INVOKEVIRTUAL); - default: - throw new RuntimeException("Oops: No append for this type? " + type); - } - } /** Create a field instruction. * @@ -251,25 +216,25 @@ public class InstructionFactory index = cp.addFieldref(class_name, name, signature); switch(kind) { - case Constants.GETFIELD: return new GETFIELD(index); - case Constants.PUTFIELD: return new PUTFIELD(index); - case Constants.GETSTATIC: return new GETSTATIC(index); - case Constants.PUTSTATIC: return new PUTSTATIC(index); - - default: - throw new RuntimeException("Oops: Unknown getfield kind:" + kind); + case Constants.GETFIELD: return new FieldInstruction(Constants.GETFIELD,index); + case Constants.PUTFIELD: return new FieldInstruction(Constants.PUTFIELD,index); + case Constants.GETSTATIC: return new FieldInstruction(Constants.GETSTATIC,index); + case Constants.PUTSTATIC: return new FieldInstruction(Constants.PUTSTATIC,index); + + default: + throw new RuntimeException("Oops: Unknown getfield kind:" + kind); } } /** Create reference to `this' */ public static Instruction createThis() { - return new ALOAD(0); + return new InstructionLV(Constants.ALOAD,0); } /** Create typed return */ - public static ReturnInstruction createReturn(Type type) { + public static Instruction createReturn(Type type) { switch(type.getType()) { case Constants.T_ARRAY: case Constants.T_OBJECT: return ARETURN; @@ -288,154 +253,76 @@ public class InstructionFactory } } - private static final ArithmeticInstruction createBinaryIntOp(char first, String op) { - switch(first) { - case '-' : return ISUB; - case '+' : return IADD; - case '%' : return IREM; - case '*' : return IMUL; - case '/' : return IDIV; - case '&' : return IAND; - case '|' : return IOR; - case '^' : return IXOR; - case '<' : return ISHL; - case '>' : return op.equals(">>>")? (ArithmeticInstruction)IUSHR : - (ArithmeticInstruction)ISHR; - default: throw new RuntimeException("Invalid operand " + op); - } - } - - private static final ArithmeticInstruction createBinaryLongOp(char first, String op) { - switch(first) { - case '-' : return LSUB; - case '+' : return LADD; - case '%' : return LREM; - case '*' : return LMUL; - case '/' : return LDIV; - case '&' : return LAND; - case '|' : return LOR; - case '^' : return LXOR; - case '<' : return LSHL; - case '>' : return op.equals(">>>")? (ArithmeticInstruction)LUSHR : - (ArithmeticInstruction)LSHR; - default: throw new RuntimeException("Invalid operand " + op); - } - } - - private static final ArithmeticInstruction createBinaryFloatOp(char op) { - switch(op) { - case '-' : return FSUB; - case '+' : return FADD; - case '*' : return FMUL; - case '/' : return FDIV; - default: throw new RuntimeException("Invalid operand " + op); - } - } - - private static final ArithmeticInstruction createBinaryDoubleOp(char op) { - switch(op) { - case '-' : return DSUB; - case '+' : return DADD; - case '*' : return DMUL; - case '/' : return DDIV; - default: throw new RuntimeException("Invalid operand " + op); - } - } - - /** - * Create binary operation for simple basic types, such as int and float. - * - * @param op operation, such as "+", "*", "<<", etc. - */ - public static ArithmeticInstruction createBinaryOperation(String op, Type type) { - char first = op.toCharArray()[0]; - - switch(type.getType()) { - case Constants.T_BYTE: - case Constants.T_SHORT: - case Constants.T_INT: - case Constants.T_CHAR: return createBinaryIntOp(first, op); - case Constants.T_LONG: return createBinaryLongOp(first, op); - case Constants.T_FLOAT: return createBinaryFloatOp(first); - case Constants.T_DOUBLE: return createBinaryDoubleOp(first); - default: throw new RuntimeException("Invalid type " + type); - } - } - /** * @param size size of operand, either 1 (int, e.g.) or 2 (double) */ - public static StackInstruction createPop(int size) { - return (size == 2)? (StackInstruction)POP2 : - (StackInstruction)POP; + public static Instruction createPop(int size) { + return (size == 2)? POP2 : POP; } /** * @param size size of operand, either 1 (int, e.g.) or 2 (double) */ - public static StackInstruction createDup(int size) { - return (size == 2)? (StackInstruction)DUP2 : - (StackInstruction)DUP; + public static Instruction createDup(int size) { + return (size == 2)? DUP2:DUP; } /** * @param size size of operand, either 1 (int, e.g.) or 2 (double) */ - public static StackInstruction createDup_2(int size) { - return (size == 2)? (StackInstruction)DUP2_X2 : - (StackInstruction)DUP_X2; + public static Instruction createDup_2(int size) { + return (size == 2)? DUP2_X2 :DUP_X2; } /** * @param size size of operand, either 1 (int, e.g.) or 2 (double) */ - public static StackInstruction createDup_1(int size) { - return (size == 2)? (StackInstruction)DUP2_X1 : - (StackInstruction)DUP_X1; + public static Instruction createDup_1(int size) { + return (size == 2)? DUP2_X1 : DUP_X1; } /** * @param index index of local variable */ - public static LocalVariableInstruction createStore(Type type, int index) { + public static InstructionLV createStore(Type type, int index) { switch(type.getType()) { - case Constants.T_BOOLEAN: - case Constants.T_CHAR: - case Constants.T_BYTE: - case Constants.T_SHORT: - case Constants.T_INT: return new ISTORE(index); - case Constants.T_FLOAT: return new FSTORE(index); - case Constants.T_DOUBLE: return new DSTORE(index); - case Constants.T_LONG: return new LSTORE(index); - case Constants.T_ARRAY: - case Constants.T_OBJECT: return new ASTORE(index); - default: throw new RuntimeException("Invalid type " + type); + case Constants.T_BOOLEAN: + case Constants.T_CHAR: + case Constants.T_BYTE: + case Constants.T_SHORT: + case Constants.T_INT: return new InstructionLV(Constants.ISTORE,index); + case Constants.T_FLOAT: return new InstructionLV(Constants.FSTORE,index); + case Constants.T_DOUBLE: return new InstructionLV(Constants.DSTORE,index); + case Constants.T_LONG: return new InstructionLV(Constants.LSTORE,index); + case Constants.T_ARRAY: + case Constants.T_OBJECT: return new InstructionLV(Constants.ASTORE,index); + default: throw new RuntimeException("Invalid type " + type); } } /** * @param index index of local variable */ - public static LocalVariableInstruction createLoad(Type type, int index) { + public static InstructionLV createLoad(Type type, int index) { switch(type.getType()) { - case Constants.T_BOOLEAN: - case Constants.T_CHAR: - case Constants.T_BYTE: - case Constants.T_SHORT: - case Constants.T_INT: return new ILOAD(index); - case Constants.T_FLOAT: return new FLOAD(index); - case Constants.T_DOUBLE: return new DLOAD(index); - case Constants.T_LONG: return new LLOAD(index); - case Constants.T_ARRAY: - case Constants.T_OBJECT: return new ALOAD(index); - default: throw new RuntimeException("Invalid type " + type); + case Constants.T_BOOLEAN: + case Constants.T_CHAR: + case Constants.T_BYTE: + case Constants.T_SHORT: + case Constants.T_INT: return new InstructionLV(Constants.ILOAD,index); + case Constants.T_FLOAT: return new InstructionLV(Constants.FLOAD,index); + case Constants.T_DOUBLE: return new InstructionLV(Constants.DLOAD,index); + case Constants.T_LONG: return new InstructionLV(Constants.LLOAD,index); + case Constants.T_ARRAY: + case Constants.T_OBJECT: return new InstructionLV(Constants.ALOAD,index); + default: throw new RuntimeException("Invalid type " + type); } } /** * @param type type of elements of array, i.e., array.getElementType() */ - public static ArrayInstruction createArrayLoad(Type type) { + public static Instruction createArrayLoad(Type type) { switch(type.getType()) { case Constants.T_BOOLEAN: case Constants.T_BYTE: return BALOAD; @@ -454,7 +341,7 @@ public class InstructionFactory /** * @param type type of elements of array, i.e., array.getElementType() */ - public static ArrayInstruction createArrayStore(Type type) { + public static Instruction createArrayStore(Type type) { switch(type.getType()) { case Constants.T_BOOLEAN: case Constants.T_BYTE: return BASTORE; @@ -470,7 +357,7 @@ public class InstructionFactory } } - + private static final char[] shortNames = { 'C', 'F', 'D', 'B', 'S', 'I', 'L' }; /** Create conversion operation for two stack operands, this may be an I2C, instruction, e.g., * if the operands are basic types and CHECKCAST if they are reference types. */ @@ -479,68 +366,95 @@ public class InstructionFactory byte dest = dest_type.getType(); byte src = src_type.getType(); - if(dest == Constants.T_LONG && (src == Constants.T_CHAR || src == Constants.T_BYTE || - src == Constants.T_SHORT)) - src = Constants.T_INT; - - String[] short_names = { "C", "F", "D", "B", "S", "I", "L" }; - - String name = "org.aspectj.apache.bcel.generic." + short_names[src - Constants.T_CHAR] + - "2" + short_names[dest - Constants.T_CHAR]; + if (dest == Constants.T_LONG && (src == Constants.T_CHAR || src == Constants.T_BYTE || src == Constants.T_SHORT)) + src = Constants.T_INT; + + if (src==Constants.T_DOUBLE) { + switch (dest) { + case Constants.T_FLOAT: return InstructionConstants.D2F; + case Constants.T_INT: return InstructionConstants.D2I; + case Constants.T_LONG: return InstructionConstants.D2L; + } + } else if (src==Constants.T_FLOAT) { + switch (dest) { + case Constants.T_DOUBLE: return InstructionConstants.F2D; + case Constants.T_INT: return InstructionConstants.F2I; + case Constants.T_LONG: return InstructionConstants.F2L; + } + } else if (src==Constants.T_INT) { + switch (dest) { + case Constants.T_BYTE: return InstructionConstants.I2B; + case Constants.T_CHAR: return InstructionConstants.I2C; + case Constants.T_DOUBLE: return InstructionConstants.I2D; + case Constants.T_FLOAT: return InstructionConstants.I2F; + case Constants.T_LONG: return InstructionConstants.I2L; + case Constants.T_SHORT: return InstructionConstants.I2S; + } + } else if (src==Constants.T_LONG) { + switch (dest) { + case Constants.T_DOUBLE: return InstructionConstants.L2D; + case Constants.T_FLOAT: return InstructionConstants.L2F; + case Constants.T_INT: return InstructionConstants.L2I; + } + } + +// String name = "org.aspectj.apache.bcel.generic." + short_names[src - Constants.T_CHAR] + +// "2" + short_names[dest - Constants.T_CHAR]; - Instruction i = null; - try { - i = (Instruction)java.lang.Class.forName(name).newInstance(); - } catch(Exception e) { - throw new RuntimeException("Could not find instruction: " + name); - } - - return i; +// Instruction i = null; +// try { +// i = (Instruction)java.lang.Class.forName(name).newInstance(); +// } catch(Exception e) { +// throw new RuntimeException("Could not find instruction: " + name); +// } + + return null; +// return i; } else if((src_type instanceof ReferenceType) && (dest_type instanceof ReferenceType)) { if(dest_type instanceof ArrayType) - return new CHECKCAST(cp.addArrayClass((ArrayType)dest_type)); + return new InstructionCP(Constants.CHECKCAST,cp.addArrayClass((ArrayType)dest_type)); else - return new CHECKCAST(cp.addClass(((ObjectType)dest_type).getClassName())); + return new InstructionCP(Constants.CHECKCAST,cp.addClass(((ObjectType)dest_type).getClassName())); } else throw new RuntimeException("Can not cast " + src_type + " to " + dest_type); } - public GETFIELD createGetField(String class_name, String name, Type t) { - return new GETFIELD(cp.addFieldref(class_name, name, t.getSignature())); + public FieldInstruction createGetField(String class_name, String name, Type t) { + return new FieldInstruction(Constants.GETFIELD,cp.addFieldref(class_name, name, t.getSignature())); } - public GETSTATIC createGetStatic(String class_name, String name, Type t) { - return new GETSTATIC(cp.addFieldref(class_name, name, t.getSignature())); + public FieldInstruction createGetStatic(String class_name, String name, Type t) { + return new FieldInstruction(Constants.GETSTATIC,cp.addFieldref(class_name, name, t.getSignature())); } - public PUTFIELD createPutField(String class_name, String name, Type t) { - return new PUTFIELD(cp.addFieldref(class_name, name, t.getSignature())); + public FieldInstruction createPutField(String class_name, String name, Type t) { + return new FieldInstruction(Constants.PUTFIELD,cp.addFieldref(class_name, name, t.getSignature())); } - public PUTSTATIC createPutStatic(String class_name, String name, Type t) { - return new PUTSTATIC(cp.addFieldref(class_name, name, t.getSignature())); + public FieldInstruction createPutStatic(String class_name, String name, Type t) { + return new FieldInstruction(Constants.PUTSTATIC,cp.addFieldref(class_name, name, t.getSignature())); } - public CHECKCAST createCheckCast(ReferenceType t) { + public Instruction createCheckCast(ReferenceType t) { if(t instanceof ArrayType) - return new CHECKCAST(cp.addArrayClass((ArrayType)t)); + return new InstructionCP(Constants.CHECKCAST,cp.addArrayClass((ArrayType)t)); else - return new CHECKCAST(cp.addClass((ObjectType)t)); + return new InstructionCP(Constants.CHECKCAST,cp.addClass((ObjectType)t)); } - public INSTANCEOF createInstanceOf(ReferenceType t) { + public Instruction createInstanceOf(ReferenceType t) { if(t instanceof ArrayType) - return new INSTANCEOF(cp.addArrayClass((ArrayType)t)); + return new InstructionCP(Constants.INSTANCEOF,cp.addArrayClass((ArrayType)t)); else - return new INSTANCEOF(cp.addClass((ObjectType)t)); + return new InstructionCP(Constants.INSTANCEOF,cp.addClass((ObjectType)t)); } - public NEW createNew(ObjectType t) { - return new NEW(cp.addClass(t)); + public Instruction createNew(ObjectType t) { + return new InstructionCP(Constants.NEW,cp.addClass(t)); } - public NEW createNew(String s) { + public Instruction createNew(String s) { return createNew(new ObjectType(s)); } @@ -550,11 +464,11 @@ public class InstructionFactory public Instruction createNewArray(Type t, short dim) { if(dim == 1) { if(t instanceof ObjectType) - return new ANEWARRAY(cp.addClass((ObjectType)t)); + return new InstructionCP(Constants.ANEWARRAY,cp.addClass((ObjectType)t)); else if(t instanceof ArrayType) - return new ANEWARRAY(cp.addArrayClass((ArrayType)t)); + return new InstructionCP(Constants.ANEWARRAY,cp.addArrayClass((ArrayType)t)); else - return new NEWARRAY(((BasicType)t).getType()); + return new InstructionByte(Constants.NEWARRAY,((BasicType)t).getType()); } else { ArrayType at; @@ -591,28 +505,28 @@ public class InstructionFactory /** Create branch instruction by given opcode, except LOOKUPSWITCH and TABLESWITCH. * For those you should use the SWITCH compound instruction. */ - public static BranchInstruction createBranchInstruction(short opcode, InstructionHandle target) { + public static InstructionBranch createBranchInstruction(short opcode, InstructionHandle target) { switch(opcode) { - case Constants.IFEQ: return new IFEQ(target); - case Constants.IFNE: return new IFNE(target); - case Constants.IFLT: return new IFLT(target); - case Constants.IFGE: return new IFGE(target); - case Constants.IFGT: return new IFGT(target); - case Constants.IFLE: return new IFLE(target); - case Constants.IF_ICMPEQ: return new IF_ICMPEQ(target); - case Constants.IF_ICMPNE: return new IF_ICMPNE(target); - case Constants.IF_ICMPLT: return new IF_ICMPLT(target); - case Constants.IF_ICMPGE: return new IF_ICMPGE(target); - case Constants.IF_ICMPGT: return new IF_ICMPGT(target); - case Constants.IF_ICMPLE: return new IF_ICMPLE(target); - case Constants.IF_ACMPEQ: return new IF_ACMPEQ(target); - case Constants.IF_ACMPNE: return new IF_ACMPNE(target); - case Constants.GOTO: return new GOTO(target); - case Constants.JSR: return new JSR(target); - case Constants.IFNULL: return new IFNULL(target); - case Constants.IFNONNULL: return new IFNONNULL(target); - case Constants.GOTO_W: return new GOTO_W(target); - case Constants.JSR_W: return new JSR_W(target); + case Constants.IFEQ: return new InstructionBranch(Constants.IFEQ,target); + case Constants.IFNE: return new InstructionBranch(Constants.IFNE,target); + case Constants.IFLT: return new InstructionBranch(Constants.IFLT,target); + case Constants.IFGE: return new InstructionBranch(Constants.IFGE,target); + case Constants.IFGT: return new InstructionBranch(Constants.IFGT,target); + case Constants.IFLE: return new InstructionBranch(Constants.IFLE,target); + case Constants.IF_ICMPEQ: return new InstructionBranch(Constants.IF_ICMPEQ,target); + case Constants.IF_ICMPNE: return new InstructionBranch(Constants.IF_ICMPNE,target); + case Constants.IF_ICMPLT: return new InstructionBranch(Constants.IF_ICMPLT,target); + case Constants.IF_ICMPGE: return new InstructionBranch(Constants.IF_ICMPGE,target); + case Constants.IF_ICMPGT: return new InstructionBranch(Constants.IF_ICMPGT,target); + case Constants.IF_ICMPLE: return new InstructionBranch(Constants.IF_ICMPLE,target); + case Constants.IF_ACMPEQ: return new InstructionBranch(Constants.IF_ACMPEQ,target); + case Constants.IF_ACMPNE: return new InstructionBranch(Constants.IF_ACMPNE,target); + case Constants.GOTO: return new InstructionBranch(Constants.GOTO,target); + case Constants.JSR: return new InstructionBranch(Constants.JSR,target); + case Constants.IFNULL: return new InstructionBranch(Constants.IFNULL,target); + case Constants.IFNONNULL: return new InstructionBranch(Constants.IFNONNULL,target); + case Constants.GOTO_W: return new InstructionBranch(Constants.GOTO_W,target); + case Constants.JSR_W: return new InstructionBranch(Constants.JSR_W,target); default: throw new RuntimeException("Invalid opcode: " + opcode); } @@ -620,6 +534,113 @@ public class InstructionFactory public void setClassGen(ClassGen c) { cg = c; } public ClassGen getClassGen() { return cg; } - public void setConstantPool(ConstantPoolGen c) { cp = c; } - public ConstantPoolGen getConstantPool() { return cp; } + public void setConstantPool(ConstantPool c) { cp = c; } + public ConstantPool getConstantPool() { return cp; } + + + /** + * Returns the right instruction for putting whatever you want onto the stack + */ + public static Instruction PUSH(ConstantPool cp, int value) { + Instruction instruction = null; + if ((value >= -1) && (value <= 5)) { + return INSTRUCTIONS[Constants.ICONST_0 + value]; + } else if ((value >= -128) && (value <= 127)) // Use BIPUSH + instruction = new InstructionByte(Constants.BIPUSH,(byte)value); + else if((value >= -32768) && (value <= 32767)) // Use SIPUSH + instruction = new InstructionShort(Constants.SIPUSH,(short)value); + else // If everything fails create a Constant pool entry + { + int pos = cp.addInteger(value); + if (pos<=Constants.MAX_BYTE) { + instruction = new InstructionCP(Constants.LDC,pos); + } else { + instruction = new InstructionCP(Constants.LDC_W,pos); + } + } + return instruction; + } + + public static Instruction PUSH(ConstantPool cp, ObjectType t) { + return new InstructionCP(Constants.LDC_W,cp.addClass(t)); + } + + public static Instruction PUSH(ConstantPool cp, boolean value) { + return INSTRUCTIONS[Constants.ICONST_0 + (value? 1 : 0)]; + } + + public static Instruction PUSH(ConstantPool cp, float value) { + Instruction instruction = null; + if(value == 0.0) + instruction = FCONST_0; + else if(value == 1.0) + instruction = FCONST_1; + else if(value == 2.0) + instruction = FCONST_2; + else { + // Create a Constant pool entry + int i = cp.addFloat(value); + instruction = new InstructionCP(i<=Constants.MAX_BYTE?Constants.LDC:Constants.LDC_W,i); + } + return instruction; + } + + public static Instruction PUSH(ConstantPool cp, long value) { + Instruction instruction = null; + if(value == 0) + instruction = LCONST_0; + else if(value == 1) + instruction = LCONST_1; + else // Create a Constant pool entry + instruction = new InstructionCP(Constants.LDC2_W,cp.addLong(value)); + return instruction; + } + + public static Instruction PUSH(ConstantPool cp, double value) { + Instruction instruction = null; + if(value == 0.0) + instruction = DCONST_0; + else if(value == 1.0) + instruction = DCONST_1; + else { + // Create a Constant pool entry + instruction = new InstructionCP(Constants.LDC2_W,cp.addDouble(value)); + } + return instruction; + } + + public static Instruction PUSH(ConstantPool cp, String value) { + Instruction instruction = null; + if(value == null) + instruction = ACONST_NULL; + else { + int i = cp.addString(value); + instruction = new InstructionCP(i<=Constants.MAX_BYTE?Constants.LDC:Constants.LDC_W,i); + } + return instruction; + } + + public static Instruction PUSH(ConstantPool cp, Number value) { + Instruction instruction = null; + if((value instanceof Integer) || (value instanceof Short) || (value instanceof Byte)) + instruction = PUSH(cp, value.intValue()); + else if(value instanceof Double) + instruction = PUSH(cp, value.doubleValue()); + else if(value instanceof Float) + instruction = PUSH(cp, value.floatValue()); + else if(value instanceof Long) + instruction = PUSH(cp, value.longValue()); + else + throw new ClassGenException("What's this: " + value); + return instruction; + } + + public static Instruction PUSH(ConstantPool cp, Character value) { + return PUSH(cp, (int)value.charValue()); + } + + public static Instruction PUSH(ConstantPool cp, Boolean value) { + return PUSH(cp, value.booleanValue()); + } + } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionHandle.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionHandle.java index b4a2b4c8e..7680cd841 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionHandle.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionHandle.java @@ -71,7 +71,7 @@ import java.util.HashMap; * can traverse the list via an Enumeration returned by * InstructionList.elements(). * - * @version $Id: InstructionHandle.java,v 1.3 2007/05/22 09:11:40 aclement Exp $ + * @version $Id: InstructionHandle.java,v 1.4 2008/05/28 23:52:59 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Instruction * @see BranchHandle @@ -82,7 +82,6 @@ public class InstructionHandle implements java.io.Serializable { Instruction instruction; protected int i_position = -1; // byte code offset of instruction private HashSet targeters; - private HashMap attributes; public final InstructionHandle getNext() { return next; } public final InstructionHandle getPrev() { return prev; } @@ -93,11 +92,11 @@ public class InstructionHandle implements java.io.Serializable { * Old instruction is disposed using Instruction.dispose(). */ public void setInstruction(Instruction i) { // Overridden in BranchHandle - if(i == null) - throw new ClassGenException("Assigning null to handle"); - - if((this.getClass() != BranchHandle.class) && (i instanceof BranchInstruction)) - throw new ClassGenException("Assigning branch instruction " + i + " to plain handle"); +// if(i == null) +// throw new ClassGenException("Assigning null to handle"); +// +// if((this.getClass() != BranchHandle.class) && (i instanceof InstructionBranch)) +// throw new ClassGenException("Assigning branch instruction " + i + " to plain handle"); if(instruction != null) instruction.dispose(); @@ -121,11 +120,12 @@ public class InstructionHandle implements java.io.Serializable { } - /** Factory method. + /** + * Factory method. */ static final InstructionHandle getInstructionHandle(Instruction i) { return new InstructionHandle(i); - } + } /** * Called by InstructionList.setPositions when setting the position for every @@ -157,12 +157,12 @@ public class InstructionHandle implements java.io.Serializable { /** * Delete contents, i.e., remove user access and make handle reusable. */ + // OPTIMIZE get rid of this? why do we need it void dispose() { next = prev = null; instruction.dispose(); instruction = null; i_position = -1; - attributes = null; removeAllTargeters(); } @@ -219,49 +219,11 @@ public class InstructionHandle implements java.io.Serializable { return toString(true); } - /** Add an attribute to an instruction handle. - * - * @param key the key object to store/retrieve the attribute - * @param attr the attribute to associate with this handle - */ - public void addAttribute(Object key, Object attr) { - if(attributes == null) - attributes = new HashMap(3); - - attributes.put(key, attr); - } - - /** Delete an attribute of an instruction handle. - * - * @param key the key object to retrieve the attribute - */ - public void removeAttribute(Object key) { - if(attributes != null) - attributes.remove(key); - } - - /** Get attribute of an instruction handle. - * - * @param key the key object to store/retrieve the attribute - */ - public Object getAttribute(Object key) { - if(attributes != null) - return attributes.get(key); - - return null; - } - - /** @return all attributes associated with this handle - */ - public Collection getAttributes() { - return attributes.values(); - } - /** Convenience method, simply calls accept() on the contained instruction. * * @param v Visitor object */ - public void accept(Visitor v) { + public void accept(InstVisitor v) { instruction.accept(v); } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionLV.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionLV.java new file mode 100644 index 000000000..cfeeac0bd --- /dev/null +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionLV.java @@ -0,0 +1,183 @@ +package org.aspectj.apache.bcel.generic; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache BCEL" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache BCEL", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ +import java.io.DataOutputStream; +import java.io.IOException; + +import org.aspectj.apache.bcel.Constants; + +/** + * Abstract super class for instructions dealing with local variables. + * + * @version $Id: InstructionLV.java,v 1.2 2008/05/28 23:52:57 aclement Exp $ + * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> + */ +public class InstructionLV extends Instruction { + protected int lvar = -1; + + + public InstructionLV(short opcode, int lvar) { + this.opcode = opcode; + this.lvar = lvar; + } + + public InstructionLV(short opcode) { + this.opcode = opcode; + } + + public void dump(DataOutputStream out) throws IOException { + if (lvar==-1) { + out.writeByte(opcode); + } else { + if (lvar<4) { + if (opcode==ALOAD) { out.writeByte(ALOAD_0+lvar); + } else if (opcode==ASTORE) { out.writeByte(ASTORE_0+lvar); + } else if (opcode==ILOAD) { out.writeByte(ILOAD_0+lvar); + } else if (opcode==ISTORE) { out.writeByte(ISTORE_0+lvar); + } else if (opcode==DLOAD) { out.writeByte(DLOAD_0+lvar); + } else if (opcode==DSTORE) { out.writeByte(DSTORE_0+lvar); + } else if (opcode==FLOAD) { out.writeByte(FLOAD_0+lvar); + } else if (opcode==FSTORE) { out.writeByte(FSTORE_0+lvar); + } else if (opcode==LLOAD) { out.writeByte(LLOAD_0+lvar); + } else if (opcode==LSTORE) { out.writeByte(LSTORE_0+lvar); + } else { + if (wide()) out.writeByte(Constants.WIDE); + out.writeByte(opcode); + if (wide()) out.writeShort(lvar); + else out.writeByte(lvar); + } + } else { + if (wide()) out.writeByte(Constants.WIDE); + out.writeByte(opcode); + if (wide()) out.writeShort(lvar); + else out.writeByte(lvar); + } + } + } + + /** + * Long output format: + * + * 'name of opcode' "[" 'opcode number' "]" + * "(" 'length of instruction' ")" "<" 'local variable index' ">" + */ + public String toString(boolean verbose) { + if(((opcode >= Constants.ILOAD_0) && (opcode <= Constants.ALOAD_3)) || + ((opcode >= Constants.ISTORE_0) && (opcode <= Constants.ASTORE_3))) + return super.toString(verbose); + else + return super.toString(verbose) + ((lvar!=-1&&lvar<4)?"_":" ") + lvar; + } + + public boolean isALOAD() { + return opcode==ALOAD || (opcode>=ALOAD_0 && opcode<=ALOAD_3); + } + + public boolean isASTORE() { + return opcode==ASTORE || (opcode>=ASTORE_0 && opcode<=ASTORE_3); + } + + /** + * @return local variable index referred by this instruction. + */ + // optimize! + public final int getIndex() { + if (lvar!=-1) return lvar; + if (opcode>= Constants.ILOAD_0 && opcode <= Constants.ALOAD_3) { + return (opcode - Constants.ILOAD_0) % 4; + } else if (opcode>= Constants.ISTORE_0 && opcode <= Constants.ASTORE_3) { + return (opcode - Constants.ISTORE_0) % 4; + } + return -1; + } + + public void setIndex(int i) { + // Switching the index for a load/store without a current index specified (ie. an aload_1 or istore_2) + // means we need to should adjust to a normal aload/istore opcode + if (getIndex()!=i) { + if(opcode>= Constants.ILOAD_0 && opcode <= Constants.ALOAD_3) { + opcode = (short)(ILOAD + (opcode-ILOAD_0)/4); + } else if (opcode>= Constants.ISTORE_0 && opcode <= Constants.ASTORE_3) { + opcode = (short)(ISTORE+ (opcode-ISTORE_0)/4); + } + this.lvar = i; + } + } + + public int getLength() { + int size=Constants.iLen[opcode]; + if (lvar==-1) { + return size; + } else { + if (lvar<4) { + if (opcode==ALOAD || opcode==ASTORE) return 1; + else if (opcode==ILOAD || opcode==ISTORE) return 1; + else if (opcode==DLOAD || opcode==DSTORE) return 1; + else if (opcode==FLOAD || opcode==FSTORE) return 1; + else if (opcode==LLOAD || opcode==LSTORE) return 1; + else { + if (wide()) return size +2; + return size; + } + } else { + if (wide()) return size +2; + return size; + } + } + } + + private final boolean wide() { return lvar > Constants.MAX_BYTE; } + +} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionList.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionList.java index cbf6adf90..8482e13a8 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionList.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionList.java @@ -56,6 +56,7 @@ package org.aspectj.apache.bcel.generic; import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.classfile.Constant; +import org.aspectj.apache.bcel.classfile.ConstantPool; import org.aspectj.apache.bcel.util.ByteSequence; import java.io.*; import java.util.Iterator; @@ -75,7 +76,7 @@ import java.util.ArrayList; * A list is finally dumped to a byte code array with <a * href="#getByteCode()">getByteCode</a>. * - * @version $Id: InstructionList.java,v 1.5 2007/02/28 13:10:32 aclement Exp $ + * @version $Id: InstructionList.java,v 1.6 2008/05/28 23:52:57 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see Instruction * @see InstructionHandle @@ -103,19 +104,10 @@ public class InstructionList implements Serializable { * Create instruction list containing one instruction. * @param i initial instruction */ - public InstructionList(BranchInstruction i) { + public InstructionList(InstructionBranch i) { append(i); } - /** - * Initialize list with (nonnull) compound instruction. Consumes argument - * list, i.e., it becomes empty. - * - * @param c compound instruction (list) - */ - public InstructionList(CompoundInstruction c) { - append(c.getInstructionList()); - } /** * Test for empty list. @@ -138,7 +130,6 @@ public class InstructionList implements Serializable { public static InstructionHandle findHandle(InstructionHandle[] ihs, int[] pos, int count,int target,boolean returnClosestIfNoExactMatch) { int l=0, r = count - 1; - // Do a binary search since the pos array is ordered int i,j; do { @@ -147,7 +138,7 @@ public class InstructionList implements Serializable { if (j == target) return ihs[i]; // found it else if (target < j) r=i-1; // else constrain search area else l=i+1; // target > j - } while(l <= r); + } while (l <= r); if (returnClosestIfNoExactMatch) { i = (l+r)/2; if (i<0) i=0; @@ -172,11 +163,11 @@ public class InstructionList implements Serializable { public InstructionHandle[] getInstructionsAsArray() { return getInstructionHandles(); } - + public InstructionHandle findHandle(int pos,InstructionHandle[] instructionArray) { return findHandle(instructionArray,byte_positions,length,pos); } - + public InstructionHandle findHandle(int pos,InstructionHandle[] instructionArray,boolean useClosestApproximationIfNoExactFound) { return findHandle(instructionArray,byte_positions,length,pos,useClosestApproximationIfNoExactFound); } @@ -197,24 +188,24 @@ public class InstructionList implements Serializable { */ try { while(bytes.available() > 0) { - // Remember byte offset and associate it with the instruction - int off = bytes.getIndex(); - pos[count] = off; + // Remember byte offset and associate it with the instruction + int off = bytes.getIndex(); + pos[count] = off; + + /* Read one instruction from the byte stream, the byte position is set + * accordingly. + */ + Instruction i = Instruction.readInstruction(bytes); + InstructionHandle ih; + if (i instanceof InstructionBranch) // Use proper append() method + ih = append((InstructionBranch)i); + else + ih = append(i); - /* Read one instruction from the byte stream, the byte position is set - * accordingly. - */ - Instruction i = Instruction.readInstruction(bytes); - InstructionHandle ih; - if(i instanceof BranchInstruction) // Use proper append() method - ih = append((BranchInstruction)i); - else - ih = append(i); - - ih.setPosition(off); - ihs[count] = ih; - - count++; + ih.setPosition(off); + ihs[count] = ih; + + count++; } } catch(IOException e) { throw new ClassGenException(e.toString()); } @@ -224,34 +215,35 @@ public class InstructionList implements Serializable { /* Pass 2: Look for BranchInstruction and update their targets, i.e., * convert offsets to instruction handles. */ + // OPTIMIZE better way of doing this? keep little map from earlier from pos -> instruction handle? for(int i=0; i < count; i++) { if(ihs[i] instanceof BranchHandle) { - BranchInstruction bi = (BranchInstruction)ihs[i].instruction; - int target = bi.position + bi.getIndex(); /* Byte code position: - * relative -> absolute. */ - // Search for target position - InstructionHandle ih = findHandle(ihs, pos, count, target); - - if(ih == null) // Search failed - throw new ClassGenException("Couldn't find target for branch: " + bi); + InstructionBranch bi = (InstructionBranch)ihs[i].instruction; + int target = bi.positionOfThisInstruction + bi.getIndex(); /* Byte code position: + * relative -> absolute. */ + // Search for target position + InstructionHandle ih = findHandle(ihs, pos, count, target); - bi.setTarget(ih); // Update target + if(ih == null) // Search failed + throw new ClassGenException("Couldn't find target for branch: " + bi); + + bi.setTarget(ih); // Update target + + // If it is a Select instruction, update all branch targets + if(bi instanceof InstructionSelect) { // Either LOOKUPSWITCH or TABLESWITCH + InstructionSelect s = (InstructionSelect)bi; + int[] indices = s.getIndices(); + + for(int j=0; j < indices.length; j++) { + target = bi.positionOfThisInstruction + indices[j]; + ih = findHandle(ihs, pos, count, target); + + if(ih == null) // Search failed + throw new ClassGenException("Couldn't find target for switch: " + bi); - // If it is a Select instruction, update all branch targets - if(bi instanceof Select) { // Either LOOKUPSWITCH or TABLESWITCH - Select s = (Select)bi; - int[] indices = s.getIndices(); - - for(int j=0; j < indices.length; j++) { - target = bi.position + indices[j]; - ih = findHandle(ihs, pos, count, target); - - if(ih == null) // Search failed - throw new ClassGenException("Couldn't find target for switch: " + bi); - - s.setTarget(j, ih); // Update target - } - } + s.setTarget(j, ih); // Update target + } + } } } } @@ -373,7 +365,7 @@ public class InstructionList implements Serializable { * @param i branch instruction to append * @return branch instruction handle of the appended instruction */ - public BranchHandle append(BranchInstruction i) { + public BranchHandle append(InstructionBranch i) { BranchHandle ih = BranchHandle.getBranchHandle(i); append(ih); @@ -392,37 +384,6 @@ public class InstructionList implements Serializable { return append(i, new InstructionList(j)); } - /** - * Append a compound instruction, after instruction i. - * - * @param i Instruction in list - * @param c The composite instruction (containing an InstructionList) - * @return instruction handle of the first appended instruction - */ - public InstructionHandle append(Instruction i, CompoundInstruction c) { - return append(i, c.getInstructionList()); - } - - /** - * Append a compound instruction. - * - * @param c The composite instruction (containing an InstructionList) - * @return instruction handle of the first appended instruction - */ - public InstructionHandle append(CompoundInstruction c) { - return append(c.getInstructionList()); - } - - /** - * Append a compound instruction. - * - * @param ih where to append the instruction list - * @param c The composite instruction (containing an InstructionList) - * @return instruction handle of the first appended instruction - */ - public InstructionHandle append(InstructionHandle ih, CompoundInstruction c) { - return append(ih, c.getInstructionList()); - } /** * Append an instruction after instruction (handle) ih contained in this list. @@ -442,7 +403,7 @@ public class InstructionList implements Serializable { * @param i Instruction to append * @return instruction handle pointing to the <B>first</B> appended instruction */ - public BranchHandle append(InstructionHandle ih, BranchInstruction i) { + public BranchHandle append(InstructionHandle ih, InstructionBranch i) { BranchHandle bh = BranchHandle.getBranchHandle(i); InstructionList il = new InstructionList(); il.append(bh); @@ -558,7 +519,7 @@ public class InstructionList implements Serializable { * @param i branch instruction to insert * @return branch instruction handle of the appended instruction */ - public BranchHandle insert(BranchInstruction i) { + public BranchHandle insert(InstructionBranch i) { BranchHandle ih = BranchHandle.getBranchHandle(i); insert(ih); return ih; @@ -576,26 +537,6 @@ public class InstructionList implements Serializable { return insert(i, new InstructionList(j)); } - /** - * Insert a compound instruction before instruction i. - * - * @param i Instruction in list - * @param c The composite instruction (containing an InstructionList) - * @return instruction handle of the first inserted instruction - */ - public InstructionHandle insert(Instruction i, CompoundInstruction c) { - return insert(i, c.getInstructionList()); - } - - /** - * Insert a compound instruction. - * - * @param c The composite instruction (containing an InstructionList) - * @return instruction handle of the first inserted instruction - */ - public InstructionHandle insert(CompoundInstruction c) { - return insert(c.getInstructionList()); - } /** * Insert an instruction before instruction (handle) ih contained in this list. @@ -609,24 +550,13 @@ public class InstructionList implements Serializable { } /** - * Insert a compound instruction. - * - * @param ih where to insert the instruction list - * @param c The composite instruction (containing an InstructionList) - * @return instruction handle of the first inserted instruction - */ - public InstructionHandle insert(InstructionHandle ih, CompoundInstruction c) { - return insert(ih, c.getInstructionList()); - } - - /** * Insert an instruction before instruction (handle) ih contained in this list. * * @param ih where to insert to the instruction list * @param i Instruction to insert * @return instruction handle of the first inserted instruction */ - public BranchHandle insert(InstructionHandle ih, BranchInstruction i) { + public BranchHandle insert(InstructionHandle ih, InstructionBranch i) { BranchHandle bh = BranchHandle.getBranchHandle(i); InstructionList il = new InstructionList(); il.append(bh); @@ -709,42 +639,44 @@ public class InstructionList implements Serializable { } /** - * Remove from instruction `prev' to instruction `next' both contained - * in this list. Throws TargetLostException when one of the removed instruction handles + * Remove from instruction 'prev' to instruction 'next' both contained + * in this list. + * + * If careAboutLostTargeters is true then this method will throw a + * TargetLostException when one of the removed instruction handles * is still being targeted. * * @param prev where to start deleting (predecessor, exclusive) * @param next where to end deleting (successor, exclusive) */ - private void remove(InstructionHandle prev, InstructionHandle next) - throws TargetLostException - { + private void remove(InstructionHandle prev, InstructionHandle next, boolean careAboutLostTargeters) throws TargetLostException { InstructionHandle first, last; // First and last deleted instruction - if((prev == null) && (next == null)) { // singleton list + if ((prev == null) && (next == null)) { // singleton list first = last = start; start = end = null; } else { - if(prev == null) { // At start of list - first = start; - start = next; + if (prev == null) { // At start of list + first = start; + start = next; } else { - first = prev.next; - prev.next = next; + first = prev.next; + prev.next = next; } - - if(next == null) { // At end of list - last = end; - end = prev; + if (next == null) { // At end of list + last = end; + end = prev; } else { - last = next.prev; - next.prev = prev; + last = next.prev; + next.prev = prev; } } first.prev = null; // Completely separated from rest of list last.next = null; + if (!careAboutLostTargeters) return; + ArrayList target_vec = new ArrayList(); for(InstructionHandle ih=first; ih != null; ih = ih.next) @@ -756,11 +688,26 @@ public class InstructionList implements Serializable { length--; if(ih.hasTargeters()) { // Still got targeters? - target_vec.add(ih); - buf.append(ih.toString(true) + " "); - ih.next = ih.prev = null; - } else - ih.dispose(); + InstructionTargeter[] targeters = ih.getTargeters(); + boolean isOK = false; + for (int i = 0; i < targeters.length; i++) { + InstructionTargeter instructionTargeter = targeters[i]; + if (instructionTargeter.getClass().getName().endsWith("ShadowRange") || + instructionTargeter.getClass().getName().endsWith("ExceptionRange") || + instructionTargeter.getClass().getName().endsWith("LineNumberTag") ) isOK=true; + else System.out.println(instructionTargeter.getClass()); + } + if (!isOK) { + + target_vec.add(ih); + buf.append(ih.toString(true) + " "); + ih.next = ih.prev = null; + } else { + ih.dispose(); + } + } else { + ih.dispose(); + } } buf.append("}"); @@ -779,7 +726,7 @@ public class InstructionList implements Serializable { * @param ih instruction (handle) to remove */ public void delete(InstructionHandle ih) throws TargetLostException { - remove(ih.prev, ih.next); + remove(ih.prev, ih.next,false); } /** @@ -788,14 +735,14 @@ public class InstructionList implements Serializable { * * @param i instruction to remove */ - public void delete(Instruction i) throws TargetLostException { - InstructionHandle ih; - - if((ih = findInstruction1(i)) == null) - throw new ClassGenException("Instruction " + i + - " is not contained in this list."); - delete(ih); - } +// public void delete(Instruction i) throws TargetLostException { +// InstructionHandle ih; +// +// if((ih = findInstruction1(i)) == null) +// throw new ClassGenException("Instruction " + i + +// " is not contained in this list."); +// delete(ih); +// } /** * Remove instructions from instruction `from' to instruction `to' contained @@ -808,7 +755,7 @@ public class InstructionList implements Serializable { public void delete(InstructionHandle from, InstructionHandle to) throws TargetLostException { - remove(from.prev, to.next); + remove(from.prev, to.next,false); } /** @@ -891,73 +838,72 @@ public class InstructionList implements Serializable { int index = 0, count = 0; int[] pos = new int[length]; - /* Pass 0: Sanity checks - */ - if(check) { - for(InstructionHandle ih=start; ih != null; ih = ih.next) { - Instruction i = ih.instruction; - - if(i instanceof BranchInstruction) { // target instruction within list? - Instruction inst = ((BranchInstruction)i).getTarget().instruction; - if(!contains(inst)) - throw new ClassGenException("Branch target of " + - Constants.OPCODE_NAMES[i.opcode] + ":" + - inst + " not in instruction list"); - - if(i instanceof Select) { - InstructionHandle[] targets = ((Select)i).getTargets(); - - for(int j=0; j < targets.length; j++) { - inst = targets[j].instruction; - if(!contains(inst)) - throw new ClassGenException("Branch target of " + - Constants.OPCODE_NAMES[i.opcode] + ":" + - inst + " not in instruction list"); - } - } - - if(!(ih instanceof BranchHandle)) - throw new ClassGenException("Branch instruction " + - Constants.OPCODE_NAMES[i.opcode] + ":" + - inst + " not contained in BranchHandle."); - - } + // Pass 0: Sanity checks + if (check) { + for (InstructionHandle ih=start; ih != null; ih = ih.next) { + Instruction i = ih.instruction; + + if (i instanceof InstructionBranch) { // target instruction within list? + Instruction inst = ((InstructionBranch)i).getTarget().instruction; + if(!contains(inst)) + throw new ClassGenException("Branch target of " + + Constants.OPCODE_NAMES[i.opcode] + ":" + + inst + " not in instruction list"); + + if(i instanceof InstructionSelect) { + InstructionHandle[] targets = ((InstructionSelect)i).getTargets(); + + for(int j=0; j < targets.length; j++) { + inst = targets[j].instruction; + if(!contains(inst)) + throw new ClassGenException("Branch target of " + + Constants.OPCODE_NAMES[i.opcode] + ":" + + inst + " not in instruction list"); + } + } + + if(!(ih instanceof BranchHandle)) + throw new ClassGenException("Branch instruction " + + Constants.OPCODE_NAMES[i.opcode] + ":" + + inst + " not contained in BranchHandle."); + + } } } - /* Pass 1: Set position numbers and sum up the maximum number of bytes an - * instruction may be shifted. - */ - for(InstructionHandle ih=start; ih != null; ih = ih.next) { - Instruction i = ih.instruction; - - ih.setPosition(index); - pos[count++] = index; - - /* Get an estimate about how many additional bytes may be added, because - * BranchInstructions may have variable length depending on the target - * offset (short vs. int) or alignment issues (TABLESWITCH and - * LOOKUPSWITCH). - */ - switch(i.getOpcode()) { - case Constants.JSR: case Constants.GOTO: - max_additional_bytes += 2; - break; - - case Constants.TABLESWITCH: case Constants.LOOKUPSWITCH: - max_additional_bytes += 3; - break; - } - - index += i.getLength(); + // Pass 1: Set position numbers and sum up the maximum number of bytes an + // instruction may be shifted. + for (InstructionHandle ih=start; ih != null; ih = ih.next) { + Instruction i = ih.instruction; + ih.setPosition(index); + pos[count++] = index; + + /* Get an estimate about how many additional bytes may be added, because + * BranchInstructions may have variable length depending on the target + * offset (short vs. int) or alignment issues (TABLESWITCH and + * LOOKUPSWITCH). + */ + switch(i.opcode) { + case Constants.JSR: + case Constants.GOTO: + max_additional_bytes += 2; + break; + + case Constants.TABLESWITCH: + case Constants.LOOKUPSWITCH: + max_additional_bytes += 3; + break; + } + index += i.getLength(); } /* Pass 2: Expand the variable-length (Branch)Instructions depending on * the target offset (short or int) and ensure that branch targets are * within this list. */ - for(InstructionHandle ih=start; ih != null; ih = ih.next) - additional_bytes += ih.updatePosition(additional_bytes, max_additional_bytes); + for (InstructionHandle ih=start; ih != null; ih = ih.next) { + additional_bytes += ih.updatePosition(additional_bytes, max_additional_bytes); + } /* Pass 3: Update position numbers (which may have changed due to the * preceding expansions), like pass 1. @@ -965,7 +911,6 @@ public class InstructionList implements Serializable { index=count=0; for(InstructionHandle ih=start; ih != null; ih = ih.next) { Instruction i = ih.instruction; - ih.setPosition(index); pos[count++] = index; index += i.getLength(); @@ -990,8 +935,8 @@ public class InstructionList implements Serializable { try { for(InstructionHandle ih=start; ih != null; ih = ih.next) { - Instruction i = ih.instruction; - i.dump(out); // Traverse list + Instruction i = ih.instruction; + i.dump(out); // Traverse list } } catch(IOException e) { System.err.println(e); @@ -1100,8 +1045,8 @@ public class InstructionList implements Serializable { Instruction i = ih.instruction; Instruction c = i.copy(); // Use clone for shallow copy - if(c instanceof BranchInstruction) - map.put(ih, il.append((BranchInstruction)c)); + if(c instanceof InstructionBranch) + map.put(ih, il.append((InstructionBranch)c)); else map.put(ih, il.append(c)); } @@ -1115,17 +1060,17 @@ public class InstructionList implements Serializable { Instruction i = ih.instruction; Instruction c = ch.instruction; - if(i instanceof BranchInstruction) { - BranchInstruction bi = (BranchInstruction)i; - BranchInstruction bc = (BranchInstruction)c; + if(i instanceof InstructionBranch) { + InstructionBranch bi = (InstructionBranch)i; + InstructionBranch bc = (InstructionBranch)c; InstructionHandle itarget = bi.getTarget(); // old target // New target is in hash map bc.setTarget((InstructionHandle)map.get(itarget)); - if(bi instanceof Select) { // Either LOOKUPSWITCH or TABLESWITCH - InstructionHandle[] itargets = ((Select)bi).getTargets(); - InstructionHandle[] ctargets = ((Select)bc).getTargets(); + if(bi instanceof InstructionSelect) { // Either LOOKUPSWITCH or TABLESWITCH + InstructionHandle[] itargets = ((InstructionSelect)bi).getTargets(); + InstructionHandle[] ctargets = ((InstructionSelect)bc).getTargets(); for(int j=0; j < itargets.length; j++) { // Update all targets ctargets[j] = (InstructionHandle)map.get(itargets[j]); @@ -1143,14 +1088,14 @@ public class InstructionList implements Serializable { /** Replace all references to the old constant pool with references to the new * constant pool */ - public void replaceConstantPool(ConstantPoolGen old_cp, ConstantPoolGen new_cp) { + public void replaceConstantPool(ConstantPool old_cp, ConstantPool new_cp) { for(InstructionHandle ih=start; ih != null; ih = ih.next) { Instruction i = ih.instruction; - if(i instanceof CPInstruction) { - CPInstruction ci = (CPInstruction)i; - Constant c = old_cp.getConstant(ci.getIndex()); - ci.setIndex(new_cp.addConstant(c, old_cp)); + if(i.isConstantPoolInstruction()) { + InstructionCP ci = (InstructionCP)i; + Constant c = old_cp.getConstant(ci.getIndex()); + ci.setIndex(new_cp.addConstant(c, old_cp)); } } } @@ -1209,19 +1154,19 @@ public class InstructionList implements Serializable { for(InstructionHandle ih = start; ih != null; ih = ih.next) { Instruction i = ih.getInstruction(); - if(i instanceof BranchInstruction) { - BranchInstruction b = (BranchInstruction)i; + if(i instanceof InstructionBranch) { + InstructionBranch b = (InstructionBranch)i; InstructionHandle target = b.getTarget(); if(target == old_target) b.setTarget(new_target); - if(b instanceof Select) { // Either LOOKUPSWITCH or TABLESWITCH - InstructionHandle[] targets = ((Select)b).getTargets(); + if(b instanceof InstructionSelect) { // Either LOOKUPSWITCH or TABLESWITCH + InstructionHandle[] targets = ((InstructionSelect)b).getTargets(); for(int j=0; j < targets.length; j++) // Update targets if(targets[j] == old_target) - ((Select)b).setTarget(j, new_target); + ((InstructionSelect)b).setTarget(j, new_target); } } } @@ -1242,11 +1187,8 @@ public class InstructionList implements Serializable { InstructionHandle start = lg[i].getStart(); InstructionHandle end = lg[i].getEnd(); - if(start == old_target) - lg[i].setStart(new_target); - - if(end == old_target) - lg[i].setEnd(new_target); + if (start == old_target) lg[i].setStart(new_target); + if (end == old_target) lg[i].setEnd(new_target); } } @@ -1273,32 +1215,6 @@ public class InstructionList implements Serializable { } } - private ArrayList observers; - - /** Add observer for this object. - */ - public void addObserver(InstructionListObserver o) { - if(observers == null) - observers = new ArrayList(); - - observers.add(o); - } - /** Remove observer for this object. - */ - public void removeObserver(InstructionListObserver o) { - if(observers != null) - observers.remove(o); - } - - /** Call notify() method on all observers. This method is not called - * automatically whenever the state has changed, but has to be - * called by the user after he has finished editing the object. - */ - public void update() { - if(observers != null) - for(Iterator e = observers.iterator(); e.hasNext(); ) - ((InstructionListObserver)e.next()).notify(this); - } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionListObserver.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionListObserver.java deleted file mode 100644 index df0740168..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionListObserver.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Implement this interface if you're interested in changes to an InstructionList object - * and register yourself with addObserver(). - * - * @version $Id: InstructionListObserver.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public interface InstructionListObserver { - public void notify(InstructionList list); -} - diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/Select.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionSelect.java index f8a8faf9c..8556aebf9 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/Select.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionSelect.java @@ -59,28 +59,22 @@ import org.aspectj.apache.bcel.util.ByteSequence; /** * Select - Abstract super class for LOOKUPSWITCH and TABLESWITCH instructions. * - * @version $Id: Select.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ + * @version $Id: InstructionSelect.java,v 1.2 2008/05/28 23:52:59 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see LOOKUPSWITCH * @see TABLESWITCH * @see InstructionList */ -public abstract class Select extends BranchInstruction - implements VariableLengthInstruction, StackProducer -{ +public abstract class InstructionSelect extends InstructionBranch { protected int[] match; // matches, i.e., case 1: ... protected int[] indices; // target offsets protected InstructionHandle[] targets; // target objects in instruction list - protected int fixed_length; // fixed length defined by subclasses - protected int match_length; // number of cases + protected int fixedLength; // fixed length defined by subclasses + protected int matchLength; // number of cases protected int padding = 0; // number of pad bytes for alignment - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - Select() {} - + protected short length; + public int getLength() { return length; } /** * (Match, target) pairs for switch. * `Match' and `targets' must have the same length of course. @@ -89,7 +83,7 @@ public abstract class Select extends BranchInstruction * @param targets instruction targets * @param target default instruction target */ - Select(short opcode, int[] match, InstructionHandle[] targets, + InstructionSelect(short opcode, int[] match, InstructionHandle[] targets, InstructionHandle target) { super(opcode, target); @@ -99,12 +93,25 @@ public abstract class Select extends BranchInstruction this.match = match; - if((match_length = match.length) != targets.length) + if((matchLength = match.length) != targets.length) throw new ClassGenException("Match and target array have not the same length"); - indices = new int[match_length]; + indices = new int[matchLength]; } + + 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 - positionOfThisInstruction; + } /** * Since this is a variable length instruction, it may shift the following * instructions which then need to update their position. @@ -119,14 +126,14 @@ public abstract class Select extends BranchInstruction * @return additional offset caused by possible change of this instruction's length */ protected int updatePosition(int offset, int max_offset) { - position += offset; // Additional offset caused by preceding SWITCHs, GOTOs, etc. + positionOfThisInstruction += offset; // Additional offset caused by preceding SWITCHs, GOTOs, etc. short old_length = length; /* Alignment on 4-byte-boundary, + 1, because of tag byte. */ - padding = (4 - ((position + 1) % 4)) % 4; - length = (short)(fixed_length + padding); // Update length + padding = (4 - ((positionOfThisInstruction + 1) % 4)) % 4; + length = (short)(fixedLength + padding); // Update length return length - old_length; } @@ -141,23 +148,35 @@ public abstract class Select extends BranchInstruction for(int i=0; i < padding; i++) // Padding bytes out.writeByte(0); - index = getTargetOffset(); // Write default target offset - out.writeInt(index); + targetIndex = getTargetOffset(); // Write default target offset + out.writeInt(targetIndex); } - /** - * Read needed data (e.g. index) from file. - */ - protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException - { - padding = (4 - (bytes.getIndex() % 4)) % 4; // Compute number of pad bytes +// /** +// * Read needed data (e.g. index) from file. +// */ +// protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException +// { +// padding = (4 - (bytes.getIndex() % 4)) % 4; // Compute number of pad bytes +// +// for(int i=0; i < padding; i++) { +// bytes.readByte(); +// } +// +// // Default branch target common for both cases (TABLESWITCH, LOOKUPSWITCH) +// targetIndex = bytes.readInt(); +// } + + public InstructionSelect(short opcode, ByteSequence bytes) throws IOException { + super(opcode); + padding = (4 - (bytes.getIndex() % 4)) % 4; // Compute number of pad bytes - for(int i=0; i < padding; i++) { - bytes.readByte(); - } - - // Default branch target common for both cases (TABLESWITCH, LOOKUPSWITCH) - index = bytes.readInt(); + for(int i=0; i < padding; i++) { + bytes.readByte(); + } + + // Default branch target common for both cases (TABLESWITCH, LOOKUPSWITCH) + targetIndex = bytes.readInt(); } /** @@ -167,7 +186,7 @@ public abstract class Select extends BranchInstruction StringBuffer buf = new StringBuffer(super.toString(verbose)); if(verbose) { - for(int i=0; i < match_length; i++) { + for(int i=0; i < matchLength; i++) { String s = "null"; if(targets[i] != null) @@ -197,7 +216,7 @@ public abstract class Select extends BranchInstruction public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) { boolean targeted = false; - if(target == old_ih) { + if(targetInstruction == old_ih) { targeted = true; setTarget(new_ih); } @@ -217,7 +236,7 @@ public abstract class Select extends BranchInstruction * @return true, if ih is target of this instruction */ public boolean containsTarget(InstructionHandle ih) { - if(target == ih) + if(targetInstruction == ih) return true; for(int i=0; i < targets.length; i++) diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/NamedAndTyped.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionShort.java index 4b4ed30d5..08f7854d0 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/NamedAndTyped.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionShort.java @@ -54,18 +54,26 @@ package org.aspectj.apache.bcel.generic; * <http://www.apache.org/>. */ -/** - * Denote entity that has both name and type. This is true for local variables, - * methods and fields. - * - * @version $Id: NamedAndTyped.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> +import java.io.*; + +/** + * Instruction that needs one short */ -public interface NamedAndTyped { - public String getName(); - public Type getType(); - public void setName(String name); - public void setType(Type type); +public class InstructionShort extends Instruction { + private short s; -} + public InstructionShort(short opcode, short s) { + this.opcode = opcode; + this.s = s; + } + + public void dump(DataOutputStream out) throws IOException { + out.writeByte(opcode); + out.writeShort(s); + } + public String toString(boolean verbose) { + return super.toString(verbose) + " " + s; + } + +} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionTargeter.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionTargeter.java index 1d19aacb7..950ed3fa9 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionTargeter.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionTargeter.java @@ -61,7 +61,7 @@ package org.aspectj.apache.bcel.generic; * @see BranchHandle * @see LocalVariableGen * @see CodeExceptionGen - * @version $Id: InstructionTargeter.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: InstructionTargeter.java,v 1.3 2008/05/28 23:52:57 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public interface InstructionTargeter { diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/InvokeInstruction.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/InvokeInstruction.java index 93fef42a5..fbc55a66a 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/InvokeInstruction.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/InvokeInstruction.java @@ -62,21 +62,15 @@ import org.aspectj.apache.bcel.classfile.ConstantPool; /** * Super class for the INVOKExxx family of instructions. * - * @version $Id: InvokeInstruction.java,v 1.4 2006/07/19 12:06:17 aclement Exp $ + * @version $Id: InvokeInstruction.java,v 1.5 2008/05/28 23:52:54 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ -public abstract class InvokeInstruction extends FieldOrMethod - implements ExceptionThrower, TypedInstruction, StackConsumer, StackProducer { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - InvokeInstruction() {} +public class InvokeInstruction extends FieldOrMethod { /** * @param index to constant pool */ - protected InvokeInstruction(short opcode, int index) { + public InvokeInstruction(short opcode, int index) { super(opcode, index); } @@ -96,7 +90,7 @@ public abstract class InvokeInstruction extends FieldOrMethod * constant pool entry they reference. * @return Number of words consumed from stack by this instruction */ - public int consumeStack(ConstantPoolGen cpg) { + public int consumeStack(ConstantPool cpg) { String signature = getSignature(cpg); int sum = Type.getArgumentSizes(signature); if (opcode!=Constants.INVOKESTATIC) sum+=1; @@ -108,31 +102,31 @@ public abstract class InvokeInstruction extends FieldOrMethod * constant pool entry they reference. * @return Number of words produced onto stack by this instruction */ - public int produceStack(ConstantPoolGen cpg) { + public int produceStack(ConstantPool cpg) { return getReturnType(cpg).getSize(); } /** @return return type of referenced method. */ - public Type getType(ConstantPoolGen cpg) { + public Type getType(ConstantPool cpg) { return getReturnType(cpg); } /** @return name of referenced method. */ - public String getMethodName(ConstantPoolGen cpg) { + public String getMethodName(ConstantPool cpg) { return getName(cpg); } /** @return return type of referenced method. */ - public Type getReturnType(ConstantPoolGen cpg) { + public Type getReturnType(ConstantPool cpg) { return Type.getReturnType(getSignature(cpg)); } /** @return argument types of referenced method. */ - public Type[] getArgumentTypes(ConstantPoolGen cpg) { + public Type[] getArgumentTypes(ConstantPool cpg) { return Type.getArgumentTypes(getSignature(cpg)); } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/JSR.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/JSR.java deleted file mode 100644 index 0c91d2d9b..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/JSR.java +++ /dev/null @@ -1,119 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ -import java.io.*; - -/** - * JSR - Jump to subroutine - * - * @version $Id: JSR.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class JSR extends JsrInstruction implements VariableLengthInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - JSR() {} - - public JSR(InstructionHandle target) { - super(org.aspectj.apache.bcel.Constants.JSR, target); - } - - /** - * Dump instruction as byte code to stream out. - * @param out Output stream - */ - public void dump(DataOutputStream out) throws IOException { - index = getTargetOffset(); - if(opcode == org.aspectj.apache.bcel.Constants.JSR) - super.dump(out); - else { // JSR_W - index = getTargetOffset(); - out.writeByte(opcode); - out.writeInt(index); - } - } - - protected int updatePosition(int offset, int max_offset) { - int i = getTargetOffset(); // Depending on old position value - - position += offset; // Position may be shifted by preceding expansions - - if(Math.abs(i) >= (32767 - max_offset)) { // to large for short (estimate) - opcode = org.aspectj.apache.bcel.Constants.JSR_W; - length = 5; - return 2; // 5 - 3 - } - - return 0; - } - - /** - * 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.visitVariableLengthInstruction(this); - v.visitBranchInstruction(this); - v.visitJsrInstruction(this); - v.visitJSR(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/JSR_W.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/JSR_W.java deleted file mode 100644 index 8de66f0d1..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/JSR_W.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ -import java.io.*; -import org.aspectj.apache.bcel.util.ByteSequence; - -/** - * JSR_W - Jump to subroutine - * - * @version $Id: JSR_W.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class JSR_W extends JsrInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - JSR_W() {} - - public JSR_W(InstructionHandle target) { - super(org.aspectj.apache.bcel.Constants.JSR_W, target); - length = 5; - } - - /** - * Dump instruction as byte code to stream out. - * @param out Output stream - */ - public void dump(DataOutputStream out) throws IOException { - index = getTargetOffset(); - out.writeByte(opcode); - out.writeInt(index); - } - - /** - * Read needed data (e.g. index) from file. - */ - protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException - { - index = bytes.readInt(); - length = 5; - } - - /** - * 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.visitBranchInstruction(this); - v.visitJsrInstruction(this); - v.visitJSR_W(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/JsrInstruction.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/JsrInstruction.java deleted file mode 100644 index 4967f88c3..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/JsrInstruction.java +++ /dev/null @@ -1,115 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Super class for JSR - Jump to subroutine - * - * @version $Id: JsrInstruction.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public abstract class JsrInstruction extends BranchInstruction - implements UnconditionalBranch, TypedInstruction, StackProducer -{ - JsrInstruction(short opcode, InstructionHandle target) { - super(opcode, target); - } - - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - JsrInstruction(){} - - /** @return return address type - */ - public Type getType(ConstantPoolGen cp) { - return new ReturnaddressType(physicalSuccessor()); - } - - /** - * Returns an InstructionHandle to the physical successor - * of this JsrInstruction. <B>For this method to work, - * this JsrInstruction object must not be shared between - * multiple InstructionHandle objects!</B> - * Formally, there must not be InstructionHandle objects - * i, j where i != j and i.getInstruction() == this == - * j.getInstruction(). - * @return an InstructionHandle to the "next" instruction that - * will be executed when RETurned from a subroutine. - */ - public InstructionHandle physicalSuccessor(){ - InstructionHandle ih = this.target; - - // Rewind! - while(ih.getPrev() != null) - ih = ih.getPrev(); - - // Find the handle for "this" JsrInstruction object. - while(ih.getInstruction() != this) - ih = ih.getNext(); - - InstructionHandle toThis = ih; - - while(ih != null){ - ih = ih.getNext(); - if ((ih != null) && (ih.getInstruction() == this)) - throw new RuntimeException("physicalSuccessor() called on a shared JsrInstruction."); - } - - // Return the physical successor - return toThis.getNext(); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/L2D.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/L2D.java deleted file mode 100644 index f9384bf1b..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/L2D.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * L2D - Convert long to double - * <PRE>Stack: ..., value.word1, value.word2 -> ..., result.word1, result.word2</PRE> - * - * @version $Id: L2D.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class L2D extends ConversionInstruction { - public L2D() { - super(org.aspectj.apache.bcel.Constants.L2D); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitConversionInstruction(this); - v.visitL2D(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/L2F.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/L2F.java deleted file mode 100644 index 6bd9307ac..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/L2F.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * L2F - Convert long to float - * <PRE>Stack: ..., value.word1, value.word2 -> ..., result</PRE> - * - * @version $Id: L2F.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class L2F extends ConversionInstruction { - public L2F() { - super(org.aspectj.apache.bcel.Constants.L2F); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitConversionInstruction(this); - v.visitL2F(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/L2I.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/L2I.java deleted file mode 100644 index 26614e697..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/L2I.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * L2I - Convert long to int - * <PRE>Stack: ..., value.word1, value.word2 -> ..., result</PRE> - * - * @version $Id: L2I.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class L2I extends ConversionInstruction { - public L2I() { - super(org.aspectj.apache.bcel.Constants.L2I); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitConversionInstruction(this); - v.visitL2I(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LADD.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LADD.java deleted file mode 100644 index ddd181d01..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LADD.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * LADD - Add longs - * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -></PRE> - * ..., result.word1, result.word2 - * - * @version $Id: LADD.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class LADD extends ArithmeticInstruction { - public LADD() { - super(org.aspectj.apache.bcel.Constants.LADD); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitLADD(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LALOAD.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LALOAD.java deleted file mode 100644 index da3dcc225..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LALOAD.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * LALOAD - Load long from array - * <PRE>Stack: ..., arrayref, index -> ..., value1, value2</PRE> - * - * @version $Id: LALOAD.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class LALOAD extends ArrayInstruction implements StackProducer { - /** Load long from array - */ - public LALOAD() { - super(org.aspectj.apache.bcel.Constants.LALOAD); - } - - - /** - * 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.visitLALOAD(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LAND.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LAND.java deleted file mode 100644 index 057be5202..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LAND.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * LAND - Bitwise AND longs - * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -></PRE> - * ..., result.word1, result.word2 - * - * @version $Id: LAND.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class LAND extends ArithmeticInstruction { - public LAND() { - super(org.aspectj.apache.bcel.Constants.LAND); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitLAND(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LASTORE.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LASTORE.java deleted file mode 100644 index 0f80f5242..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LASTORE.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * LASTORE - Store into long array - * <PRE>Stack: ..., arrayref, index, value.word1, value.word2 -> ...</PRE> - * - * @version $Id: LASTORE.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class LASTORE extends ArrayInstruction implements StackConsumer { - /** Store long into array - */ - public LASTORE() { - super(org.aspectj.apache.bcel.Constants.LASTORE); - } - - - /** - * 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.visitLASTORE(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LCMP.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LCMP.java deleted file mode 100644 index c7497a0f4..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LCMP.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * LCMP - Compare longs: - * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -></PRE> - * ..., result <= -1, 0, 1> - * - * @version $Id: LCMP.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class LCMP extends Instruction - implements TypedInstruction, StackProducer, StackConsumer -{ - public LCMP() { - super(org.aspectj.apache.bcel.Constants.LCMP, (short)1); - } - - /** @return Type.LONG - */ - public Type getType(ConstantPoolGen cp) { - return Type.LONG; - } - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitLCMP(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LCONST.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LCONST.java deleted file mode 100644 index ecda1ba4c..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LCONST.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * LCONST - Push 0 or 1, other values cause an exception - * - * <PRE>Stack: ... -> ..., </PRE> - * - * @version $Id: LCONST.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class LCONST extends Instruction - implements ConstantPushInstruction, TypedInstruction { - private long value; - - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - LCONST() {} - - public LCONST(long l) { - super(org.aspectj.apache.bcel.Constants.LCONST_0, (short)1); - - if(l == 0) - opcode = org.aspectj.apache.bcel.Constants.LCONST_0; - else if(l == 1) - opcode = org.aspectj.apache.bcel.Constants.LCONST_1; - else - throw new ClassGenException("LCONST can be used only for 0 and 1: " + l); - - value = l; - } - - public Number getValue() { return new Long(value); } - - /** @return Type.LONG - */ - public Type getType(ConstantPoolGen cp) { - return Type.LONG; - } - - /** - * 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.visitLCONST(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LDC.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LDC.java deleted file mode 100644 index 7f7922847..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LDC.java +++ /dev/null @@ -1,172 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ -import java.io.*; -import org.aspectj.apache.bcel.util.ByteSequence; - -/** - * LDC - Push item from constant pool. - * - * <PRE>Stack: ... -> ..., item</PRE> - * - * @version $Id: LDC.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class LDC extends CPInstruction - implements PushInstruction, ExceptionThrower, TypedInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - LDC() {} - - public LDC(int index) { - super(org.aspectj.apache.bcel.Constants.LDC_W, index); - setSize(); - } - - // Adjust to proper size - protected final void setSize() { - if(index <= org.aspectj.apache.bcel.Constants.MAX_BYTE) { // Fits in one byte? - opcode = org.aspectj.apache.bcel.Constants.LDC; - length = 2; - } else { - opcode = org.aspectj.apache.bcel.Constants.LDC_W; - length = 3; - } - } - - /** - * Dump instruction as byte code to stream out. - * @param out Output stream - */ - public void dump(DataOutputStream out) throws IOException { - out.writeByte(opcode); - - if(length == 2) - out.writeByte(index); - else // Applies for LDC_W - out.writeShort(index); - } - - /** - * Set the index to constant pool and adjust size. - */ - public final void setIndex(int index) { - super.setIndex(index); - setSize(); - } - - /** - * Read needed data (e.g. index) from file. - */ - protected void initFromFile(ByteSequence bytes, boolean wide) - throws IOException - { - length = 2; - index = bytes.readUnsignedByte(); - } - - public Object getValue(ConstantPoolGen cpg) { - org.aspectj.apache.bcel.classfile.Constant c = cpg.getConstantPool().getConstant(index); - - switch(c.getTag()) { - case org.aspectj.apache.bcel.Constants.CONSTANT_String: - int i = ((org.aspectj.apache.bcel.classfile.ConstantString)c).getStringIndex(); - c = cpg.getConstantPool().getConstant(i); - return ((org.aspectj.apache.bcel.classfile.ConstantUtf8)c).getBytes(); - - case org.aspectj.apache.bcel.Constants.CONSTANT_Float: - return new Float(((org.aspectj.apache.bcel.classfile.ConstantFloat)c).getBytes()); - - case org.aspectj.apache.bcel.Constants.CONSTANT_Integer: - return new Integer(((org.aspectj.apache.bcel.classfile.ConstantInteger)c).getBytes()); - - default: // Never reached - throw new RuntimeException("Unknown or invalid constant type at " + index); - } - } - - public Type getType(ConstantPoolGen cpg) { - switch(cpg.getConstantPool().getConstant(index).getTag()) { - case org.aspectj.apache.bcel.Constants.CONSTANT_String: return Type.STRING; - case org.aspectj.apache.bcel.Constants.CONSTANT_Float: return Type.FLOAT; - case org.aspectj.apache.bcel.Constants.CONSTANT_Integer: return Type.INT; - default: // Never reached - throw new RuntimeException("Unknown or invalid constant type at " + index); - } - } - - public Class[] getExceptions() { - return org.aspectj.apache.bcel.ExceptionConstants.EXCS_STRING_RESOLUTION; - } - - /** - * 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.visitExceptionThrower(this); - v.visitTypedInstruction(this); - v.visitCPInstruction(this); - v.visitLDC(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LDC2_W.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LDC2_W.java deleted file mode 100644 index e031c6c23..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LDC2_W.java +++ /dev/null @@ -1,116 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * LDC2_W - Push long or double from constant pool - * - * <PRE>Stack: ... -> ..., item.word1, item.word2</PRE> - * - * @version $Id: LDC2_W.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class LDC2_W extends CPInstruction - implements PushInstruction, TypedInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - LDC2_W() {} - - public LDC2_W(int index) { - super(org.aspectj.apache.bcel.Constants.LDC2_W, index); - } - - public Type getType(ConstantPoolGen cpg) { - switch(cpg.getConstantPool().getConstant(index).getTag()) { - case org.aspectj.apache.bcel.Constants.CONSTANT_Long: return Type.LONG; - case org.aspectj.apache.bcel.Constants.CONSTANT_Double: return Type.DOUBLE; - default: // Never reached - throw new RuntimeException("Unknown constant type " + opcode); - } - } - - public Number getValue(ConstantPoolGen cpg) { - org.aspectj.apache.bcel.classfile.Constant c = cpg.getConstantPool().getConstant(index); - - switch(c.getTag()) { - case org.aspectj.apache.bcel.Constants.CONSTANT_Long: - return new Long(((org.aspectj.apache.bcel.classfile.ConstantLong)c).getBytes()); - - case org.aspectj.apache.bcel.Constants.CONSTANT_Double: - return new Double(((org.aspectj.apache.bcel.classfile.ConstantDouble)c).getBytes()); - - default: // Never reached - throw new RuntimeException("Unknown or invalid constant type at " + index); - } - } - - /** - * 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.visitCPInstruction(this); - v.visitLDC2_W(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LDC_W.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LDC_W.java deleted file mode 100644 index 1a057dc0a..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LDC_W.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ -import java.io.IOException; -import org.aspectj.apache.bcel.util.ByteSequence; - -/** - * LDC_W - Push item from constant pool (wide index) - * - * <PRE>Stack: ... -> ..., item.word1, item.word2</PRE> - * - * @version $Id: LDC_W.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class LDC_W extends LDC { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - LDC_W() {} - - public LDC_W(int index) { - super(index); - } - - /** - * Read needed data (i.e., index) from file. - */ - protected void initFromFile(ByteSequence bytes, boolean wide) - throws IOException - { - setIndex(bytes.readUnsignedShort()); - // Override just in case it has been changed - // opcode = org.aspectj.apache.bcel.Constants.LDC_W; - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LDIV.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LDIV.java deleted file mode 100644 index 23be3a49d..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LDIV.java +++ /dev/null @@ -1,91 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * LDIV - Divide longs - * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -></PRE> - * ..., result.word1, result.word2 - * - * @version $Id: LDIV.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class LDIV extends ArithmeticInstruction implements ExceptionThrower { - public LDIV() { - super(org.aspectj.apache.bcel.Constants.LDIV); - } - - public Class[] getExceptions() { - return new Class[] { org.aspectj.apache.bcel.ExceptionConstants.ARITHMETIC_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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitLDIV(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LLOAD.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LLOAD.java deleted file mode 100644 index 51b819727..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LLOAD.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * LLOAD - Load long from local variable - *<PRE>Stack ... -> ..., result.word1, result.word2</PRE> - * - * @version $Id: LLOAD.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class LLOAD extends LoadInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - LLOAD() { - super(org.aspectj.apache.bcel.Constants.LLOAD, org.aspectj.apache.bcel.Constants.LLOAD_0); - } - - public LLOAD(int n) { - super(org.aspectj.apache.bcel.Constants.LLOAD, org.aspectj.apache.bcel.Constants.LLOAD_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.visitLLOAD(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LMUL.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LMUL.java deleted file mode 100644 index 9106cc737..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LMUL.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * LMUL - Multiply longs - * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -></PRE> - * ..., result.word1, result.word2 - * - * @version $Id: LMUL.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class LMUL extends ArithmeticInstruction { - public LMUL() { - super(org.aspectj.apache.bcel.Constants.LMUL); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitLMUL(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LNEG.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LNEG.java deleted file mode 100644 index 23cfd1508..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LNEG.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * LNEG - Negate long - * <PRE>Stack: ..., value.word1, value.word2 -> ..., result.word1, result.word2</PRE> - * - * @version $Id: LNEG.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class LNEG extends ArithmeticInstruction { - public LNEG() { - super(org.aspectj.apache.bcel.Constants.LNEG); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitLNEG(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LOOKUPSWITCH.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LOOKUPSWITCH.java index 5b0e93890..889bbbc6d 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LOOKUPSWITCH.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/LOOKUPSWITCH.java @@ -54,29 +54,27 @@ package org.aspectj.apache.bcel.generic; * <http://www.apache.org/>. */ import java.io.*; + +import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.util.ByteSequence; /** * LOOKUPSWITCH - Switch with unordered set of values * - * @version $Id: LOOKUPSWITCH.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: LOOKUPSWITCH.java,v 1.3 2008/05/28 23:52:57 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see SWITCH */ -public class LOOKUPSWITCH extends Select { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - LOOKUPSWITCH() {} +public class LOOKUPSWITCH extends InstructionSelect { + public LOOKUPSWITCH(int[] match, InstructionHandle[] targets, InstructionHandle target) { super(org.aspectj.apache.bcel.Constants.LOOKUPSWITCH, match, targets, target); - length = (short)(9 + match_length * 8); /* alignment remainder assumed + length = (short)(9 + matchLength * 8); /* alignment remainder assumed * 0 here, until dump time. */ - fixed_length = length; + fixedLength = length; } /** @@ -85,9 +83,9 @@ public class LOOKUPSWITCH extends Select { */ public void dump(DataOutputStream out) throws IOException { super.dump(out); - out.writeInt(match_length); // npairs + out.writeInt(matchLength); // npairs - for(int i=0; i < match_length; i++) { + for(int i=0; i < matchLength; i++) { out.writeInt(match[i]); // match-offset pairs out.writeInt(indices[i] = getTargetOffset(targets[i])); } @@ -96,38 +94,22 @@ public class LOOKUPSWITCH extends Select { /** * Read needed data (e.g. index) from file. */ - protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException + public LOOKUPSWITCH(ByteSequence bytes) throws IOException { - super.initFromFile(bytes, wide); // reads padding + super(Constants.LOOKUPSWITCH,bytes); // reads padding - match_length = bytes.readInt(); - fixed_length = (short)(9 + match_length * 8); - length = (short)(fixed_length + padding); + matchLength = bytes.readInt(); + fixedLength = (short)(9 + matchLength * 8); + length = (short)(fixedLength + padding); - match = new int[match_length]; - indices = new int[match_length]; - targets = new InstructionHandle[match_length]; + match = new int[matchLength]; + indices = new int[matchLength]; + targets = new InstructionHandle[matchLength]; - for(int i=0; i < match_length; i++) { + for(int i=0; i < matchLength; i++) { match[i] = bytes.readInt(); indices[i] = bytes.readInt(); } } - - /** - * 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.visitVariableLengthInstruction(this); - v.visitStackProducer(this); - v.visitBranchInstruction(this); - v.visitSelect(this); - v.visitLOOKUPSWITCH(this); - } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LOR.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LOR.java deleted file mode 100644 index 9fe18bdbc..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LOR.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * LOR - Bitwise OR long - * <PRE>Stack: ..., value1, value2 -> ..., result</PRE> - * - * @version $Id: LOR.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class LOR extends ArithmeticInstruction { - public LOR() { - super(org.aspectj.apache.bcel.Constants.LOR); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitLOR(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LREM.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LREM.java deleted file mode 100644 index cfc0ac1f6..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LREM.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * LREM - Remainder of long - * <PRE>Stack: ..., value1, value2 -> result</PRE> - * - * @version $Id: LREM.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class LREM extends ArithmeticInstruction implements ExceptionThrower { - public LREM() { - super(org.aspectj.apache.bcel.Constants.LREM); - } - - public Class[] getExceptions() { return new Class[] { org.aspectj.apache.bcel.ExceptionConstants.ARITHMETIC_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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitLREM(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LRETURN.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LRETURN.java deleted file mode 100644 index e80362351..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LRETURN.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * LRETURN - Return long from method - * <PRE>Stack: ..., value.word1, value.word2 -> <empty></PRE> - * - * @version $Id: LRETURN.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class LRETURN extends ReturnInstruction { - public LRETURN() { - super(org.aspectj.apache.bcel.Constants.LRETURN); - } - - - /** - * 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.visitLRETURN(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LSHL.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LSHL.java deleted file mode 100644 index cc26d99d6..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LSHL.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * LSHL - Arithmetic shift left long - * <PRE>Stack: ..., value1.word1, value1.word2, value2 -> ..., result.word1, result.word2</PRE> - * - * @version $Id: LSHL.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class LSHL extends ArithmeticInstruction { - public LSHL() { - super(org.aspectj.apache.bcel.Constants.LSHL); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitLSHL(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LSHR.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LSHR.java deleted file mode 100644 index fa4813b8d..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LSHR.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * LSHR - Arithmetic shift right long - * <PRE>Stack: ..., value1.word1, value1.word2, value2 -> ..., result.word1, result.word2</PRE> - * - * @version $Id: LSHR.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class LSHR extends ArithmeticInstruction { - public LSHR() { - super(org.aspectj.apache.bcel.Constants.LSHR); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitLSHR(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LSTORE.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LSTORE.java deleted file mode 100644 index 42f0c2d7e..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LSTORE.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * LSTORE - Store long into local variable - * <PRE>Stack: ..., value.word1, value.word2 -> ... </PRE> - * - * @version $Id: LSTORE.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class LSTORE extends StoreInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - LSTORE() { - super(org.aspectj.apache.bcel.Constants.LSTORE, org.aspectj.apache.bcel.Constants.LSTORE_0); - } - - public LSTORE(int n) { - super(org.aspectj.apache.bcel.Constants.LSTORE, org.aspectj.apache.bcel.Constants.LSTORE_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.visitLSTORE(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LSUB.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LSUB.java deleted file mode 100644 index efc96f637..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LSUB.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * LSUB - Substract longs - * <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -></PRE> - * ..., result.word1, result.word2 - * - * @version $Id: LSUB.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class LSUB extends ArithmeticInstruction { - public LSUB() { - super(org.aspectj.apache.bcel.Constants.LSUB); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitLSUB(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LUSHR.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LUSHR.java deleted file mode 100644 index a96f652b5..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LUSHR.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * LUSHR - Logical shift right long - * <PRE>Stack: ..., value1, value2 -> ..., result</PRE> - * - * @version $Id: LUSHR.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class LUSHR extends ArithmeticInstruction { - public LUSHR() { - super(org.aspectj.apache.bcel.Constants.LUSHR); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitLUSHR(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LXOR.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LXOR.java deleted file mode 100644 index e162b4e32..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LXOR.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * LXOR - Bitwise XOR long - * <PRE>Stack: ..., value1, value2 -> ..., result</PRE> - * - * @version $Id: LXOR.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class LXOR extends ArithmeticInstruction { - public LXOR() { - super(org.aspectj.apache.bcel.Constants.LXOR); - } - - - /** - * 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.visitTypedInstruction(this); - v.visitStackProducer(this); - v.visitStackConsumer(this); - v.visitArithmeticInstruction(this); - v.visitLXOR(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LineNumberGen.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LineNumberGen.java index 7504ecce4..237720c7b 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LineNumberGen.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/LineNumberGen.java @@ -60,7 +60,7 @@ import org.aspectj.apache.bcel.classfile.LineNumber; * This class represents a line number within a method, i.e., give an instruction * a line number corresponding to the source code line. * - * @version $Id: LineNumberGen.java,v 1.4 2004/11/22 08:31:27 aclement Exp $ + * @version $Id: LineNumberGen.java,v 1.5 2008/05/28 23:53:00 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see LineNumber * @see MethodGen @@ -110,7 +110,7 @@ public class LineNumberGen } public void setInstruction(InstructionHandle ih) { - BranchInstruction.notifyTarget(this.ih, ih, this); + InstructionBranch.notifyTarget(this.ih, ih, this); this.ih = ih; } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LineNumberTag.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LineNumberTag.java index a35b86594..fe1d56c27 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LineNumberTag.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/LineNumberTag.java @@ -14,7 +14,9 @@ package org.aspectj.apache.bcel.generic; -/** we don't actually target instructions, but instructions target us. */ +/** + * we don't actually target instructions, but instructions target us. + */ public class LineNumberTag extends Tag { private final int lineNumber; @@ -23,17 +25,19 @@ public class LineNumberTag extends Tag { this.lineNumber = lineNumber; } - public int getLineNumber() { return lineNumber; } + public int getLineNumber() { + return lineNumber; + } - // ---- from Object - public String toString() { return "line " + lineNumber; - } + } + public boolean equals(Object other) { - if (! (other instanceof LineNumberTag)) return false; + if (!(other instanceof LineNumberTag)) return false; return lineNumber == ((LineNumberTag)other).lineNumber; } + public int hashCode() { return lineNumber; } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LoadClass.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LoadClass.java deleted file mode 100644 index 7b105542c..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LoadClass.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Denotes that an instruction may start the process of loading and resolving - * the referenced class in the Virtual Machine. - * - * @version $Id: LoadClass.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public interface LoadClass { - /** - * Returns the ObjectType of the referenced class or interface - * that may be loaded and resolved. - * @return object type that may be loaded or null if a primitive is - * referenced - */ - public ObjectType getLoadClassType(ConstantPoolGen cpg); - - /** - * Returns the type associated with this instruction. - * LoadClass instances are always typed, but this type - * does not always refer to the type of the class or interface - * that it possibly forces to load. For example, GETFIELD would - * return the type of the field and not the type of the class - * where the field is defined. - * If no class is forced to be loaded, <B>null</B> is returned. - * An example for this is an ANEWARRAY instruction that creates - * an int[][]. - * @see #getLoadClassType(ConstantPoolGen) - */ - public Type getType(ConstantPoolGen cpg); -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LocalVariableGen.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LocalVariableGen.java index 49f50591b..ee615993e 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LocalVariableGen.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/LocalVariableGen.java @@ -56,6 +56,7 @@ package org.aspectj.apache.bcel.generic; import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.classfile.LocalVariable; +import org.aspectj.apache.bcel.classfile.ConstantPool; /** * This class represents a local variable within a method. It contains its @@ -63,13 +64,13 @@ import org.aspectj.apache.bcel.classfile.LocalVariable; * with getLocalVariable which needs the instruction list and the constant * pool as parameters. * - * @version $Id: LocalVariableGen.java,v 1.5 2005/09/28 06:07:20 acolyer Exp $ + * @version $Id: LocalVariableGen.java,v 1.6 2008/05/28 23:52:54 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see LocalVariable * @see MethodGen */ public class LocalVariableGen - implements InstructionTargeter, NamedAndTyped, Cloneable, + implements InstructionTargeter, /*NamedAndTyped,*/ Cloneable, java.io.Serializable { private int index; @@ -114,7 +115,7 @@ public class LocalVariableGen * @param il instruction list (byte code) which this variable belongs to * @param cp constant pool */ - public LocalVariable getLocalVariable(ConstantPoolGen cp) { + public LocalVariable getLocalVariable(ConstantPool cp) { int start_pc = start.getPosition(); int length = end.getPosition() - start_pc; @@ -126,7 +127,7 @@ public class LocalVariableGen int signature_index = cp.addUtf8(type.getSignature()); return new LocalVariable(start_pc, length, name_index, - signature_index, index, cp.getConstantPool()); + signature_index, index, cp); } public void setIndex(int index) { this.index = index; } @@ -140,12 +141,12 @@ public class LocalVariableGen public InstructionHandle getEnd() { return end; } public void setStart(InstructionHandle start) { - BranchInstruction.notifyTarget(this.start, start, this); + InstructionBranch.notifyTarget(this.start, start, this); this.start = start; } public void setEnd(InstructionHandle end) { - BranchInstruction.notifyTarget(this.end, end, this); + InstructionBranch.notifyTarget(this.end, end, this); this.end = end; } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LocalVariableInstruction.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LocalVariableInstruction.java deleted file mode 100644 index fd27935ff..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LocalVariableInstruction.java +++ /dev/null @@ -1,224 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ -import java.io.DataOutputStream; -import java.io.IOException; - -import org.aspectj.apache.bcel.Constants; -import org.aspectj.apache.bcel.util.ByteSequence; - -/** - * Abstract super class for instructions dealing with local variables. - * - * @version $Id: LocalVariableInstruction.java,v 1.9 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public abstract class LocalVariableInstruction extends Instruction - implements TypedInstruction, IndexedInstruction { - protected int n = -1; // index of referenced variable - private short c_tag = -1; // compact version, such as ILOAD_0 - private short canon_tag = -1; // canonical tag such as ILOAD - - private final boolean wide() { return n > Constants.MAX_BYTE; } - - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - * tag and length are defined in readInstruction and initFromFile, respectively. - */ - LocalVariableInstruction(short canon_tag, short c_tag) { - super(); - this.canon_tag = canon_tag; - this.c_tag = c_tag; - } - - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Also used by IINC()! - */ - LocalVariableInstruction() { - } - - /** - * @param opcode Instruction opcode - * @param c_tag Instruction number for compact version, ALOAD_0, e.g. - * @param n local variable index (unsigned short) - */ - protected LocalVariableInstruction(short opcode, short c_tag, int n) { - super(opcode, (short)2); - - this.c_tag = c_tag; - canon_tag = opcode; - - setIndex(n); - } - - /** - * Dump instruction as byte code to stream out. - * @param out Output stream - */ - public void dump(DataOutputStream out) throws IOException { - if(wide()) // Need WIDE prefix ? - out.writeByte(Constants.WIDE); - - out.writeByte(opcode); - - if(length > 1) { // Otherwise ILOAD_n, instruction, e.g. - if(wide()) - out.writeShort(n); - else - out.writeByte(n); - } - } - - /** - * Long output format: - * - * <name of opcode> "["<opcode number>"]" - * "("<length of instruction>")" "<"< local variable index>">" - * - * @param verbose long/short format switch - * @return mnemonic for instruction - */ - public String toString(boolean verbose) { - if(((opcode >= Constants.ILOAD_0) && - (opcode <= Constants.ALOAD_3)) || - ((opcode >= Constants.ISTORE_0) && - (opcode <= Constants.ASTORE_3))) - return super.toString(verbose); - else - return super.toString(verbose) + " " + n; - } - - /** - * Read needed data (e.g. index) from file. - * PRE: (ILOAD <= tag <= ALOAD_3) || (ISTORE <= tag <= ASTORE_3) - */ - protected void initFromFile(ByteSequence bytes, boolean wide) - throws IOException - { - if(wide) { - n = bytes.readUnsignedShort(); - } else if(((opcode >= Constants.ILOAD) && - (opcode <= Constants.ALOAD)) || - ((opcode >= Constants.ISTORE) && - (opcode <= Constants.ASTORE))) { - n = bytes.readUnsignedByte(); - } else if(opcode <= Constants.ALOAD_3) { // compact load instruction such as ILOAD_2 - n = (opcode - Constants.ILOAD_0) % 4; - } else { // Assert ISTORE_0 <= tag <= ASTORE_3 - n = (opcode - Constants.ISTORE_0) % 4; - } - workOutLength(); - } - - private void workOutLength() { - if(n >= 0 && n <= 3) { // Use more compact instruction xLOAD_n - opcode = (short)(c_tag + n); - length = 1; - } else { - opcode = canon_tag; - if(wide()) length = 4; - else length = 2; - } - } - - /** - * @return local variable index referred by this instruction. - */ - public final int getIndex() { return n; } - - /** - * Set the local variable index - */ - public void setIndex(int n) { - if((n < 0) || (n > Constants.MAX_SHORT)) - throw new ClassGenException("Illegal value: " + n); - - this.n = n; - workOutLength(); - } - - /** @return canonical tag for instruction, e.g., ALOAD for ALOAD_0 - */ - public short getCanonicalTag() { - return canon_tag; - } - - /** - * Returns the type associated with the instruction - - * in case of ALOAD or ASTORE Type.OBJECT is returned. - * This is just a bit incorrect, because ALOAD and ASTORE - * may work on every ReferenceType (including Type.NULL) and - * ASTORE may even work on a ReturnaddressType . - * @return type associated with the instruction - */ - public Type getType(ConstantPoolGen cp) { - switch(canon_tag) { - case Constants.ILOAD: case Constants.ISTORE: - return Type.INT; - case Constants.LLOAD: case Constants.LSTORE: - return Type.LONG; - case Constants.DLOAD: case Constants.DSTORE: - return Type.DOUBLE; - case Constants.FLOAD: case Constants.FSTORE: - return Type.FLOAT; - case Constants.ALOAD: case Constants.ASTORE: - return Type.OBJECT; - - default: throw new ClassGenException("Oops: unknown case in switch" + canon_tag); - } - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/LocalVariableTag.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/LocalVariableTag.java index 266f3b868..ffe857079 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/LocalVariableTag.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/LocalVariableTag.java @@ -52,8 +52,6 @@ public final class LocalVariableTag extends Tag { public boolean isRemapped() { return this.remapped; } - // ---- from Object - public String toString() { return "local " + slot + ": " + signature + " " + name; } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/MONITORENTER.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/MONITORENTER.java deleted file mode 100644 index 9a6600aff..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/MONITORENTER.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * MONITORENTER - Enter monitor for object - * <PRE>Stack: ..., objectref -> ...</PRE> - * - * @version $Id: MONITORENTER.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class MONITORENTER extends Instruction - implements ExceptionThrower, StackConsumer { - public MONITORENTER() { - super(org.aspectj.apache.bcel.Constants.MONITORENTER, (short)1); - } - - public Class[] getExceptions() { - return new Class[] { org.aspectj.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.visitStackConsumer(this); - v.visitMONITORENTER(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/MONITOREXIT.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/MONITOREXIT.java deleted file mode 100644 index 5641063e1..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/MONITOREXIT.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * MONITOREXIT - Exit monitor for object - * <PRE>Stack: ..., objectref -> ...</PRE> - * - * @version $Id: MONITOREXIT.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class MONITOREXIT extends Instruction - implements ExceptionThrower, StackConsumer { - public MONITOREXIT() { - super(org.aspectj.apache.bcel.Constants.MONITOREXIT, (short)1); - } - - public Class[] getExceptions() { - return new Class[] { org.aspectj.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.visitStackConsumer(this); - v.visitMONITOREXIT(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/MULTIANEWARRAY.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/MULTIANEWARRAY.java index 3472fd218..eddc2e995 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/MULTIANEWARRAY.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/MULTIANEWARRAY.java @@ -54,34 +54,23 @@ package org.aspectj.apache.bcel.generic; * <http://www.apache.org/>. */ import java.io.*; -import org.aspectj.apache.bcel.util.ByteSequence; import org.aspectj.apache.bcel.classfile.ConstantPool; +import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.ExceptionConstants; /** * MULTIANEWARRAY - Create new mutidimensional array of references * <PRE>Stack: ..., count1, [count2, ...] -> ..., arrayref</PRE> * - * @version $Id: MULTIANEWARRAY.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: MULTIANEWARRAY.java,v 1.3 2008/05/28 23:52:59 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ -public class MULTIANEWARRAY extends CPInstruction implements LoadClass, AllocationInstruction, ExceptionThrower { +public class MULTIANEWARRAY extends InstructionCP { private short dimensions; - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - MULTIANEWARRAY() {} - public MULTIANEWARRAY(int index, short dimensions) { - super(org.aspectj.apache.bcel.Constants.MULTIANEWARRAY, index); - - if(dimensions < 1) - throw new ClassGenException("Invalid dimensions value: " + dimensions); - + super(Constants.MULTIANEWARRAY, index); this.dimensions = dimensions; - length = 4; } /** @@ -97,13 +86,13 @@ public class MULTIANEWARRAY extends CPInstruction implements LoadClass, Allocati /** * Read needed data (i.e., no. dimension) from file. */ - protected void initFromFile(ByteSequence bytes, boolean wide) - throws IOException - { - super.initFromFile(bytes, wide); - dimensions = bytes.readByte(); - length = 4; - } +// protected void initFromFile(ByteSequence bytes, boolean wide) +// throws IOException +// { +// super.initFromFile(bytes, wide); +// dimensions = bytes.readByte(); +//// length = 4; +// } /** * @return number of dimensions to be created @@ -129,7 +118,7 @@ public class MULTIANEWARRAY extends CPInstruction implements LoadClass, Allocati * constant pool entry they reference. * @return Number of words consumed from stack by this instruction */ - public int consumeStack(ConstantPoolGen cpg) { return dimensions; } + public int consumeStack(ConstantPool cpg) { return dimensions; } public Class[] getExceptions() { Class[] cs = new Class[2 + ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length]; @@ -143,7 +132,7 @@ public class MULTIANEWARRAY extends CPInstruction implements LoadClass, Allocati return cs; } - public ObjectType getLoadClassType(ConstantPoolGen cpg) { + public ObjectType getLoadClassType(ConstantPool cpg) { Type t = getType(cpg); if (t instanceof ArrayType){ @@ -153,20 +142,20 @@ public class MULTIANEWARRAY extends CPInstruction implements LoadClass, Allocati 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.visitAllocationInstruction(this); - v.visitExceptionThrower(this); - v.visitTypedInstruction(this); - v.visitCPInstruction(this); - v.visitMULTIANEWARRAY(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.visitLoadClass(this); +// v.visitAllocationInstruction(this); +// v.visitExceptionThrower(this); +// v.visitTypedInstruction(this); +// v.visitCPInstruction(this); +// v.visitMULTIANEWARRAY(this); +// } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/MethodGen.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/MethodGen.java index d88f5091a..6d29f10f8 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/MethodGen.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/MethodGen.java @@ -69,44 +69,47 @@ import org.aspectj.apache.bcel.classfile.LineNumber; import org.aspectj.apache.bcel.classfile.LineNumberTable; import org.aspectj.apache.bcel.classfile.LocalVariable; import org.aspectj.apache.bcel.classfile.LocalVariableTable; +import org.aspectj.apache.bcel.classfile.ConstantPool; import org.aspectj.apache.bcel.classfile.Method; import org.aspectj.apache.bcel.classfile.Utility; -import org.aspectj.apache.bcel.classfile.annotation.Annotation; +import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; import org.aspectj.apache.bcel.classfile.annotation.RuntimeAnnotations; import org.aspectj.apache.bcel.classfile.annotation.RuntimeParameterAnnotations; -import org.aspectj.apache.bcel.generic.annotation.AnnotationGen; /** * Template class for building up a method. This is done by defining exception * handlers, adding thrown exceptions, local variables and attributes, whereas - * the `LocalVariableTable' and `LineNumberTable' attributes will be set + * the 'LocalVariableTable' and 'LineNumberTable' attributes will be set * automatically for the code. Use stripAttributes() if you don't like this. * * While generating code it may be necessary to insert NOP operations. You can * use the `removeNOPs' method to get rid off them. * The resulting method object can be obtained via the `getMethod()' method. * - * @version $Id: MethodGen.java,v 1.8 2007/02/28 13:10:32 aclement Exp $ + * @version $Id: MethodGen.java,v 1.9 2008/05/28 23:52:57 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @author <A HREF="http://www.vmeng.com/beard">Patrick C. Beard</A> [setMaxStack()] * @see InstructionList * @see Method */ public class MethodGen extends FieldGenOrMethodGen { - private String class_name; - private Type[] arg_types; - private String[] arg_names; - private int max_locals; - private int max_stack; + private String classname; + private Type[] parameterTypes; + private String[] parameterNames; + private int maxLocals; + private int maxStack; private InstructionList il; - private boolean strip_attributes; + + // Indicates whether to produce code attributes for LineNumberTable and LocalVariableTable, like javac -O + private boolean stripAttributes; + private int highestLineNumber = 0; - private ArrayList variable_vec = new ArrayList(); - private ArrayList line_number_vec = new ArrayList(); - private ArrayList exception_vec = new ArrayList(); + private ArrayList localVariablesList = new ArrayList(); + private ArrayList lineNumbersList = new ArrayList(); + private ArrayList exceptionsList = new ArrayList(); private ArrayList throws_vec = new ArrayList(); - private ArrayList code_attrs_vec = new ArrayList(); + private ArrayList codeAttributesList = new ArrayList(); private List[] param_annotations; // Array of lists containing AnnotationGen objects private boolean hasParameterAnnotations = false; private boolean haveUnpackedParameterAnnotations = false; @@ -135,59 +138,61 @@ public class MethodGen extends FieldGenOrMethodGen { */ public MethodGen(int access_flags, Type return_type, Type[] arg_types, String[] arg_names, String method_name, String class_name, - InstructionList il, ConstantPoolGen cp) { - setAccessFlags(access_flags); - setType(return_type); - setArgumentTypes(arg_types); - setArgumentNames(arg_names); - setName(method_name); - setClassName(class_name); - setInstructionList(il); - setConstantPool(cp); - - boolean abstract_ = isAbstract() || isNative(); - InstructionHandle start = null; - InstructionHandle end = null; - - if(!abstract_) { - start = il.getStart(); - end = il.getEnd(); - - /* Add local variables, namely the implicit `this' and the arguments - */ -// if(!isStatic() && (class_name != null)) { // Instance method -> `this' is local var 0 -// addLocalVariable("this", new ObjectType(class_name), start, end); + InstructionList il, ConstantPool cp) { + + this.modifiers = access_flags; + this.type = return_type; + this.parameterTypes = arg_types; + this.parameterNames = arg_names; + this.name = method_name; + this.classname = class_name; + this.il = il; + this.cp = cp; + + // OPTIMIZE this code messes with the local variables - do we need it? +// boolean abstract_ = isAbstract() || isNative(); +// InstructionHandle start = null; +// InstructionHandle end = null; +// +// if (!abstract_) { +// start = il.getStart(); +// end = il.getEnd(); +// +// /* Add local variables, namely the implicit `this' and the arguments +// */ +//// if(!isStatic() && (class_name != null)) { // Instance method -> `this' is local var 0 +//// addLocalVariable("this", new ObjectType(class_name), start, end); +//// } +// } + +// if(arg_types != null) { +// int size = arg_types.length; +// +// for(int i=0; i < size; i++) { +// if(Type.VOID == arg_types[i]) { +// throw new ClassGenException("'void' is an illegal argument type for a method"); +// } // } - } - - if(arg_types != null) { - int size = arg_types.length; - - for(int i=0; i < size; i++) { - if(Type.VOID == arg_types[i]) { - throw new ClassGenException("'void' is an illegal argument type for a method"); - } - } - - if(arg_names != null) { // Names for variables provided? - if(size != arg_names.length) - throw new ClassGenException("Mismatch in argument array lengths: " + - size + " vs. " + arg_names.length); - } else { // Give them dummy names -// arg_names = new String[size]; -// -// for(int i=0; i < size; i++) -// arg_names[i] = "arg" + i; // -// setArgumentNames(arg_names); - } +// if(arg_names != null) { // Names for variables provided? +// if(size != arg_names.length) +// throw new ClassGenException("Mismatch in argument array lengths: " + +// size + " vs. " + arg_names.length); +// } else { // Give them dummy names +//// arg_names = new String[size]; +//// +//// for(int i=0; i < size; i++) +//// arg_names[i] = "arg" + i; +//// +//// setArgumentNames(arg_names); +// } - if(!abstract_) { - for(int i=0; i < size; i++) { -// addLocalVariable(arg_names[i], arg_types[i], start, end); - } - } - } +// if(!abstract_) { +// for(int i=0; i < size; i++) { +//// addLocalVariable(arg_names[i], arg_types[i], start, end); +// } +// } +// } } public int getHighestlinenumber() { return highestLineNumber; } @@ -200,20 +205,20 @@ public class MethodGen extends FieldGenOrMethodGen { * @param cp constant pool */ - public MethodGen(Method m, String class_name, ConstantPoolGen cp) { + public MethodGen(Method m, String class_name, ConstantPool cp) { this(m,class_name,cp,false); } - public MethodGen(Method m, String class_name, ConstantPoolGen cp,boolean useTags) { - + public MethodGen(Method m, String class_name, ConstantPool cp,boolean useTags) { this( - m.getAccessFlags(), - Type.getReturnType(m.getSignature()), - Type.getArgumentTypes(m.getSignature()), + m.getModifiers(), + // OPTIMIZE implementation of getReturnType() and getArgumentTypes() on Method seems weak + m.getReturnType(), + m.getArgumentTypes(), null /* may be overridden anyway */, m.getName(), class_name, - ((m.getAccessFlags() & (Constants.ACC_ABSTRACT | Constants.ACC_NATIVE)) == 0)? new InstructionList(m.getCode().getCode()) : null, + ((m.getModifiers() & (Constants.ACC_ABSTRACT | Constants.ACC_NATIVE)) == 0)? new InstructionList(m.getCode().getCode()) : null, cp); Attribute[] attributes = m.getAttributes(); @@ -238,7 +243,7 @@ public class MethodGen extends FieldGenOrMethodGen { ObjectType c_type = null; if (type > 0) { - String cen = m.getConstantPool().getConstantString( type, Constants.CONSTANT_Class); + String cen = m.getConstantPool().getConstantString_CONSTANTClass(type); c_type = new ObjectType(cen); } @@ -285,6 +290,7 @@ public class MethodGen extends FieldGenOrMethodGen { } } } else if (a instanceof LocalVariableTable) { + // Lets have a go at creating Tags directly if (useTags) { LocalVariable[] lv = ((LocalVariableTable) a).getLocalVariableTable(); @@ -297,7 +303,7 @@ public class MethodGen extends FieldGenOrMethodGen { byte b = t.getType(); if (b!= Constants.T_ADDRESS) { int increment = t.getSize(); - if (l.getIndex()+increment>max_locals) max_locals = l.getIndex()+increment; + if (l.getIndex()+increment>maxLocals) maxLocals = l.getIndex()+increment; } int end = l.getStartPC()+l.getLength(); do { @@ -334,7 +340,7 @@ public class MethodGen extends FieldGenOrMethodGen { RuntimeAnnotations runtimeAnnotations = (RuntimeAnnotations) a; List l = runtimeAnnotations.getAnnotations(); for (Iterator it = l.iterator(); it.hasNext();) { - Annotation element = (Annotation) it.next(); + AnnotationGen element = (AnnotationGen) it.next(); addAnnotation(new AnnotationGen(element, cp, false)); } } else { @@ -356,22 +362,21 @@ public class MethodGen extends FieldGenOrMethodGen { * @see LocalVariable */ public LocalVariableGen addLocalVariable(String name, Type type, int slot, - InstructionHandle start, - InstructionHandle end) { - byte t = type.getType(); - if (t != Constants.T_ADDRESS) { - int add = type.getSize(); - if (slot + add > max_locals) max_locals = slot + add; + InstructionHandle start, InstructionHandle end) { +// byte t = type.getType(); +// if (t != Constants.T_ADDRESS) { + int size = type.getSize(); + if (slot + size > maxLocals) maxLocals = slot + size; LocalVariableGen l = new LocalVariableGen(slot, name, type, start, end); - int i; - if ((i = variable_vec.indexOf(l)) >= 0) variable_vec.set(i, l); // Overwrite if necessary - else variable_vec.add(l); + int i = localVariablesList.indexOf(l); + if (i >= 0) localVariablesList.set(i, l); // Overwrite if necessary + else localVariablesList.add(l); return l; - } else { - throw new IllegalArgumentException("Can not use " + type + - " as type for local variable"); - - } +// } else { +// throw new IllegalArgumentException("Can not use " + type + +// " as type for local variable"); +// +// } } /** @@ -389,7 +394,7 @@ public class MethodGen extends FieldGenOrMethodGen { public LocalVariableGen addLocalVariable(String name, Type type, InstructionHandle start, InstructionHandle end) { - return addLocalVariable(name, type, max_locals, start, end); + return addLocalVariable(name, type, maxLocals, start, end); } /** @@ -397,14 +402,14 @@ public class MethodGen extends FieldGenOrMethodGen { * with an explicit index argument. */ public void removeLocalVariable(LocalVariableGen l) { - variable_vec.remove(l); + localVariablesList.remove(l); } /** * Remove all local variables. */ public void removeLocalVariables() { - variable_vec.clear(); + localVariablesList.clear(); } /** @@ -436,9 +441,9 @@ public class MethodGen extends FieldGenOrMethodGen { * @return array of declared local variables sorted by index */ public LocalVariableGen[] getLocalVariables() { - int size = variable_vec.size(); + int size = localVariablesList.size(); LocalVariableGen[] lg = new LocalVariableGen[size]; - variable_vec.toArray(lg); + localVariablesList.toArray(lg); for(int i=0; i < size; i++) { if(lg[i].getStart() == null) @@ -457,7 +462,7 @@ public class MethodGen extends FieldGenOrMethodGen { /** * @return `LocalVariableTable' attribute of all the local variables of this method. */ - public LocalVariableTable getLocalVariableTable(ConstantPoolGen cp) { + public LocalVariableTable getLocalVariableTable(ConstantPool cp) { LocalVariableGen[] lg = getLocalVariables(); int size = lg.length; LocalVariable[] lv = new LocalVariable[size]; @@ -466,7 +471,7 @@ public class MethodGen extends FieldGenOrMethodGen { lv[i] = lg[i].getLocalVariable(cp); return new LocalVariableTable(cp.addUtf8("LocalVariableTable"), - 2 + lv.length * 10, lv, cp.getConstantPool()); + 2 + lv.length * 10, lv, cp); } /** @@ -478,7 +483,7 @@ public class MethodGen extends FieldGenOrMethodGen { */ public LineNumberGen addLineNumber(InstructionHandle ih, int src_line) { LineNumberGen l = new LineNumberGen(ih, src_line); - line_number_vec.add(l); + lineNumbersList.add(l); return l; } @@ -486,39 +491,37 @@ public class MethodGen extends FieldGenOrMethodGen { * Remove a line number. */ public void removeLineNumber(LineNumberGen l) { - line_number_vec.remove(l); + lineNumbersList.remove(l); } /** * Remove all line numbers. */ public void removeLineNumbers() { - line_number_vec.clear(); + lineNumbersList.clear(); } /* * @return array of line numbers */ public LineNumberGen[] getLineNumbers() { - LineNumberGen[] lg = new LineNumberGen[line_number_vec.size()]; - line_number_vec.toArray(lg); + LineNumberGen[] lg = new LineNumberGen[lineNumbersList.size()]; + lineNumbersList.toArray(lg); return lg; } /** - * @return `LineNumberTable' attribute of all the local variables of this method. + * @return 'LineNumberTable' attribute for all the local variables of this method. */ - public LineNumberTable getLineNumberTable(ConstantPoolGen cp) { - int size = line_number_vec.size(); - LineNumber[] ln = new LineNumber[size]; + public LineNumberTable getLineNumberTable(ConstantPool cp) { + int size = lineNumbersList.size(); + LineNumber[] ln = new LineNumber[size]; - try { - for(int i=0; i < size; i++) - ln[i] = ((LineNumberGen)line_number_vec.get(i)).getLineNumber(); - } catch(ArrayIndexOutOfBoundsException e) {} // Never occurs + for(int i=0; i < size; i++) { + ln[i] = ((LineNumberGen)lineNumbersList.get(i)).getLineNumber(); + } - return new LineNumberTable(cp.addUtf8("LineNumberTable"), - 2 + ln.length * 4, ln, cp.getConstantPool()); + return new LineNumberTable(cp.addUtf8("LineNumberTable"), 2 + ln.length * 4, ln, cp); } /** @@ -541,7 +544,7 @@ public class MethodGen extends FieldGenOrMethodGen { CodeExceptionGen c = new CodeExceptionGen(start_pc, end_pc, handler_pc, catch_type); - exception_vec.add(c); + exceptionsList.add(c); return c; } @@ -549,22 +552,22 @@ public class MethodGen extends FieldGenOrMethodGen { * Remove an exception handler. */ public void removeExceptionHandler(CodeExceptionGen c) { - exception_vec.remove(c); + exceptionsList.remove(c); } /** * Remove all line numbers. */ public void removeExceptionHandlers() { - exception_vec.clear(); + exceptionsList.clear(); } /* * @return array of declared exception handlers */ public CodeExceptionGen[] getExceptionHandlers() { - CodeExceptionGen[] cg = new CodeExceptionGen[exception_vec.size()]; - exception_vec.toArray(cg); + CodeExceptionGen[] cg = new CodeExceptionGen[exceptionsList.size()]; + exceptionsList.toArray(cg); return cg; } @@ -572,12 +575,12 @@ public class MethodGen extends FieldGenOrMethodGen { * @return code exceptions for `Code' attribute */ private CodeException[] getCodeExceptions() { - int size = exception_vec.size(); + int size = exceptionsList.size(); CodeException[] c_exc = new CodeException[size]; try { for(int i=0; i < size; i++) { - CodeExceptionGen c = (CodeExceptionGen)exception_vec.get(i); + CodeExceptionGen c = (CodeExceptionGen)exceptionsList.get(i); c_exc[i] = c.getCodeException(cp); } } catch(ArrayIndexOutOfBoundsException e) {} @@ -620,7 +623,7 @@ public class MethodGen extends FieldGenOrMethodGen { /** * @return `Exceptions' attribute of all the exceptions thrown by this method. */ - private ExceptionTable getExceptionTable(ConstantPoolGen cp) { + private ExceptionTable getExceptionTable(ConstantPool cp) { int size = throws_vec.size(); int[] ex = new int[size]; @@ -630,7 +633,7 @@ public class MethodGen extends FieldGenOrMethodGen { } catch(ArrayIndexOutOfBoundsException e) {} return new ExceptionTable(cp.addUtf8("Exceptions"), - 2 + 2 * size, ex, cp.getConstantPool()); + 2 + 2 * size, ex, cp); } /** @@ -642,18 +645,10 @@ public class MethodGen extends FieldGenOrMethodGen { * * @param a attribute to be added */ - public void addCodeAttribute(Attribute a) { code_attrs_vec.add(a); } + public void addCodeAttribute(Attribute a) { codeAttributesList.add(a); } - public void addAnnotationsAsAttribute(ConstantPoolGen cp) { - Attribute[] attrs = Utility.getAnnotationAttributes(cp,annotation_vec); - if (attrs!=null) { - for (int i = 0; i < attrs.length; i++) { - addAttribute(attrs[i]); - } - } - } - public void addParameterAnnotationsAsAttribute(ConstantPoolGen cp) { + public void addParameterAnnotationsAsAttribute(ConstantPool cp) { if (!hasParameterAnnotations) return; Attribute[] attrs = Utility.getParameterAnnotationAttributes(cp,param_annotations); if (attrs!=null) { @@ -666,21 +661,21 @@ public class MethodGen extends FieldGenOrMethodGen { /** * Remove a code attribute. */ - public void removeCodeAttribute(Attribute a) { code_attrs_vec.remove(a); } + public void removeCodeAttribute(Attribute a) { codeAttributesList.remove(a); } /** * Remove all code attributes. */ public void removeCodeAttributes() { - code_attrs_vec.clear(); + codeAttributesList.clear(); } /** * @return all attributes of this method. */ public Attribute[] getCodeAttributes() { - Attribute[] attributes = new Attribute[code_attrs_vec.size()]; - code_attrs_vec.toArray(attributes); + Attribute[] attributes = new Attribute[codeAttributesList.size()]; + codeAttributesList.toArray(attributes); return attributes; } @@ -708,10 +703,10 @@ public class MethodGen extends FieldGenOrMethodGen { /* Create LocalVariableTable and LineNumberTable attributes (for debuggers, e.g.) */ - if((variable_vec.size() > 0) && !strip_attributes) + if((localVariablesList.size() > 0) && !stripAttributes) addCodeAttribute(lvt = getLocalVariableTable(cp)); - if((line_number_vec.size() > 0) && !strip_attributes) + if((lineNumbersList.size() > 0) && !stripAttributes) addCodeAttribute(lnt = getLineNumberTable(cp)); Attribute[] code_attrs = getCodeAttributes(); @@ -729,9 +724,9 @@ public class MethodGen extends FieldGenOrMethodGen { if((il != null) && !isAbstract()) { // Remove any stale code attribute - Attribute[] attributes = getAttributes(); - for(int i=0; i < attributes.length; i++) { - Attribute a = attributes[i]; + List attributes = getAttributes(); + for(int i=0; i < attributes.size(); i++) { + Attribute a = (Attribute) attributes.get(i); if(a instanceof Code) removeAttribute(a); } @@ -740,10 +735,10 @@ public class MethodGen extends FieldGenOrMethodGen { 8 + byte_code.length + // prologue byte code 2 + exc_len + // exceptions 2 + attrs_len, // attributes - max_stack, max_locals, + maxStack, maxLocals, byte_code, c_exc, code_attrs, - cp.getConstantPool()); + cp); addAttribute(code); } @@ -757,10 +752,11 @@ public class MethodGen extends FieldGenOrMethodGen { if(throws_vec.size() > 0) addAttribute(et = getExceptionTable(cp)); // Add `Exceptions' if there are "throws" clauses - Method m = new Method(access_flags, name_index, signature_index, - getAttributes(), cp.getConstantPool()); + Method m = new Method(modifiers, name_index, signature_index, + getAttributesImmutable(), cp); // Undo effects of adding attributes + // OPTIMIZE why redo this? is there a better way to clean up? if(lvt != null) removeCodeAttribute(lvt); if(lnt != null) removeCodeAttribute(lnt); if(code != null) removeAttribute(code); @@ -770,74 +766,43 @@ public class MethodGen extends FieldGenOrMethodGen { } /** - * Remove all NOPs from the instruction list (if possible) and update every - * object refering to them, i.e., branch instructions, local variables and - * exception handlers. - */ - public void removeNOPs() { - if(il != null) { - InstructionHandle next; - /* Check branch instructions. - */ - for(InstructionHandle ih = il.getStart(); ih != null; ih = next) { - next = ih.next; - - if((next != null) && (ih.getInstruction() instanceof NOP)) { - try { - il.delete(ih); - } catch(TargetLostException e) { - InstructionHandle[] targets = e.getTargets(); - - for(int i=0; i < targets.length; i++) { - InstructionTargeter[] targeters = targets[i].getTargeters(); - - for(int j=0; j < targeters.length; j++) - targeters[j].updateTarget(targets[i], next); - } - } - } - } - } - } - - /** * Set maximum number of local variables. */ - public void setMaxLocals(int m) { max_locals = m; } - public int getMaxLocals() { return max_locals; } + public void setMaxLocals(int m) { maxLocals = m; } + public int getMaxLocals() { return maxLocals; } /** * Set maximum stack size for this method. */ - public void setMaxStack(int m) { max_stack = m; } - public int getMaxStack() { return max_stack; } + public void setMaxStack(int m) { maxStack = m; } + public int getMaxStack() { return maxStack; } /** @return class that contains this method */ - public String getClassName() { return class_name; } - public void setClassName(String class_name) { this.class_name = class_name; } + public String getClassName() { return classname; } + public void setClassName(String class_name) { this.classname = class_name; } public void setReturnType(Type return_type) { setType(return_type); } public Type getReturnType() { return getType(); } - public void setArgumentTypes(Type[] arg_types) { this.arg_types = arg_types; } - public Type[] getArgumentTypes() { return (Type[])arg_types.clone(); } - public void setArgumentType(int i, Type type) { arg_types[i] = type; } - public Type getArgumentType(int i) { return arg_types[i]; } + public void setArgumentTypes(Type[] arg_types) { this.parameterTypes = arg_types; } + public Type[] getArgumentTypes() { return this.parameterTypes;}// OPTIMIZE dont need clone here? (Type[])arg_types.clone(); } + public void setArgumentType(int i, Type type) { parameterTypes[i] = type; } + public Type getArgumentType(int i) { return parameterTypes[i]; } - public void setArgumentNames(String[] arg_names) { this.arg_names = arg_names; } + public void setArgumentNames(String[] arg_names) { this.parameterNames = arg_names; } public String[] getArgumentNames() { - if (arg_names!=null) return (String[])arg_names.clone(); + if (parameterNames!=null) return (String[])parameterNames.clone(); else return new String[0]; } - public void setArgumentName(int i, String name) { arg_names[i] = name; } - public String getArgumentName(int i) { return arg_names[i]; } + public void setArgumentName(int i, String name) { parameterNames[i] = name; } + public String getArgumentName(int i) { return parameterNames[i]; } public InstructionList getInstructionList() { return il; } public void setInstructionList(InstructionList il) { this.il = il; } public String getSignature() { - return Type.getMethodSignature(type, arg_types); + return Type.getMethodSignature(type, parameterTypes); } /** @@ -845,9 +810,9 @@ public class MethodGen extends FieldGenOrMethodGen { */ public void setMaxStack() { if(il != null) - max_stack = getMaxStack(cp, il, getExceptionHandlers()); + maxStack = getMaxStack(cp, il, getExceptionHandlers()); else - max_stack = 0; + maxStack = 0; } /** @@ -857,33 +822,30 @@ public class MethodGen extends FieldGenOrMethodGen { if(il != null) { int max = isStatic()? 0 : 1; - if(arg_types != null) - for(int i=0; i < arg_types.length; i++) - max += arg_types[i].getSize(); + if(parameterTypes != null) + for(int i=0; i < parameterTypes.length; i++) + max += parameterTypes[i].getSize(); for(InstructionHandle ih = il.getStart(); ih != null; ih = ih.getNext()) { Instruction ins = ih.getInstruction(); - if((ins instanceof LocalVariableInstruction) || - (ins instanceof RET) || (ins instanceof IINC)) + if((ins instanceof InstructionLV) || + (ins instanceof RET)) { - int index = ((IndexedInstruction)ins).getIndex() + - ((TypedInstruction)ins).getType(cp).getSize(); + int index = ins.getIndex() + + ins.getType(cp).getSize(); if(index > max) max = index; } } - max_locals = max; + maxLocals = max; } else - max_locals = 0; + maxLocals = 0; } - /** Do not/Do produce attributes code attributesLineNumberTable and - * LocalVariableTable, like javac -O - */ - public void stripAttributes(boolean flag) { strip_attributes = flag; } + public void stripAttributes(boolean flag) { stripAttributes = flag; } static final class BranchTarget { InstructionHandle target; @@ -932,7 +894,7 @@ public class MethodGen extends FieldGenOrMethodGen { * * @return maximum stack depth used by method */ - public static int getMaxStack(ConstantPoolGen cp, InstructionList il, CodeExceptionGen[] et) { + public static int getMaxStack(ConstantPool cp, InstructionList il, CodeExceptionGen[] et) { BranchStack branchTargets = new BranchStack(); /* Initially, populate the branch stack with the exception @@ -948,28 +910,29 @@ public class MethodGen extends FieldGenOrMethodGen { int stackDepth = 0, maxStackDepth = 0; InstructionHandle ih = il.getStart(); - while(ih != null) { Instruction instruction = ih.getInstruction(); - short opcode = instruction.getOpcode(); - int delta = instruction.produceStack(cp) - instruction.consumeStack(cp); + short opcode = instruction.opcode; + int prod = instruction.produceStack(cp); + int con = instruction.consumeStack(cp); + int delta = prod-con; stackDepth += delta; if(stackDepth > maxStackDepth) maxStackDepth = stackDepth; // choose the next instruction based on whether current is a branch. - if(instruction instanceof BranchInstruction) { - BranchInstruction branch = (BranchInstruction) instruction; - if(instruction instanceof Select) { + if(instruction instanceof InstructionBranch) { + InstructionBranch branch = (InstructionBranch) instruction; + if(instruction instanceof InstructionSelect) { // explore all of the select's targets. the default target is handled below. - Select select = (Select) branch; + InstructionSelect select = (InstructionSelect) branch; InstructionHandle[] targets = select.getTargets(); for (int i = 0; i < targets.length; i++) branchTargets.push(targets[i], stackDepth); // nothing to fall through to. ih = null; - } else if(!(branch instanceof IfInstruction)) { + } else if(!(branch.isIfInstruction())) { // if an instruction that comes back to following PC, // push next instruction, with stack depth reduced by 1. if(opcode == Constants.JSR || opcode == Constants.JSR_W) @@ -1002,33 +965,6 @@ public class MethodGen extends FieldGenOrMethodGen { return maxStackDepth; } - private ArrayList observers; - - /** Add observer for this object. - */ - public void addObserver(MethodObserver o) { - if(observers == null) - observers = new ArrayList(); - - observers.add(o); - } - - /** Remove observer for this object. - */ - public void removeObserver(MethodObserver o) { - if(observers != null) - observers.remove(o); - } - - /** Call notify() method on all observers. This method is not called - * automatically whenever the state has changed, but has to be - * called by the user after he has finished editing the object. - */ - public void update() { - if(observers != null) - for(Iterator e = observers.iterator(); e.hasNext(); ) - ((MethodObserver)e.next()).notify(this); - } /** * Return string representation close to declaration format, @@ -1037,8 +973,8 @@ public class MethodGen extends FieldGenOrMethodGen { * @return String representation of the method. */ public final String toString() { - String access = Utility.accessToString(access_flags); - String signature = Type.getMethodSignature(type, arg_types); + String access = Utility.accessToString(modifiers); + String signature = Type.getMethodSignature(type, parameterTypes); signature = Utility.methodSignatureToString(signature, name, access, true, getLocalVariableTable(cp)); @@ -1055,7 +991,7 @@ public class MethodGen extends FieldGenOrMethodGen { /** @return deep copy of this method */ - public MethodGen copy(String class_name, ConstantPoolGen cp) { + public MethodGen copy(String class_name, ConstantPool cp) { Method m = ((MethodGen)clone()).getMethod(); MethodGen mg = new MethodGen(m, class_name, this.cp); @@ -1074,7 +1010,7 @@ public class MethodGen extends FieldGenOrMethodGen { */ public List getAnnotationsOnParameter(int i) { ensureExistingParameterAnnotationsUnpacked(); - if (!hasParameterAnnotations || i>arg_types.length) return null; + if (!hasParameterAnnotations || i>parameterTypes.length) return null; return param_annotations[i]; } @@ -1088,27 +1024,27 @@ public class MethodGen extends FieldGenOrMethodGen { private void ensureExistingParameterAnnotationsUnpacked() { if (haveUnpackedParameterAnnotations) return; // Find attributes that contain parameter annotation data - Attribute[] attrs = getAttributes(); + List attrs = getAttributes(); RuntimeParameterAnnotations paramAnnVisAttr = null; RuntimeParameterAnnotations paramAnnInvisAttr=null; List accumulatedAnnotations = new ArrayList(); - for (int i = 0; i < attrs.length; i++) { - Attribute attribute = attrs[i]; + for (int i = 0; i < attrs.size(); i++) { + Attribute attribute = (Attribute)attrs.get(i); if (attribute instanceof RuntimeParameterAnnotations) { // Initialize param_annotations if (!hasParameterAnnotations) { - param_annotations = new List[arg_types.length]; - for (int j=0;j<arg_types.length;j++) param_annotations[j]=new ArrayList(); + param_annotations = new List[parameterTypes.length]; + for (int j=0;j<parameterTypes.length;j++) param_annotations[j]=new ArrayList(); } hasParameterAnnotations = true; RuntimeParameterAnnotations rpa = (RuntimeParameterAnnotations)attribute; if (rpa.areVisible()) paramAnnVisAttr = rpa; else paramAnnInvisAttr=rpa; - for (int j=0; j<arg_types.length; j++) { + for (int j=0; j<parameterTypes.length; j++) { // This returns Annotation[] ... - Annotation[] immutableArray = rpa.getAnnotationsOnParameter(j); + AnnotationGen[] immutableArray = rpa.getAnnotationsOnParameter(j); // ... which needs transforming into an AnnotationGen[] ... List mutable = makeMutableVersion(immutableArray); // ... then add these to any we already know about @@ -1121,7 +1057,7 @@ public class MethodGen extends FieldGenOrMethodGen { haveUnpackedParameterAnnotations = true; } - private List /*AnnotationGen*/ makeMutableVersion(Annotation[] mutableArray) { + private List /*AnnotationGen*/ makeMutableVersion(AnnotationGen[] mutableArray) { List result = new ArrayList(); for (int i = 0; i < mutableArray.length; i++) { result.add(new AnnotationGen(mutableArray[i],getConstantPool(),false)); @@ -1132,7 +1068,7 @@ public class MethodGen extends FieldGenOrMethodGen { public void addParameterAnnotation(int parameterIndex, AnnotationGen annotation) { ensureExistingParameterAnnotationsUnpacked(); if (!hasParameterAnnotations) { - param_annotations = new List[arg_types.length]; + param_annotations = new List[parameterTypes.length]; hasParameterAnnotations = true; } List existingAnnotations = param_annotations[parameterIndex]; diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/MethodObserver.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/MethodObserver.java deleted file mode 100644 index 7cee06f64..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/MethodObserver.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Implement this interface if you're interested in changes to a MethodGen object - * and register yourself with addObserver(). - * - * @version $Id: MethodObserver.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public interface MethodObserver { - public void notify(MethodGen method); -} - diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/NEW.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/NEW.java deleted file mode 100644 index 323569595..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/NEW.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ -import org.aspectj.apache.bcel.ExceptionConstants; - -/** - * NEW - Create new object - * <PRE>Stack: ... -> ..., objectref</PRE> - * - * @version $Id: NEW.java,v 1.8 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class NEW extends CPInstruction - implements LoadClass, AllocationInstruction, ExceptionThrower, StackProducer { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - NEW() {} - - public NEW(int index) { - super(org.aspectj.apache.bcel.Constants.NEW, index); - } - - public Class[] getExceptions(){ - Class[] cs = new Class[2 + 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+1] = ExceptionConstants.INSTANTIATION_ERROR; - cs[ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length] = ExceptionConstants.ILLEGAL_ACCESS_ERROR; - - return cs; - } - - public ObjectType getLoadClassType(ConstantPoolGen cpg) { - return (ObjectType)getType(cpg); - } - - /** - * 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.visitNEW(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/NEWARRAY.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/NEWARRAY.java deleted file mode 100644 index 97d98dfdc..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/NEWARRAY.java +++ /dev/null @@ -1,140 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ -import java.io.*; -import org.aspectj.apache.bcel.util.ByteSequence; - -/** - * NEWARRAY - Create new array of basic type (int, short, ...) - * <PRE>Stack: ..., count -> ..., arrayref</PRE> - * type must be one of T_INT, T_SHORT, ... - * - * @version $Id: NEWARRAY.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class NEWARRAY extends Instruction - implements AllocationInstruction, ExceptionThrower, StackProducer { - private byte type; - - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - NEWARRAY() {} - - public NEWARRAY(byte type) { - super(org.aspectj.apache.bcel.Constants.NEWARRAY, (short)2); - this.type = type; - } - - public NEWARRAY(BasicType type) { - this(type.getType()); - } - - /** - * Dump instruction as byte code to stream out. - * @param out Output stream - */ - public void dump(DataOutputStream out) throws IOException { - out.writeByte(opcode); - out.writeByte(type); - } - - /** - * @return numeric code for basic element type - */ - public final byte getTypecode() { return type; } - - /** - * @return type of constructed array - */ - public final Type getType() { - return new ArrayType(BasicType.getType(type), 1); - } - - /** - * @return mnemonic for instruction - */ - public String toString(boolean verbose) { - return super.toString(verbose) + " " + org.aspectj.apache.bcel.Constants.TYPE_NAMES[type]; - } - /** - * Read needed data (e.g. index) from file. - */ - protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException - { - type = bytes.readByte(); - length = 2; - } - - public Class[] getExceptions() { - return new Class[] { org.aspectj.apache.bcel.ExceptionConstants.NEGATIVE_ARRAY_SIZE_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.visitAllocationInstruction(this); - v.visitExceptionThrower(this); - v.visitStackProducer(this); - v.visitNEWARRAY(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/NOP.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/NOP.java deleted file mode 100644 index b71de55c7..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/NOP.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * NOP - Do nothing - * - * @version $Id: NOP.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class NOP extends Instruction { - public NOP() { - super(org.aspectj.apache.bcel.Constants.NOP, (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.visitNOP(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ObjectType.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ObjectType.java index 19a59fdf2..cf3bb25e6 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ObjectType.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/ObjectType.java @@ -60,7 +60,7 @@ import org.aspectj.apache.bcel.classfile.JavaClass; /** * Denotes reference such as java.lang.String. * - * @version $Id: ObjectType.java,v 1.3 2006/07/19 12:06:16 aclement Exp $ + * @version $Id: ObjectType.java,v 1.4 2008/05/28 23:52:55 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public final class ObjectType extends ReferenceType { diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/POP.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/POP.java deleted file mode 100644 index 7c50e7283..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/POP.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * POP - Pop top operand stack word - * - * <PRE>Stack: ..., word -> ...</PRE> - * - * @version $Id: POP.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class POP extends StackInstruction implements PopInstruction { - public POP() { - super(org.aspectj.apache.bcel.Constants.POP); - } - - - /** - * 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.visitPopInstruction(this); - v.visitStackInstruction(this); - v.visitPOP(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/POP2.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/POP2.java deleted file mode 100644 index 109401b4b..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/POP2.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * POP2 - Pop two top operand stack words - * - * <PRE>Stack: ..., word2, word1 -> ...</PRE> - * - * @version $Id: POP2.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class POP2 extends StackInstruction implements PopInstruction { - public POP2() { - super(org.aspectj.apache.bcel.Constants.POP2); - } - - - /** - * 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.visitPopInstruction(this); - v.visitStackInstruction(this); - v.visitPOP2(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/PUSH.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/PUSH.java deleted file mode 100644 index ace01863b..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/PUSH.java +++ /dev/null @@ -1,199 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ -import org.aspectj.apache.bcel.Constants; - -/** - * Wrapper class for push operations, which are implemented either as BIPUSH, - * LDC or xCONST_n instructions. - * - * @version $Id: PUSH.java,v 1.9 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public final class PUSH - implements CompoundInstruction, VariableLengthInstruction, InstructionConstants -{ - private Instruction instruction; - - /** - * This constructor also applies for values of type short, char, byte - * - * @param cp Constant pool - * @param value to be pushed - */ - public PUSH(ConstantPoolGen cp, int value) { - if((value >= -1) && (value <= 5)) // Use ICONST_n - instruction = INSTRUCTIONS[Constants.ICONST_0 + value]; - else if((value >= -128) && (value <= 127)) // Use BIPUSH - instruction = new BIPUSH((byte)value); - else if((value >= -32768) && (value <= 32767)) // Use SIPUSH - instruction = new SIPUSH((short)value); - else // If everything fails create a Constant pool entry - instruction = new LDC(cp.addInteger(value)); - } - - public PUSH(ConstantPoolGen cp, ObjectType t) { - instruction = new LDC_W(cp.addClass(t)); - } - - /** - * @param cp Constant pool - * @param value to be pushed - */ - public PUSH(ConstantPoolGen cp, boolean value) { - instruction = INSTRUCTIONS[Constants.ICONST_0 + (value? 1 : 0)]; - } - - /** - * @param cp Constant pool - * @param value to be pushed - */ - public PUSH(ConstantPoolGen cp, float value) { - if(value == 0.0) - instruction = FCONST_0; - else if(value == 1.0) - instruction = FCONST_1; - else if(value == 2.0) - instruction = FCONST_2; - else // Create a Constant pool entry - instruction = new LDC(cp.addFloat(value)); - } - - /** - * @param cp Constant pool - * @param value to be pushed - */ - public PUSH(ConstantPoolGen cp, long value) { - if(value == 0) - instruction = LCONST_0; - else if(value == 1) - instruction = LCONST_1; - else // Create a Constant pool entry - instruction = new LDC2_W(cp.addLong(value)); - } - - /** - * @param cp Constant pool - * @param value to be pushed - */ - public PUSH(ConstantPoolGen cp, double value) { - if(value == 0.0) - instruction = DCONST_0; - else if(value == 1.0) - instruction = DCONST_1; - else // Create a Constant pool entry - instruction = new LDC2_W(cp.addDouble(value)); - } - - /** - * @param cp Constant pool - * @param value to be pushed - */ - public PUSH(ConstantPoolGen cp, String value) { - if(value == null) - instruction = ACONST_NULL; - else // Create a Constant pool entry - instruction = new LDC(cp.addString(value)); - } - - /** - * @param cp Constant pool - * @param value to be pushed - */ - public PUSH(ConstantPoolGen cp, Number value) { - if((value instanceof Integer) || (value instanceof Short) || (value instanceof Byte)) - instruction = new PUSH(cp, value.intValue()).instruction; - else if(value instanceof Double) - instruction = new PUSH(cp, value.doubleValue()).instruction; - else if(value instanceof Float) - instruction = new PUSH(cp, value.floatValue()).instruction; - else if(value instanceof Long) - instruction = new PUSH(cp, value.longValue()).instruction; - else - throw new ClassGenException("What's this: " + value); - } - - /** - * @param cp Constant pool - * @param value to be pushed - */ - public PUSH(ConstantPoolGen cp, Character value) { - this(cp, (int)value.charValue()); - } - - /** - * @param cp Constant pool - * @param value to be pushed - */ - public PUSH(ConstantPoolGen cp, Boolean value) { - this(cp, value.booleanValue()); - } - - public final InstructionList getInstructionList() { - return new InstructionList(instruction); - } - - public final Instruction getInstruction() { - return instruction; - } - - /** - * @return mnemonic for instruction - */ - public String toString() { - return instruction.toString() + " (PUSH)"; - } -} - diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/PUTFIELD.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/PUTFIELD.java deleted file mode 100644 index 4618d8853..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/PUTFIELD.java +++ /dev/null @@ -1,118 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -import org.aspectj.apache.bcel.Constants; -import org.aspectj.apache.bcel.ExceptionConstants; - -/** - * PUTFIELD - Put field in object - * <PRE>Stack: ..., objectref, value -> ...</PRE> - * OR - * <PRE>Stack: ..., objectref, value.word1, value.word2 -> ...</PRE> - * - * @version $Id: PUTFIELD.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class PUTFIELD - extends FieldInstruction - implements PopInstruction,ExceptionThrower{ - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - PUTFIELD() {} - - public PUTFIELD(int index) { - super(Constants.PUTFIELD, index); - } - - public int consumeStack(ConstantPoolGen cpg) { return getFieldSize(cpg) + 1; } - - public Class[] getExceptions() { - Class[] cs = new Class[2 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length]; - - System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0, - cs, 0, ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length); - - cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length+1] = - ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR; - cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] = - ExceptionConstants.NULL_POINTER_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.visitExceptionThrower(this); - v.visitStackConsumer(this); - v.visitPopInstruction(this); - v.visitTypedInstruction(this); - v.visitLoadClass(this); - v.visitCPInstruction(this); - v.visitFieldOrMethod(this); - v.visitFieldInstruction(this); - v.visitPUTFIELD(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/PUTSTATIC.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/PUTSTATIC.java deleted file mode 100644 index d867a6669..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/PUTSTATIC.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -import org.aspectj.apache.bcel.Constants; -import org.aspectj.apache.bcel.ExceptionConstants; - -/** - * PUTSTATIC - Put static field in class - * <PRE>Stack: ..., value -> ...</PRE> - * OR - * <PRE>Stack: ..., value.word1, value.word2 -> ...</PRE> - * - * @version $Id: PUTSTATIC.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class PUTSTATIC extends FieldInstruction - implements ExceptionThrower, PopInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - PUTSTATIC() {} - - public PUTSTATIC(int index) { - super(Constants.PUTSTATIC, index); - } - - public int consumeStack(ConstantPoolGen cpg) { return getFieldSize(cpg); } - - public Class[] getExceptions() { - Class[] cs = new Class[1 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length]; - - System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0, - cs, 0, ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length); - cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] = - ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR; - - 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.visitExceptionThrower(this); - v.visitStackConsumer(this); - v.visitPopInstruction(this); - v.visitTypedInstruction(this); - v.visitLoadClass(this); - v.visitCPInstruction(this); - v.visitFieldOrMethod(this); - v.visitFieldInstruction(this); - v.visitPUTSTATIC(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/PopInstruction.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/PopInstruction.java deleted file mode 100644 index 5e334d652..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/PopInstruction.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Denotes an unparameterized instruction to pop a value on top from the stack, - * such as ISTORE, POP, PUTSTATIC. - * - * @version $Id: PopInstruction.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - * @see ISTORE - * @see POP - */ -public interface PopInstruction extends StackConsumer { -} - diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/PushInstruction.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/PushInstruction.java deleted file mode 100644 index 28462d10c..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/PushInstruction.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Denotes an unparameterized instruction to produce a value on top of the stack, - * such as ILOAD, LDC, SIPUSH, DUP, ICONST, etc. - * - * @version $Id: PushInstruction.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - - * @see ILOAD - * @see ICONST - * @see LDC - * @see DUP - * @see SIPUSH - * @see GETSTATIC - */ -public interface PushInstruction extends StackProducer { -} - diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/RET.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/RET.java index 39f374997..1bb6b843f 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/RET.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/RET.java @@ -54,108 +54,53 @@ package org.aspectj.apache.bcel.generic; * <http://www.apache.org/>. */ import java.io.*; -import org.aspectj.apache.bcel.util.ByteSequence; + +import org.aspectj.apache.bcel.Constants; +import org.aspectj.apache.bcel.classfile.ConstantPool; /** * RET - Return from subroutine * * <PRE>Stack: ..., -> ..., address</PRE> * - * @version $Id: RET.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: RET.java,v 1.3 2008/05/28 23:53:00 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ -public class RET extends Instruction implements IndexedInstruction, TypedInstruction { +public class RET extends Instruction { private boolean wide; private int index; // index to local variable containg the return address - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - RET() {} - public RET(int index) { - super(org.aspectj.apache.bcel.Constants.RET, (short)2); - setIndex(index); // May set wide as side effect + public RET(int index,boolean wide) { + super(Constants.RET); + this.index = index; + this.wide = wide; + //this.wide = index > org.aspectj.apache.bcel.Constants.MAX_BYTE; } - /** - * Dump instruction as byte code to stream out. - * @param out Output stream - */ public void dump(DataOutputStream out) throws IOException { - if(wide) - out.writeByte(org.aspectj.apache.bcel.Constants.WIDE); - + if (wide) out.writeByte(org.aspectj.apache.bcel.Constants.WIDE); out.writeByte(opcode); - - if(wide) - out.writeShort(index); - else - out.writeByte(index); + if(wide) out.writeShort(index); + else out.writeByte(index); } - private final void setWide() { - if(wide = index > org.aspectj.apache.bcel.Constants.MAX_BYTE) - length = 4; // Including the wide byte - else - length = 2; + public int getLength() { + if (wide) return 4; else return 2; } - /** - * Read needed data (e.g. index) from file. - */ - protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException - { - this.wide = wide; - - if(wide) { - index = bytes.readUnsignedShort(); - length = 4; - } else { - index = bytes.readUnsignedByte(); - length = 2; - } - } - - /** - * @return index of local variable containg the return address - */ public final int getIndex() { return index; } - - /** - * Set index of local variable containg the return address - */ - public final void setIndex(int n) { - if(n < 0) - throw new ClassGenException("Negative index value: " + n); - - index = n; - setWide(); + public final void setIndex(int index) { + this.index = index; + this.wide = index > org.aspectj.apache.bcel.Constants.MAX_BYTE; } - /** - * @return mnemonic for instruction - */ public String toString(boolean verbose) { return super.toString(verbose) + " " + index; } - /** @return return address type - */ - public Type getType(ConstantPoolGen cp) { + public Type getType(ConstantPool cp) { return ReturnaddressType.NO_TARGET; } - /** - * 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.visitRET(this); - } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/RETURN.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/RETURN.java deleted file mode 100644 index 6fc7b7cae..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/RETURN.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * RETURN - Return from void method - * <PRE>Stack: ... -> <empty></PRE> - * - * @version $Id: RETURN.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class RETURN extends ReturnInstruction { - public RETURN() { - super(org.aspectj.apache.bcel.Constants.RETURN); - } - - - /** - * 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.visitRETURN(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ReferenceType.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ReferenceType.java index 13a8d6358..743e7b9c5 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ReferenceType.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/ReferenceType.java @@ -61,7 +61,7 @@ import org.aspectj.apache.bcel.classfile.JavaClass; /** * Super class for object and array types. * - * @version $Id: ReferenceType.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: ReferenceType.java,v 1.3 2008/05/28 23:52:58 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public abstract class ReferenceType extends Type { diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ReturnInstruction.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ReturnInstruction.java deleted file mode 100644 index 20f8dcea2..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ReturnInstruction.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ -import org.aspectj.apache.bcel.Constants; -import org.aspectj.apache.bcel.ExceptionConstants; - -/** - * Super class for the xRETURN family of instructions. - * - * @version $Id: ReturnInstruction.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public abstract class ReturnInstruction extends Instruction - implements ExceptionThrower, TypedInstruction, StackConsumer { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - ReturnInstruction() {} - - /** - * @param opcode of instruction - */ - protected ReturnInstruction(short opcode) { - super(opcode, (short)1); - } - - public Type getType() { - switch(opcode) { - case Constants.IRETURN: return Type.INT; - case Constants.LRETURN: return Type.LONG; - case Constants.FRETURN: return Type.FLOAT; - case Constants.DRETURN: return Type.DOUBLE; - case Constants.ARETURN: return Type.OBJECT; - case Constants.RETURN: return Type.VOID; - - default: // Never reached - throw new ClassGenException("Unknown type " + opcode); - } - } - - public Class[] getExceptions() { - return new Class[] { ExceptionConstants.ILLEGAL_MONITOR_STATE }; - } - - /** @return type associated with the instruction - */ - public Type getType(ConstantPoolGen cp) { - return getType(); - } -} - diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ReturnaddressType.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ReturnaddressType.java index 0b1c6a418..45ffae9b7 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ReturnaddressType.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/ReturnaddressType.java @@ -60,7 +60,7 @@ import org.aspectj.apache.bcel.generic.InstructionHandle; * Returnaddress, the type JSR or JSR_W instructions push upon the stack. * * see vmspec2 §3.3.3 - * @version $Id: ReturnaddressType.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: ReturnaddressType.java,v 1.3 2008/05/28 23:52:56 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase">Enver Haase</A> */ public class ReturnaddressType extends Type { diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/SALOAD.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/SALOAD.java deleted file mode 100644 index 8902d3489..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/SALOAD.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * SALOAD - Load short from array - * <PRE>Stack: ..., arrayref, index -> ..., value</PRE> - * - * @version $Id: SALOAD.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class SALOAD extends ArrayInstruction implements StackProducer { - public SALOAD() { - super(org.aspectj.apache.bcel.Constants.SALOAD); - } - - - /** - * 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.visitSALOAD(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/SASTORE.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/SASTORE.java deleted file mode 100644 index a98ef3764..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/SASTORE.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * SASTORE - Store into short array - * <PRE>Stack: ..., arrayref, index, value -> ...</PRE> - * - * @version $Id: SASTORE.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class SASTORE extends ArrayInstruction implements StackConsumer { - public SASTORE() { - super(org.aspectj.apache.bcel.Constants.SASTORE); - } - - - /** - * 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.visitSASTORE(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/SIPUSH.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/SIPUSH.java deleted file mode 100644 index 9f5eeb5ab..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/SIPUSH.java +++ /dev/null @@ -1,128 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ -import java.io.*; -import org.aspectj.apache.bcel.util.ByteSequence; - -/** - * SIPUSH - Push short - * - * <PRE>Stack: ... -> ..., value</PRE> - * - * @version $Id: SIPUSH.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class SIPUSH extends Instruction implements ConstantPushInstruction { - private short b; - - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - SIPUSH() {} - - public SIPUSH(short b) { - super(org.aspectj.apache.bcel.Constants.SIPUSH, (short)3); - this.b = b; - } - - /** - * Dump instruction as short code to stream out. - */ - public void dump(DataOutputStream out) throws IOException { - super.dump(out); - out.writeShort(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 = 3; - b = bytes.readShort(); - } - - public Number getValue() { return new Integer(b); } - - /** @return Type.SHORT - */ - public Type getType(ConstantPoolGen cp) { - return Type.SHORT; - } - - /** - * 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.visitSIPUSH(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/SWAP.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/SWAP.java deleted file mode 100644 index 831741a22..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/SWAP.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * SWAP - Swa top operand stack word - * <PRE>Stack: ..., word2, word1 -> ..., word1, word2</PRE> - * - * @version $Id: SWAP.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public class SWAP extends StackInstruction implements StackConsumer, StackProducer { - public SWAP() { - super(org.aspectj.apache.bcel.Constants.SWAP); - } - - - /** - * 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.visitStackProducer(this); - v.visitStackInstruction(this); - v.visitSWAP(this); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/StackConsumer.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/StackConsumer.java deleted file mode 100644 index f9b00c244..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/StackConsumer.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Denote an instruction that may consume a value from the stack. - * - * @version $Id: StackConsumer.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public interface StackConsumer { - /** @return how many words are consumed from stack - */ - public int consumeStack(ConstantPoolGen cpg); -} - diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/StackInstruction.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/StackInstruction.java deleted file mode 100644 index 041e22693..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/StackInstruction.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Super class for stack operations like DUP and POP. - * - * @version $Id: StackInstruction.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public abstract class StackInstruction extends Instruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - StackInstruction() {} - - /** - * @param opcode instruction opcode - */ - protected StackInstruction(short opcode) { - super(opcode, (short)1); - } - - /** @return Type.UNKNOWN - */ - public Type getType(ConstantPoolGen cp) { - return Type.UNKNOWN; - } -} - diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/StackProducer.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/StackProducer.java deleted file mode 100644 index 22325c804..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/StackProducer.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Denote an instruction that may produce a value on top of the stack - * (this excludes DUP_X1, e.g.) - * - * @version $Id: StackProducer.java,v 1.6 2008/04/25 17:58:20 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public interface StackProducer { - /** @return how many words are produced on stack - */ - public int produceStack(ConstantPoolGen cpg); -} - diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/StoreInstruction.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/StoreInstruction.java deleted file mode 100644 index f136372d7..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/StoreInstruction.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Denotes an unparameterized instruction to store a value into a local variable, - * e.g. ISTORE. - * - * @version $Id: StoreInstruction.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public abstract class StoreInstruction extends LocalVariableInstruction - implements PopInstruction -{ - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - * tag and length are defined in readInstruction and initFromFile, respectively. - */ - StoreInstruction(short canon_tag, short c_tag) { - super(canon_tag, c_tag); - } - - /** - * @param opcode Instruction opcode - * @param c_tag Instruction number for compact version, ASTORE_0, e.g. - * @param n local variable index (unsigned short) - */ - protected StoreInstruction(short opcode, short c_tag, int n) { - super(opcode, c_tag, 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) { - v.visitStackConsumer(this); - v.visitPopInstruction(this); - v.visitTypedInstruction(this); - v.visitLocalVariableInstruction(this); - v.visitStoreInstruction(this); - } -} - diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/SWITCH.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/SwitchBuilder.java index 089aa5873..eac6bf364 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/SWITCH.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/SwitchBuilder.java @@ -59,13 +59,13 @@ package org.aspectj.apache.bcel.generic; * TABLESWITCH instruction, depending on whether the match values (int[]) can be * sorted with no gaps between the numbers. * - * @version $Id: SWITCH.java,v 1.8 2008/04/25 17:58:21 aclement Exp $ + * @version $Id: SwitchBuilder.java,v 1.2 2008/05/28 23:52:57 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ -public final class SWITCH implements CompoundInstruction { +public final class SwitchBuilder { private int[] match; private InstructionHandle[] targets; - private Select instruction; + private InstructionSelect instruction; private int match_length; /** @@ -83,8 +83,7 @@ public final class SWITCH implements CompoundInstruction { * @param target the default target * @param max_gap maximum gap that may between case branches */ - public SWITCH(int[] match, InstructionHandle[] targets, - InstructionHandle target, int max_gap) { + public SwitchBuilder(int[] match, InstructionHandle[] targets,InstructionHandle target, int max_gap) { this.match = (int[])match.clone(); this.targets = (InstructionHandle[])targets.clone(); @@ -107,8 +106,7 @@ public final class SWITCH implements CompoundInstruction { } } - public SWITCH(int[] match, InstructionHandle[] targets, - InstructionHandle target) { + public SwitchBuilder(int[] match, InstructionHandle[] targets, InstructionHandle target) { this(match, targets, target, 1); } @@ -177,11 +175,7 @@ public final class SWITCH implements CompoundInstruction { return true; } - public final InstructionList getInstructionList() { - return new InstructionList(instruction); - } - - public final Instruction getInstruction() { + public final InstructionSelect getInstruction() { return instruction; } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/TABLESWITCH.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/TABLESWITCH.java index e40ef6890..9769db4b0 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/TABLESWITCH.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/TABLESWITCH.java @@ -54,21 +54,19 @@ package org.aspectj.apache.bcel.generic; * <http://www.apache.org/>. */ import java.io.*; + +import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.util.ByteSequence; /** * TABLESWITCH - Switch within given range of values, i.e., low..high * - * @version $Id: TABLESWITCH.java,v 1.3 2005/08/25 11:35:49 aclement Exp $ + * @version $Id: TABLESWITCH.java,v 1.4 2008/05/28 23:52:54 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see SWITCH */ -public class TABLESWITCH extends Select { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - TABLESWITCH() {} +public class TABLESWITCH extends InstructionSelect { + /** * @param match sorted array of match values, match[0] must be low value, @@ -84,9 +82,9 @@ public class TABLESWITCH extends Select { // throw new RuntimeException("A tableswitch with no targets should be represented as a LOOKUPSWITCH"); // } - length = (short)(13 + match_length * 4); /* Alignment remainder assumed + length = (short)(13 + matchLength * 4); /* Alignment remainder assumed * 0 here, until dump time */ - fixed_length = length; + fixedLength = length; } /** @@ -96,59 +94,43 @@ public class TABLESWITCH extends Select { public void dump(DataOutputStream out) throws IOException { super.dump(out); - int low = (match_length > 0)? match[0] : 0; + int low = (matchLength > 0)? match[0] : 0; out.writeInt(low); - int high = (match_length > 0)? match[match_length - 1] : 0; + int high = (matchLength > 0)? match[matchLength - 1] : 0; out.writeInt(high); // See aj bug pr104720 // if (match_length==0) out.writeInt(0); // following the switch you need to supply "HIGH-LOW+1" entries - for(int i=0; i < match_length; i++) // jump offsets + for(int i=0; i < matchLength; i++) // jump offsets out.writeInt(indices[i] = getTargetOffset(targets[i])); } /** * Read needed data (e.g. index) from file. */ - protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException + public TABLESWITCH(ByteSequence bytes) throws IOException { - super.initFromFile(bytes, wide); + super(Constants.TABLESWITCH,bytes); int low = bytes.readInt(); int high = bytes.readInt(); - match_length = high - low + 1; - fixed_length = (short)(13 + match_length * 4); - length = (short)(fixed_length + padding); + matchLength = high - low + 1; + fixedLength = (short)(13 + matchLength * 4); + length = (short)(fixedLength + padding); - match = new int[match_length]; - indices = new int[match_length]; - targets = new InstructionHandle[match_length]; + match = new int[matchLength]; + indices = new int[matchLength]; + targets = new InstructionHandle[matchLength]; for(int i=low; i <= high; i++) match[i - low] = i; - for(int i=0; i < match_length; i++) { + for(int i=0; i < matchLength; i++) { indices[i] = bytes.readInt(); } } - - /** - * 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.visitVariableLengthInstruction(this); - v.visitStackProducer(this); - v.visitBranchInstruction(this); - v.visitSelect(this); - v.visitTABLESWITCH(this); - } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/Tag.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/Tag.java index 3220dd6d9..15b39473a 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/Tag.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/Tag.java @@ -11,11 +11,11 @@ * Andy Clement pushed down into bcel module * ******************************************************************/ - package org.aspectj.apache.bcel.generic; - -/** A tag is an instruction-targeter that doesn't bother remembering its target(s) */ +/** + * A tag is an instruction-targeter that does not remember its target + */ public abstract class Tag implements InstructionTargeter, Cloneable { public Tag() { @@ -26,10 +26,11 @@ public abstract class Tag implements InstructionTargeter, Cloneable { return false; } - public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) { - old_ih.removeTargeter(this); - if (new_ih != null) - new_ih.addTargeter(this); + public void updateTarget(InstructionHandle oldHandle, InstructionHandle newHandle) { + oldHandle.removeTargeter(this); + if (newHandle != null) { + newHandle.addTargeter(this); + } } public Tag copy() { diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/TargetLostException.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/TargetLostException.java index e72394da4..3a195705c 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/TargetLostException.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/TargetLostException.java @@ -82,9 +82,10 @@ package org.aspectj.apache.bcel.generic; * @see InstructionHandle * @see InstructionList * @see InstructionTargeter - * @version $Id: TargetLostException.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: TargetLostException.java,v 1.3 2008/05/28 23:52:55 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ +// OPTIMIZE make unchecked, or get rid of it! public final class TargetLostException extends Exception { private InstructionHandle[] targets; diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/Type.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/Type.java index 7ea02cb45..efb930059 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/Type.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/Type.java @@ -65,7 +65,7 @@ import org.aspectj.apache.bcel.classfile.Utility; * Abstract super class for all possible java types, namely basic types * such as int, object types like String and array types, e.g. int[] * - * @version $Id: Type.java,v 1.7 2006/07/19 12:06:17 aclement Exp $ + * @version $Id: Type.java,v 1.8 2008/05/28 23:52:56 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * * modified: @@ -113,10 +113,12 @@ public abstract class Type implements java.io.Serializable { */ public int getSize() { switch(type) { - case Constants.T_DOUBLE: - case Constants.T_LONG: return 2; - case Constants.T_VOID: return 0; - default: return 1; + case Constants.T_DOUBLE: case Constants.T_LONG: + return 2; + case Constants.T_VOID: + return 0; + default: + return 1; } } @@ -139,24 +141,19 @@ public abstract class Type implements java.io.Serializable { public static String getMethodSignature(Type return_type, Type[] arg_types) { StringBuffer buf = new StringBuffer("("); int length = (arg_types == null)? 0 : arg_types.length; - - for(int i=0; i < length; i++) + for(int i=0; i < length; i++) { buf.append(arg_types[i].getSignature()); + } buf.append(')'); buf.append(return_type.getSignature()); - return buf.toString(); } - - // private static int consumed_chars=0; // Remember position in string, see getArgumentTypes - public static final Type getType(String signature) { TypeHolder th = getTypeInternal(signature); return th.getType(); } - /** * Convert signature to a Type object. * @param signature signature string such as Ljava/lang/String; @@ -224,6 +221,7 @@ public abstract class Type implements java.io.Serializable { * @param signature signature string such as (Ljava/lang/String;)V * @return array of argument types */ + // OPTIMIZE crap impl public static Type[] getArgumentTypes(String signature) { ArrayList vec = new ArrayList(); int index; diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/TypedInstruction.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/TypedInstruction.java deleted file mode 100644 index 7867831c3..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/TypedInstruction.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Get the type associated with an instruction, int for ILOAD, or the type - * of the field of a PUTFIELD instruction, e.g.. - * - * @version $Id: TypedInstruction.java,v 1.6 2008/04/25 17:58:21 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public interface TypedInstruction { - public Type getType(ConstantPoolGen cpg); -} - diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/UnconditionalBranch.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/UnconditionalBranch.java deleted file mode 100644 index e457ac691..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/UnconditionalBranch.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Denotes an instruction to perform an unconditional branch, i.e., GOTO, JSR. - * - * @version $Id: UnconditionalBranch.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - - * @see GOTO - * @see JSR - */ -public interface UnconditionalBranch {} - diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/VariableLengthInstruction.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/VariableLengthInstruction.java deleted file mode 100644 index 34e7b03b1..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/VariableLengthInstruction.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Denotes an instruction to be a variable length instruction, such as - * GOTO, JSR, LOOKUPSWITCH and TABLESWITCH. - * - * @version $Id: VariableLengthInstruction.java,v 1.6 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - - * @see GOTO - * @see JSR - * @see LOOKUPSWITCH - * @see TABLESWITCH - */ -public interface VariableLengthInstruction {} - diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/Visitor.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/Visitor.java deleted file mode 100644 index 91024133e..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/Visitor.java +++ /dev/null @@ -1,247 +0,0 @@ -package org.aspectj.apache.bcel.generic; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * Interface implementing the Visitor pattern programming style. - * I.e., a class that implements this interface can handle all types of - * instructions with the properly typed methods just by calling the accept() - * method. - * - * @version $Id: Visitor.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - */ -public interface Visitor { - public void visitStackInstruction(StackInstruction obj); - public void visitLocalVariableInstruction(LocalVariableInstruction obj); - public void visitBranchInstruction(BranchInstruction obj); - public void visitLoadClass(LoadClass obj); - public void visitFieldInstruction(FieldInstruction obj); - public void visitIfInstruction(IfInstruction obj); - public void visitConversionInstruction(ConversionInstruction obj); - public void visitPopInstruction(PopInstruction obj); - public void visitStoreInstruction(StoreInstruction obj); - public void visitTypedInstruction(TypedInstruction obj); - public void visitSelect(Select obj); - public void visitJsrInstruction(JsrInstruction obj); - public void visitGotoInstruction(GotoInstruction obj); - public void visitUnconditionalBranch(UnconditionalBranch obj); - public void visitPushInstruction(PushInstruction obj); - public void visitArithmeticInstruction(ArithmeticInstruction obj); - public void visitCPInstruction(CPInstruction obj); - public void visitInvokeInstruction(InvokeInstruction obj); - public void visitArrayInstruction(ArrayInstruction obj); - public void visitAllocationInstruction(AllocationInstruction obj); - public void visitReturnInstruction(ReturnInstruction obj); - public void visitFieldOrMethod(FieldOrMethod obj); - public void visitConstantPushInstruction(ConstantPushInstruction obj); - public void visitExceptionThrower(ExceptionThrower obj); - public void visitLoadInstruction(LoadInstruction obj); - public void visitVariableLengthInstruction(VariableLengthInstruction obj); - public void visitStackProducer(StackProducer obj); - public void visitStackConsumer(StackConsumer obj); - public void visitACONST_NULL(ACONST_NULL obj); - public void visitGETSTATIC(GETSTATIC obj); - public void visitIF_ICMPLT(IF_ICMPLT obj); - public void visitMONITOREXIT(MONITOREXIT obj); - public void visitIFLT(IFLT obj); - public void visitLSTORE(LSTORE obj); - public void visitPOP2(POP2 obj); - public void visitBASTORE(BASTORE obj); - public void visitISTORE(ISTORE obj); - public void visitCHECKCAST(CHECKCAST obj); - public void visitFCMPG(FCMPG obj); - public void visitI2F(I2F obj); - public void visitATHROW(ATHROW obj); - public void visitDCMPL(DCMPL obj); - public void visitARRAYLENGTH(ARRAYLENGTH obj); - public void visitDUP(DUP obj); - public void visitINVOKESTATIC(INVOKESTATIC obj); - public void visitLCONST(LCONST obj); - public void visitDREM(DREM obj); - public void visitIFGE(IFGE obj); - public void visitCALOAD(CALOAD obj); - public void visitLASTORE(LASTORE obj); - public void visitI2D(I2D obj); - public void visitDADD(DADD obj); - public void visitINVOKESPECIAL(INVOKESPECIAL obj); - public void visitIAND(IAND obj); - public void visitPUTFIELD(PUTFIELD obj); - public void visitILOAD(ILOAD obj); - public void visitDLOAD(DLOAD obj); - public void visitDCONST(DCONST obj); - public void visitNEW(NEW obj); - public void visitIFNULL(IFNULL obj); - public void visitLSUB(LSUB obj); - public void visitL2I(L2I obj); - public void visitISHR(ISHR obj); - public void visitTABLESWITCH(TABLESWITCH obj); - public void visitIINC(IINC obj); - public void visitDRETURN(DRETURN obj); - public void visitFSTORE(FSTORE obj); - public void visitDASTORE(DASTORE obj); - public void visitIALOAD(IALOAD obj); - public void visitDDIV(DDIV obj); - public void visitIF_ICMPGE(IF_ICMPGE obj); - public void visitLAND(LAND obj); - public void visitIDIV(IDIV obj); - public void visitLOR(LOR obj); - public void visitCASTORE(CASTORE obj); - public void visitFREM(FREM obj); - public void visitLDC(LDC obj); - public void visitBIPUSH(BIPUSH obj); - public void visitDSTORE(DSTORE obj); - public void visitF2L(F2L obj); - public void visitFMUL(FMUL obj); - public void visitLLOAD(LLOAD obj); - public void visitJSR(JSR obj); - public void visitFSUB(FSUB obj); - public void visitSASTORE(SASTORE obj); - public void visitALOAD(ALOAD obj); - public void visitDUP2_X2(DUP2_X2 obj); - public void visitRETURN(RETURN obj); - public void visitDALOAD(DALOAD obj); - public void visitSIPUSH(SIPUSH obj); - public void visitDSUB(DSUB obj); - public void visitL2F(L2F obj); - public void visitIF_ICMPGT(IF_ICMPGT obj); - public void visitF2D(F2D obj); - public void visitI2L(I2L obj); - public void visitIF_ACMPNE(IF_ACMPNE obj); - public void visitPOP(POP obj); - public void visitI2S(I2S obj); - public void visitIFEQ(IFEQ obj); - public void visitSWAP(SWAP obj); - public void visitIOR(IOR obj); - public void visitIREM(IREM obj); - public void visitIASTORE(IASTORE obj); - public void visitNEWARRAY(NEWARRAY obj); - public void visitINVOKEINTERFACE(INVOKEINTERFACE obj); - public void visitINEG(INEG obj); - public void visitLCMP(LCMP obj); - public void visitJSR_W(JSR_W obj); - public void visitMULTIANEWARRAY(MULTIANEWARRAY obj); - public void visitDUP_X2(DUP_X2 obj); - public void visitSALOAD(SALOAD obj); - public void visitIFNONNULL(IFNONNULL obj); - public void visitDMUL(DMUL obj); - public void visitIFNE(IFNE obj); - public void visitIF_ICMPLE(IF_ICMPLE obj); - public void visitLDC2_W(LDC2_W obj); - public void visitGETFIELD(GETFIELD obj); - public void visitLADD(LADD obj); - public void visitNOP(NOP obj); - public void visitFALOAD(FALOAD obj); - public void visitINSTANCEOF(INSTANCEOF obj); - public void visitIFLE(IFLE obj); - public void visitLXOR(LXOR obj); - public void visitLRETURN(LRETURN obj); - public void visitFCONST(FCONST obj); - public void visitIUSHR(IUSHR obj); - public void visitBALOAD(BALOAD obj); - public void visitDUP2(DUP2 obj); - public void visitIF_ACMPEQ(IF_ACMPEQ obj); - public void visitIMPDEP1(IMPDEP1 obj); - public void visitMONITORENTER(MONITORENTER obj); - public void visitLSHL(LSHL obj); - public void visitDCMPG(DCMPG obj); - public void visitD2L(D2L obj); - public void visitIMPDEP2(IMPDEP2 obj); - public void visitL2D(L2D obj); - public void visitRET(RET obj); - public void visitIFGT(IFGT obj); - public void visitIXOR(IXOR obj); - public void visitINVOKEVIRTUAL(INVOKEVIRTUAL obj); - public void visitFASTORE(FASTORE obj); - public void visitIRETURN(IRETURN obj); - public void visitIF_ICMPNE(IF_ICMPNE obj); - public void visitFLOAD(FLOAD obj); - public void visitLDIV(LDIV obj); - public void visitPUTSTATIC(PUTSTATIC obj); - public void visitAALOAD(AALOAD obj); - public void visitD2I(D2I obj); - public void visitIF_ICMPEQ(IF_ICMPEQ obj); - public void visitAASTORE(AASTORE obj); - public void visitARETURN(ARETURN obj); - public void visitDUP2_X1(DUP2_X1 obj); - public void visitFNEG(FNEG obj); - public void visitGOTO_W(GOTO_W obj); - public void visitD2F(D2F obj); - public void visitGOTO(GOTO obj); - public void visitISUB(ISUB obj); - public void visitF2I(F2I obj); - public void visitDNEG(DNEG obj); - public void visitICONST(ICONST obj); - public void visitFDIV(FDIV obj); - public void visitI2B(I2B obj); - public void visitLNEG(LNEG obj); - public void visitLREM(LREM obj); - public void visitIMUL(IMUL obj); - public void visitIADD(IADD obj); - public void visitLSHR(LSHR obj); - public void visitLOOKUPSWITCH(LOOKUPSWITCH obj); - public void visitDUP_X1(DUP_X1 obj); - public void visitFCMPL(FCMPL obj); - public void visitI2C(I2C obj); - public void visitLMUL(LMUL obj); - public void visitLUSHR(LUSHR obj); - public void visitISHL(ISHL obj); - public void visitLALOAD(LALOAD obj); - public void visitASTORE(ASTORE obj); - public void visitANEWARRAY(ANEWARRAY obj); - public void visitFRETURN(FRETURN obj); - public void visitFADD(FADD obj); - public void visitBREAKPOINT(BREAKPOINT obj); -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/ArrayElementValueGen.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/ArrayElementValueGen.java deleted file mode 100644 index e7d216655..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/ArrayElementValueGen.java +++ /dev/null @@ -1,100 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2004 IBM - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andy Clement - initial implementation {date} - * ******************************************************************/ - -package org.aspectj.apache.bcel.generic.annotation; - -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.aspectj.apache.bcel.classfile.annotation.ArrayElementValue; -import org.aspectj.apache.bcel.classfile.annotation.ElementValue; -import org.aspectj.apache.bcel.generic.ConstantPoolGen; - - -public class ArrayElementValueGen extends ElementValueGen { - - // J5TODO: Should we make this an array or a list? A list would be easier to modify ... - private List /*ElementValueGen*/ evalues; - - public ArrayElementValueGen(ConstantPoolGen cp) { - super(ARRAY,cp); - evalues = new ArrayList(); - } - - public ArrayElementValueGen(int type, ElementValueGen[] datums, ConstantPoolGen cpool) { - super(type,cpool); - if (type != ARRAY) - throw new RuntimeException("Only element values of type array can be built with this ctor"); - this.evalues = new ArrayList(); - for (int i = 0; i < datums.length; i++) { - evalues.add(datums[i]); - } - } - - /** - * Return immutable variant of this ArrayElementValueGen - */ - public ElementValue getElementValue() { - ElementValue[] immutableData = new ElementValue[evalues.size()]; - int i =0; - for (Iterator iter = evalues.iterator(); iter.hasNext();) { - ElementValueGen element = (ElementValueGen) iter.next(); - immutableData[i++] = element.getElementValue(); - } - return new ArrayElementValue(type,immutableData,cpGen.getConstantPool()); - } - - /** - * @param value - * @param cpool - */ - public ArrayElementValueGen(ArrayElementValue value, ConstantPoolGen cpool,boolean copyPoolEntries) { - super(ARRAY,cpool); - evalues = new ArrayList(); - ElementValue[] in = value.getElementValuesArray(); - for (int i = 0; i < in.length; i++) { - evalues.add(ElementValueGen.copy(in[i],cpool,copyPoolEntries)); - } - } - - public void dump(DataOutputStream dos) throws IOException { - dos.writeByte(type); // u1 type of value (ARRAY == '[') - dos.writeShort(evalues.size()); - for (Iterator iter = evalues.iterator(); iter.hasNext();) { - ElementValueGen element = (ElementValueGen) iter.next(); - element.dump(dos); - } - } - - public String stringifyValue() { - StringBuffer sb = new StringBuffer(); - sb.append("["); - for (Iterator iter = evalues.iterator(); iter.hasNext();) { - ElementValueGen element = (ElementValueGen) iter.next(); - sb.append(element.stringifyValue()); - if (iter.hasNext()) sb.append(","); - } - sb.append("]"); - return sb.toString(); - } - - public List getElementValues() { return evalues;} - public int getElementValuesSize() { return evalues.size();} - - public void addElement(ElementValueGen gen) { - evalues.add(gen); - } - -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/package.html b/bcel-builder/src/org/aspectj/apache/bcel/generic/package.html deleted file mode 100644 index 961290d83..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/package.html +++ /dev/null @@ -1,16 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- -$Id: package.html,v 1.6 2008/04/25 17:58:21 aclement Exp $ ---> -</head> -<body bgcolor="white"> -<p> -This package contains the "generic" part of the -<a href="http://jakarta.apache.org/bcel/">Byte Code Engineering -Library</a>, i.e., classes to dynamically modify class objects and -byte code instructions. -</p> -</body> -</html> diff --git a/bcel-builder/src/org/aspectj/apache/bcel/package.html b/bcel-builder/src/org/aspectj/apache/bcel/package.html deleted file mode 100644 index 5af36c65a..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/package.html +++ /dev/null @@ -1,17 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- -$Id: package.html,v 1.6 2008/04/25 17:58:27 aclement Exp $ ---> -</head> -<body bgcolor="white"> -<p> -This package contains basic classes for the -<a href="http://jakarta.apache.org/bcel/">Byte Code Engineering Library</a> - and constants defined by the -<a href="http://www.javasoft.com/docs/books/vmspec/index.html"> - JVM specification</a>. -</p> -</body> -</html> diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/AttributeHTML.java b/bcel-builder/src/org/aspectj/apache/bcel/util/AttributeHTML.java deleted file mode 100644 index e29b89888..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/AttributeHTML.java +++ /dev/null @@ -1,272 +0,0 @@ -package org.aspectj.apache.bcel.util; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintWriter; - -import org.aspectj.apache.bcel.classfile.Attribute; -import org.aspectj.apache.bcel.classfile.Code; -import org.aspectj.apache.bcel.classfile.CodeException; -import org.aspectj.apache.bcel.classfile.ConstantPool; -import org.aspectj.apache.bcel.classfile.ConstantUtf8; -import org.aspectj.apache.bcel.classfile.ConstantValue; -import org.aspectj.apache.bcel.classfile.ExceptionTable; -import org.aspectj.apache.bcel.classfile.InnerClass; -import org.aspectj.apache.bcel.classfile.InnerClasses; -import org.aspectj.apache.bcel.classfile.LineNumber; -import org.aspectj.apache.bcel.classfile.LineNumberTable; -import org.aspectj.apache.bcel.classfile.LocalVariable; -import org.aspectj.apache.bcel.classfile.LocalVariableTable; -import org.aspectj.apache.bcel.classfile.SourceFile; -import org.aspectj.apache.bcel.classfile.Utility; - -/** - * Convert found attributes into HTML file. - * - * @version $Id: AttributeHTML.java,v 1.7 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - * - */ -final class AttributeHTML implements org.aspectj.apache.bcel.Constants { - private String class_name; // name of current class - private PrintWriter file; // file to write to - private int attr_count = 0; - private ConstantHTML constant_html; - private ConstantPool constant_pool; - - AttributeHTML(String dir, String class_name, ConstantPool constant_pool, - ConstantHTML constant_html) throws IOException - { - this.class_name = class_name; - this.constant_pool = constant_pool; - this.constant_html = constant_html; - - file = new PrintWriter(new FileOutputStream(dir + class_name + "_attributes.html")); - file.println("<HTML><BODY BGCOLOR=\"#C0C0C0\"><TABLE BORDER=0>"); - } - - private final String codeLink(int link, int method_number) { - return "<A HREF=\"" + class_name + "_code.html#code" + - method_number + "@" + link + "\" TARGET=Code>" + - link + "</A>"; - } - - final void close() { - file.println("</TABLE></BODY></HTML>"); - file.close(); - } - - final void writeAttribute(Attribute attribute, String anchor) throws IOException { - writeAttribute(attribute, anchor, 0); - } - - final void writeAttribute(Attribute attribute, String anchor, int method_number) throws IOException { - byte tag = attribute.getTag(); - int index; - - if(tag == ATTR_UNKNOWN) // Don't know what to do about this one - return; - - attr_count++; // Increment number of attributes found so far - - if(attr_count % 2 == 0) - file.print("<TR BGCOLOR=\"#C0C0C0\"><TD>"); - else - file.print("<TR BGCOLOR=\"#A0A0A0\"><TD>"); - - file.println("<H4><A NAME=\"" + anchor + "\">" + attr_count + " " + ATTRIBUTE_NAMES[tag] + "</A></H4>"); - - /* Handle different attributes - */ - switch(tag) { - case ATTR_CODE: - Code c = (Code)attribute; - - // Some directly printable values - file.print("<UL><LI>Maximum stack size = " + c.getMaxStack() + - "</LI>\n<LI>Number of local variables = " + - c.getMaxLocals() + "</LI>\n<LI><A HREF=\"" + class_name + - "_code.html#method" + method_number + "\" TARGET=Code>Byte code</A></LI></UL>\n"); - - // Get handled exceptions and list them - CodeException[] ce = c.getExceptionTable(); - int len = ce.length; - - if(len > 0) { - file.print("<P><B>Exceptions handled</B><UL>"); - - for(int i=0; i < len; i++) { - int catch_type = ce[i].getCatchType(); // Index in constant pool - - file.print("<LI>"); - - if(catch_type != 0) - file.print(constant_html.referenceConstant(catch_type)); // Create Link to _cp.html - else - file.print("Any Exception"); - - file.print("<BR>(Ranging from lines " + codeLink(ce[i].getStartPC(), method_number) + - " to " + codeLink(ce[i].getEndPC(), method_number) + ", handled at line " + - codeLink(ce[i].getHandlerPC(), method_number) + ")</LI>"); - } - file.print("</UL>"); - } - break; - - case ATTR_CONSTANT_VALUE: - index = ((ConstantValue)attribute).getConstantValueIndex(); - - // Reference _cp.html - file.print("<UL><LI><A HREF=\"" + class_name + "_cp.html#cp" + index + - "\" TARGET=\"ConstantPool\">Constant value index(" + index +")</A></UL>\n"); - break; - - case ATTR_SOURCE_FILE: - index = ((SourceFile)attribute).getSourceFileIndex(); - - // Reference _cp.html - file.print("<UL><LI><A HREF=\"" + class_name + "_cp.html#cp" + index + - "\" TARGET=\"ConstantPool\">Source file index(" + index +")</A></UL>\n"); - break; - - case ATTR_EXCEPTIONS: - // List thrown exceptions - int[] indices = ((ExceptionTable)attribute).getExceptionIndexTable(); - - file.print("<UL>"); - - for(int i=0; i < indices.length; i++) - file.print("<LI><A HREF=\"" + class_name + "_cp.html#cp" + indices[i] + - "\" TARGET=\"ConstantPool\">Exception class index(" + indices[i] + ")</A>\n"); - - file.print("</UL>\n"); - break; - - case ATTR_LINE_NUMBER_TABLE: - LineNumber[] line_numbers =((LineNumberTable)attribute).getLineNumberTable(); - - // List line number pairs - file.print("<P>"); - - for(int i=0; i < line_numbers.length; i++) { - file.print("(" + line_numbers[i].getStartPC() + ", " + line_numbers[i].getLineNumber() + ")"); - - if(i < line_numbers.length - 1) - file.print(", "); // breakable - } - break; - - case ATTR_LOCAL_VARIABLE_TABLE: - LocalVariable[] vars = ((LocalVariableTable)attribute).getLocalVariableTable(); - - // List name, range and type - file.print("<UL>"); - - for(int i=0; i < vars.length; i++) { - index = vars[i].getSignatureIndex(); - String signature = ((ConstantUtf8)constant_pool.getConstant(index, CONSTANT_Utf8)).getBytes(); - signature = Utility.signatureToString(signature, false); - int start = vars[i].getStartPC(); - int end = (start + vars[i].getLength()); - - file.println("<LI>" + Class2HTML.referenceType(signature) + - " <B>" + vars[i].getName() + "</B> in slot %" + vars[i].getIndex() + - "<BR>Valid from lines " + - "<A HREF=\"" + class_name + "_code.html#code" + method_number + "@" + start + "\" TARGET=Code>" + - start + "</A> to " + - "<A HREF=\"" + class_name + "_code.html#code" + method_number + "@" + end + "\" TARGET=Code>" + - end + "</A></LI>"); - } - file.print("</UL>\n"); - - break; - - case ATTR_INNER_CLASSES: - InnerClass[] classes = ((InnerClasses)attribute).getInnerClasses(); - - // List inner classes - file.print("<UL>"); - - for(int i=0; i < classes.length; i++) { - String name, access; - - index = classes[i].getInnerNameIndex(); - if(index > 0) - name =((ConstantUtf8)constant_pool.getConstant(index, CONSTANT_Utf8)).getBytes(); - else - name = "<anonymous>"; - - access = Utility.accessToString(classes[i].getInnerAccessFlags()); - - file.print("<LI><FONT COLOR=\"#FF0000\">" + access + "</FONT> "+ - constant_html.referenceConstant(classes[i].getInnerClassIndex()) + - " in class " + - constant_html.referenceConstant(classes[i].getOuterClassIndex()) + - " named " + name + "</LI>\n"); - } - - file.print("</UL>\n"); - break; - - default: // Such as Unknown attribute or Deprecated - file.print("<P>" + attribute.toString()); - } - - file.println("</TD></TR>"); - file.flush(); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/ByteSequence.java b/bcel-builder/src/org/aspectj/apache/bcel/util/ByteSequence.java index 58b21e82d..072a7ba52 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/ByteSequence.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/util/ByteSequence.java @@ -60,7 +60,7 @@ import java.io.*; * via the `readByte()' method. This is used to implement a wrapper for the * Java byte code stream to gain some more readability. * - * @version $Id: ByteSequence.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: ByteSequence.java,v 1.3 2008/05/28 23:52:53 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public final class ByteSequence extends DataInputStream { diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/Class2HTML.java b/bcel-builder/src/org/aspectj/apache/bcel/util/Class2HTML.java deleted file mode 100644 index 16929ef34..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/Class2HTML.java +++ /dev/null @@ -1,270 +0,0 @@ -package org.aspectj.apache.bcel.util; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintWriter; - -import org.aspectj.apache.bcel.Constants; -import org.aspectj.apache.bcel.classfile.Attribute; -import org.aspectj.apache.bcel.classfile.ClassParser; -import org.aspectj.apache.bcel.classfile.ConstantPool; -import org.aspectj.apache.bcel.classfile.JavaClass; -import org.aspectj.apache.bcel.classfile.Method; -import org.aspectj.apache.bcel.classfile.Utility; - -/** - * Read class file(s) and convert them into HTML files. - * - * Given a JavaClass object "class" that is in package "package" five files - * will be created in the specified directory. - * - * <OL> - * <LI> "package"."class".html as the main file which defines the frames for - * the following subfiles. - * <LI> "package"."class"_attributes.html contains all (known) attributes found in the file - * <LI> "package"."class"_cp.html contains the constant pool - * <LI> "package"."class"_code.html contains the byte code - * <LI> "package"."class"_methods.html contains references to all methods and fields of the class - * </OL> - * - * All subfiles reference each other appropiately, e.g. clicking on a - * method in the Method's frame will jump to the appropiate method in - * the Code frame. - * - * @version $Id: Class2HTML.java,v 1.8 2008/04/25 17:58:27 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> -*/ -public class Class2HTML implements Constants -{ - private JavaClass java_class; // current class object - private String dir; - - private static String class_package; // name of package, unclean to make it static, but ... - private static String class_name; // name of current class, dito - private static ConstantPool constant_pool; - - /** - * Write contents of the given JavaClass into HTML files. - * - * @param java_class The class to write - * @param dir The directory to put the files in - */ - public Class2HTML(JavaClass java_class, String dir) throws IOException { - Method[] methods = java_class.getMethods(); - - this.java_class = java_class; - this.dir = dir; - class_name = java_class.getClassName(); // Remember full name - constant_pool = java_class.getConstantPool(); - - // Get package name by tacking off everything after the last `.' - int index = class_name.lastIndexOf('.'); - if(index > -1) - class_package = class_name.substring(0, index); - else - class_package = ""; // default package - - ConstantHTML constant_html = new ConstantHTML(dir, class_name, class_package, methods, - constant_pool); - - /* Attributes can't be written in one step, so we just open a file - * which will be written consequently. - */ - AttributeHTML attribute_html = new AttributeHTML(dir, class_name, constant_pool, constant_html); - - MethodHTML method_html = new MethodHTML(dir, class_name, methods, java_class.getFields(), - constant_html, attribute_html); - // Write main file (with frames, yuk) - writeMainHTML(attribute_html); - new CodeHTML(dir, class_name, methods, constant_pool, constant_html); - attribute_html.close(); - } - - public static void main(String argv[]) - { - String[] file_name = new String[argv.length]; - int files=0; - ClassParser parser=null; - JavaClass java_class=null; - String zip_file = null; - char sep = System.getProperty("file.separator").toCharArray()[0]; - String dir = "." + sep; // Where to store HTML files - - try { - /* Parse command line arguments. - */ - for(int i=0; i < argv.length; i++) { - if(argv[i].charAt(0) == '-') { // command line switch - if(argv[i].equals("-d")) { // Specify target directory, default `.´ - dir = argv[++i]; - - if(!dir.endsWith("" + sep)) - dir = dir + sep; - - new File(dir).mkdirs(); // Create target directory if necessary - } - else if(argv[i].equals("-zip")) - zip_file = argv[++i]; - else - System.out.println("Unknown option " + argv[i]); - } - else // add file name to list */ - file_name[files++] = argv[i]; - } - - if(files == 0) - System.err.println("Class2HTML: No input files specified."); - else { // Loop through files ... - for(int i=0; i < files; i++) { - System.out.print("Processing " + file_name[i] + "..."); - if(zip_file == null) - parser = new ClassParser(file_name[i]); // Create parser object from file - else - parser = new ClassParser(zip_file, file_name[i]); // Create parser object from zip file - - java_class = parser.parse(); - new Class2HTML(java_class, dir); - System.out.println("Done."); - } - } - } catch(Exception e) { - System.out.println(e); - e.printStackTrace(System.out); - } - } - - /** - * Utility method that converts a class reference in the constant pool, - * i.e., an index to a string. - */ - static String referenceClass(int index) { - String str = constant_pool.getConstantString(index, CONSTANT_Class); - str = Utility.compactClassName(str); - str = Utility.compactClassName(str, class_package + ".", true); - - return "<A HREF=\"" + class_name + "_cp.html#cp" + index + - "\" TARGET=ConstantPool>" + str + "</A>"; - } - - static final String referenceType(String type) { - String short_type = Utility.compactClassName(type); - short_type = Utility.compactClassName(short_type, class_package + ".", true); - - int index = type.indexOf('['); // Type is an array? - if(index > -1) - type = type.substring(0, index); // Tack of the `[' - - // test for basic type - if(type.equals("int") || type.equals("short") || type.equals("boolean") || type.equals("void") || - type.equals("char") || type.equals("byte") || type.equals("long") || type.equals("double") || - type.equals("float")) - return "<FONT COLOR=\"#00FF00\">" + type + "</FONT>"; - else - return "<A HREF=\"" + type + ".html\" TARGET=_top>" + short_type + "</A>"; - } - - static String toHTML(String str) { - StringBuffer buf = new StringBuffer(); - - try { // Filter any characters HTML doesn't like such as < and > in particular - for(int i=0; i < str.length(); i++) { - char ch; - - switch(ch=str.charAt(i)) { - case '<': buf.append("<"); break; - case '>': buf.append(">"); break; - case '\n': buf.append("\\n"); break; - case '\r': buf.append("\\r"); break; - default: buf.append(ch); - } - } - } catch(StringIndexOutOfBoundsException e) {} // Never occurs - - return buf.toString(); - } - - private void writeMainHTML(AttributeHTML attribute_html) throws IOException { - PrintWriter file = new PrintWriter(new FileOutputStream(dir + class_name + ".html")); - Attribute[] attributes = java_class.getAttributes(); - - file.println("<HTML>\n" + "<HEAD><TITLE>Documentation for " + class_name + "</TITLE>" + - "</HEAD>\n" + - "<FRAMESET BORDER=1 cols=\"30%,*\">\n" + - "<FRAMESET BORDER=1 rows=\"80%,*\">\n" + - - "<FRAME NAME=\"ConstantPool\" SRC=\"" + class_name + "_cp.html" + "\"\n MARGINWIDTH=\"0\" " + - "MARGINHEIGHT=\"0\" FRAMEBORDER=\"1\" SCROLLING=\"AUTO\">\n" + - "<FRAME NAME=\"Attributes\" SRC=\"" + class_name + "_attributes.html" + - "\"\n MARGINWIDTH=\"0\" " + - "MARGINHEIGHT=\"0\" FRAMEBORDER=\"1\" SCROLLING=\"AUTO\">\n" + - "</FRAMESET>\n" + - - "<FRAMESET BORDER=1 rows=\"80%,*\">\n" + - "<FRAME NAME=\"Code\" SRC=\"" + class_name + "_code.html\"\n MARGINWIDTH=0 " + - "MARGINHEIGHT=0 FRAMEBORDER=1 SCROLLING=\"AUTO\">\n" + - "<FRAME NAME=\"Methods\" SRC=\"" + class_name + "_methods.html\"\n MARGINWIDTH=0 " + - "MARGINHEIGHT=0 FRAMEBORDER=1 SCROLLING=\"AUTO\">\n" + - "</FRAMESET></FRAMESET></HTML>" - ); - - file.close(); - - for(int i=0; i < attributes.length; i++) - attribute_html.writeAttribute(attributes[i], "class" + i); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/ClassLoader.java b/bcel-builder/src/org/aspectj/apache/bcel/util/ClassLoader.java deleted file mode 100644 index 5eed50042..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/ClassLoader.java +++ /dev/null @@ -1,227 +0,0 @@ -package org.aspectj.apache.bcel.util; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -import java.io.ByteArrayInputStream; -import java.util.Hashtable; - -import org.aspectj.apache.bcel.Constants; -import org.aspectj.apache.bcel.classfile.ClassParser; -import org.aspectj.apache.bcel.classfile.ConstantClass; -import org.aspectj.apache.bcel.classfile.ConstantPool; -import org.aspectj.apache.bcel.classfile.ConstantUtf8; -import org.aspectj.apache.bcel.classfile.JavaClass; -import org.aspectj.apache.bcel.classfile.Utility; - -/** - * <p>Drop in replacement for the standard class loader of the JVM. You can use it - * in conjunction with the JavaWrapper to dynamically modify/create classes - * as they're requested.</p> - * - * <p>This class loader recognizes special requests in a distinct - * format, i.e., when the name of the requested class contains with - * "$$BCEL$$" it calls the createClass() method with that name - * (everything bevor the $$BCEL$$ is considered to be the package - * name. You can subclass the class loader and override that - * method. "Normal" classes class can be modified by overriding the - * modifyClass() method which is called just before defineClass().</p> - * - * <p>There may be a number of packages where you have to use the default - * class loader (which may also be faster). You can define the set of packages - * where to use the system class loader in the constructor. The default value contains - * "java.", "sun.", "javax."</p> - * - * @version $Id: ClassLoader.java,v 1.7 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - * @see JavaWrapper - * @see ClassPath - */ -public class ClassLoader extends java.lang.ClassLoader { - private Hashtable classes = new Hashtable(); // Hashtable is synchronized thus thread-safe - private String[] ignored_packages = { - "java.", "javax.", "sun." - }; - private Repository repository = SyntheticRepository.getInstance(); - private java.lang.ClassLoader deferTo = ClassLoader.getSystemClassLoader(); - - public ClassLoader() { - } - - public ClassLoader(java.lang.ClassLoader deferTo) { - this.deferTo = deferTo; - this.repository = new ClassLoaderRepository(deferTo); - } - - /** @param ignored_packages classes contained in these packages will be loaded - * with the system class loader - */ - public ClassLoader(String[] ignored_packages) { - addIgnoredPkgs(ignored_packages); - } - - public ClassLoader(java.lang.ClassLoader deferTo, String [] ignored_packages) { - this.deferTo = deferTo; - this.repository = new ClassLoaderRepository(deferTo); - - addIgnoredPkgs(ignored_packages); - } - - private void addIgnoredPkgs(String[] ignored_packages) { - String[] new_p = new String[ignored_packages.length + this.ignored_packages.length]; - - System.arraycopy(this.ignored_packages, 0, new_p, 0, this.ignored_packages.length); - System.arraycopy(ignored_packages, 0, new_p, this.ignored_packages.length, - ignored_packages.length); - - this.ignored_packages = new_p; - } - - protected Class loadClass(String class_name, boolean resolve) - throws ClassNotFoundException - { - Class cl = null; - - /* First try: lookup hash table. - */ - if((cl=(Class)classes.get(class_name)) == null) { - /* Second try: Load system class using system class loader. You better - * don't mess around with them. - */ - for(int i=0; i < ignored_packages.length; i++) { - if(class_name.startsWith(ignored_packages[i])) { - cl = deferTo.loadClass(class_name); - break; - } - } - - if(cl == null) { - JavaClass clazz = null; - - /* Third try: Special request? - */ - if(class_name.indexOf("$$BCEL$$") >= 0) - clazz = createClass(class_name); - else { // Fourth try: Load classes via repository - if ((clazz = repository.loadClass(class_name)) != null) { - clazz = modifyClass(clazz); - } - else - throw new ClassNotFoundException(class_name); - } - - if(clazz != null) { - byte[] bytes = clazz.getBytes(); - cl = defineClass(class_name, bytes, 0, bytes.length); - } else // Fourth try: Use default class loader - cl = Class.forName(class_name); - } - - if(resolve) - resolveClass(cl); - } - - classes.put(class_name, cl); - - return cl; - } - - /** Override this method if you want to alter a class before it gets actually - * loaded. Does nothing by default. - */ - protected JavaClass modifyClass(JavaClass clazz) { - return clazz; - } - - /** - * Override this method to create you own classes on the fly. The - * name contains the special token $$BCEL$$. Everything before that - * token is consddered to be a package name. You can encode you own - * arguments into the subsequent string. You must regard however not - * to use any "illegal" characters, i.e., characters that may not - * appear in a Java class name too<br> - * - * The default implementation interprets the string as a encoded compressed - * Java class, unpacks and decodes it with the Utility.decode() method, and - * parses the resulting byte array and returns the resulting JavaClass object. - * - * @param class_name compressed byte code with "$$BCEL$$" in it - */ - protected JavaClass createClass(String class_name) { - int index = class_name.indexOf("$$BCEL$$"); - String real_name = class_name.substring(index + 8); - - JavaClass clazz = null; - try { - byte[] bytes = Utility.decode(real_name, true); - ClassParser parser = new ClassParser(new ByteArrayInputStream(bytes), "foo"); - - clazz = parser.parse(); - } catch(Throwable e) { - e.printStackTrace(); - return null; - } - - // Adapt the class name to the passed value - ConstantPool cp = clazz.getConstantPool(); - - ConstantClass cl = (ConstantClass)cp.getConstant(clazz.getClassNameIndex(), - Constants.CONSTANT_Class); - ConstantUtf8 name = (ConstantUtf8)cp.getConstant(cl.getNameIndex(), - Constants.CONSTANT_Utf8); - name.setBytes(class_name.replace('.', '/')); - - return clazz; - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/ClassLoaderRepository.java b/bcel-builder/src/org/aspectj/apache/bcel/util/ClassLoaderRepository.java index 74f3d47a2..f019bafc6 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/ClassLoaderRepository.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/util/ClassLoaderRepository.java @@ -80,7 +80,7 @@ import org.aspectj.apache.bcel.classfile.JavaClass; * * @see org.aspectj.apache.bcel.Repository * - * @version $Id: ClassLoaderRepository.java,v 1.10 2008/05/27 18:46:34 aclement Exp $ + * @version $Id: ClassLoaderRepository.java,v 1.11 2008/05/28 23:52:53 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @author David Dixon-Peugh */ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/ClassPath.java b/bcel-builder/src/org/aspectj/apache/bcel/util/ClassPath.java index ef9d1e5c3..447d0c50d 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/ClassPath.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/util/ClassPath.java @@ -62,7 +62,7 @@ import java.io.*; * Responsible for loading (class) files from the CLASSPATH. Inspired by * sun.tools.ClassPath. * - * @version $Id: ClassPath.java,v 1.3 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: ClassPath.java,v 1.4 2008/05/28 23:52:53 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ public class ClassPath implements Serializable { diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/ClassQueue.java b/bcel-builder/src/org/aspectj/apache/bcel/util/ClassQueue.java index 2793fb450..ae91f305d 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/ClassQueue.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/util/ClassQueue.java @@ -60,7 +60,7 @@ import org.aspectj.apache.bcel.classfile.JavaClass; * Utility class implementing a (typesafe) queue of JavaClass * objects. * - * @version $Id: ClassQueue.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: ClassQueue.java,v 1.3 2008/05/28 23:52:53 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see ClassVector */ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/ClassSet.java b/bcel-builder/src/org/aspectj/apache/bcel/util/ClassSet.java deleted file mode 100644 index 1b4c0d6e0..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/ClassSet.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.aspectj.apache.bcel.util; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ -import java.util.HashMap; -import java.util.Collection; -import org.aspectj.apache.bcel.classfile.JavaClass; - -/** - * Utility class implementing a (typesafe) set of JavaClass objects. - * Since JavaClass has no equals() method, the name of the class is - * used for comparison. - * - * @version $Id: ClassSet.java,v 1.6 2008/04/25 17:58:27 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - * @see ClassStack -*/ -public class ClassSet implements java.io.Serializable { - private HashMap _map = new HashMap(); - - public boolean add(JavaClass clazz) { - boolean result = false; - - if(!_map.containsKey(clazz.getClassName())) { - result = true; - _map.put(clazz.getClassName(), clazz); - } - - return result; - } - - public void remove(JavaClass clazz) { _map.remove(clazz.getClassName()); } - public boolean empty() { return _map.isEmpty(); } - - public JavaClass[] toArray() { - Collection values = _map.values(); - JavaClass[] classes = new JavaClass[values.size()]; - values.toArray(classes); - return classes; - } - - public String[] getClassNames() { - return (String[])_map.keySet().toArray(new String[_map.keySet().size()]); - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/ClassStack.java b/bcel-builder/src/org/aspectj/apache/bcel/util/ClassStack.java deleted file mode 100644 index c32934eb1..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/ClassStack.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.aspectj.apache.bcel.util; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ -import java.util.Stack; -import org.aspectj.apache.bcel.classfile.JavaClass; - -/** - * Utility class implementing a (typesafe) stack of JavaClass objects. - * - * @version $Id: ClassStack.java,v 1.6 2008/04/25 17:58:27 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - * @see Stack -*/ -public class ClassStack implements java.io.Serializable { - private Stack stack = new Stack(); - - public void push(JavaClass clazz) { stack.push(clazz); } - public JavaClass pop() { return (JavaClass)stack.pop(); } - public JavaClass top() { return (JavaClass)stack.peek(); } - public boolean empty() { return stack.empty(); } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/ClassVector.java b/bcel-builder/src/org/aspectj/apache/bcel/util/ClassVector.java index 1f73c9334..7667cd2dc 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/ClassVector.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/util/ClassVector.java @@ -60,7 +60,7 @@ import org.aspectj.apache.bcel.classfile.JavaClass; * Utility class implementing a (typesafe) collection of JavaClass * objects. Contains the most important methods of a Vector. * - * @version $Id: ClassVector.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: ClassVector.java,v 1.3 2008/05/28 23:52:53 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @see ClassQueue */ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/CodeHTML.java b/bcel-builder/src/org/aspectj/apache/bcel/util/CodeHTML.java deleted file mode 100644 index 658fe63cd..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/CodeHTML.java +++ /dev/null @@ -1,632 +0,0 @@ -package org.aspectj.apache.bcel.util; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.BitSet; - -import org.aspectj.apache.bcel.classfile.Attribute; -import org.aspectj.apache.bcel.classfile.Code; -import org.aspectj.apache.bcel.classfile.CodeException; -import org.aspectj.apache.bcel.classfile.ConstantFieldref; -import org.aspectj.apache.bcel.classfile.ConstantInterfaceMethodref; -import org.aspectj.apache.bcel.classfile.ConstantMethodref; -import org.aspectj.apache.bcel.classfile.ConstantNameAndType; -import org.aspectj.apache.bcel.classfile.ConstantPool; -import org.aspectj.apache.bcel.classfile.LocalVariable; -import org.aspectj.apache.bcel.classfile.LocalVariableTable; -import org.aspectj.apache.bcel.classfile.Method; -import org.aspectj.apache.bcel.classfile.Utility; - -/** - * Convert code into HTML file. - * - * @version $Id: CodeHTML.java,v 1.7 2008/04/25 17:58:22 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - * - */ -final class CodeHTML implements org.aspectj.apache.bcel.Constants { - private String class_name; // name of current class - private Method[] methods; // Methods to print - private PrintWriter file; // file to write to - private BitSet goto_set; - private ConstantPool constant_pool; - private ConstantHTML constant_html; - private static boolean wide=false; - - CodeHTML(String dir, String class_name, - Method[] methods, ConstantPool constant_pool, - ConstantHTML constant_html) throws IOException - { - this.class_name = class_name; - this.methods = methods; - this.constant_pool = constant_pool; - this.constant_html = constant_html; - - file = new PrintWriter(new FileOutputStream(dir + class_name + "_code.html")); - file.println("<HTML><BODY BGCOLOR=\"#C0C0C0\">"); - - for(int i=0; i < methods.length; i++) - writeMethod(methods[i], i); - - file.println("</BODY></HTML>"); - file.close(); - } - - /** - * Disassemble a stream of byte codes and return the - * string representation. - * - * @param stream data input stream - * @return String representation of byte code - */ - private final String codeToHTML(ByteSequence bytes, int method_number) - throws IOException - { - short opcode = (short)bytes.readUnsignedByte(); - StringBuffer buf; - String name, signature; - int default_offset=0, low, high; - int index, class_index, vindex, constant; - int[] jump_table; - int no_pad_bytes=0, offset; - - buf = new StringBuffer("<TT>" + OPCODE_NAMES[opcode] + "</TT></TD><TD>"); - - /* Special case: Skip (0-3) padding bytes, i.e., the - * following bytes are 4-byte-aligned - */ - if((opcode == TABLESWITCH) || (opcode == LOOKUPSWITCH)) { - int remainder = bytes.getIndex() % 4; - no_pad_bytes = (remainder == 0)? 0 : 4 - remainder; - - for(int i=0; i < no_pad_bytes; i++) - bytes.readByte(); - - // Both cases have a field default_offset in common - default_offset = bytes.readInt(); - } - - switch(opcode) { - case TABLESWITCH: - low = bytes.readInt(); - high = bytes.readInt(); - - offset = bytes.getIndex() - 12 - no_pad_bytes - 1; - default_offset += offset; - - buf.append("<TABLE BORDER=1><TR>"); - - // Print switch indices in first row (and default) - jump_table = new int[high - low + 1]; - for(int i=0; i < jump_table.length; i++) { - jump_table[i] = offset + bytes.readInt(); - - buf.append("<TH>" + (low + i) + "</TH>"); - } - buf.append("<TH>default</TH></TR>\n<TR>"); - - // Print target and default indices in second row - for(int i=0; i < jump_table.length; i++) - buf.append("<TD><A HREF=\"#code" + method_number + "@" + - jump_table[i] + "\">" + jump_table[i] + "</A></TD>"); - buf.append("<TD><A HREF=\"#code" + method_number + "@" + - default_offset + "\">" + default_offset + "</A></TD></TR>\n</TABLE>\n"); - - break; - - /* Lookup switch has variable length arguments. - */ - case LOOKUPSWITCH: - int npairs = bytes.readInt(); - offset = bytes.getIndex() - 8 - no_pad_bytes - 1; - jump_table = new int[npairs]; - default_offset += offset; - - buf.append("<TABLE BORDER=1><TR>"); - - // Print switch indices in first row (and default) - for(int i=0; i < npairs; i++) { - int match = bytes.readInt(); - - jump_table[i] = offset + bytes.readInt(); - buf.append("<TH>" + match + "</TH>"); - } - buf.append("<TH>default</TH></TR>\n<TR>"); - - // Print target and default indices in second row - for(int i=0; i < npairs; i++) - buf.append("<TD><A HREF=\"#code" + method_number + "@" + - jump_table[i] + "\">" + jump_table[i] + "</A></TD>"); - buf.append("<TD><A HREF=\"#code" + method_number + "@" + - default_offset + "\">" + default_offset + "</A></TD></TR>\n</TABLE>\n"); - break; - - /* Two address bytes + offset from start of byte stream form the - * jump target. - */ - case GOTO: case IFEQ: case IFGE: case IFGT: - case IFLE: case IFLT: - case IFNE: case IFNONNULL: case IFNULL: case IF_ACMPEQ: - case IF_ACMPNE: case IF_ICMPEQ: case IF_ICMPGE: case IF_ICMPGT: - case IF_ICMPLE: case IF_ICMPLT: case IF_ICMPNE: case JSR: - - index = (int)(bytes.getIndex() + bytes.readShort() - 1); - - buf.append("<A HREF=\"#code" + method_number + "@" + index + "\">" + index + "</A>"); - break; - - /* Same for 32-bit wide jumps - */ - case GOTO_W: case JSR_W: - int windex = bytes.getIndex() + bytes.readInt() - 1; - buf.append("<A HREF=\"#code" + method_number + "@" + windex + "\">" + - windex + "</A>"); - break; - - /* Index byte references local variable (register) - */ - case ALOAD: case ASTORE: case DLOAD: case DSTORE: case FLOAD: - case FSTORE: case ILOAD: case ISTORE: case LLOAD: case LSTORE: - case RET: - if(wide) { - vindex = bytes.readShort(); - wide=false; // Clear flag - } - else - vindex = bytes.readUnsignedByte(); - - buf.append("%" + vindex); - break; - - /* - * Remember wide byte which is used to form a 16-bit address in the - * following instruction. Relies on that the method is called again with - * the following opcode. - */ - case WIDE: - wide = true; - buf.append("(wide)"); - break; - - /* Array of basic type. - */ - case NEWARRAY: - buf.append("<FONT COLOR=\"#00FF00\">" + TYPE_NAMES[bytes.readByte()] + "</FONT>"); - break; - - /* Access object/class fields. - */ - case GETFIELD: case GETSTATIC: case PUTFIELD: case PUTSTATIC: - index = bytes.readShort(); - ConstantFieldref c1 = (ConstantFieldref)constant_pool.getConstant(index, CONSTANT_Fieldref); - - class_index = c1.getClassIndex(); - name = constant_pool.getConstantString(class_index, CONSTANT_Class); - name = Utility.compactClassName(name, false); - - index = c1.getNameAndTypeIndex(); - String field_name = constant_pool.constantToString(index, CONSTANT_NameAndType); - - if(name.equals(class_name)) { // Local field - buf.append("<A HREF=\"" + class_name + "_methods.html#field" + field_name + - "\" TARGET=Methods>" + field_name + "</A>\n"); - } - else - buf.append(constant_html.referenceConstant(class_index) + "." + field_name); - - break; - - /* Operands are references to classes in constant pool - */ - case CHECKCAST: case INSTANCEOF: case NEW: - index = bytes.readShort(); - buf.append(constant_html.referenceConstant(index)); - break; - - /* Operands are references to methods in constant pool - */ - case INVOKESPECIAL: case INVOKESTATIC: case INVOKEVIRTUAL: case INVOKEINTERFACE: - int m_index = bytes.readShort(); - String str; - - if(opcode == INVOKEINTERFACE) { // Special treatment needed - int nargs = bytes.readUnsignedByte(); // Redundant - int reserved = bytes.readUnsignedByte(); // Reserved - - ConstantInterfaceMethodref c=(ConstantInterfaceMethodref)constant_pool.getConstant(m_index, CONSTANT_InterfaceMethodref); - - class_index = c.getClassIndex(); - str = constant_pool.constantToString(c); - index = c.getNameAndTypeIndex(); - } - else { - ConstantMethodref c = (ConstantMethodref)constant_pool.getConstant(m_index, CONSTANT_Methodref); - class_index = c.getClassIndex(); - - str = constant_pool.constantToString(c); - index = c.getNameAndTypeIndex(); - } - - name = Class2HTML.referenceClass(class_index); - str = Class2HTML.toHTML(constant_pool.constantToString(constant_pool.getConstant(index, CONSTANT_NameAndType))); - - // Get signature, i.e., types - ConstantNameAndType c2 = (ConstantNameAndType)constant_pool. - getConstant(index, CONSTANT_NameAndType); - signature = constant_pool.constantToString(c2.getSignatureIndex(), - CONSTANT_Utf8); - String[] args = Utility.methodSignatureArgumentTypes(signature, false); - String type = Utility.methodSignatureReturnType(signature, false); - - buf.append(name + ".<A HREF=\"" + class_name + "_cp.html#cp" + m_index + - "\" TARGET=ConstantPool>" + str + "</A>" + "("); - - // List arguments - for(int i=0; i < args.length; i++) { - buf.append(Class2HTML.referenceType(args[i])); - - if(i < args.length - 1) - buf.append(", "); - } - // Attach return type - buf.append("):" + Class2HTML.referenceType(type)); - - break; - - /* Operands are references to items in constant pool - */ - case LDC_W: case LDC2_W: - index = bytes.readShort(); - - buf.append("<A HREF=\"" + class_name + "_cp.html#cp" + index + - "\" TARGET=\"ConstantPool\">" + - Class2HTML.toHTML(constant_pool.constantToString(index, - constant_pool. - getConstant(index).getTag()))+ - "</a>"); - break; - - case LDC: - index = bytes.readUnsignedByte(); - buf.append("<A HREF=\"" + class_name + "_cp.html#cp" + index + - "\" TARGET=\"ConstantPool\">" + - Class2HTML.toHTML(constant_pool.constantToString(index, - constant_pool. - getConstant(index).getTag()))+ - "</a>"); - break; - - /* Array of references. - */ - case ANEWARRAY: - index = bytes.readShort(); - - buf.append(constant_html.referenceConstant(index)); - break; - - /* Multidimensional array of references. - */ - case MULTIANEWARRAY: - index = bytes.readShort(); - int dimensions = bytes.readByte(); - buf.append(constant_html.referenceConstant(index) + ":" + dimensions + "-dimensional"); - break; - - /* Increment local variable. - */ - case IINC: - if(wide) { - vindex = bytes.readShort(); - constant = bytes.readShort(); - wide = false; - } - else { - vindex = bytes.readUnsignedByte(); - constant = bytes.readByte(); - } - buf.append("%" + vindex + " " + constant); - break; - - default: - if(NO_OF_OPERANDS[opcode] > 0) { - for(int i=0; i < TYPE_OF_OPERANDS[opcode].length; i++) { - switch(TYPE_OF_OPERANDS[opcode][i]) { - case T_BYTE: - buf.append(bytes.readUnsignedByte()); - break; - - case T_SHORT: // Either branch or index - buf.append(bytes.readShort()); - break; - - case T_INT: - buf.append(bytes.readInt()); - break; - - default: // Never reached - System.err.println("Unreachable default case reached!"); - System.exit(-1); - } - buf.append(" "); - } - } - } - - buf.append("</TD>"); - return buf.toString(); - } - - /** - * Find all target addresses in code, so that they can be marked - * with <A NAME = ...>. Target addresses are kept in an BitSet object. - */ - private final void findGotos(ByteSequence bytes, Method method, Code code) - throws IOException - { - int index; - goto_set = new BitSet(bytes.available()); - int opcode; - - /* First get Code attribute from method and the exceptions handled - * (try .. catch) in this method. We only need the line number here. - */ - - if(code != null) { - CodeException[] ce = code.getExceptionTable(); - int len = ce.length; - - for(int i=0; i < len; i++) { - goto_set.set(ce[i].getStartPC()); - goto_set.set(ce[i].getEndPC()); - goto_set.set(ce[i].getHandlerPC()); - } - - // Look for local variables and their range - Attribute[] attributes = code.getAttributes(); - for(int i=0; i < attributes.length; i++) { - if(attributes[i].getTag() == ATTR_LOCAL_VARIABLE_TABLE) { - LocalVariable[] vars = ((LocalVariableTable)attributes[i]).getLocalVariableTable(); - - for(int j=0; j < vars.length; j++) { - int start = vars[j].getStartPC(); - int end = (int)(start + vars[j].getLength()); - goto_set.set(start); - goto_set.set(end); - } - break; - } - } - } - - // Get target addresses from GOTO, JSR, TABLESWITCH, etc. - for(int i=0; bytes.available() > 0; i++) { - opcode = bytes.readUnsignedByte(); - //System.out.println(OPCODE_NAMES[opcode]); - switch(opcode) { - case TABLESWITCH: case LOOKUPSWITCH: - //bytes.readByte(); // Skip already read byte - - int remainder = bytes.getIndex() % 4; - int no_pad_bytes = (remainder == 0)? 0 : 4 - remainder; - int default_offset, offset; - - for(int j=0; j < no_pad_bytes; j++) - bytes.readByte(); - - // Both cases have a field default_offset in common - default_offset = bytes.readInt(); - - if(opcode == TABLESWITCH) { - int low = bytes.readInt(); - int high = bytes.readInt(); - - offset = bytes.getIndex() - 12 - no_pad_bytes - 1; - default_offset += offset; - goto_set.set(default_offset); - - for(int j=0; j < (high - low + 1); j++) { - index = offset + bytes.readInt(); - goto_set.set(index); - } - } - else { // LOOKUPSWITCH - int npairs = bytes.readInt(); - - offset = bytes.getIndex() - 8 - no_pad_bytes - 1; - default_offset += offset; - goto_set.set(default_offset); - - for(int j=0; j < npairs; j++) { - int match = bytes.readInt(); - - index = offset + bytes.readInt(); - goto_set.set(index); - } - } - break; - - case GOTO: case IFEQ: case IFGE: case IFGT: - case IFLE: case IFLT: - case IFNE: case IFNONNULL: case IFNULL: case IF_ACMPEQ: - case IF_ACMPNE: case IF_ICMPEQ: case IF_ICMPGE: case IF_ICMPGT: - case IF_ICMPLE: case IF_ICMPLT: case IF_ICMPNE: case JSR: - //bytes.readByte(); // Skip already read byte - index = bytes.getIndex() + bytes.readShort() - 1; - - goto_set.set(index); - break; - - case GOTO_W: case JSR_W: - //bytes.readByte(); // Skip already read byte - index = bytes.getIndex() + bytes.readInt() - 1; - goto_set.set(index); - break; - - default: - bytes.unreadByte(); - codeToHTML(bytes, 0); // Ignore output - } - } - } - - /** - * Write a single method with the byte code associated with it. - */ - private void writeMethod(Method method, int method_number) - throws IOException - { - // Get raw signature - String signature = method.getSignature(); - // Get array of strings containing the argument types - String[] args = Utility.methodSignatureArgumentTypes(signature, false); - // Get return type string - String type = Utility.methodSignatureReturnType(signature, false); - // Get method name - String name = method.getName(); - String html_name = Class2HTML.toHTML(name); - // Get method's access flags - String access = Utility.accessToString(method.getAccessFlags()); - access = Utility.replace(access, " ", " "); - // Get the method's attributes, the Code Attribute in particular - Attribute[] attributes= method.getAttributes(); - - file.print("<P><B><FONT COLOR=\"#FF0000\">" + access + "</FONT> " + - "<A NAME=method" + method_number + ">" + Class2HTML.referenceType(type) + - "</A> <A HREF=\"" + class_name + "_methods.html#method" + method_number + - "\" TARGET=Methods>" + html_name + "</A>("); - - for(int i=0; i < args.length; i++) { - file.print(Class2HTML.referenceType(args[i])); - if(i < args.length - 1) - file.print(", "); - } - - file.println(")</B></P>"); - - Code c=null; - byte[] code=null; - - if(attributes.length > 0) { - file.print("<H4>Attributes</H4><UL>\n"); - for(int i=0; i < attributes.length; i++) { - byte tag = attributes[i].getTag(); - - if(tag != ATTR_UNKNOWN) - file.print("<LI><A HREF=\"" + class_name + "_attributes.html#method" + method_number + "@" + i + - "\" TARGET=Attributes>" + ATTRIBUTE_NAMES[tag] + "</A></LI>\n"); - else - file.print("<LI>" + attributes[i] + "</LI>"); - - if(tag == ATTR_CODE) { - c = (Code)attributes[i]; - Attribute[] attributes2 = c.getAttributes(); - code = c.getCode(); - - file.print("<UL>"); - for(int j=0; j < attributes2.length; j++) { - tag = attributes2[j].getTag(); - file.print("<LI><A HREF=\"" + class_name + "_attributes.html#" + - "method" + method_number + "@" + i + "@" + j + "\" TARGET=Attributes>" + - ATTRIBUTE_NAMES[tag] + "</A></LI>\n"); - - } - file.print("</UL>"); - } - } - file.println("</UL>"); - } - - if(code != null) { // No code, an abstract method, e.g. - //System.out.println(name + "\n" + Utility.codeToString(code, constant_pool, 0, -1)); - - // Print the byte code - ByteSequence stream = new ByteSequence(code); - stream.mark(stream.available()); - findGotos(stream, method, c); - stream.reset(); - - file.println("<TABLE BORDER=0><TR><TH ALIGN=LEFT>Byte<BR>offset</TH>" + - "<TH ALIGN=LEFT>Instruction</TH><TH ALIGN=LEFT>Argument</TH>"); - - for(int i=0; stream.available() > 0; i++) { - int offset = stream.getIndex(); - String str = codeToHTML(stream, method_number); - String anchor = ""; - - /* Set an anchor mark if this line is targetted by a goto, jsr, etc. - * Defining an anchor for every line is very inefficient! - */ - if(goto_set.get(offset)) - anchor = "<A NAME=code" + method_number + "@" + offset + "></A>"; - - String anchor2; - if(stream.getIndex() == code.length) // last loop - anchor2 = "<A NAME=code" + method_number + "@" + code.length + ">" + offset + "</A>"; - else - anchor2 = "" + offset; - - file.println("<TR VALIGN=TOP><TD>" + anchor2 + "</TD><TD>" + anchor + str + "</TR>"); - } - - // Mark last line, may be targetted from Attributes window - file.println("<TR><TD> </A></TD></TR>"); - file.println("</TABLE>"); - } - - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/ConstantHTML.java b/bcel-builder/src/org/aspectj/apache/bcel/util/ConstantHTML.java deleted file mode 100644 index 7e6afbaa5..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/ConstantHTML.java +++ /dev/null @@ -1,274 +0,0 @@ - -package org.aspectj.apache.bcel.util; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintWriter; - -import org.aspectj.apache.bcel.classfile.Constant; -import org.aspectj.apache.bcel.classfile.ConstantClass; -import org.aspectj.apache.bcel.classfile.ConstantFieldref; -import org.aspectj.apache.bcel.classfile.ConstantInterfaceMethodref; -import org.aspectj.apache.bcel.classfile.ConstantMethodref; -import org.aspectj.apache.bcel.classfile.ConstantNameAndType; -import org.aspectj.apache.bcel.classfile.ConstantPool; -import org.aspectj.apache.bcel.classfile.ConstantString; -import org.aspectj.apache.bcel.classfile.Method; -import org.aspectj.apache.bcel.classfile.Utility; - -/** - * Convert constant pool into HTML file. - * - * @version $Id: ConstantHTML.java,v 1.7 2008/04/25 17:58:27 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - * - */ -final class ConstantHTML implements org.aspectj.apache.bcel.Constants { - private String class_name; // name of current class - private String class_package; // name of package - private ConstantPool constant_pool; // reference to constant pool - private PrintWriter file; // file to write to - private String[] constant_ref; // String to return for cp[i] - private Constant[] constants; // The constants in the cp - private Method[] methods; - - ConstantHTML(String dir, String class_name, String class_package, Method[] methods, - ConstantPool constant_pool) throws IOException - { - this.class_name = class_name; - this.class_package = class_package; - this.constant_pool = constant_pool; - this.methods = methods; - constants = constant_pool.getConstantPool(); - file = new PrintWriter(new FileOutputStream(dir + class_name + "_cp.html")); - constant_ref = new String[constants.length]; - constant_ref[0] = "<unknown>"; - - file.println("<HTML><BODY BGCOLOR=\"#C0C0C0\"><TABLE BORDER=0>"); - - // Loop through constants, constants[0] is reserved - for(int i=1; i < constants.length; i++) { - if(i % 2 == 0) - file.print("<TR BGCOLOR=\"#C0C0C0\"><TD>"); - else - file.print("<TR BGCOLOR=\"#A0A0A0\"><TD>"); - - if(constants[i] != null) - writeConstant(i); - - file.print("</TD></TR>\n"); - } - - file.println("</TABLE></BODY></HTML>"); - file.close(); - } - - String referenceConstant(int index) { - return constant_ref[index]; - } - - private void writeConstant(int index) { - byte tag = constants[index].getTag(); - int class_index, name_index; - String ref; - - // The header is always the same - file.println("<H4> <A NAME=cp" + index + ">" + index + "</A> " + CONSTANT_NAMES[tag] + "</H4>"); - - /* For every constant type get the needed parameters and print them appropiately - */ - switch(tag) { - case CONSTANT_InterfaceMethodref: - case CONSTANT_Methodref: - // Get class_index and name_and_type_index, depending on type - if(tag == CONSTANT_Methodref) { - ConstantMethodref c = (ConstantMethodref)constant_pool.getConstant(index, CONSTANT_Methodref); - class_index = c.getClassIndex(); - name_index = c.getNameAndTypeIndex(); - } - else { - ConstantInterfaceMethodref c1 = (ConstantInterfaceMethodref)constant_pool.getConstant(index, CONSTANT_InterfaceMethodref); - class_index = c1.getClassIndex(); - name_index = c1.getNameAndTypeIndex(); - } - - // Get method name and its class - String method_name = constant_pool.constantToString(name_index, CONSTANT_NameAndType); - String html_method_name = Class2HTML.toHTML(method_name); - - // Partially compacted class name, i.e., / -> . - String method_class = constant_pool.constantToString(class_index, CONSTANT_Class); - String short_method_class = Utility.compactClassName(method_class); // I.e., remove java.lang. - short_method_class = Utility.compactClassName(method_class); // I.e., remove java.lang. - short_method_class = Utility.compactClassName(short_method_class, class_package + ".", true); // Remove class package prefix - - // Get method signature - ConstantNameAndType c2 = (ConstantNameAndType)constant_pool.getConstant(name_index, CONSTANT_NameAndType); - String signature = constant_pool.constantToString(c2.getSignatureIndex(), CONSTANT_Utf8); - // Get array of strings containing the argument types - String[] args = Utility.methodSignatureArgumentTypes(signature, false); - - // Get return type string - String type = Utility.methodSignatureReturnType(signature, false); - String ret_type = Class2HTML.referenceType(type); - - StringBuffer buf = new StringBuffer("("); - for(int i=0; i < args.length; i++) { - buf.append(Class2HTML.referenceType(args[i])); - if(i < args.length - 1) - buf.append(", "); - } - buf.append(")"); - - String arg_types = buf.toString(); - - if(method_class.equals(class_name)) // Method is local to class - ref = "<A HREF=\"" + class_name + "_code.html#method" + getMethodNumber(method_name + signature) + - "\" TARGET=Code>" + html_method_name + "</A>"; - else - ref = "<A HREF=\"" + method_class + ".html" + "\" TARGET=_top>" + short_method_class + - "</A>." + html_method_name; - - constant_ref[index] = ret_type + " <A HREF=\"" + class_name + "_cp.html#cp" + class_index + - "\" TARGET=Constants>" + - short_method_class + "</A>.<A HREF=\"" + class_name + "_cp.html#cp" + - index + "\" TARGET=ConstantPool>" + html_method_name + "</A> " + arg_types; - - file.println("<P><TT>" + ret_type + " " + ref + arg_types + " </TT>\n<UL>" + - "<LI><A HREF=\"#cp" + class_index + "\">Class index(" + class_index + ")</A>\n" + - "<LI><A HREF=\"#cp" + name_index + "\">NameAndType index(" + name_index + ")</A></UL>"); - break; - - case CONSTANT_Fieldref: - // Get class_index and name_and_type_index - ConstantFieldref c3 = (ConstantFieldref)constant_pool.getConstant(index, CONSTANT_Fieldref); - class_index = c3.getClassIndex(); - name_index = c3.getNameAndTypeIndex(); - - // Get method name and its class (compacted) - String field_class = constant_pool.constantToString(class_index, CONSTANT_Class); - String short_field_class = Utility.compactClassName(field_class); // I.e., remove java.lang. - short_field_class = Utility.compactClassName(short_field_class, class_package + ".", true); // Remove class package prefix - - String field_name = constant_pool.constantToString(name_index, CONSTANT_NameAndType); - - if(field_class.equals(class_name)) // Field is local to class - ref = "<A HREF=\"" + field_class + "_methods.html#field" + - field_name + "\" TARGET=Methods>" + field_name + "</A>"; - else - ref = "<A HREF=\"" + field_class + ".html\" TARGET=_top>" + - short_field_class + "</A>." + field_name + "\n"; - - constant_ref[index] = "<A HREF=\"" + class_name + "_cp.html#cp" + class_index + "\" TARGET=Constants>" + - short_field_class + "</A>.<A HREF=\"" + class_name + "_cp.html#cp" + - index + "\" TARGET=ConstantPool>" + field_name + "</A>"; - - file.println("<P><TT>" + ref + "</TT><BR>\n" + "<UL>" + - "<LI><A HREF=\"#cp" + class_index + "\">Class(" + class_index + ")</A><BR>\n" + - "<LI><A HREF=\"#cp" + name_index + "\">NameAndType(" + name_index + ")</A></UL>"); - break; - - case CONSTANT_Class: - ConstantClass c4 = (ConstantClass)constant_pool.getConstant(index, CONSTANT_Class); - name_index = c4.getNameIndex(); - String class_name2 = constant_pool.constantToString(index, tag); // / -> . - String short_class_name = Utility.compactClassName(class_name2); // I.e., remove java.lang. - short_class_name = Utility.compactClassName(short_class_name, class_package + ".", true); // Remove class package prefix - - ref = "<A HREF=\"" + class_name2 + ".html\" TARGET=_top>" + short_class_name + "</A>"; - constant_ref[index] = "<A HREF=\"" + class_name + "_cp.html#cp" + index + - "\" TARGET=ConstantPool>" + short_class_name + "</A>"; - - file.println("<P><TT>" + ref + "</TT><UL>" + - "<LI><A HREF=\"#cp" + name_index + "\">Name index(" + name_index + ")</A></UL>\n"); - break; - - case CONSTANT_String: - ConstantString c5 = (ConstantString)constant_pool.getConstant(index, CONSTANT_String); - name_index = c5.getStringIndex(); - - String str = Class2HTML.toHTML(constant_pool.constantToString(index, tag)); - - file.println("<P><TT>" + str + "</TT><UL>" + - "<LI><A HREF=\"#cp" + name_index + "\">Name index(" + name_index + ")</A></UL>\n"); - break; - - case CONSTANT_NameAndType: - ConstantNameAndType c6 = (ConstantNameAndType)constant_pool.getConstant(index, CONSTANT_NameAndType); - name_index = c6.getNameIndex(); - int signature_index = c6.getSignatureIndex(); - - file.println("<P><TT>" + Class2HTML.toHTML(constant_pool.constantToString(index, tag)) + "</TT><UL>" + - "<LI><A HREF=\"#cp" + name_index + "\">Name index(" + name_index + ")</A>\n" + - "<LI><A HREF=\"#cp" + signature_index + "\">Signature index(" + - signature_index + ")</A></UL>\n"); - break; - - default: - file.println("<P><TT>" + Class2HTML.toHTML(constant_pool.constantToString(index, tag)) + "</TT>\n"); - } // switch - } - - private final int getMethodNumber(String str) { - for(int i=0; i < methods.length; i++) { - String cmp = methods[i].getName() + methods[i].getSignature(); - if(cmp.equals(str)) - return i; - } - return -1; - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/JavaWrapper.java b/bcel-builder/src/org/aspectj/apache/bcel/util/JavaWrapper.java deleted file mode 100644 index 0c7d70e47..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/JavaWrapper.java +++ /dev/null @@ -1,152 +0,0 @@ -package org.aspectj.apache.bcel.util; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -import java.lang.reflect.*; - -/** - * Java interpreter replacement, i.e., wrapper that uses its own ClassLoader - * to modify/generate classes as they're requested. You can take this as a template - * for your own applications.<br> - * Call this wrapper with - * <pre>java org.aspectj.apache.bcel.util.JavaWrapper <real.class.name> [arguments]</pre> - * <p> - * To use your own class loader you can set the "bcel.classloader" system property - * which defaults to "org.aspectj.apache.bcel.util.ClassLoader", e.g., with - * <pre>java org.aspectj.apache.bcel.util.JavaWrapper -Dbcel.classloader=foo.MyLoader <real.class.name> [arguments]</pre> - * </p> - * - * @version $Id: JavaWrapper.java,v 1.6 2008/04/25 17:58:27 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - * @see ClassLoader - */ -public class JavaWrapper { - private java.lang.ClassLoader loader; - - private static java.lang.ClassLoader getClassLoader() { - String s = System.getProperty("bcel.classloader"); - - if((s == null) || "".equals(s)) - s = "org.aspectj.apache.bcel.util.ClassLoader"; - - try { - return (java.lang.ClassLoader)Class.forName(s).newInstance(); - } catch(Exception e) { - throw new RuntimeException(e.toString()); - } - } - - public JavaWrapper(java.lang.ClassLoader loader) { - this.loader = loader; - } - - public JavaWrapper() { - this(getClassLoader()); - } - - /** Runs the main method of the given class with the arguments passed in argv - * - * @param class_name the fully qualified class name - * @param argv the arguments just as you would pass them directly - */ - public void runMain(String class_name, String[] argv) throws ClassNotFoundException - { - Class cl = loader.loadClass(class_name); - Method method = null; - - try { - method = cl.getMethod("main", new Class[] { argv.getClass() }); - - /* Method main is sane ? - */ - int m = method.getModifiers(); - Class r = method.getReturnType(); - - if(!(Modifier.isPublic(m) && Modifier.isStatic(m)) || - Modifier.isAbstract(m) || (r != Void.TYPE)) - throw new NoSuchMethodException(); - } catch(NoSuchMethodException no) { - System.out.println("In class " + class_name + - ": public static void main(String[] argv) is not defined"); - return; - } - - try { - method.invoke(null, new Object[] { argv }); - } catch(Exception ex) { - ex.printStackTrace(); - } - } - - /** Default main method used as wrapper, expects the fully qualified class name - * of the real class as the first argument. - */ - public static void main(String[] argv) throws Exception { - /* Expects class name as first argument, other arguments are by-passed. - */ - if(argv.length == 0) { - System.out.println("Missing class name."); - return; - } - - String class_name = argv[0]; - String[] new_argv = new String[argv.length - 1]; - System.arraycopy(argv, 1, new_argv, 0, new_argv.length); - - JavaWrapper wrapper = new JavaWrapper(); - wrapper.runMain(class_name, new_argv); - } -} - diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/MethodHTML.java b/bcel-builder/src/org/aspectj/apache/bcel/util/MethodHTML.java deleted file mode 100644 index 0730d4cd7..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/MethodHTML.java +++ /dev/null @@ -1,208 +0,0 @@ -package org.aspectj.apache.bcel.util; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintWriter; - -import org.aspectj.apache.bcel.classfile.Attribute; -import org.aspectj.apache.bcel.classfile.Code; -import org.aspectj.apache.bcel.classfile.ConstantValue; -import org.aspectj.apache.bcel.classfile.ExceptionTable; -import org.aspectj.apache.bcel.classfile.Field; -import org.aspectj.apache.bcel.classfile.Method; -import org.aspectj.apache.bcel.classfile.Utility; - -/** - * Convert methods and fields into HTML file. - * - * @version $Id: MethodHTML.java,v 1.7 2008/04/25 17:58:27 aclement Exp $ - * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> - * - */ -final class MethodHTML implements org.aspectj.apache.bcel.Constants { - private String class_name; // name of current class - private PrintWriter file; // file to write to - private ConstantHTML constant_html; - private AttributeHTML attribute_html; - - MethodHTML(String dir, String class_name, - Method[] methods, Field[] fields, - ConstantHTML constant_html, AttributeHTML attribute_html) throws IOException - { - this.class_name = class_name; - this.attribute_html = attribute_html; - this.constant_html = constant_html; - - file = new PrintWriter(new FileOutputStream(dir + class_name + "_methods.html")); - - file.println("<HTML><BODY BGCOLOR=\"#C0C0C0\"><TABLE BORDER=0>"); - file.println("<TR><TH ALIGN=LEFT>Access flags</TH><TH ALIGN=LEFT>Type</TH>" + - "<TH ALIGN=LEFT>Field name</TH></TR>"); - for(int i=0; i < fields.length; i++) - writeField(fields[i]); - file.println("</TABLE>"); - - file.println("<TABLE BORDER=0><TR><TH ALIGN=LEFT>Access flags</TH>" + - "<TH ALIGN=LEFT>Return type</TH><TH ALIGN=LEFT>Method name</TH>" + - "<TH ALIGN=LEFT>Arguments</TH></TR>"); - for(int i=0; i < methods.length; i++) - writeMethod(methods[i], i); - - file.println("</TABLE></BODY></HTML>"); - file.close(); - } - - /** - * Print field of class. - * - * @param field field to print - * @exception java.io.IOException - */ - private void writeField(Field field) throws IOException { - String type = Utility.signatureToString(field.getSignature()); - String name = field.getName(); - String access = Utility.accessToString(field.getAccessFlags()); - Attribute[] attributes; - - access = Utility.replace(access, " ", " "); - - file.print("<TR><TD><FONT COLOR=\"#FF0000\">" + access + "</FONT></TD>\n<TD>" + - Class2HTML.referenceType(type) + "</TD><TD><A NAME=\"field" + name + "\">" + - name + "</A></TD>"); - - attributes = field.getAttributes(); - - // Write them to the Attributes.html file with anchor "<name>[<i>]" - for(int i=0; i < attributes.length; i++) - attribute_html.writeAttribute(attributes[i], name + "@" + i); - - for(int i=0; i < attributes.length; i++) { - if(attributes[i].getTag() == ATTR_CONSTANT_VALUE) { // Default value - String str = ((ConstantValue)attributes[i]).toString(); - - // Reference attribute in _attributes.html - file.print("<TD>= <A HREF=\"" + class_name + "_attributes.html#" + - name + "@" + i + "\" TARGET=\"Attributes\">" + str + "</TD>\n"); - break; - } - } - - file.println("</TR>"); - } - - private final void writeMethod(Method method, int method_number) throws IOException { - // Get raw signature - String signature = method.getSignature(); - // Get array of strings containing the argument types - String[] args = Utility.methodSignatureArgumentTypes(signature, false); - // Get return type string - String type = Utility.methodSignatureReturnType(signature, false); - // Get method name - String name = method.getName(), html_name; - // Get method's access flags - String access = Utility.accessToString(method.getAccessFlags()); - // Get the method's attributes, the Code Attribute in particular - Attribute[] attributes = method.getAttributes(); - - /* HTML doesn't like names like <clinit> and spaces are places to break - * lines. Both we don't want... - */ - access = Utility.replace(access, " ", " "); - html_name = Class2HTML.toHTML(name); - - file.print("<TR VALIGN=TOP><TD><FONT COLOR=\"#FF0000\"><A NAME=method" + method_number + ">" + - access + "</A></FONT></TD>"); - - file.print("<TD>" + Class2HTML.referenceType(type) + "</TD><TD>" + - "<A HREF=" + class_name + "_code.html#method" + method_number + - " TARGET=Code>" + html_name + "</A></TD>\n<TD>("); - - for(int i=0; i < args.length; i++) { - file.print(Class2HTML.referenceType(args[i])); - if(i < args.length - 1) - file.print(", "); - } - - file.print(")</TD></TR>"); - - // Check for thrown exceptions - for(int i=0; i < attributes.length; i++) { - attribute_html.writeAttribute(attributes[i], "method" + method_number + "@" + i, - method_number); - - byte tag = attributes[i].getTag(); - if(tag == ATTR_EXCEPTIONS) { - file.print("<TR VALIGN=TOP><TD COLSPAN=2></TD><TH ALIGN=LEFT>throws</TH><TD>"); - int[] exceptions = ((ExceptionTable)attributes[i]).getExceptionIndexTable(); - - for(int j=0; j < exceptions.length; j++) { - file.print(constant_html.referenceConstant(exceptions[j])); - - if(j < exceptions.length - 1) - file.print(", "); - } - file.println("</TD></TR>"); - } else if(tag == ATTR_CODE) { - Attribute[] c_a = ((Code)attributes[i]).getAttributes(); - - for(int j=0; j < c_a.length; j++) - attribute_html.writeAttribute(c_a[j], "method" + method_number + "@" + i + "@" + j, - method_number); - } - } - } -} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/NonCachingClassLoaderRepository.java b/bcel-builder/src/org/aspectj/apache/bcel/util/NonCachingClassLoaderRepository.java index d41188cf1..bbd0ab55e 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/NonCachingClassLoaderRepository.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/util/NonCachingClassLoaderRepository.java @@ -56,9 +56,15 @@ package org.aspectj.apache.bcel.util; import java.io.IOException; import java.io.InputStream; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.SoftReference; import java.net.URL; import java.net.URLClassLoader; -import java.util.WeakHashMap; +import java.util.AbstractMap; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; import org.aspectj.apache.bcel.classfile.ClassParser; import org.aspectj.apache.bcel.classfile.JavaClass; @@ -72,7 +78,7 @@ import org.aspectj.apache.bcel.classfile.JavaClass; * * @see org.aspectj.apache.bcel.Repository * - * @version $Id: NonCachingClassLoaderRepository.java,v 1.2 2008/05/27 18:46:34 aclement Exp $ + * @version $Id: NonCachingClassLoaderRepository.java,v 1.3 2008/05/28 23:52:53 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @author David Dixon-Peugh * @@ -83,8 +89,77 @@ public class NonCachingClassLoaderRepository private static java.lang.ClassLoader bootClassLoader = null; private ClassLoaderReference loaderRef; - private WeakHashMap loadedClasses = - new WeakHashMap(); // CLASSNAME X JAVACLASS + private Map loadedClasses = + new SoftHashMap(); // CLASSNAME X JAVACLASS + + public static class SoftHashMap extends AbstractMap { + private Map map; + private ReferenceQueue rq = new ReferenceQueue(); + + public SoftHashMap(Map map) { this.map = map; } + public SoftHashMap() { this(new HashMap()); } + public SoftHashMap(Map map, boolean b) { this(map); } + + class SpecialValue extends SoftReference { + private final Object key; + SpecialValue(Object k,Object v) { + super(v,rq); + this.key = k; + } + } + + private void processQueue() { + SpecialValue sv = null; + while ((sv = (SpecialValue)rq.poll())!=null) { + map.remove(sv.key); + } + } + + public Object get(Object key) { + SpecialValue value = (SpecialValue)map.get(key); + if (value==null) return null; + if (value.get()==null) { + // it got GC'd + map.remove(value.key); + return null; + } else { + return value.get(); + } + } + + public Object put(Object k, Object v) { + processQueue(); + return map.put(k, new SpecialValue(k,v)); + } + + public Set entrySet() { + return map.entrySet(); + } + + public void clear() { + processQueue(); + Set keys = map.keySet(); + for (Iterator iterator = keys.iterator(); iterator.hasNext();) { + Object name = (Object) iterator.next(); + map.remove(name); + } + } + + public int size() { + processQueue(); + return map.size(); + } + + public Object remove(Object k) { + processQueue(); + SpecialValue value = (SpecialValue)map.remove(k); + if (value==null) return null; + if (value.get()!=null) { + return value.get(); + } + return null; + } + } public NonCachingClassLoaderRepository(java.lang.ClassLoader loader) { this.loaderRef = new DefaultClassLoaderReference((loader != null) ? loader : getBootClassLoader()); diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/Repository.java b/bcel-builder/src/org/aspectj/apache/bcel/util/Repository.java index 8b8bec2e8..f35f1a005 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/Repository.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/util/Repository.java @@ -62,7 +62,7 @@ import org.aspectj.apache.bcel.classfile.JavaClass; * Repository.setRepository method. * * @see org.aspectj.apache.bcel.Repository - * @version $Id: Repository.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: Repository.java,v 1.3 2008/05/28 23:52:53 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @author David Dixon-Peugh */ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/SyntheticRepository.java b/bcel-builder/src/org/aspectj/apache/bcel/util/SyntheticRepository.java index 17ed633b9..0f609b2f2 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/SyntheticRepository.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/util/SyntheticRepository.java @@ -79,7 +79,7 @@ import org.aspectj.apache.bcel.classfile.JavaClass; * * @see org.aspectj.apache.bcel.Repository * - * @version $Id: SyntheticRepository.java,v 1.6 2006/07/19 12:06:16 aclement Exp $ + * @version $Id: SyntheticRepository.java,v 1.7 2008/05/28 23:52:53 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @author David Dixon-Peugh */ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/package.html b/bcel-builder/src/org/aspectj/apache/bcel/util/package.html deleted file mode 100644 index 81df81708..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/package.html +++ /dev/null @@ -1,25 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- -$Id: package.html,v 1.6 2008/04/25 17:58:27 aclement Exp $ ---> -</head> -<body bgcolor="white"> -<p> -This package contains utility classes for the -<a href="http://jakarta.apache.org/bcel/">Byte Code Engineering -Library</a>, namely: -</p> -<p> -<ul> -<li>Collection classes for JavaClass objects</li> -<li>A converter for class files to HTML</li> -<li>A tool to find instructions patterns via regular expressions</li> -<li>A class to find classes as defined in the CLASSPATH</li> -<li>A class loader that allows to create clases at run time</li> -</ul> - -</p> -</body> -</html> diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/package.html b/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/package.html deleted file mode 100644 index 599d9c7dc..000000000 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/package.html +++ /dev/null @@ -1,24 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- -$Id: package.html,v 1.6 2008/04/25 17:58:27 aclement Exp $ ---> -</head> -<body bgcolor="white"> - -Exception classes used by JustIce, mostly used internally. You don't need to bother with them. - -<h2>Package Specification</h2> - -Contained in this package are Exception classes for use with the JustIce verifier. - -<h2>Related Documentation</h2> - -For a simple demonstration of JustIce working, please see: -<ul> - <li><a href="http://www.inf.fu-berlin.de/~ehaase/cgi-html/Verifier.html">A WWW front-end for JustIce.</a> -</ul> - -</body> -</html> diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AllTests.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AllTests.java index da406e725..cf270b5b0 100644 --- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AllTests.java +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AllTests.java @@ -31,8 +31,9 @@ import org.aspectj.apache.bcel.classfile.tests.VarargsTest; public class AllTests { public static Test suite() { - TestSuite suite = new TestSuite("Tests for BCEL Java5 support"); + TestSuite suite = new TestSuite("Tests for BCEL"); //$JUnit-BEGIN$ + suite.addTestSuite(Fundamentals.class); suite.addTestSuite(RuntimeVisibleParameterAnnotationAttributeTest.class); suite.addTestSuite(AnnotationDefaultAttributeTest.class); suite.addTestSuite(EnclosingMethodAttributeTest.class); diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AnnotationDefaultAttributeTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AnnotationDefaultAttributeTest.java index ced29d489..2a57bbaac 100644 --- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AnnotationDefaultAttributeTest.java +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AnnotationDefaultAttributeTest.java @@ -15,8 +15,8 @@ package org.aspectj.apache.bcel.classfile.tests; import org.aspectj.apache.bcel.classfile.AnnotationDefault; import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.Method; -import org.aspectj.apache.bcel.classfile.annotation.ElementValue; -import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValue; +import org.aspectj.apache.bcel.classfile.annotation.ElementValueGen; +import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValueGen; public class AnnotationDefaultAttributeTest extends BcelTestCase { @@ -35,9 +35,9 @@ public class AnnotationDefaultAttributeTest extends BcelTestCase { Method m = getMethod(clazz,"fruit"); AnnotationDefault a = (AnnotationDefault) findAttribute("AnnotationDefault",m.getAttributes()); - SimpleElementValue val = (SimpleElementValue) a.getElementValue(); + SimpleElementValueGen val = (SimpleElementValueGen) a.getElementValue(); assertTrue("Should be STRING but is "+val.getElementValueType(), - val.getElementValueType()==ElementValue.STRING); + val.getElementValueType()==ElementValueGen.STRING); assertTrue("Should have default of bananas but default is "+val.getValueString(), val.getValueString().equals("bananas")); } diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java index c863fda83..306a1a387 100644 --- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java @@ -21,16 +21,16 @@ import java.util.Vector; import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.classfile.Utility; import org.aspectj.apache.bcel.classfile.Attribute; +import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; +import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePairGen; +import org.aspectj.apache.bcel.classfile.annotation.ElementValueGen; import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleAnnotations; import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisibleAnnotations; import org.aspectj.apache.bcel.classfile.annotation.RuntimeAnnotations; +import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValueGen; import org.aspectj.apache.bcel.generic.ClassGen; -import org.aspectj.apache.bcel.generic.ConstantPoolGen; +import org.aspectj.apache.bcel.classfile.ConstantPool; import org.aspectj.apache.bcel.generic.ObjectType; -import org.aspectj.apache.bcel.generic.annotation.AnnotationGen; -import org.aspectj.apache.bcel.generic.annotation.ElementNameValuePairGen; -import org.aspectj.apache.bcel.generic.annotation.ElementValueGen; -import org.aspectj.apache.bcel.generic.annotation.SimpleElementValueGen; public class AnnotationGenTest extends BcelTestCase { @@ -50,7 +50,7 @@ public class AnnotationGenTest extends BcelTestCase { // Create the containing class ClassGen cg = createClassGen("HelloWorld"); - ConstantPoolGen cp = cg.getConstantPool(); + ConstantPool cp = cg.getConstantPool(); // Create the simple primitive value '4' of type 'int' SimpleElementValueGen evg = @@ -81,7 +81,7 @@ public class AnnotationGenTest extends BcelTestCase { // Create the containing class ClassGen cg = createClassGen("HelloWorld"); - ConstantPoolGen cp = cg.getConstantPool(); + ConstantPool cp = cg.getConstantPool(); // Create the simple primitive value '4' of type 'int' SimpleElementValueGen evg = @@ -138,7 +138,7 @@ public class AnnotationGenTest extends BcelTestCase { //// // Helper methods - private void checkSerialize(AnnotationGen a,ConstantPoolGen cpg) { + private void checkSerialize(AnnotationGen a,ConstantPool cpg) { try { String beforeName = a.getTypeName(); List beforeValues = a.getValues(); diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/BcelTestCase.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/BcelTestCase.java index db2d1c78c..b8a0b503f 100644 --- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/BcelTestCase.java +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/BcelTestCase.java @@ -19,13 +19,12 @@ import java.util.List; import org.aspectj.apache.bcel.classfile.Attribute; import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.Method; -import org.aspectj.apache.bcel.classfile.annotation.Annotation; -import org.aspectj.apache.bcel.generic.ConstantPoolGen; +import org.aspectj.apache.bcel.classfile.ConstantPool; +import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; +import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePairGen; +import org.aspectj.apache.bcel.classfile.annotation.ElementValueGen; +import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValueGen; import org.aspectj.apache.bcel.generic.ObjectType; -import org.aspectj.apache.bcel.generic.annotation.AnnotationGen; -import org.aspectj.apache.bcel.generic.annotation.ElementNameValuePairGen; -import org.aspectj.apache.bcel.generic.annotation.ElementValueGen; -import org.aspectj.apache.bcel.generic.annotation.SimpleElementValueGen; import org.aspectj.apache.bcel.util.ClassPath; import org.aspectj.apache.bcel.util.SyntheticRepository; @@ -100,17 +99,6 @@ public class BcelTestCase extends TestCase { return (Attribute)chosenAttrsList.get(0); } - protected String dumpAnnotations(Annotation[] as) { - StringBuffer result = new StringBuffer(); - result.append("["); - for (int i = 0; i < as.length; i++) { - Annotation annotation = as[i]; - result.append(annotation.toShortString()); - if (i+1<as.length) result.append(","); - } - result.append("]"); - return result.toString(); - } protected String dumpAnnotations(AnnotationGen[] as) { StringBuffer result = new StringBuffer(); @@ -136,7 +124,7 @@ public class BcelTestCase extends TestCase { return result.toString(); } - public AnnotationGen createFruitAnnotation(ConstantPoolGen cp, String aFruit, boolean visibility) { + public AnnotationGen createFruitAnnotation(ConstantPool cp, String aFruit, boolean visibility) { SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.STRING,cp,aFruit); ElementNameValuePairGen nvGen = new ElementNameValuePairGen("fruit",evg,cp); ObjectType t = new ObjectType("SimpleStringAnnotation"); diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ClassPrinter.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ClassPrinter.java deleted file mode 100644 index 2efd1ae44..000000000 --- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ClassPrinter.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.aspectj.apache.bcel.classfile.tests; - -import java.io.File; - -import org.aspectj.apache.bcel.classfile.JavaClass; -import org.aspectj.apache.bcel.util.ClassPath; -import org.aspectj.apache.bcel.util.SyntheticRepository; - -public class ClassPrinter extends BcelTestCase { - - public static void main(String[] args) throws ClassNotFoundException { - new ClassPrinter().run(args); - } - - public void run(String[] args) throws ClassNotFoundException { - ClassPath cp = new ClassPath(args[0]+File.pathSeparator+System.getProperty("java.class.path")); - SyntheticRepository sr = SyntheticRepository.getInstance(cp); - JavaClass clazz = sr.loadClass(args[1]); - System.err.println(clazz.toString()); - } -} diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ElementValueGenTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ElementValueGenTest.java index fa0f437e2..8fc5207bd 100644 --- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ElementValueGenTest.java +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ElementValueGenTest.java @@ -17,12 +17,12 @@ import java.io.IOException; import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.generic.ClassGen; -import org.aspectj.apache.bcel.generic.ConstantPoolGen; +import org.aspectj.apache.bcel.classfile.ConstantPool; +import org.aspectj.apache.bcel.classfile.annotation.ClassElementValueGen; +import org.aspectj.apache.bcel.classfile.annotation.ElementValueGen; +import org.aspectj.apache.bcel.classfile.annotation.EnumElementValueGen; +import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValueGen; import org.aspectj.apache.bcel.generic.ObjectType; -import org.aspectj.apache.bcel.generic.annotation.ClassElementValueGen; -import org.aspectj.apache.bcel.generic.annotation.ElementValueGen; -import org.aspectj.apache.bcel.generic.annotation.EnumElementValueGen; -import org.aspectj.apache.bcel.generic.annotation.SimpleElementValueGen; public class ElementValueGenTest extends BcelTestCase { @@ -40,7 +40,7 @@ public class ElementValueGenTest extends BcelTestCase { public void testCreateIntegerElementValue() { ClassGen cg = createClassGen("HelloWorld"); - ConstantPoolGen cp = cg.getConstantPool(); + ConstantPool cp = cg.getConstantPool(); SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_INT,cp,555); // Creation of an element like that should leave a new entry in the cpool @@ -51,7 +51,7 @@ public class ElementValueGenTest extends BcelTestCase { public void testCreateFloatElementValue() { ClassGen cg = createClassGen("HelloWorld"); - ConstantPoolGen cp = cg.getConstantPool(); + ConstantPool cp = cg.getConstantPool(); SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_FLOAT,cp,111.222f); // Creation of an element like that should leave a new entry in the cpool @@ -62,7 +62,7 @@ public class ElementValueGenTest extends BcelTestCase { public void testCreateDoubleElementValue() { ClassGen cg = createClassGen("HelloWorld"); - ConstantPoolGen cp = cg.getConstantPool(); + ConstantPool cp = cg.getConstantPool(); SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_DOUBLE,cp,333.44); // Creation of an element like that should leave a new entry in the cpool @@ -74,7 +74,7 @@ public class ElementValueGenTest extends BcelTestCase { public void testCreateLongElementValue() { ClassGen cg = createClassGen("HelloWorld"); - ConstantPoolGen cp = cg.getConstantPool(); + ConstantPool cp = cg.getConstantPool(); SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_LONG,cp,3334455L); // Creation of an element like that should leave a new entry in the cpool @@ -86,7 +86,7 @@ public class ElementValueGenTest extends BcelTestCase { public void testCreateCharElementValue() { ClassGen cg = createClassGen("HelloWorld"); - ConstantPoolGen cp = cg.getConstantPool(); + ConstantPool cp = cg.getConstantPool(); SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_CHAR,cp,(char)'t'); // Creation of an element like that should leave a new entry in the cpool @@ -98,7 +98,7 @@ public class ElementValueGenTest extends BcelTestCase { public void testCreateByteElementValue() { ClassGen cg = createClassGen("HelloWorld"); - ConstantPoolGen cp = cg.getConstantPool(); + ConstantPool cp = cg.getConstantPool(); SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_CHAR,cp,(byte)'z'); // Creation of an element like that should leave a new entry in the cpool @@ -110,7 +110,7 @@ public class ElementValueGenTest extends BcelTestCase { public void testCreateBooleanElementValue() { ClassGen cg = createClassGen("HelloWorld"); - ConstantPoolGen cp = cg.getConstantPool(); + ConstantPool cp = cg.getConstantPool(); SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_BOOLEAN,cp,true); // Creation of an element like that should leave a new entry in the cpool @@ -122,7 +122,7 @@ public class ElementValueGenTest extends BcelTestCase { public void testCreateShortElementValue() { ClassGen cg = createClassGen("HelloWorld"); - ConstantPoolGen cp = cg.getConstantPool(); + ConstantPool cp = cg.getConstantPool(); SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_SHORT,cp,(short)42); // Creation of an element like that should leave a new entry in the cpool @@ -139,7 +139,7 @@ public class ElementValueGenTest extends BcelTestCase { // Create HelloWorld ClassGen cg = createClassGen("HelloWorld"); - ConstantPoolGen cp = cg.getConstantPool(); + ConstantPool cp = cg.getConstantPool(); SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.STRING,cp,"hello"); // Creation of an element like that should leave a new entry in the cpool @@ -153,7 +153,7 @@ public class ElementValueGenTest extends BcelTestCase { public void testCreateEnumElementValue() { ClassGen cg = createClassGen("HelloWorld"); - ConstantPoolGen cp = cg.getConstantPool(); + ConstantPool cp = cg.getConstantPool(); ObjectType enumType = new ObjectType("SimpleEnum"); // Supports rainbow :) @@ -176,7 +176,7 @@ public class ElementValueGenTest extends BcelTestCase { public void testCreateClassElementValue() { ClassGen cg = createClassGen("HelloWorld"); - ConstantPoolGen cp = cg.getConstantPool(); + ConstantPool cp = cg.getConstantPool(); ObjectType classType = new ObjectType("java.lang.Integer"); @@ -192,7 +192,7 @@ public class ElementValueGenTest extends BcelTestCase { //// // Helper methods - private void checkSerialize(ElementValueGen evgBefore,ConstantPoolGen cpg) { + private void checkSerialize(ElementValueGen evgBefore,ConstantPool cpg) { try { String beforeValue = evgBefore.stringifyValue(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/FieldAnnotationsTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/FieldAnnotationsTest.java index b62e5d88f..0bcf1ac81 100644 --- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/FieldAnnotationsTest.java +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/FieldAnnotationsTest.java @@ -18,11 +18,10 @@ import java.util.Iterator; import org.aspectj.apache.bcel.classfile.Field; import org.aspectj.apache.bcel.classfile.JavaClass; -import org.aspectj.apache.bcel.classfile.annotation.Annotation; -import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePair; +import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; +import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePairGen; import org.aspectj.apache.bcel.generic.ClassGen; import org.aspectj.apache.bcel.generic.FieldGen; -import org.aspectj.apache.bcel.generic.annotation.AnnotationGen; import org.aspectj.apache.bcel.util.SyntheticRepository; @@ -105,7 +104,7 @@ public class FieldAnnotationsTest extends BcelTestCase { for (int i = 0; i < fields.length; i++) { Field f = fields[i]; - Annotation[] fieldAnnotations = f.getAnnotations(); + AnnotationGen[] fieldAnnotations = f.getAnnotations(); if (f.getName().equals(fieldname)) { checkAnnotation(fieldAnnotations[0],annotationName,annotationElementName,annotationElementValue); @@ -113,11 +112,11 @@ public class FieldAnnotationsTest extends BcelTestCase { } } - private void checkAnnotation(Annotation a,String name,String elementname,String elementvalue) { + private void checkAnnotation(AnnotationGen a,String name,String elementname,String elementvalue) { assertTrue("Expected annotation to have name "+name+" but it had name "+a.getTypeName(), a.getTypeName().equals(name)); assertTrue("Expected annotation to have one element but it had "+a.getValues().size(),a.getValues().size()==1); - ElementNameValuePair envp = (ElementNameValuePair)a.getValues().get(0); + ElementNameValuePairGen envp = (ElementNameValuePairGen)a.getValues().get(0); assertTrue("Expected element name "+elementname+" but was "+envp.getNameString(), elementname.equals(envp.getNameString())); assertTrue("Expected element value "+elementvalue+" but was "+envp.getValue().stringifyValue(), @@ -127,9 +126,9 @@ public class FieldAnnotationsTest extends BcelTestCase { // helper methods - public void checkValue(Annotation a,String name,String tostring) { + public void checkValue(AnnotationGen a,String name,String tostring) { for (Iterator i = a.getValues().iterator(); i.hasNext();) { - ElementNameValuePair element = (ElementNameValuePair) i.next(); + ElementNameValuePairGen element = (ElementNameValuePairGen) i.next(); if (element.getNameString().equals(name)) { if (!element.getValue().stringifyValue().equals(tostring)) { fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue()); diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/Fundamentals.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/Fundamentals.java new file mode 100644 index 000000000..c54beb5b3 --- /dev/null +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/Fundamentals.java @@ -0,0 +1,319 @@ +package org.aspectj.apache.bcel.classfile.tests; + +import org.aspectj.apache.bcel.Constants; +import org.aspectj.apache.bcel.generic.FieldInstruction; +import org.aspectj.apache.bcel.generic.IINC; +import org.aspectj.apache.bcel.generic.INVOKEINTERFACE; +import org.aspectj.apache.bcel.generic.Instruction; +import org.aspectj.apache.bcel.generic.InstructionBranch; +import org.aspectj.apache.bcel.generic.InstructionByte; +import org.aspectj.apache.bcel.generic.InstructionCP; +import org.aspectj.apache.bcel.generic.InstructionConstants; +import org.aspectj.apache.bcel.generic.InstructionHandle; +import org.aspectj.apache.bcel.generic.InstructionLV; +import org.aspectj.apache.bcel.generic.InstructionShort; +import org.aspectj.apache.bcel.generic.InvokeInstruction; +import org.aspectj.apache.bcel.generic.LOOKUPSWITCH; +import org.aspectj.apache.bcel.generic.MULTIANEWARRAY; +import org.aspectj.apache.bcel.generic.RET; +import org.aspectj.apache.bcel.generic.TABLESWITCH; + +import junit.framework.TestCase; + +// Check things that have to be true based on the specification +public class Fundamentals extends TestCase { + + // Checking: opcode, length, consumed stack entries, produced stack entries + public void testInstructions() { + + // Instructions 000-009 + checkInstruction(InstructionConstants.NOP,0,1,0,0); + checkInstruction(InstructionConstants.ACONST_NULL,1,1,0,1); + checkInstruction(InstructionConstants.ICONST_M1,2,1,0,1); + checkInstruction(InstructionConstants.ICONST_0,3,1,0,1); + checkInstruction(InstructionConstants.ICONST_1,4,1,0,1); + checkInstruction(InstructionConstants.ICONST_2,5,1,0,1); + checkInstruction(InstructionConstants.ICONST_3,6,1,0,1); + checkInstruction(InstructionConstants.ICONST_4,7,1,0,1); + checkInstruction(InstructionConstants.ICONST_5,8,1,0,1); + checkInstruction(InstructionConstants.LCONST_0,9,1,0,2); + + // Instructions 010-019 + checkInstruction(InstructionConstants.LCONST_1,10,1,0,2); + checkInstruction(InstructionConstants.FCONST_0,11,1,0,1); + checkInstruction(InstructionConstants.FCONST_1,12,1,0,1); + checkInstruction(InstructionConstants.FCONST_2,13,1,0,1); + checkInstruction(InstructionConstants.DCONST_0,14,1,0,2); + checkInstruction(InstructionConstants.DCONST_1,15,1,0,2); + checkInstruction(new InstructionByte(Constants.BIPUSH,b0),16,2,0,1); + checkInstruction(new InstructionShort(Constants.SIPUSH,s0),17,3,0,1); + checkInstruction(new InstructionCP(Constants.LDC,b0),18,2,0,1); + checkInstruction(new InstructionCP(Constants.LDC_W,s0),19,2,0,1); + + // Instructions 020-029 + checkInstruction(new InstructionCP(Constants.LDC2_W,s0),20,3,0,2); + checkInstruction(new InstructionLV(Constants.ILOAD,s20),21,2,0,1); + checkInstruction(new InstructionLV(Constants.LLOAD,s20),22,2,0,2); + checkInstruction(new InstructionLV(Constants.FLOAD,s20),23,2,0,1); + checkInstruction(new InstructionLV(Constants.DLOAD,s20),24,2,0,2); + checkInstruction(new InstructionLV(Constants.ALOAD,s20),25,2,0,1); + checkInstruction(InstructionConstants.ILOAD_0,26,1,0,1); + checkInstruction(InstructionConstants.ILOAD_1,27,1,0,1); + checkInstruction(InstructionConstants.ILOAD_2,28,1,0,1); + checkInstruction(InstructionConstants.ILOAD_3,29,1,0,1); + + // Instructions 030-039 + checkInstruction(InstructionConstants.LLOAD_0,30,1,0,2); + checkInstruction(InstructionConstants.LLOAD_1,31,1,0,2); + checkInstruction(InstructionConstants.LLOAD_2,32,1,0,2); + checkInstruction(InstructionConstants.LLOAD_3,33,1,0,2); + checkInstruction(InstructionConstants.FLOAD_0,34,1,0,1); + checkInstruction(InstructionConstants.FLOAD_1,35,1,0,1); + checkInstruction(InstructionConstants.FLOAD_2,36,1,0,1); + checkInstruction(InstructionConstants.FLOAD_3,37,1,0,1); + checkInstruction(InstructionConstants.DLOAD_0,38,1,0,2); + checkInstruction(InstructionConstants.DLOAD_1,39,1,0,2); + + // Instructions 040-049 + checkInstruction(InstructionConstants.DLOAD_2,40,1,0,2); + checkInstruction(InstructionConstants.DLOAD_3,41,1,0,2); + checkInstruction(InstructionConstants.ALOAD_0,42,1,0,1); + checkInstruction(InstructionConstants.ALOAD_1,43,1,0,1); + checkInstruction(InstructionConstants.ALOAD_2,44,1,0,1); + checkInstruction(InstructionConstants.ALOAD_3,45,1,0,1); + checkInstruction(InstructionConstants.IALOAD,46,1,2,1); + checkInstruction(InstructionConstants.LALOAD,47,1,2,2); + checkInstruction(InstructionConstants.FALOAD,48,1,2,1); + checkInstruction(InstructionConstants.DALOAD,49,1,2,2); + + // Instructions 050-059 + checkInstruction(InstructionConstants.AALOAD,50,1,2,1); + checkInstruction(InstructionConstants.BALOAD,51,1,2,1); + checkInstruction(InstructionConstants.CALOAD,52,1,2,1); + checkInstruction(InstructionConstants.SALOAD,53,1,2,1); + checkInstruction(new InstructionLV(Constants.ISTORE,s20),54,2,1,0); + checkInstruction(new InstructionLV(Constants.LSTORE,s20),55,2,2,0); + checkInstruction(new InstructionLV(Constants.FSTORE,s20),56,2,1,0); + checkInstruction(new InstructionLV(Constants.DSTORE,s20),57,2,2,0); + checkInstruction(new InstructionLV(Constants.ASTORE,s20),58,2,1,0); + checkInstruction(InstructionConstants.ISTORE_0,59,1,1,0); + + // Instructions 060-069 + checkInstruction(InstructionConstants.ISTORE_1,60,1,1,0); + checkInstruction(InstructionConstants.ISTORE_2,61,1,1,0); + checkInstruction(InstructionConstants.ISTORE_3,62,1,1,0); + checkInstruction(InstructionConstants.LSTORE_0,63,1,2,0); + checkInstruction(InstructionConstants.LSTORE_1,64,1,2,0); + checkInstruction(InstructionConstants.LSTORE_2,65,1,2,0); + checkInstruction(InstructionConstants.LSTORE_3,66,1,2,0); + checkInstruction(InstructionConstants.FSTORE_0,67,1,1,0); + checkInstruction(InstructionConstants.FSTORE_1,68,1,1,0); + checkInstruction(InstructionConstants.FSTORE_2,69,1,1,0); + + // Instructions 070-079 + checkInstruction(InstructionConstants.FSTORE_3,70,1,1,0); + checkInstruction(InstructionConstants.DSTORE_0,71,1,2,0); + checkInstruction(InstructionConstants.DSTORE_1,72,1,2,0); + checkInstruction(InstructionConstants.DSTORE_2,73,1,2,0); + checkInstruction(InstructionConstants.DSTORE_3,74,1,2,0); + checkInstruction(InstructionConstants.ASTORE_0,75,1,1,0); + checkInstruction(InstructionConstants.ASTORE_1,76,1,1,0); + checkInstruction(InstructionConstants.ASTORE_2,77,1,1,0); + checkInstruction(InstructionConstants.ASTORE_3,78,1,1,0); + checkInstruction(InstructionConstants.IASTORE,79,1,3,0); + + // Instructions 080-089 + checkInstruction(InstructionConstants.LASTORE,80,1,4,0); + checkInstruction(InstructionConstants.FASTORE,81,1,3,0); + checkInstruction(InstructionConstants.DASTORE,82,1,4,0); + checkInstruction(InstructionConstants.AASTORE,83,1,3,0); + checkInstruction(InstructionConstants.BASTORE,84,1,3,0); + checkInstruction(InstructionConstants.CASTORE,85,1,3,0); + checkInstruction(InstructionConstants.SASTORE,86,1,3,0); + checkInstruction(InstructionConstants.POP,87,1,1,0); + checkInstruction(InstructionConstants.POP2,88,1,2,0); + checkInstruction(InstructionConstants.DUP,89,1,1,2); + + // Instructions 090-099 + checkInstruction(InstructionConstants.DUP_X1,90,1,2,3); + checkInstruction(InstructionConstants.DUP_X2,91,1,3,4); + checkInstruction(InstructionConstants.DUP2,92,1,2,4); + checkInstruction(InstructionConstants.DUP2_X1,93,1,3,5); + checkInstruction(InstructionConstants.DUP2_X2,94,1,4,6); + checkInstruction(InstructionConstants.SWAP,95,1,2,2); + checkInstruction(InstructionConstants.IADD,96,1,2,1); + checkInstruction(InstructionConstants.LADD,97,1,4,2); + checkInstruction(InstructionConstants.FADD,98,1,2,1); + checkInstruction(InstructionConstants.DADD,99,1,4,2); + + // Instructions 100-109 + checkInstruction(InstructionConstants.ISUB,100,1,2,1); + checkInstruction(InstructionConstants.LSUB,101,1,4,2); + checkInstruction(InstructionConstants.FSUB,102,1,2,1); + checkInstruction(InstructionConstants.DSUB,103,1,4,2); + checkInstruction(InstructionConstants.IMUL,104,1,2,1); + checkInstruction(InstructionConstants.LMUL,105,1,4,2); + checkInstruction(InstructionConstants.FMUL,106,1,2,1); + checkInstruction(InstructionConstants.DMUL,107,1,4,2); + checkInstruction(InstructionConstants.IDIV,108,1,2,1); + checkInstruction(InstructionConstants.LDIV,109,1,4,2); + + // Instructions 110-119 + checkInstruction(InstructionConstants.FDIV,110,1,2,1); + checkInstruction(InstructionConstants.DDIV,111,1,4,2); + checkInstruction(InstructionConstants.IREM,112,1,2,1); + checkInstruction(InstructionConstants.LREM,113,1,4,2); + checkInstruction(InstructionConstants.FREM,114,1,2,1); + checkInstruction(InstructionConstants.DREM,115,1,4,2); + checkInstruction(InstructionConstants.INEG,116,1,1,1); + checkInstruction(InstructionConstants.LNEG,117,1,2,2); + checkInstruction(InstructionConstants.FNEG,118,1,1,1); + checkInstruction(InstructionConstants.DNEG,119,1,2,2); + + // Instructions 120-129 + checkInstruction(InstructionConstants.ISHL,120,1,2,1); + checkInstruction(InstructionConstants.LSHL,121,1,3,2); + checkInstruction(InstructionConstants.ISHR,122,1,2,1); + checkInstruction(InstructionConstants.LSHR,123,1,3,2); + checkInstruction(InstructionConstants.IUSHR,124,1,2,1); + checkInstruction(InstructionConstants.LUSHR,125,1,3,2); + checkInstruction(InstructionConstants.IAND,126,1,2,1); + checkInstruction(InstructionConstants.LAND,127,1,4,2); + checkInstruction(InstructionConstants.IOR,128,1,2,1); + checkInstruction(InstructionConstants.LOR,129,1,4,2); + + // Instructions 130-139 + checkInstruction(InstructionConstants.IXOR,130,1,2,1); + checkInstruction(InstructionConstants.LXOR,131,1,4,2); + checkInstruction(new IINC(0,0,false),132,3,0,0); + checkInstruction(InstructionConstants.I2L,133,1,1,2); + checkInstruction(InstructionConstants.I2F,134,1,1,1); + checkInstruction(InstructionConstants.I2D,135,1,1,2); + checkInstruction(InstructionConstants.L2I,136,1,2,1); + checkInstruction(InstructionConstants.L2F,137,1,2,1); + checkInstruction(InstructionConstants.L2D,138,1,2,2); + checkInstruction(InstructionConstants.F2I,139,1,1,1); + + // Instructions 140-149 + checkInstruction(InstructionConstants.F2L,140,1,1,2); + checkInstruction(InstructionConstants.F2D,141,1,1,2); + checkInstruction(InstructionConstants.D2I,142,1,2,1); + checkInstruction(InstructionConstants.D2L,143,1,2,2); + checkInstruction(InstructionConstants.D2F,144,1,2,1); + checkInstruction(InstructionConstants.I2B,145,1,1,1); + checkInstruction(InstructionConstants.I2C,146,1,1,1); + checkInstruction(InstructionConstants.I2S,147,1,1,1); + checkInstruction(InstructionConstants.LCMP,148,1,4,1); + checkInstruction(InstructionConstants.FCMPL,149,1,2,1); + + // Instructions 150-159 + checkInstruction(InstructionConstants.FCMPG,150,1,2,1); + checkInstruction(InstructionConstants.DCMPL,151,1,4,1); + checkInstruction(InstructionConstants.DCMPG,152,1,4,1); + checkInstruction(new InstructionBranch(Constants.IFEQ,s0),153,3,1,0); + checkInstruction(new InstructionBranch(Constants.IFNE,s0),154,3,1,0); + checkInstruction(new InstructionBranch(Constants.IFLT,s0),155,3,1,0); + checkInstruction(new InstructionBranch(Constants.IFGE,s0),156,3,1,0); + checkInstruction(new InstructionBranch(Constants.IFGT,s0),157,3,1,0); + checkInstruction(new InstructionBranch(Constants.IFLE,s0),158,3,1,0); + checkInstruction(new InstructionBranch(Constants.IF_ICMPEQ,s0),159,3,2,0); + + // Instructions 160-169 + checkInstruction(new InstructionBranch(Constants.IF_ICMPNE,s0),160,3,2,0); + checkInstruction(new InstructionBranch(Constants.IF_ICMPLT,s0),161,3,2,0); + checkInstruction(new InstructionBranch(Constants.IF_ICMPGE,s0),162,3,2,0); + checkInstruction(new InstructionBranch(Constants.IF_ICMPGT,s0),163,3,2,0); + checkInstruction(new InstructionBranch(Constants.IF_ICMPLE,s0),164,3,2,0); + checkInstruction(new InstructionBranch(Constants.IF_ACMPEQ,s0),165,3,2,0); + checkInstruction(new InstructionBranch(Constants.IF_ACMPNE,s0),166,3,2,0); + checkInstruction(new InstructionBranch(Constants.GOTO,s0),167,3,0,0); + checkInstruction(new InstructionBranch(Constants.JSR,s0),168,3,0,1); + checkInstruction(new RET(0,false),169,2,0,0); + + // Instructions 170-179 + checkInstruction(new TABLESWITCH(new int[]{},new InstructionHandle[]{},null),170,VARIES,1,0); + checkInstruction(new LOOKUPSWITCH(new int[]{},new InstructionHandle[]{},null),171,VARIES,1,0); + checkInstruction(InstructionConstants.IRETURN,172,1,1,0); + checkInstruction(InstructionConstants.LRETURN,173,1,2,0); + checkInstruction(InstructionConstants.FRETURN,174,1,1,0); + checkInstruction(InstructionConstants.DRETURN,175,1,2,0); + checkInstruction(InstructionConstants.ARETURN,176,1,1,0); + checkInstruction(InstructionConstants.RETURN,177,1,0,0); + checkInstruction(new FieldInstruction(Constants.GETSTATIC,0),178,3,0,VARIES); + checkInstruction(new FieldInstruction(Constants.PUTSTATIC,0),179,3,VARIES,0); + + // Instructions 180-189 + checkInstruction(new FieldInstruction(Constants.GETFIELD,0),180,3,1,VARIES); + checkInstruction(new FieldInstruction(Constants.PUTFIELD,0),181,3,VARIES,0); + checkInstruction(new InvokeInstruction(Constants.INVOKEVIRTUAL,0),182,3,VARIES,VARIES); // PRODUCE STACK VARIES OK HERE? (AND NEXT COUPLE) + checkInstruction(new InvokeInstruction(Constants.INVOKESPECIAL,0),183,3,VARIES,VARIES); + checkInstruction(new InvokeInstruction(Constants.INVOKESTATIC,0),184,3,VARIES,VARIES); + checkInstruction(new INVOKEINTERFACE(0,1,0),185,5,VARIES,VARIES); + // 186 does not exist + checkInstruction(new InstructionCP(Constants.NEW,b0),187,3,0,1); + checkInstruction(new InstructionByte(Constants.NEWARRAY,b0),188,2,1,1); + checkInstruction(new InstructionCP(Constants.ANEWARRAY,0),189,3,1,1); + + // Instructions 190-199 + checkInstruction(InstructionConstants.ARRAYLENGTH,190,1,1,1); + checkInstruction(InstructionConstants.ATHROW,191,1,1,1); + checkInstruction(new InstructionCP(Constants.CHECKCAST,s0),192,3,1,1); + checkInstruction(new InstructionCP(Constants.INSTANCEOF,s0),193,3,1,1); + checkInstruction(InstructionConstants.MONITORENTER,194,1,1,0); + checkInstruction(InstructionConstants.MONITOREXIT,195,1,1,0); + // 196 is 'wide' tag + checkInstruction(new MULTIANEWARRAY(s0,b0),197,4,VARIES,1); + checkInstruction(new InstructionBranch(Constants.IFNULL,s0),198,3,1,0); + checkInstruction(new InstructionBranch(Constants.IFNONNULL,s0),199,3,1,0); + + // Instructions 200-209 + checkInstruction(new InstructionBranch(Constants.GOTO_W,0),200,5,0,0); + checkInstruction(new InstructionBranch(Constants.JSR_W,0),201,5,0,1); + + // Internally used instructions skipped + } + + public void checkInstruction(Instruction i,int opcode, int length, int stackConsumed, int stackProduced) { + String header = new String("Checking instruction '"+i+"' "); + if (i.opcode!=opcode) + fail(header+" expected opcode "+opcode+" but it is "+i.opcode); + + if (length!=VARIES && i.getLength()!=length) + fail(header+" expected length "+length+" but it is "+i.getLength()); +// if (stackConsumed>0) { +// if ((Constants.instFlags[opcode]&Constants.STACK_CONSUMER)==0) +// fail(header+" expected it to be a STACK_CONSUMER but it is not"); +// } else { +// if ((Constants.instFlags[opcode]&Constants.STACK_CONSUMER)!=0) +// fail(header+" expected it not to be a STACK_CONSUMER but it is"); +// } + if (stackConsumed==VARIES) { + if (Constants.CONSUME_STACK[opcode]!=Constants.UNPREDICTABLE) + fail("Instruction '"+i+"' should be consuming some unpredictable number of stack entries but it says it will consume "+Constants.CONSUME_STACK[opcode]); + + } else { + if (Constants.CONSUME_STACK[opcode]!=stackConsumed) + fail("Instruction '"+i+"' should be consuming "+stackConsumed+" stack entries but it says it will consume "+Constants.CONSUME_STACK[opcode]); + } +// if (stackProduced>0) { +// if ((Constants.instFlags[opcode]&Constants.STACK_PRODUCER)==0) +// fail(header+" expected it to be a STACK_PRODUCER but it is not"); +// } else { +// if ((Constants.instFlags[opcode]&Constants.STACK_PRODUCER)!=0) +// fail(header+" expected it not to be a STACK_PRODUCER but it is"); +// } + if (stackProduced==VARIES) { + if (Constants.stackEntriesProduced[opcode]!=Constants.UNPREDICTABLE) + fail(header+" should be producing some unpredictable number of stack entries but it says it will produce "+Constants.stackEntriesProduced[opcode]); + + } else { + if (Constants.stackEntriesProduced[opcode]!=stackProduced) + fail(header+" should be producing "+stackProduced+" stack entries but it says it will produce "+Constants.stackEntriesProduced[opcode]); + } + } + + private final static byte b0 = 0; + private final static short s0 = 0; + private final static short s20 = 20; + private final static int VARIES = -1; +} diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/GeneratingAnnotatedClassesTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/GeneratingAnnotatedClassesTest.java index 6c0258beb..6306c3edc 100644 --- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/GeneratingAnnotatedClassesTest.java +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/GeneratingAnnotatedClassesTest.java @@ -17,15 +17,16 @@ import java.util.List; import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.Method; -import org.aspectj.apache.bcel.classfile.annotation.Annotation; -import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePair; -import org.aspectj.apache.bcel.classfile.annotation.ElementValue; -import org.aspectj.apache.bcel.generic.ALOAD; -import org.aspectj.apache.bcel.generic.ASTORE; import org.aspectj.apache.bcel.generic.ArrayType; import org.aspectj.apache.bcel.generic.ClassGen; -import org.aspectj.apache.bcel.generic.ConstantPoolGen; -import org.aspectj.apache.bcel.generic.GOTO; +import org.aspectj.apache.bcel.classfile.ConstantPool; +import org.aspectj.apache.bcel.classfile.annotation.AnnotationElementValueGen; +import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; +import org.aspectj.apache.bcel.classfile.annotation.ArrayElementValueGen; +import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePairGen; +import org.aspectj.apache.bcel.classfile.annotation.ElementValueGen; +import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValueGen; +import org.aspectj.apache.bcel.generic.InstructionBranch; import org.aspectj.apache.bcel.generic.InstructionConstants; import org.aspectj.apache.bcel.generic.InstructionFactory; import org.aspectj.apache.bcel.generic.InstructionHandle; @@ -33,14 +34,7 @@ import org.aspectj.apache.bcel.generic.InstructionList; import org.aspectj.apache.bcel.generic.LocalVariableGen; import org.aspectj.apache.bcel.generic.MethodGen; import org.aspectj.apache.bcel.generic.ObjectType; -import org.aspectj.apache.bcel.generic.PUSH; import org.aspectj.apache.bcel.generic.Type; -import org.aspectj.apache.bcel.generic.annotation.AnnotationElementValueGen; -import org.aspectj.apache.bcel.generic.annotation.AnnotationGen; -import org.aspectj.apache.bcel.generic.annotation.ArrayElementValueGen; -import org.aspectj.apache.bcel.generic.annotation.ElementNameValuePairGen; -import org.aspectj.apache.bcel.generic.annotation.ElementValueGen; -import org.aspectj.apache.bcel.generic.annotation.SimpleElementValueGen; import org.aspectj.apache.bcel.util.SyntheticRepository; /** @@ -76,7 +70,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase { // Create HelloWorld ClassGen cg = createClassGen("HelloWorld"); - ConstantPoolGen cp = cg.getConstantPool(); + ConstantPool cp = cg.getConstantPool(); InstructionList il = new InstructionList(); cg.addAnnotation(createSimpleVisibleAnnotation(cp)); @@ -88,21 +82,21 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase { JavaClass jc = getClassFrom(".","HelloWorld"); - Annotation[] as = jc.getAnnotations(); + AnnotationGen[] as = jc.getAnnotations(); assertTrue("Should be two annotations but found "+as.length,as.length==2); - Annotation one = as[0]; - Annotation two = as[1]; + AnnotationGen one = as[0]; + AnnotationGen two = as[1]; assertTrue("Name of annotation 1 should be SimpleAnnotation but it is "+as[0].getTypeName(), as[0].getTypeName().equals("SimpleAnnotation")); assertTrue("Name of annotation 2 should be SimpleAnnotation but it is "+as[1].getTypeName(), as[1].getTypeName().equals("SimpleAnnotation")); List vals = as[0].getValues(); - ElementNameValuePair nvp = (ElementNameValuePair) vals.get(0); + ElementNameValuePairGen nvp = (ElementNameValuePairGen) vals.get(0); assertTrue("Name of element in SimpleAnnotation should be 'id' but it is "+ nvp.getNameString(),nvp.getNameString().equals("id")); - ElementValue ev = nvp.getValue(); + ElementValueGen ev = nvp.getValue(); assertTrue("Type of element value should be int but it is "+ev.getElementValueType(), - ev.getElementValueType()==ElementValue.PRIMITIVE_INT); + ev.getElementValueType()==ElementValueGen.PRIMITIVE_INT); assertTrue("Value of element should be 4 but it is "+ev.stringifyValue(), ev.stringifyValue().equals("4")); assertTrue(createTestdataFile("HelloWorld.class").delete()); @@ -117,7 +111,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase { public void testGenerateMethodLevelAnnotations1() throws ClassNotFoundException { // Create HelloWorld ClassGen cg = createClassGen("HelloWorld"); - ConstantPoolGen cp = cg.getConstantPool(); + ConstantPool cp = cg.getConstantPool(); InstructionList il = new InstructionList(); buildClassContentsWithAnnotatedMethods(cg, cp, il); @@ -158,7 +152,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase { public void testGenerateMethodLevelAnnotations2() throws ClassNotFoundException { // Create HelloWorld ClassGen cg = createClassGen("HelloWorld"); - ConstantPoolGen cp = cg.getConstantPool(); + ConstantPool cp = cg.getConstantPool(); InstructionList il = new InstructionList(); buildClassContentsWithAnnotatedMethods(cg, cp, il); @@ -247,9 +241,9 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase { ElementValueGen value = (ElementValueGen)nvp.getValue(); assertTrue("Value should be ArrayElementValueGen but is "+value,value instanceof ArrayElementValueGen); ArrayElementValueGen arrayValue = (ArrayElementValueGen)value; - assertTrue("Array value should be size one but is "+arrayValue.getElementValuesSize(), - arrayValue.getElementValuesSize()==1); - ElementValueGen innerValue = (ElementValueGen)arrayValue.getElementValues().get(0); + assertTrue("Array value should be size one but is "+arrayValue.getElementValuesArraySize(), + arrayValue.getElementValuesArraySize()==1); + ElementValueGen innerValue = (ElementValueGen)arrayValue.getElementValuesArray()[0]; assertTrue("Value in the array should be AnnotationElementValueGen but is "+innerValue, innerValue instanceof AnnotationElementValueGen); AnnotationElementValueGen innerAnnotationValue = (AnnotationElementValueGen)innerValue; @@ -287,7 +281,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase { public void testModifyingClasses1() throws ClassNotFoundException { JavaClass jc = getClassFrom("testcode.jar","SimpleAnnotatedClass"); ClassGen cgen = new ClassGen(jc); - ConstantPoolGen cp = cgen.getConstantPool(); + ConstantPool cp = cgen.getConstantPool(); cgen.addAnnotation(createFruitAnnotation(cp,"Pineapple")); assertTrue("Should now have two annotations but has "+cgen.getAnnotations().length, cgen.getAnnotations().length==2); @@ -301,7 +295,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase { public void testModifyingClasses2() throws ClassNotFoundException { JavaClass jc = getClassFrom("testcode.jar","SimpleAnnotatedClass"); ClassGen cgen = new ClassGen(jc); - ConstantPoolGen cp = cgen.getConstantPool(); + ConstantPool cp = cgen.getConstantPool(); cgen.addAnnotation(createCombinedAnnotation(cp)); assertTrue("Should now have two annotations but has "+cgen.getAnnotations().length, cgen.getAnnotations().length==2); @@ -327,7 +321,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase { dumpClass(cg,dir+File.separator+fname); } - private void buildClassContentsWithAnnotatedMethods(ClassGen cg, ConstantPoolGen cp, InstructionList il) { + private void buildClassContentsWithAnnotatedMethods(ClassGen cg, ConstantPool cp, InstructionList il) { // Create method 'public static void main(String[]argv)' MethodGen mg = createMethodGen("main",il,cp); InstructionFactory factory = new InstructionFactory(cg); @@ -356,14 +350,14 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase { LocalVariableGen lg = mg.addLocalVariable("in", new ObjectType( "java.io.BufferedReader"), null, null); int in = lg.getIndex(); - lg.setStart(il.append(new ASTORE(in))); // "in" valid from here + lg.setStart(il.append(InstructionFactory.createASTORE(in))); // "in" valid from here // Create local variable name and initialize it to null lg = mg.addLocalVariable("name", Type.STRING, null, null); int name = lg.getIndex(); il.append(InstructionConstants.ACONST_NULL); - lg.setStart(il.append(new ASTORE(name))); // "name" valid from here + lg.setStart(il.append(InstructionFactory.createASTORE(name))); // "name" valid from here // Create try-catch block: We remember the start of the block, read a // line from the standard input and store it into the variable name . @@ -378,13 +372,13 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase { // il.append(new ALOAD(in)); // il.append(factory.createInvoke("java.io.BufferedReader", "readLine", // Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); - InstructionHandle try_start = il.append(new PUSH(cp,"Andy")); - il.append(new ASTORE(name)); + InstructionHandle try_start = il.append(InstructionFactory.PUSH(cp,"Andy")); + il.append(InstructionFactory.createASTORE(name)); // Upon normal execution we jump behind exception handler, the target // address is not known yet. - GOTO g = new GOTO(null); + InstructionBranch g = new InstructionBranch(Constants.GOTO); InstructionHandle try_end = il.append(g); // We add the exception handler which simply returns from the method. @@ -392,7 +386,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase { LocalVariableGen var_ex = mg.addLocalVariable("ex",Type.getType("Ljava.io.IOException;"),null,null); int var_ex_slot = var_ex.getIndex(); - InstructionHandle handler = il.append(new ASTORE(var_ex_slot)); + InstructionHandle handler = il.append(InstructionFactory.createASTORE(var_ex_slot)); var_ex.setStart(handler); var_ex.setEnd(il.append(InstructionConstants.RETURN)); @@ -411,12 +405,12 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase { il.append(factory.createNew(Type.STRINGBUFFER)); il.append(InstructionConstants.DUP); - il.append(new PUSH(cp, "Hello, ")); + il.append(InstructionFactory.PUSH(cp, "Hello, ")); il .append(factory.createInvoke("java.lang.StringBuffer", "<init>", Type.VOID, new Type[] { Type.STRING }, Constants.INVOKESPECIAL)); - il.append(new ALOAD(name)); + il.append(InstructionFactory.createALOAD(name)); il.append(factory.createInvoke("java.lang.StringBuffer", "append", Type.STRINGBUFFER, new Type[] { Type.STRING }, Constants.INVOKEVIRTUAL)); @@ -439,7 +433,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase { cg.addEmptyConstructor(Constants.ACC_PUBLIC); } - private void buildClassContents(ClassGen cg, ConstantPoolGen cp, InstructionList il) { + private void buildClassContents(ClassGen cg, ConstantPool cp, InstructionList il) { // Create method 'public static void main(String[]argv)' MethodGen mg = createMethodGen("main",il,cp); InstructionFactory factory = new InstructionFactory(cg); @@ -467,14 +461,14 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase { LocalVariableGen lg = mg.addLocalVariable("in", new ObjectType( "java.io.BufferedReader"), null, null); int in = lg.getIndex(); - lg.setStart(il.append(new ASTORE(in))); // "in" valid from here + lg.setStart(il.append(InstructionFactory.createASTORE(in))); // "in" valid from here // Create local variable name and initialize it to null lg = mg.addLocalVariable("name", Type.STRING, null, null); int name = lg.getIndex(); il.append(InstructionConstants.ACONST_NULL); - lg.setStart(il.append(new ASTORE(name))); // "name" valid from here + lg.setStart(il.append(InstructionFactory.createASTORE(name))); // "name" valid from here // Create try-catch block: We remember the start of the block, read a // line from the standard input and store it into the variable name . @@ -489,13 +483,13 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase { // il.append(new ALOAD(in)); // il.append(factory.createInvoke("java.io.BufferedReader", "readLine", // Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); - InstructionHandle try_start = il.append(new PUSH(cp,"Andy")); - il.append(new ASTORE(name)); + InstructionHandle try_start = il.append(InstructionFactory.PUSH(cp,"Andy")); + il.append(InstructionFactory.createASTORE(name)); // Upon normal execution we jump behind exception handler, the target // address is not known yet. - GOTO g = new GOTO(null); + InstructionBranch g = new InstructionBranch(Constants.GOTO); InstructionHandle try_end = il.append(g); // We add the exception handler which simply returns from the method. @@ -503,7 +497,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase { LocalVariableGen var_ex = mg.addLocalVariable("ex",Type.getType("Ljava.io.IOException;"),null,null); int var_ex_slot = var_ex.getIndex(); - InstructionHandle handler = il.append(new ASTORE(var_ex_slot)); + InstructionHandle handler = il.append(InstructionFactory.createASTORE(var_ex_slot)); var_ex.setStart(handler); var_ex.setEnd(il.append(InstructionConstants.RETURN)); @@ -522,12 +516,12 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase { il.append(factory.createNew(Type.STRINGBUFFER)); il.append(InstructionConstants.DUP); - il.append(new PUSH(cp, "Hello, ")); + il.append(InstructionFactory.PUSH(cp, "Hello, ")); il .append(factory.createInvoke("java.lang.StringBuffer", "<init>", Type.VOID, new Type[] { Type.STRING }, Constants.INVOKESPECIAL)); - il.append(new ALOAD(name)); + il.append(InstructionFactory.createALOAD(name)); il.append(factory.createInvoke("java.lang.StringBuffer", "append", Type.STRINGBUFFER, new Type[] { Type.STRING }, Constants.INVOKEVIRTUAL)); @@ -566,7 +560,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase { "<generated>", Constants.ACC_PUBLIC | Constants.ACC_SUPER, null); } - private MethodGen createMethodGen(String methodname,InstructionList il,ConstantPoolGen cp) { + private MethodGen createMethodGen(String methodname,InstructionList il,ConstantPool cp) { return new MethodGen( Constants.ACC_STATIC | Constants.ACC_PUBLIC, // access flags Type.VOID, // return type @@ -577,7 +571,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase { } - public AnnotationGen createSimpleVisibleAnnotation(ConstantPoolGen cp) { + public AnnotationGen createSimpleVisibleAnnotation(ConstantPool cp) { SimpleElementValueGen evg = new SimpleElementValueGen( ElementValueGen.PRIMITIVE_INT, cp, 4); @@ -592,7 +586,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase { return a; } - public AnnotationGen createFruitAnnotation(ConstantPoolGen cp,String aFruit) { + public AnnotationGen createFruitAnnotation(ConstantPool cp,String aFruit) { SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.STRING,cp,aFruit); ElementNameValuePairGen nvGen = new ElementNameValuePairGen("fruit",evg,cp); ObjectType t = new ObjectType("SimpleStringAnnotation"); @@ -601,7 +595,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase { return new AnnotationGen(t,elements,true,cp); } - public AnnotationGen createCombinedAnnotation(ConstantPoolGen cp) { + public AnnotationGen createCombinedAnnotation(ConstantPool cp) { // Create an annotation instance AnnotationGen a = createSimpleVisibleAnnotation(cp); ArrayElementValueGen array = new ArrayElementValueGen(cp); @@ -612,7 +606,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase { return new AnnotationGen(new ObjectType("CombinedAnnotation"),elements,true,cp); } - public AnnotationGen createSimpleInvisibleAnnotation(ConstantPoolGen cp) { + public AnnotationGen createSimpleInvisibleAnnotation(ConstantPool cp) { SimpleElementValueGen evg = new SimpleElementValueGen( ElementValueGen.PRIMITIVE_INT, cp, 4); diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/GenericSignatureParsingTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/GenericSignatureParsingTest.java index b4b8dbce3..dbc3ae154 100644 --- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/GenericSignatureParsingTest.java +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/GenericSignatureParsingTest.java @@ -11,11 +11,16 @@ * ******************************************************************/ package org.aspectj.apache.bcel.classfile.tests; +import java.util.ArrayList; + +import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.classfile.Attribute; +import org.aspectj.apache.bcel.classfile.ClassFormatException; import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.Method; import org.aspectj.apache.bcel.classfile.Signature; import org.aspectj.apache.bcel.classfile.Utility; +import org.aspectj.apache.bcel.classfile.Utility.ResultHolder; /** * Generics introduces more complex signature possibilities, they are no longer just @@ -149,27 +154,27 @@ public class GenericSignatureParsingTest extends BcelTestCase { // These routines call BCEL to determine if it can correctly translate from one form to the other. private void checkClassTypeSignature(String sig, String expected) { StringBuffer result = new StringBuffer(); - int p = Utility.readClassTypeSignatureFrom(sig,0,result,false); + int p = GenericSignatureParsingTest.readClassTypeSignatureFrom(sig,0,result,false); assertTrue("Only swallowed "+p+" chars of this sig "+sig+" (len="+sig.length()+")",p==sig.length()); assertTrue("Expected '"+expected+"' but got '"+result.toString()+"'",result.toString().equals(expected)); } private void checkMethodTypeToSignature(String ret,String[] args,String expected) { - String res = Utility.methodTypeToSignature(ret,args); + String res = GenericSignatureParsingTest.methodTypeToSignature(ret,args); if (!res.equals(expected)) { fail("Should match. Got: "+res+" Expected:"+expected); } } private void checkMethodSignatureReturnType(String sig,String expected) { - String result = Utility.methodSignatureReturnType(sig,false); + String result = GenericSignatureParsingTest.methodSignatureReturnType(sig,false); if (!result.equals(expected)) { fail("Should match. Got: "+result+" Expected:"+expected); } } private void checkMethodSignatureArgumentTypes(String in,String[] expected) { - String[] result = Utility.methodSignatureArgumentTypes(in,false); + String[] result = GenericSignatureParsingTest.methodSignatureArgumentTypes(in,false); if (result.length!=expected.length) { fail("Expected "+expected.length+" entries to be returned but only got "+result.length); } @@ -191,5 +196,278 @@ public class GenericSignatureParsingTest extends BcelTestCase { } return null; } + + + /** + * Takes a string and consumes a single complete signature from it, returning + * how many chars it consumed. The chopit flag indicates whether to shorten + * type references ( java/lang/String => String ) + * + * FIXME asc this should also create some kind of object you can query for information about whether its parameterized, what the bounds are, etc... + */ + public static final int readClassTypeSignatureFrom(String signature, int posn, StringBuffer result, boolean chopit) { + int idx = posn; + try { + switch (signature.charAt(idx)) { + case 'B' : result.append("byte"); return 1; + case 'C' : result.append("char"); return 1; + case 'D' : result.append("double"); return 1; + case 'F' : result.append("float"); return 1; + case 'I' : result.append("int"); return 1; + case 'J' : result.append("long"); return 1; + case 'S' : result.append("short"); return 1; + case 'Z' : result.append("boolean");return 1; + case 'V' : result.append("void"); return 1; + + + //FIXME ASC Need a state machine to check we are parsing the right stuff here ! + case 'T' : + idx++; + int nextSemiIdx = signature.indexOf(';',idx); + result.append(signature.substring(idx,nextSemiIdx)); + return nextSemiIdx+1-posn; + + case '+' : + result.append("? extends "); + return readClassTypeSignatureFrom(signature,idx+1,result,chopit)+1; + + case '-' : + result.append("? super "); + return readClassTypeSignatureFrom(signature,idx+1,result,chopit)+1; + + case '*' : + result.append("?"); + return 1; + + case 'L' : // Full class name + boolean parameterized = false; + int idxSemicolon = signature.indexOf(';',idx); // Look for closing ';' or '<' + int idxAngly = signature.indexOf('<',idx); + int endOfSig = idxSemicolon; + if ((idxAngly!=-1) && idxAngly<endOfSig) { endOfSig = idxAngly; parameterized = true; } + + String p = signature.substring(idx+1,endOfSig); + String t = Utility.compactClassName(p,chopit); + + result.append(t); + idx=endOfSig; + // we might have finished now, depending on whether this is a parameterized type... + if (parameterized) { + idx++; + result.append("<"); + while (signature.charAt(idx)!='>') { + idx+=readClassTypeSignatureFrom(signature,idx,result,chopit); + if (signature.charAt(idx)!='>') result.append(","); + } + result.append(">");idx++; + } + if (signature.charAt(idx)!=';') throw new RuntimeException("Did not find ';' at end of signature, found "+signature.charAt(idx)); + idx++; + return idx-posn; + + + case '[' : // Array declaration + int dim = 0; + while (signature.charAt(idx)=='[') {dim++;idx++;} + idx+=readClassTypeSignatureFrom(signature,idx,result,chopit); + while (dim>0) {result.append("[]");dim--;} + return idx-posn; + + default : throw new ClassFormatException("Invalid signature: `" + + signature + "'"); + } + } catch(StringIndexOutOfBoundsException e) { // Should never occur + throw new ClassFormatException("Invalid signature: " + e + ":" + signature); + } + } + + + public static final String readClassTypeSignatureFrom(String signature) { + StringBuffer sb = new StringBuffer(); + GenericSignatureParsingTest.readClassTypeSignatureFrom(signature,0,sb,false); + return sb.toString(); + } + + + public static int countBrackets(String brackets) { + char[] chars = brackets.toCharArray(); + int count = 0; + boolean open = false; + + for(int i=0; i<chars.length; i++) { + switch(chars[i]) { + case '[': + if (open) throw new RuntimeException("Illegally nested brackets:" + brackets); + open = true; + break; + + case ']': + if (!open) throw new RuntimeException("Illegally nested brackets:" + brackets); + open = false; + count++; + break; + + default: + } + } + + if (open) throw new RuntimeException("Illegally nested brackets:" + brackets); + + return count; + } + + + /** + * Parse Java type such as "char", or "java.lang.String[]" and return the + * signature in byte code format, e.g. "C" or "[Ljava/lang/String;" respectively. + * + * @param type Java type + * @return byte code signature + */ + public static String getSignature(String type) { + StringBuffer buf = new StringBuffer(); + char[] chars = type.toCharArray(); + boolean char_found = false, delim = false; + int index = -1; + + loop: + for (int i=0; i < chars.length; i++) { + switch (chars[i]) { + case ' ': case '\t': case '\n': case '\r': case '\f': + if (char_found) delim = true; + break; + + case '[': + if (!char_found) throw new RuntimeException("Illegal type: " + type); + index = i; + break loop; + + default: + char_found = true; + if (!delim) buf.append(chars[i]); + } + } + + int brackets = 0; + + if(index > 0) brackets = GenericSignatureParsingTest.countBrackets(type.substring(index)); + + type = buf.toString(); + buf.setLength(0); + + for (int i=0; i < brackets; i++) buf.append('['); + + boolean found = false; + + for(int i=Constants.T_BOOLEAN; (i <= Constants.T_VOID) && !found; i++) { + if (Constants.TYPE_NAMES[i].equals(type)) { + found = true; + buf.append(Constants.SHORT_TYPE_NAMES[i]); + } + } + + // Class name + if (!found) buf.append('L' + type.replace('.', '/') + ';'); + + return buf.toString(); + } + + + /** + * For some method signature (class file format) like '([Ljava/lang/String;)Z' this returns + * the string representing the return type its 'normal' form, e.g. 'boolean' + * + * @param signature Method signature + * @param chopit Shorten class names + * @return return type of method + */ + public static final String methodSignatureReturnType(String signature,boolean chopit) throws ClassFormatException { + int index; + String type; + try { + // Read return type after `)' + index = signature.lastIndexOf(')') + 1; + type = Utility.signatureToString(signature.substring(index), chopit); + } catch (StringIndexOutOfBoundsException e) { + throw new ClassFormatException("Invalid method signature: " + signature); + } + return type; + } + + + /** + * For some method signature (class file format) like '([Ljava/lang/String;)Z' this returns + * the string representing the return type its 'normal' form, e.g. 'boolean' + * + * @param signature Method signature + * @return return type of method + * @throws ClassFormatException + */ + public static final String methodSignatureReturnType(String signature) throws ClassFormatException { + return GenericSignatureParsingTest.methodSignatureReturnType(signature, true); + } + + + /** + * For some method signature (class file format) like '([Ljava/lang/String;Z)V' this returns an array + * of strings representing the arguments in their 'normal' form, e.g. '{java.lang.String[],boolean}' + * + * @param signature Method signature + * @param chopit Shorten class names + * @return Array of argument types + */ + public static final String[] methodSignatureArgumentTypes(String signature,boolean chopit) throws ClassFormatException { + ArrayList vec = new ArrayList(); + int index; + String[] types; + + try { // Read all declarations between for `(' and `)' + if (signature.charAt(0) != '(') + throw new ClassFormatException("Invalid method signature: " + signature); + + index = 1; // current string position + + while(signature.charAt(index) != ')') { + Utility.ResultHolder rh = Utility.signatureToStringInternal(signature.substring(index),chopit); + vec.add(rh.getResult()); + index += rh.getConsumedChars(); + } + } catch(StringIndexOutOfBoundsException e) { + throw new ClassFormatException("Invalid method signature: " + signature); + } + + types = new String[vec.size()]; + vec.toArray(types); + return types; + } + + + /** + * Converts string containing the method return and argument types + * to a byte code method signature. + * + * @param returnType Return type of method (e.g. "char" or "java.lang.String[]") + * @param methodArgs Types of method arguments + * @return Byte code representation of method signature + */ + public final static String methodTypeToSignature(String returnType, String[] methodArgs) throws ClassFormatException { + + StringBuffer buf = new StringBuffer("("); + + if (methodArgs != null) { + for (int i=0; i < methodArgs.length; i++) { + String str = GenericSignatureParsingTest.getSignature(methodArgs[i]); + + if (str.equals("V")) // void can't be a method argument + throw new ClassFormatException("Invalid type: " + methodArgs[i]); + + buf.append(str); + } + } + + buf.append(")" + GenericSignatureParsingTest.getSignature(returnType)); + + return buf.toString(); + } } diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/MethodAnnotationsTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/MethodAnnotationsTest.java index 5b4bbbaa9..005eb3f69 100644 --- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/MethodAnnotationsTest.java +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/MethodAnnotationsTest.java @@ -18,8 +18,8 @@ import java.util.Iterator; import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.Method; -import org.aspectj.apache.bcel.classfile.annotation.Annotation; -import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePair; +import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; +import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePairGen; import org.aspectj.apache.bcel.util.SyntheticRepository; @@ -65,7 +65,7 @@ public class MethodAnnotationsTest extends BcelTestCase { for (int i = 0; i < methods.length; i++) { Method m = methods[i]; - Annotation[] methodAnnotations = m.getAnnotations(); + AnnotationGen[] methodAnnotations = m.getAnnotations(); if (m.getName().equals(methodname)) { checkAnnotation(methodAnnotations[0],annotationName,annotationElementName,annotationElementValue); @@ -73,11 +73,11 @@ public class MethodAnnotationsTest extends BcelTestCase { } } - private void checkAnnotation(Annotation a,String name,String elementname,String elementvalue) { + private void checkAnnotation(AnnotationGen a,String name,String elementname,String elementvalue) { assertTrue("Expected annotation to have name "+name+" but it had name "+a.getTypeName(), a.getTypeName().equals(name)); assertTrue("Expected annotation to have one element but it had "+a.getValues().size(),a.getValues().size()==1); - ElementNameValuePair envp = (ElementNameValuePair)a.getValues().get(0); + ElementNameValuePairGen envp = (ElementNameValuePairGen)a.getValues().get(0); assertTrue("Expected element name "+elementname+" but was "+envp.getNameString(), elementname.equals(envp.getNameString())); assertTrue("Expected element value "+elementvalue+" but was "+envp.getValue().stringifyValue(), @@ -87,9 +87,9 @@ public class MethodAnnotationsTest extends BcelTestCase { // helper methods - public void checkValue(Annotation a,String name,String tostring) { + public void checkValue(AnnotationGen a,String name,String tostring) { for (Iterator i = a.getValues().iterator(); i.hasNext();) { - ElementNameValuePair element = (ElementNameValuePair) i.next(); + ElementNameValuePairGen element = (ElementNameValuePairGen) i.next(); if (element.getNameString().equals(name)) { if (!element.getValue().stringifyValue().equals(tostring)) { fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue()); diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java index d0afaef41..1ba040ea0 100644 --- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java @@ -17,28 +17,25 @@ import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.classfile.Attribute; import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.Method; -import org.aspectj.apache.bcel.classfile.annotation.Annotation; -import org.aspectj.apache.bcel.generic.ALOAD; -import org.aspectj.apache.bcel.generic.ASTORE; import org.aspectj.apache.bcel.generic.ArrayType; import org.aspectj.apache.bcel.generic.ClassGen; -import org.aspectj.apache.bcel.generic.ConstantPoolGen; -import org.aspectj.apache.bcel.generic.GOTO; +import org.aspectj.apache.bcel.classfile.ConstantPool; +import org.aspectj.apache.bcel.classfile.annotation.AnnotationElementValueGen; +import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; +import org.aspectj.apache.bcel.classfile.annotation.ArrayElementValueGen; +import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePairGen; +import org.aspectj.apache.bcel.classfile.annotation.ElementValueGen; +import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValueGen; +import org.aspectj.apache.bcel.generic.InstructionBranch; import org.aspectj.apache.bcel.generic.InstructionConstants; import org.aspectj.apache.bcel.generic.InstructionFactory; import org.aspectj.apache.bcel.generic.InstructionHandle; +import org.aspectj.apache.bcel.generic.InstructionLV; import org.aspectj.apache.bcel.generic.InstructionList; import org.aspectj.apache.bcel.generic.LocalVariableGen; import org.aspectj.apache.bcel.generic.MethodGen; import org.aspectj.apache.bcel.generic.ObjectType; -import org.aspectj.apache.bcel.generic.PUSH; import org.aspectj.apache.bcel.generic.Type; -import org.aspectj.apache.bcel.generic.annotation.AnnotationElementValueGen; -import org.aspectj.apache.bcel.generic.annotation.AnnotationGen; -import org.aspectj.apache.bcel.generic.annotation.ArrayElementValueGen; -import org.aspectj.apache.bcel.generic.annotation.ElementNameValuePairGen; -import org.aspectj.apache.bcel.generic.annotation.ElementValueGen; -import org.aspectj.apache.bcel.generic.annotation.SimpleElementValueGen; import org.aspectj.apache.bcel.util.SyntheticRepository; /** @@ -66,7 +63,7 @@ public class ParameterAnnotationsTest extends BcelTestCase { */ public void testParameterAnnotations_builtOK() { ClassGen clg = createClassGen("HelloWorld"); - ConstantPoolGen cpg = clg.getConstantPool(); + ConstantPool cpg = clg.getConstantPool(); InstructionList il = new InstructionList(); buildClassContentsWithAnnotatedMethods(clg,cpg,il,true); @@ -75,7 +72,7 @@ public class ParameterAnnotationsTest extends BcelTestCase { assertTrue("Class should have 2 methods but has "+i,i==2); Method mainMethod = clg.getMethods()[0]; - Annotation[] annos = mainMethod.getAnnotationsOnParameter(0); + AnnotationGen[] annos = mainMethod.getAnnotationsOnParameter(0); assertTrue("Should be two annotation on the 'argv' parameter to main() but there are "+annos.length,annos.length==2); assertTrue("This annotation should contain the string 'fruit=Apples' but it is "+annos[0].toString(), annos[0].toString().indexOf("fruit=Apples")!=-1); @@ -90,7 +87,7 @@ public class ParameterAnnotationsTest extends BcelTestCase { */ public void testParameterAnnotations_savedAndLoadedOK() throws ClassNotFoundException { ClassGen clg = createClassGen("HelloWorld"); - ConstantPoolGen cpg = clg.getConstantPool(); + ConstantPool cpg = clg.getConstantPool(); InstructionList il = new InstructionList(); buildClassContentsWithAnnotatedMethods(clg,cpg,il,true); @@ -105,7 +102,7 @@ public class ParameterAnnotationsTest extends BcelTestCase { assertTrue("Class should have 2 methods but has "+i,i==2); Method mainMethod = clg.getMethods()[0]; - Annotation[] annos = mainMethod.getAnnotationsOnParameter(0); + AnnotationGen[] annos = mainMethod.getAnnotationsOnParameter(0); assertTrue("Should be two annotation on the 'argv' parameter to main() but there are "+annos.length,annos.length==2); assertTrue("This annotation should contain the string 'fruit=Apples' but it is "+annos[0].toString(), annos[0].toString().indexOf("fruit=Apples")!=-1); @@ -124,7 +121,7 @@ public class ParameterAnnotationsTest extends BcelTestCase { JavaClass jc = getClassFrom("testcode.jar","AnnotatedParameters"); ClassGen clg = new ClassGen(jc); - ConstantPoolGen cpg = clg.getConstantPool(); + ConstantPool cpg = clg.getConstantPool(); // // Foo method looks like this: @@ -171,15 +168,15 @@ public class ParameterAnnotationsTest extends BcelTestCase { JavaClass jc2 = getClassFrom("temp2","AnnotatedParameters"); m = jc2.getMethods()[2]; - Annotation[] p1annotations = m.getAnnotationsOnParameter(0); - Annotation[] p2annotations = m.getAnnotationsOnParameter(1); + AnnotationGen[] p1annotations = m.getAnnotationsOnParameter(0); + AnnotationGen[] p2annotations = m.getAnnotationsOnParameter(1); assertTrue("Expected two annotations on the first parameter but found "+p1annotations.length,p1annotations.length==2); assertTrue("Expected two annotations on the second parameter but found "+p2annotations.length,p2annotations.length==2); String expectedString = "[@SimpleAnnotation(id=2),@SimpleStringAnnotation(fruit=Banana)]"; assertTrue("Expected formatted short string of '"+expectedString+"' but it was '"+dumpAnnotations(p1annotations)+"'", dumpAnnotations(p1annotations).equals(expectedString)); - expectedString = "[@SimpleAnnotation(id=3),@AnnotationEnumElement(enumval=Red)]"; + expectedString = "[@SimpleAnnotation(id=3),@AnnotationEnumElement(enumval=LSimpleEnum;Red)]"; assertTrue("Expected formatted short string of '"+expectedString+"' but it was '"+dumpAnnotations(p2annotations)+"'", dumpAnnotations(p2annotations).equals(expectedString)); @@ -193,7 +190,7 @@ public class ParameterAnnotationsTest extends BcelTestCase { public void testParameterAnnotations_loadedThenModifiedWithInvisibleAnnotationThenSavedAndLoadedOK() throws ClassNotFoundException { JavaClass jc = getClassFrom("testcode.jar","AnnotatedParameters"); ClassGen clg = new ClassGen(jc); - ConstantPoolGen cpg = clg.getConstantPool(); + ConstantPool cpg = clg.getConstantPool(); // // Foo method looks like this: @@ -242,15 +239,15 @@ public class ParameterAnnotationsTest extends BcelTestCase { JavaClass jc2 = getClassFrom("temp3","AnnotatedParameters"); m = jc2.getMethods()[2]; - Annotation[] p1annotations = m.getAnnotationsOnParameter(0); - Annotation[] p2annotations = m.getAnnotationsOnParameter(1); + AnnotationGen[] p1annotations = m.getAnnotationsOnParameter(0); + AnnotationGen[] p2annotations = m.getAnnotationsOnParameter(1); assertTrue("Expected two annotations on the first parameter but found "+p1annotations.length,p1annotations.length==2); assertTrue("Expected two annotations on the second parameter but found "+p2annotations.length,p2annotations.length==2); String expectedString = "[@SimpleAnnotation(id=2),@SimpleStringAnnotation(fruit=Banana)]"; assertTrue("Expected formatted short string of '"+expectedString+"' but it was '"+dumpAnnotations(p1annotations)+"'", dumpAnnotations(p1annotations).equals(expectedString)); - expectedString = "[@SimpleAnnotation(id=3),@AnnotationEnumElement(enumval=Red)]"; + expectedString = "[@SimpleAnnotation(id=3),@AnnotationEnumElement(enumval=LSimpleEnum;Red)]"; assertTrue("Expected formatted short string of '"+expectedString+"' but it was '"+dumpAnnotations(p2annotations)+"'", dumpAnnotations(p2annotations).equals(expectedString)); @@ -263,12 +260,12 @@ public class ParameterAnnotationsTest extends BcelTestCase { // attributes vanish ! clg = new ClassGen(jc2); mg = new MethodGen(m,clg.getClassName(),clg.getConstantPool()); - Attribute[] as = mg.getAttributes(); - assertTrue("Should be 2 (RIPA and RVPA) but there are "+mg.getAttributes().length,mg.getAttributes().length==2); + List as = mg.getAttributes(); + assertTrue("Should be 2 (RIPA and RVPA) but there are "+mg.getAttributes().size(),mg.getAttributes().size()==2); List l = mg.getAnnotationsOnParameter(0); assertTrue("Should be 2 annotations on first parameter but there is only "+l.size()+":"+l.toString(), l.size()==2); - assertTrue("Should be 0 but there are "+mg.getAttributes().length,mg.getAttributes().length==0); + assertTrue("Should be 0 but there are "+mg.getAttributes().size(),mg.getAttributes().size()==0); } @@ -294,7 +291,7 @@ public class ParameterAnnotationsTest extends BcelTestCase { dumpClass(cg,dir+File.separator+fname); } - private void buildClassContentsWithAnnotatedMethods(ClassGen cg, ConstantPoolGen cp, InstructionList il,boolean addParameterAnnotations) { + private void buildClassContentsWithAnnotatedMethods(ClassGen cg, ConstantPool cp, InstructionList il,boolean addParameterAnnotations) { // Create method 'public static void main(String[]argv)' MethodGen mg = createMethodGen("main",il,cp); InstructionFactory factory = new InstructionFactory(cg); @@ -323,14 +320,14 @@ public class ParameterAnnotationsTest extends BcelTestCase { LocalVariableGen lg = mg.addLocalVariable("in", new ObjectType( "java.io.BufferedReader"), null, null); int in = lg.getIndex(); - lg.setStart(il.append(new ASTORE(in))); // "in" valid from here + lg.setStart(il.append(InstructionFactory.createASTORE(in))); // "in" valid from here // Create local variable name and initialize it to null lg = mg.addLocalVariable("name", Type.STRING, null, null); int name = lg.getIndex(); il.append(InstructionConstants.ACONST_NULL); - lg.setStart(il.append(new ASTORE(name))); // "name" valid from here + lg.setStart(il.append(InstructionFactory.createASTORE(name))); // "name" valid from here // Create try-catch block: We remember the start of the block, read a // line from the standard input and store it into the variable name . @@ -345,13 +342,13 @@ public class ParameterAnnotationsTest extends BcelTestCase { // il.append(new ALOAD(in)); // il.append(factory.createInvoke("java.io.BufferedReader", "readLine", // Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); - InstructionHandle try_start = il.append(new PUSH(cp,"Andy")); - il.append(new ASTORE(name)); + InstructionHandle try_start = il.append(InstructionFactory.PUSH(cp,"Andy")); + il.append(InstructionFactory.createASTORE(name)); // Upon normal execution we jump behind exception handler, the target // address is not known yet. - GOTO g = new GOTO(null); + InstructionBranch g = new InstructionBranch(Constants.GOTO); InstructionHandle try_end = il.append(g); // We add the exception handler which simply returns from the method. @@ -359,7 +356,7 @@ public class ParameterAnnotationsTest extends BcelTestCase { LocalVariableGen var_ex = mg.addLocalVariable("ex",Type.getType("Ljava.io.IOException;"),null,null); int var_ex_slot = var_ex.getIndex(); - InstructionHandle handler = il.append(new ASTORE(var_ex_slot)); + InstructionHandle handler = il.append(InstructionFactory.createASTORE(var_ex_slot)); var_ex.setStart(handler); var_ex.setEnd(il.append(InstructionConstants.RETURN)); @@ -378,12 +375,12 @@ public class ParameterAnnotationsTest extends BcelTestCase { il.append(factory.createNew(Type.STRINGBUFFER)); il.append(InstructionConstants.DUP); - il.append(new PUSH(cp, "Hello, ")); + il.append(InstructionFactory.PUSH(cp, "Hello, ")); il .append(factory.createInvoke("java.lang.StringBuffer", "<init>", Type.VOID, new Type[] { Type.STRING }, Constants.INVOKESPECIAL)); - il.append(new ALOAD(name)); + il.append(new InstructionLV(Constants.ALOAD,name)); il.append(factory.createInvoke("java.lang.StringBuffer", "append", Type.STRINGBUFFER, new Type[] { Type.STRING }, Constants.INVOKEVIRTUAL)); @@ -408,7 +405,7 @@ public class ParameterAnnotationsTest extends BcelTestCase { cg.addEmptyConstructor(Constants.ACC_PUBLIC); } - private void buildClassContents(ClassGen cg, ConstantPoolGen cp, InstructionList il) { + private void buildClassContents(ClassGen cg, ConstantPool cp, InstructionList il) { // Create method 'public static void main(String[]argv)' MethodGen mg = createMethodGen("main",il,cp); InstructionFactory factory = new InstructionFactory(cg); @@ -436,14 +433,14 @@ public class ParameterAnnotationsTest extends BcelTestCase { LocalVariableGen lg = mg.addLocalVariable("in", new ObjectType( "java.io.BufferedReader"), null, null); int in = lg.getIndex(); - lg.setStart(il.append(new ASTORE(in))); // "in" valid from here + lg.setStart(il.append(InstructionFactory.createASTORE(in))); // "in" valid from here // Create local variable name and initialize it to null lg = mg.addLocalVariable("name", Type.STRING, null, null); int name = lg.getIndex(); il.append(InstructionConstants.ACONST_NULL); - lg.setStart(il.append(new ASTORE(name))); // "name" valid from here + lg.setStart(il.append(InstructionFactory.createASTORE(name))); // "name" valid from here // Create try-catch block: We remember the start of the block, read a // line from the standard input and store it into the variable name . @@ -458,13 +455,13 @@ public class ParameterAnnotationsTest extends BcelTestCase { // il.append(new ALOAD(in)); // il.append(factory.createInvoke("java.io.BufferedReader", "readLine", // Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); - InstructionHandle try_start = il.append(new PUSH(cp,"Andy")); - il.append(new ASTORE(name)); + InstructionHandle try_start = il.append(InstructionFactory.PUSH(cp,"Andy")); + il.append(InstructionFactory.createASTORE(name)); // Upon normal execution we jump behind exception handler, the target // address is not known yet. - GOTO g = new GOTO(null); + InstructionBranch g = new InstructionBranch(Constants.GOTO); InstructionHandle try_end = il.append(g); // We add the exception handler which simply returns from the method. @@ -472,7 +469,7 @@ public class ParameterAnnotationsTest extends BcelTestCase { LocalVariableGen var_ex = mg.addLocalVariable("ex",Type.getType("Ljava.io.IOException;"),null,null); int var_ex_slot = var_ex.getIndex(); - InstructionHandle handler = il.append(new ASTORE(var_ex_slot)); + InstructionHandle handler = il.append(InstructionFactory.createASTORE(var_ex_slot)); var_ex.setStart(handler); var_ex.setEnd(il.append(InstructionConstants.RETURN)); @@ -491,12 +488,12 @@ public class ParameterAnnotationsTest extends BcelTestCase { il.append(factory.createNew(Type.STRINGBUFFER)); il.append(InstructionConstants.DUP); - il.append(new PUSH(cp, "Hello, ")); + il.append(InstructionFactory.PUSH(cp, "Hello, ")); il .append(factory.createInvoke("java.lang.StringBuffer", "<init>", Type.VOID, new Type[] { Type.STRING }, Constants.INVOKESPECIAL)); - il.append(new ALOAD(name)); + il.append(InstructionFactory.createALOAD(name)); il.append(factory.createInvoke("java.lang.StringBuffer", "append", Type.STRINGBUFFER, new Type[] { Type.STRING }, Constants.INVOKEVIRTUAL)); @@ -535,7 +532,7 @@ public class ParameterAnnotationsTest extends BcelTestCase { "<generated>", Constants.ACC_PUBLIC | Constants.ACC_SUPER, null); } - private MethodGen createMethodGen(String methodname,InstructionList il,ConstantPoolGen cp) { + private MethodGen createMethodGen(String methodname,InstructionList il,ConstantPool cp) { return new MethodGen( Constants.ACC_STATIC | Constants.ACC_PUBLIC, // access flags Type.VOID, // return type @@ -546,7 +543,7 @@ public class ParameterAnnotationsTest extends BcelTestCase { } - public AnnotationGen createSimpleVisibleAnnotation(ConstantPoolGen cp) { + public AnnotationGen createSimpleVisibleAnnotation(ConstantPool cp) { SimpleElementValueGen evg = new SimpleElementValueGen( ElementValueGen.PRIMITIVE_INT, cp, 4); @@ -561,7 +558,7 @@ public class ParameterAnnotationsTest extends BcelTestCase { return a; } - public AnnotationGen createCombinedAnnotation(ConstantPoolGen cp) { + public AnnotationGen createCombinedAnnotation(ConstantPool cp) { // Create an annotation instance AnnotationGen a = createSimpleVisibleAnnotation(cp); ArrayElementValueGen array = new ArrayElementValueGen(cp); @@ -572,7 +569,7 @@ public class ParameterAnnotationsTest extends BcelTestCase { return new AnnotationGen(new ObjectType("CombinedAnnotation"),elements,true,cp); } - public AnnotationGen createSimpleInvisibleAnnotation(ConstantPoolGen cp) { + public AnnotationGen createSimpleInvisibleAnnotation(ConstantPool cp) { SimpleElementValueGen evg = new SimpleElementValueGen( ElementValueGen.PRIMITIVE_INT, cp, 4); diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleAnnotationAttributeTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleAnnotationAttributeTest.java index 4c8c463cb..ac9023f22 100644 --- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleAnnotationAttributeTest.java +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleAnnotationAttributeTest.java @@ -14,6 +14,7 @@ package org.aspectj.apache.bcel.classfile.tests; import java.io.File; import java.io.IOException; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -21,17 +22,16 @@ import org.aspectj.apache.bcel.classfile.Attribute; import org.aspectj.apache.bcel.classfile.ConstantPool; import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.Utility; -import org.aspectj.apache.bcel.classfile.annotation.Annotation; -import org.aspectj.apache.bcel.classfile.annotation.AnnotationElementValue; -import org.aspectj.apache.bcel.classfile.annotation.ArrayElementValue; -import org.aspectj.apache.bcel.classfile.annotation.ClassElementValue; -import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePair; -import org.aspectj.apache.bcel.classfile.annotation.ElementValue; -import org.aspectj.apache.bcel.classfile.annotation.EnumElementValue; -import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValue; +import org.aspectj.apache.bcel.classfile.annotation.AnnotationElementValueGen; +import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; +import org.aspectj.apache.bcel.classfile.annotation.ArrayElementValueGen; +import org.aspectj.apache.bcel.classfile.annotation.ClassElementValueGen; +import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePairGen; +import org.aspectj.apache.bcel.classfile.annotation.ElementValueGen; +import org.aspectj.apache.bcel.classfile.annotation.EnumElementValueGen; import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleAnnotations; +import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValueGen; import org.aspectj.apache.bcel.generic.ClassGen; -import org.aspectj.apache.bcel.generic.annotation.AnnotationGen; import org.aspectj.apache.bcel.util.SyntheticRepository; @@ -60,17 +60,17 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase { List anns = rva.getAnnotations(); assertTrue("Should be one annotation but found "+anns.size(), anns.size()==1); - Annotation ann = (Annotation) anns.get(0); + AnnotationGen ann = (AnnotationGen) anns.get(0); assertTrue("Should be called 'SimpleAnnotation' but was called "+ann.getTypeName(), ann.getTypeName().equals("SimpleAnnotation")); List l = ann.getValues(); assertTrue("Should be one value for annotation 'SimpleAnnotation' but found "+l.size(), l.size()==1); - ElementNameValuePair envp = (ElementNameValuePair)l.get(0); + ElementNameValuePairGen envp = (ElementNameValuePairGen)l.get(0); assertTrue("Name of element in SimpleAnnotation should be 'id' but it is "+envp.getNameString(), envp.getNameString().equals("id")); - SimpleElementValue evalue = (SimpleElementValue)envp.getValue(); - assertTrue("'id' should be of type int, but it is "+evalue.getElementValueType(),evalue.getElementValueType()==SimpleElementValue.PRIMITIVE_INT); + SimpleElementValueGen evalue = (SimpleElementValueGen)envp.getValue(); + assertTrue("'id' should be of type int, but it is "+evalue.getElementValueType(),evalue.getElementValueType()==SimpleElementValueGen.PRIMITIVE_INT); assertTrue("'id' should have value 4 but it is "+evalue.getValueInt(), evalue.getValueInt()==4); } @@ -79,7 +79,7 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase { SyntheticRepository repos = createRepos("testcode.jar"); JavaClass clazz = repos.loadClass("SimpleAnnotatedClass"); ConstantPool pool = clazz.getConstantPool(); - Annotation[] anns = clazz.getAnnotations(); + AnnotationGen[] anns = clazz.getAnnotations(); assertTrue("Expected one annotation on SimpleAnnotatedClass class but got "+anns.length, anns.length==1); } @@ -88,7 +88,7 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase { SyntheticRepository repos = createRepos("testcode.jar"); JavaClass clazz = repos.loadClass("SimpleAnnotatedClass"); ConstantPool pool = clazz.getConstantPool(); - Annotation[] anns = clazz.getAnnotations(); + AnnotationGen[] anns = clazz.getAnnotations(); assertTrue("Expected one annotation on SimpleAnnotatedClass class but got "+anns.length, anns.length==1); @@ -99,7 +99,7 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase { SyntheticRepository repos2 = createRepos("."); JavaClass clazz2 = repos.loadClass("SimpleAnnotatedClass"); ConstantPool pool2 = clazz2.getConstantPool(); - Annotation[] anns2 = clazz2.getAnnotations(); + AnnotationGen[] anns2 = clazz2.getAnnotations(); assertTrue("Expected one annotation on SimpleAnnotatedClass class but got "+anns2.length, anns2.length==1); @@ -135,17 +135,17 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase { } private void verifyAnnotationStringElement(JavaClass clazz) { - Annotation[] anns = clazz.getAnnotations(); + AnnotationGen[] anns = clazz.getAnnotations(); assertTrue("should be one annotation but found "+anns.length,anns.length==1); - Annotation ann = anns[0]; + AnnotationGen ann = anns[0]; assertTrue("should be called 'AnnotationStringElement' but was called "+ann.getTypeName(), ann.getTypeName().equals("AnnotationStringElement")); List l = ann.getValues(); assertTrue("Should be one value but there were "+l.size(),l.size()==1); - ElementNameValuePair nvp = (ElementNameValuePair)l.get(0); + ElementNameValuePairGen nvp = (ElementNameValuePairGen)l.get(0); assertTrue("Name of element should be 'stringval' but was "+nvp.getNameString(), nvp.getNameString().equals("stringval")); - SimpleElementValue ev = (SimpleElementValue)nvp.getValue(); + SimpleElementValueGen ev = (SimpleElementValueGen)nvp.getValue(); assertTrue("String value should be 'hello' but was '"+ev.getValueString()+"'", ev.getValueString().equals("hello")); } @@ -178,15 +178,15 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase { } private void verifyComplexAnnotation(JavaClass clazz) { - Annotation[] anns = clazz.getAnnotations(); + AnnotationGen[] anns = clazz.getAnnotations(); assertTrue("Should be one annotation but found "+anns.length,anns.length==1); - Annotation ann = anns[0]; + AnnotationGen ann = anns[0]; assertTrue("Should be called 'ComplexAnnotation' but was called "+ann.getTypeName(), ann.getTypeName().equals("ComplexAnnotation")); List l = ann.getValues(); assertTrue("Should be eight values for annotation 'ComplexAnnotation' but found "+l.size(), l.size()==8); - List names = Utility.getListOfAnnotationNames(ann); + List names = RuntimeVisibleAnnotationAttributeTest.getListOfAnnotationNames(ann); assertTrue("Cant find expected element ",names.contains("ival")); assertTrue("Cant find expected element ",names.contains("dval")); assertTrue("Cant find expected element ",names.contains("zval")); @@ -207,9 +207,9 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase { } - private void checkValue(Annotation a,String name,String tostring) { + private void checkValue(AnnotationGen a,String name,String tostring) { for (Iterator i = a.getValues().iterator(); i.hasNext();) { - ElementNameValuePair element = (ElementNameValuePair) i.next(); + ElementNameValuePairGen element = (ElementNameValuePairGen) i.next(); if (element.getNameString().equals(name)) { if (!element.getValue().stringifyValue().equals(tostring)) { fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue()); @@ -232,7 +232,7 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase { public void testAnnotationClassElementCopying() throws ClassNotFoundException { SyntheticRepository repos = createRepos("testcode.jar"); JavaClass clazz = repos.loadClass("AnnotatedWithClassClass"); - Annotation[] anns = clazz.getAnnotations(); + AnnotationGen[] anns = clazz.getAnnotations(); ClassGen cg = new ClassGen(clazz); // Checks we can copy class values in an annotation new AnnotationGen(anns[0],cg.getConstantPool(),true); @@ -256,17 +256,17 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase { } private void verifyClassAnnotation(JavaClass clazz) { - Annotation[] anns = clazz.getAnnotations(); + AnnotationGen[] anns = clazz.getAnnotations(); assertTrue("should be one annotation but found "+anns.length,anns.length==1); - Annotation ann = anns[0]; + AnnotationGen ann = anns[0]; assertTrue("should be called 'AnnotationClassElement' but was called "+ann.getTypeName(), ann.getTypeName().equals("AnnotationClassElement")); List l = ann.getValues(); assertTrue("Should be one value but there were "+l.size(),l.size()==1); - ElementNameValuePair nvp = (ElementNameValuePair)l.get(0); + ElementNameValuePairGen nvp = (ElementNameValuePairGen)l.get(0); assertTrue("Name of element should be 'clz' but was "+nvp.getNameString(), nvp.getNameString().equals("clz")); - ClassElementValue ev = (ClassElementValue)nvp.getValue(); + ClassElementValueGen ev = (ClassElementValueGen)nvp.getValue(); assertTrue("String value should be 'Ljava/lang/Integer;' but was '"+ev.getClassString()+"'", ev.getClassString().equals("Ljava/lang/Integer;")); @@ -298,20 +298,20 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase { } public void verifyAnnotationEnumElement(JavaClass clazz) { - Annotation[] anns = clazz.getAnnotations(); + AnnotationGen[] anns = clazz.getAnnotations(); assertTrue("should be one annotation but found "+anns.length,anns.length==1); - Annotation ann = anns[0]; + AnnotationGen ann = anns[0]; assertTrue("should be called 'AnnotationEnumElement' but was called "+ann.getTypeName(), ann.getTypeName().equals("AnnotationEnumElement")); List l = ann.getValues(); assertTrue("Should be one value but there were "+l.size(),l.size()==1); - ElementNameValuePair nvp = (ElementNameValuePair)l.get(0); + ElementNameValuePairGen nvp = (ElementNameValuePairGen)l.get(0); assertTrue("Name of element should be 'enumval' but was "+nvp.getNameString(), nvp.getNameString().equals("enumval")); - ElementValue ev = nvp.getValue(); - assertTrue("Should be of type EnumElementValue but is "+ev,ev instanceof EnumElementValue); - EnumElementValue eev = (EnumElementValue)ev; - assertTrue("Should be an enum type value but is "+eev.getElementValueType(),eev.getElementValueType()==SimpleElementValue.ENUM_CONSTANT); + ElementValueGen ev = nvp.getValue(); + assertTrue("Should be of type EnumElementValue but is "+ev,ev instanceof EnumElementValueGen); + EnumElementValueGen eev = (EnumElementValueGen)ev; + assertTrue("Should be an enum type value but is "+eev.getElementValueType(),eev.getElementValueType()==SimpleElementValueGen.ENUM_CONSTANT); assertTrue("Enum type for annotation should be 'SimpleEnum' but is "+Utility.signatureToString(eev.getEnumTypeString()),Utility.signatureToString(eev.getEnumTypeString()).equals("SimpleEnum")); assertTrue("String value should be 'Red' but was '"+eev.getEnumValueString()+"'", eev.getEnumValueString().equals("Red")); @@ -323,7 +323,7 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase { public void testAnnotationArraysOfAnnotations() throws ClassNotFoundException { SyntheticRepository repos = createRepos("testcode.jar"); JavaClass clazz = repos.loadClass("AnnotatedWithCombinedAnnotation"); - Annotation[] anns = clazz.getAnnotations(); + AnnotationGen[] anns = clazz.getAnnotations(); assertTrue("should be one annotation but found "+anns.length,anns.length==1); checkCombinedAnnotation(anns[0]); } @@ -331,7 +331,7 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase { public void testAnnotationArraysOfAnnotationsReadWrite() throws ClassNotFoundException, IOException { SyntheticRepository repos = createRepos("testcode.jar"); JavaClass clazz = repos.loadClass("AnnotatedWithCombinedAnnotation"); - Annotation[] anns = clazz.getAnnotations(); + AnnotationGen[] anns = clazz.getAnnotations(); assertTrue("should be one annotation but found "+anns.length,anns.length==1); checkCombinedAnnotation(anns[0]); @@ -341,7 +341,7 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase { SyntheticRepository repos2 = createRepos("."); JavaClass clazz2 = repos2.loadClass("AnnotatedWithCombinedAnnotation"); - Annotation[] anns2 = clazz2.getAnnotations(); + AnnotationGen[] anns2 = clazz2.getAnnotations(); assertTrue("should be one annotation but found "+anns2.length,anns2.length==1); checkCombinedAnnotation(anns2[0]); @@ -349,29 +349,29 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase { } - private void checkCombinedAnnotation(Annotation ann) { + private void checkCombinedAnnotation(AnnotationGen ann) { assertTrue("should be called 'CombinedAnnotation' but was called "+ann.getTypeName(), ann.getTypeName().equals("CombinedAnnotation")); List l = ann.getValues(); assertTrue("Should be one value but there were "+l.size(),l.size()==1); - ElementNameValuePair nvp = (ElementNameValuePair)l.get(0); + ElementNameValuePairGen nvp = (ElementNameValuePairGen)l.get(0); assertTrue("Name of element should be 'value' but was "+nvp.getNameString(), nvp.getNameString().equals("value")); - ElementValue ev = nvp.getValue(); - assertTrue("Should be of type ArrayElementValue but is "+ev,ev instanceof ArrayElementValue); - ArrayElementValue aev = (ArrayElementValue)ev; + ElementValueGen ev = nvp.getValue(); + assertTrue("Should be of type ArrayElementValue but is "+ev,ev instanceof ArrayElementValueGen); + ArrayElementValueGen aev = (ArrayElementValueGen)ev; assertTrue("Array element value should be of size 1 but is "+aev.getElementValuesArraySize(), aev.getElementValuesArraySize()==1); - ElementValue[] evs = aev.getElementValuesArray(); + ElementValueGen[] evs = aev.getElementValuesArray(); assertTrue("Entry in the array should be AnnotationElementValue but is "+evs[0], - evs[0] instanceof AnnotationElementValue); - AnnotationElementValue inner_ev = (AnnotationElementValue)evs[0]; - Annotation a = inner_ev.getAnnotation(); + evs[0] instanceof AnnotationElementValueGen); + AnnotationElementValueGen inner_ev = (AnnotationElementValueGen)evs[0]; + AnnotationGen a = inner_ev.getAnnotation(); assertTrue("Should be SimpleAnnotation but is "+a.getTypeName(),a.getTypeName().equals("SimpleAnnotation")); List envps = a.getValues(); assertTrue("Should be one name value pair but found "+envps.size(),envps.size()==1); - ElementNameValuePair envp = (ElementNameValuePair) envps.get(0); + ElementNameValuePairGen envp = (ElementNameValuePairGen) envps.get(0); assertTrue("Name should be 'id' but it is "+envp.getNameString(),envp.getNameString().equals("id")); assertTrue("Value of 'id' should be 4 but it is "+envp.getValue().stringifyValue(), envp.getValue().stringifyValue().equals("4")); @@ -381,5 +381,15 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase { protected void tearDown() throws Exception { super.tearDown(); } + + public static List getListOfAnnotationNames(AnnotationGen a) { + List l = a.getValues(); + List names = new ArrayList(); + for (Iterator i = l.iterator(); i.hasNext();) { + ElementNameValuePairGen element = (ElementNameValuePairGen) i.next(); + names.add(element.getNameString()); + } + return names; + } } diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleParameterAnnotationAttributeTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleParameterAnnotationAttributeTest.java index fad1dad2c..424d5352f 100644 --- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleParameterAnnotationAttributeTest.java +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleParameterAnnotationAttributeTest.java @@ -19,8 +19,8 @@ import java.util.Iterator; import org.aspectj.apache.bcel.classfile.Attribute; import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.Method; -import org.aspectj.apache.bcel.classfile.annotation.Annotation; -import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePair; +import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; +import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePairGen; import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleParameterAnnotations; import org.aspectj.apache.bcel.util.SyntheticRepository; @@ -46,12 +46,12 @@ public class RuntimeVisibleParameterAnnotationAttributeTest extends BcelTestCase assertTrue("foo takes two parameters, not "+paramAnns.getParameterAnnotations().size(), paramAnns.getParameterAnnotations().size()==2); - Annotation[] firstParamAnnotations = paramAnns.getAnnotationsOnParameter(0); + AnnotationGen[] firstParamAnnotations = paramAnns.getAnnotationsOnParameter(0); checkAnnotation(firstParamAnnotations[0],"SimpleAnnotation","id","2"); - Annotation[] secondParamAnnotations = paramAnns.getAnnotationsOnParameter(1); + AnnotationGen[] secondParamAnnotations = paramAnns.getAnnotationsOnParameter(1); checkAnnotation(secondParamAnnotations[0],"SimpleAnnotation","id","3"); - checkAnnotation(secondParamAnnotations[1],"AnnotationEnumElement","enumval","Red"); + checkAnnotation(secondParamAnnotations[1],"AnnotationEnumElement","enumval","LSimpleEnum;Red"); } if (m.getName().equals("main")) { @@ -60,7 +60,7 @@ public class RuntimeVisibleParameterAnnotationAttributeTest extends BcelTestCase assertTrue("main takes one parameter, not "+paramAnns.getParameterAnnotations().size(), paramAnns.getParameterAnnotations().size()==1); - Annotation[] firstParamAnnotations = paramAnns.getAnnotationsOnParameter(0); + AnnotationGen[] firstParamAnnotations = paramAnns.getAnnotationsOnParameter(0); checkAnnotation(firstParamAnnotations[0],"SimpleAnnotation","id","1"); } } @@ -98,22 +98,22 @@ public class RuntimeVisibleParameterAnnotationAttributeTest extends BcelTestCase Method m = methods[i]; if (m.getName().equals("foo")) { - Annotation[] firstParamAnnotations = m.getAnnotationsOnParameter(0); + AnnotationGen[] firstParamAnnotations = m.getAnnotationsOnParameter(0); checkAnnotation(firstParamAnnotations[0],"SimpleAnnotation","id","2"); - Annotation[] secondParamAnnotations = m.getAnnotationsOnParameter(1); + AnnotationGen[] secondParamAnnotations = m.getAnnotationsOnParameter(1); checkAnnotation(secondParamAnnotations[0],"SimpleAnnotation","id","3"); - checkAnnotation(secondParamAnnotations[1],"AnnotationEnumElement","enumval","Red"); + checkAnnotation(secondParamAnnotations[1],"AnnotationEnumElement","enumval","LSimpleEnum;Red"); } } } - private void checkAnnotation(Annotation a,String name,String elementname,String elementvalue) { + private void checkAnnotation(AnnotationGen a,String name,String elementname,String elementvalue) { assertTrue("Expected annotation to have name "+name+" but it had name "+a.getTypeName(), a.getTypeName().equals(name)); assertTrue("Expected annotation to have one element but it had "+a.getValues().size(),a.getValues().size()==1); - ElementNameValuePair envp = (ElementNameValuePair)a.getValues().get(0); + ElementNameValuePairGen envp = (ElementNameValuePairGen)a.getValues().get(0); assertTrue("Expected element name "+elementname+" but was "+envp.getNameString(), elementname.equals(envp.getNameString())); assertTrue("Expected element value "+elementvalue+" but was "+envp.getValue().stringifyValue(), @@ -123,9 +123,9 @@ public class RuntimeVisibleParameterAnnotationAttributeTest extends BcelTestCase // helper methods - public void checkValue(Annotation a,String name,String tostring) { + public void checkValue(AnnotationGen a,String name,String tostring) { for (Iterator i = a.getValues().iterator(); i.hasNext();) { - ElementNameValuePair element = (ElementNameValuePair) i.next(); + ElementNameValuePairGen element = (ElementNameValuePairGen) i.next(); if (element.getNameString().equals(name)) { if (!element.getValue().stringifyValue().equals(tostring)) { fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue()); diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/TypeAnnotationsTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/TypeAnnotationsTest.java index 5b2e17af8..dcb36432f 100644 --- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/TypeAnnotationsTest.java +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/TypeAnnotationsTest.java @@ -13,8 +13,8 @@ package org.aspectj.apache.bcel.classfile.tests; import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; import org.aspectj.apache.bcel.generic.ClassGen; -import org.aspectj.apache.bcel.generic.annotation.AnnotationGen; public class TypeAnnotationsTest extends BcelTestCase { diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/UtilTests.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/UtilTests.java index 1ed7e8381..8c9fb5024 100644 --- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/UtilTests.java +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/UtilTests.java @@ -12,6 +12,7 @@ package org.aspectj.apache.bcel.classfile.tests; +import org.aspectj.apache.bcel.classfile.ClassFormatException; import org.aspectj.apache.bcel.classfile.Utility; import org.aspectj.apache.bcel.generic.Type; @@ -24,7 +25,7 @@ public class UtilTests extends TestCase { } public void testUtilityClassSignatureManipulation1() { - String[] ss = Utility.methodSignatureArgumentTypes("(Ljava/lang/String;I[Ljava/lang/Integer;)"); + String[] ss = UtilTests.methodSignatureArgumentTypes("(Ljava/lang/String;I[Ljava/lang/Integer;)"); assertTrue("should be 3 not "+ss.length,ss.length==3); assertTrue("first should be 'String', not "+ss[0],ss[0].equals("String")); @@ -53,6 +54,15 @@ public class UtilTests extends TestCase { protected void tearDown() throws Exception { super.tearDown(); } + + /** + * @param signature Method signature + * @return Array of argument types + * @throws ClassFormatException + */ + public static final String[] methodSignatureArgumentTypes(String signature) throws ClassFormatException { + return GenericSignatureParsingTest.methodSignatureArgumentTypes(signature, true); + } } diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/VarargsTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/VarargsTest.java index 52590bf71..a6f8e8021 100644 --- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/VarargsTest.java +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/VarargsTest.java @@ -18,8 +18,8 @@ import java.util.Iterator; import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.Method; -import org.aspectj.apache.bcel.classfile.annotation.Annotation; -import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePair; +import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; +import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePairGen; import org.aspectj.apache.bcel.util.SyntheticRepository; @@ -77,9 +77,9 @@ public class VarargsTest extends BcelTestCase { // helper methods - public void checkValue(Annotation a,String name,String tostring) { + public void checkValue(AnnotationGen a,String name,String tostring) { for (Iterator i = a.getValues().iterator(); i.hasNext();) { - ElementNameValuePair element = (ElementNameValuePair) i.next(); + ElementNameValuePairGen element = (ElementNameValuePairGen) i.next(); if (element.getNameString().equals(name)) { if (!element.getValue().stringifyValue().equals(tostring)) { fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue()); diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/DescendingVisitor.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/DescendingVisitor.java index 7d61dc2d1..2e77bd2a4 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/DescendingVisitor.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/DescendingVisitor.java @@ -1,4 +1,4 @@ -package org.aspectj.apache.bcel.classfile; +package org.aspectj.apache.bcel.verifier; /* ==================================================================== * The Apache Software License, Version 1.1 @@ -55,6 +55,45 @@ package org.aspectj.apache.bcel.classfile; */ import java.util.Stack; +import org.aspectj.apache.bcel.classfile.AnnotationDefault; +import org.aspectj.apache.bcel.classfile.Attribute; +import org.aspectj.apache.bcel.classfile.AttributeUtils; +import org.aspectj.apache.bcel.classfile.Code; +import org.aspectj.apache.bcel.classfile.CodeException; +import org.aspectj.apache.bcel.classfile.Constant; +import org.aspectj.apache.bcel.classfile.ConstantClass; +import org.aspectj.apache.bcel.classfile.ConstantDouble; +import org.aspectj.apache.bcel.classfile.ConstantFieldref; +import org.aspectj.apache.bcel.classfile.ConstantFloat; +import org.aspectj.apache.bcel.classfile.ConstantInteger; +import org.aspectj.apache.bcel.classfile.ConstantInterfaceMethodref; +import org.aspectj.apache.bcel.classfile.ConstantLong; +import org.aspectj.apache.bcel.classfile.ConstantMethodref; +import org.aspectj.apache.bcel.classfile.ConstantNameAndType; +import org.aspectj.apache.bcel.classfile.ConstantPool; +import org.aspectj.apache.bcel.classfile.ConstantString; +import org.aspectj.apache.bcel.classfile.ConstantUtf8; +import org.aspectj.apache.bcel.classfile.ConstantValue; +import org.aspectj.apache.bcel.classfile.Deprecated; +import org.aspectj.apache.bcel.classfile.EnclosingMethod; +import org.aspectj.apache.bcel.classfile.ExceptionTable; +import org.aspectj.apache.bcel.classfile.Field; +import org.aspectj.apache.bcel.classfile.InnerClass; +import org.aspectj.apache.bcel.classfile.InnerClasses; +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.LineNumber; +import org.aspectj.apache.bcel.classfile.LineNumberTable; +import org.aspectj.apache.bcel.classfile.LocalVariable; +import org.aspectj.apache.bcel.classfile.LocalVariableTable; +import org.aspectj.apache.bcel.classfile.LocalVariableTypeTable; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.apache.bcel.classfile.Signature; +import org.aspectj.apache.bcel.classfile.SourceFile; +import org.aspectj.apache.bcel.classfile.StackMap; +import org.aspectj.apache.bcel.classfile.StackMapEntry; +import org.aspectj.apache.bcel.classfile.Synthetic; +import org.aspectj.apache.bcel.classfile.Unknown; +import org.aspectj.apache.bcel.classfile.ClassVisitor; import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisibleAnnotations; import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisibleParameterAnnotations; import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleAnnotations; @@ -66,12 +105,12 @@ import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleParameterAnnot * class supplies the traversal strategy, other classes can make use * of it. * - * @version $Id: DescendingVisitor.java,v 1.2 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: DescendingVisitor.java,v 1.2 2008/05/28 23:53:00 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ -public class DescendingVisitor implements Visitor { +public class DescendingVisitor implements ClassVisitor { private JavaClass clazz; - private Visitor visitor; + private ClassVisitor visitor; private Stack stack = new Stack(); /** @return container of current entitity, i.e., predecessor during traversal @@ -103,7 +142,7 @@ public class DescendingVisitor implements Visitor { * @param clazz Class to traverse * @param visitor visitor object to apply to all components */ - public DescendingVisitor(JavaClass clazz, Visitor visitor) { + public DescendingVisitor(JavaClass clazz, ClassVisitor visitor) { this.clazz = clazz; this.visitor = visitor; } @@ -125,10 +164,8 @@ public class DescendingVisitor implements Visitor { for(int i=0; i < methods.length; i++) methods[i].accept(this); - Attribute[] attributes = clazz.getAttributes(); - for(int i=0; i < attributes.length; i++) - attributes[i].accept(this); - + AttributeUtils.accept(clazz.getAttributes(),visitor); +// clazz.getAttributes().accept(this); clazz.getConstantPool().accept(this); stack.pop(); } @@ -136,10 +173,8 @@ public class DescendingVisitor implements Visitor { public void visitField(Field field) { stack.push(field); field.accept(visitor); - - Attribute[] attributes = field.getAttributes(); - for(int i=0; i < attributes.length; i++) - attributes[i].accept(this); + AttributeUtils.accept(field.getAttributes(),visitor); +// field.getAttributes().accept(this); stack.pop(); } @@ -152,11 +187,7 @@ public class DescendingVisitor implements Visitor { public void visitMethod(Method method) { stack.push(method); method.accept(visitor); - - Attribute[] attributes = method.getAttributes(); - for(int i=0; i < attributes.length; i++) - attributes[i].accept(this); - + AttributeUtils.accept(method.getAttributes(),visitor); stack.pop(); } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/EmptyVisitor.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/EmptyClassVisitor.java index 1113f0af5..9d9f968bd 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/EmptyVisitor.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/EmptyClassVisitor.java @@ -1,4 +1,4 @@ -package org.aspectj.apache.bcel.classfile; +package org.aspectj.apache.bcel.verifier; /* ==================================================================== * The Apache Software License, Version 1.1 @@ -54,6 +54,42 @@ package org.aspectj.apache.bcel.classfile; * <http://www.apache.org/>. */ +import org.aspectj.apache.bcel.classfile.AnnotationDefault; +import org.aspectj.apache.bcel.classfile.Code; +import org.aspectj.apache.bcel.classfile.CodeException; +import org.aspectj.apache.bcel.classfile.ConstantClass; +import org.aspectj.apache.bcel.classfile.ConstantDouble; +import org.aspectj.apache.bcel.classfile.ConstantFieldref; +import org.aspectj.apache.bcel.classfile.ConstantFloat; +import org.aspectj.apache.bcel.classfile.ConstantInteger; +import org.aspectj.apache.bcel.classfile.ConstantInterfaceMethodref; +import org.aspectj.apache.bcel.classfile.ConstantLong; +import org.aspectj.apache.bcel.classfile.ConstantMethodref; +import org.aspectj.apache.bcel.classfile.ConstantNameAndType; +import org.aspectj.apache.bcel.classfile.ConstantPool; +import org.aspectj.apache.bcel.classfile.ConstantString; +import org.aspectj.apache.bcel.classfile.ConstantUtf8; +import org.aspectj.apache.bcel.classfile.ConstantValue; +import org.aspectj.apache.bcel.classfile.Deprecated; +import org.aspectj.apache.bcel.classfile.EnclosingMethod; +import org.aspectj.apache.bcel.classfile.ExceptionTable; +import org.aspectj.apache.bcel.classfile.Field; +import org.aspectj.apache.bcel.classfile.InnerClass; +import org.aspectj.apache.bcel.classfile.InnerClasses; +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.LineNumber; +import org.aspectj.apache.bcel.classfile.LineNumberTable; +import org.aspectj.apache.bcel.classfile.LocalVariable; +import org.aspectj.apache.bcel.classfile.LocalVariableTable; +import org.aspectj.apache.bcel.classfile.LocalVariableTypeTable; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.apache.bcel.classfile.Signature; +import org.aspectj.apache.bcel.classfile.SourceFile; +import org.aspectj.apache.bcel.classfile.StackMap; +import org.aspectj.apache.bcel.classfile.StackMapEntry; +import org.aspectj.apache.bcel.classfile.Synthetic; +import org.aspectj.apache.bcel.classfile.Unknown; +import org.aspectj.apache.bcel.classfile.ClassVisitor; import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisibleAnnotations; import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisibleParameterAnnotations; import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleAnnotations; @@ -66,11 +102,11 @@ import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleParameterAnnot * By courtesy of David Spencer. * * @see DescendingVisitor - * @version $Id: EmptyVisitor.java,v 1.3 2004/11/19 16:45:18 aclement Exp $ + * @version $Id: EmptyClassVisitor.java,v 1.2 2008/05/28 23:53:00 aclement Exp $ * */ -public class EmptyVisitor implements Visitor { - protected EmptyVisitor() { } +public class EmptyClassVisitor implements ClassVisitor { + protected EmptyClassVisitor() { } public void visitCode(Code obj) {} public void visitCodeException(CodeException obj) {} diff --git a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/EmptyInstVisitor.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/EmptyInstVisitor.java new file mode 100644 index 000000000..d498ecdc0 --- /dev/null +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/EmptyInstVisitor.java @@ -0,0 +1,259 @@ +package org.aspectj.apache.bcel.verifier; + +import org.aspectj.apache.bcel.generic.FieldInstruction; +import org.aspectj.apache.bcel.generic.IINC; +import org.aspectj.apache.bcel.generic.INVOKEINTERFACE; +import org.aspectj.apache.bcel.generic.InstVisitor; +import org.aspectj.apache.bcel.generic.Instruction; +import org.aspectj.apache.bcel.generic.InstructionBranch; +import org.aspectj.apache.bcel.generic.InstructionLV; +import org.aspectj.apache.bcel.generic.InstructionSelect; +import org.aspectj.apache.bcel.generic.InvokeInstruction; +import org.aspectj.apache.bcel.generic.LOOKUPSWITCH; +import org.aspectj.apache.bcel.generic.MULTIANEWARRAY; +import org.aspectj.apache.bcel.generic.RET; +import org.aspectj.apache.bcel.generic.TABLESWITCH; + + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache BCEL" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache BCEL", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +/** + * Supplies empty method bodies to be overridden by subclasses. + * + * @version $Id: EmptyInstVisitor.java,v 1.2 2008/05/28 23:53:01 aclement Exp $ + * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> + */ +public abstract class EmptyInstVisitor implements InstVisitor { + public void visitStackInstruction(Instruction obj) { } + public void visitLocalVariableInstruction(InstructionLV obj) { } + public void visitBranchInstruction(InstructionBranch obj) { } + public void visitLoadClass(Instruction obj) { } + public void visitFieldInstruction(Instruction obj) { } + public void visitIfInstruction(Instruction obj) { } + public void visitConversionInstruction(Instruction obj) { } + public void visitPopInstruction(Instruction obj) { } + public void visitJsrInstruction(InstructionBranch obj) { } + public void visitGotoInstruction(Instruction obj) { } + public void visitStoreInstruction(Instruction obj) { } + public void visitTypedInstruction(Instruction obj) { } + public void visitSelect(InstructionSelect obj) { } + public void visitUnconditionalBranch(Instruction obj) { } + public void visitPushInstruction(Instruction obj) { } + public void visitArithmeticInstruction(Instruction obj) { } + public void visitCPInstruction(Instruction obj) { } + public void visitInvokeInstruction(InvokeInstruction obj) { } + public void visitArrayInstruction(Instruction obj) { } + public void visitAllocationInstruction(Instruction obj) { } + public void visitReturnInstruction(Instruction obj) { } + public void visitFieldOrMethod(Instruction obj) { } + public void visitConstantPushInstruction(Instruction obj) { } + public void visitExceptionThrower(Instruction obj) { } + public void visitLoadInstruction(Instruction obj) { } + public void visitVariableLengthInstruction(Instruction obj) { } + public void visitStackProducer(Instruction obj) { } + public void visitStackConsumer(Instruction obj) { } + public void visitACONST_NULL(Instruction obj) { } + public void visitGETSTATIC(FieldInstruction obj) { } + public void visitIF_ICMPLT(Instruction obj) { } + public void visitMONITOREXIT(Instruction obj) { } + public void visitIFLT(Instruction obj) { } + public void visitLSTORE(Instruction obj) { } + public void visitPOP2(Instruction obj) { } + public void visitBASTORE(Instruction obj) { } + public void visitISTORE(Instruction obj) { } + public void visitCHECKCAST(Instruction obj) { } + public void visitFCMPG(Instruction obj) { } + public void visitI2F(Instruction obj) { } + public void visitATHROW(Instruction obj) { } + public void visitDCMPL(Instruction obj) { } + public void visitARRAYLENGTH(Instruction obj) { } + public void visitDUP(Instruction obj) { } + public void visitINVOKESTATIC(InvokeInstruction obj) { } + public void visitLCONST(Instruction obj) { } + public void visitDREM(Instruction obj) { } + public void visitIFGE(Instruction obj) { } + public void visitCALOAD(Instruction obj) { } + public void visitLASTORE(Instruction obj) { } + public void visitI2D(Instruction obj) { } + public void visitDADD(Instruction obj) { } + public void visitINVOKESPECIAL(InvokeInstruction obj) { } + public void visitIAND(Instruction obj) { } + public void visitPUTFIELD(FieldInstruction obj) { } + public void visitILOAD(Instruction obj) { } + public void visitDLOAD(Instruction obj) { } + public void visitDCONST(Instruction obj) { } + public void visitNEW(Instruction obj) { } + public void visitIFNULL(Instruction obj) { } + public void visitLSUB(Instruction obj) { } + public void visitL2I(Instruction obj) { } + public void visitISHR(Instruction obj) { } + public void visitTABLESWITCH(TABLESWITCH obj) { } + public void visitIINC(IINC obj) { } + public void visitDRETURN(Instruction obj) { } + public void visitFSTORE(Instruction obj) { } + public void visitDASTORE(Instruction obj) { } + public void visitIALOAD(Instruction obj) { } + public void visitDDIV(Instruction obj) { } + public void visitIF_ICMPGE(Instruction obj) { } + public void visitLAND(Instruction obj) { } + public void visitIDIV(Instruction obj) { } + public void visitLOR(Instruction obj) { } + public void visitCASTORE(Instruction obj) { } + public void visitFREM(Instruction obj) { } + public void visitLDC(Instruction obj) { } + public void visitBIPUSH(Instruction obj) { } + public void visitDSTORE(Instruction obj) { } + public void visitF2L(Instruction obj) { } + public void visitFMUL(Instruction obj) { } + public void visitLLOAD(Instruction obj) { } + public void visitJSR(InstructionBranch obj) { } + public void visitFSUB(Instruction obj) { } + public void visitSASTORE(Instruction obj) { } + public void visitALOAD(Instruction obj) { } + public void visitDUP2_X2(Instruction obj) { } + public void visitRETURN(Instruction obj) { } + public void visitDALOAD(Instruction obj) { } + public void visitSIPUSH(Instruction obj) { } + public void visitDSUB(Instruction obj) { } + public void visitL2F(Instruction obj) { } + public void visitIF_ICMPGT(Instruction obj) { } + public void visitF2D(Instruction obj) { } + public void visitI2L(Instruction obj) { } + public void visitIF_ACMPNE(Instruction obj) { } + public void visitPOP(Instruction obj) { } + public void visitI2S(Instruction obj) { } + public void visitIFEQ(Instruction obj) { } + public void visitSWAP(Instruction obj) { } + public void visitIOR(Instruction obj) { } + public void visitIREM(Instruction obj) { } + public void visitIASTORE(Instruction obj) { } + public void visitNEWARRAY(Instruction obj) { } + public void visitINVOKEINTERFACE(INVOKEINTERFACE obj) { } + public void visitINEG(Instruction obj) { } + public void visitLCMP(Instruction obj) { } + public void visitJSR_W(InstructionBranch obj) { } + public void visitMULTIANEWARRAY(MULTIANEWARRAY obj) { } + public void visitDUP_X2(Instruction obj) { } + public void visitSALOAD(Instruction obj) { } + public void visitIFNONNULL(Instruction obj) { } + public void visitDMUL(Instruction obj) { } + public void visitIFNE(Instruction obj) { } + public void visitIF_ICMPLE(Instruction obj) { } + public void visitLDC2_W(Instruction obj) { } + public void visitGETFIELD(FieldInstruction obj) { } + public void visitLADD(Instruction obj) { } + public void visitNOP(Instruction obj) { } + public void visitFALOAD(Instruction obj) { } + public void visitINSTANCEOF(Instruction obj) { } + public void visitIFLE(Instruction obj) { } + public void visitLXOR(Instruction obj) { } + public void visitLRETURN(Instruction obj) { } + public void visitFCONST(Instruction obj) { } + public void visitIUSHR(Instruction obj) { } + public void visitBALOAD(Instruction obj) { } + public void visitDUP2(Instruction obj) { } + public void visitIF_ACMPEQ(Instruction obj) { } + public void visitIMPDEP1(Instruction obj) { } + public void visitMONITORENTER(Instruction obj) { } + public void visitLSHL(Instruction obj) { } + public void visitDCMPG(Instruction obj) { } + public void visitD2L(Instruction obj) { } + public void visitIMPDEP2(Instruction obj) { } + public void visitL2D(Instruction obj) { } + public void visitRET(RET obj) { } + public void visitIFGT(Instruction obj) { } + public void visitIXOR(Instruction obj) { } + public void visitINVOKEVIRTUAL(InvokeInstruction obj) { } + public void visitFASTORE(Instruction obj) { } + public void visitIRETURN(Instruction obj) { } + public void visitIF_ICMPNE(Instruction obj) { } + public void visitFLOAD(Instruction obj) { } + public void visitLDIV(Instruction obj) { } + public void visitPUTSTATIC(FieldInstruction obj) { } + public void visitAALOAD(Instruction obj) { } + public void visitD2I(Instruction obj) { } + public void visitIF_ICMPEQ(Instruction obj) { } + public void visitAASTORE(Instruction obj) { } + public void visitARETURN(Instruction obj) { } + public void visitDUP2_X1(Instruction obj) { } + public void visitFNEG(Instruction obj) { } + public void visitGOTO_W(Instruction obj) { } + public void visitD2F(Instruction obj) { } + public void visitGOTO(Instruction obj) { } + public void visitISUB(Instruction obj) { } + public void visitF2I(Instruction obj) { } + public void visitDNEG(Instruction obj) { } + public void visitICONST(Instruction obj) { } + public void visitFDIV(Instruction obj) { } + public void visitI2B(Instruction obj) { } + public void visitLNEG(Instruction obj) { } + public void visitLREM(Instruction obj) { } + public void visitIMUL(Instruction obj) { } + public void visitIADD(Instruction obj) { } + public void visitLSHR(Instruction obj) { } + public void visitLOOKUPSWITCH(LOOKUPSWITCH obj) { } + public void visitDUP_X1(Instruction obj) { } + public void visitFCMPL(Instruction obj) { } + public void visitI2C(Instruction obj) { } + public void visitLMUL(Instruction obj) { } + public void visitLUSHR(Instruction obj) { } + public void visitISHL(Instruction obj) { } + public void visitLALOAD(Instruction obj) { } + public void visitASTORE(Instruction obj) { } + public void visitANEWARRAY(Instruction obj) { } + public void visitFRETURN(Instruction obj) { } + public void visitFADD(Instruction obj) { } + public void visitBREAKPOINT(Instruction obj) { } +} diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/GraphicalVerifier.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/GraphicalVerifier.java index 876357ed4..834e58f22 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/GraphicalVerifier.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/GraphicalVerifier.java @@ -65,7 +65,7 @@ import org.aspectj.apache.bcel.generic.Type; /** * A graphical user interface application demonstrating JustIce. * - * @version $Id: GraphicalVerifier.java,v 1.4 2004/11/22 08:31:27 aclement Exp $ + * @version $Id: GraphicalVerifier.java,v 1.2 2008/05/28 23:53:01 aclement Exp $ * @author Enver Haase */ public class GraphicalVerifier { diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/NativeVerifier.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/NativeVerifier.java index ff31f8957..70a58abe1 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/NativeVerifier.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/NativeVerifier.java @@ -61,7 +61,7 @@ package org.aspectj.apache.bcel.verifier; * This can be used for comparison runs between the JVM-internal verifier * and JustIce. * - * @version $Id: NativeVerifier.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: NativeVerifier.java,v 1.2 2008/05/28 23:53:01 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public abstract class NativeVerifier{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/PassVerifier.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/PassVerifier.java index d059d8885..236b618e2 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/PassVerifier.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/PassVerifier.java @@ -77,7 +77,7 @@ import java.util.ArrayList; * That means, if you really want a new verification run of a certain * pass you must use a new instance of a given PassVerifier. * - * @version $Id: PassVerifier.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: PassVerifier.java,v 1.2 2008/05/28 23:53:00 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> * @see org.aspectj.apache.bcel.verifier.Verifier * @see #verify() diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/TransitiveHull.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/TransitiveHull.java index 142e7fa9f..00be6fa3d 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/TransitiveHull.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/TransitiveHull.java @@ -63,7 +63,7 @@ import org.aspectj.apache.bcel.classfile.JavaClass; * all class files encountered; this may take up a lot of time and, * more notably, memory. * - * @version $Id: TransitiveHull.java,v 1.4 2004/11/22 08:31:27 aclement Exp $ + * @version $Id: TransitiveHull.java,v 1.2 2008/05/28 23:53:00 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public class TransitiveHull implements VerifierFactoryObserver{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/VerificationResult.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerificationResult.java index f87dda6d9..b3e3cce80 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/VerificationResult.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerificationResult.java @@ -58,7 +58,7 @@ package org.aspectj.apache.bcel.verifier; * A VerificationResult is what a PassVerifier returns * after verifying. * - * @version $Id: VerificationResult.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: VerificationResult.java,v 1.2 2008/05/28 23:53:00 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> * */ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/Verifier.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/Verifier.java index aa7bb1b3d..25ce76c0b 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/Verifier.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/Verifier.java @@ -75,7 +75,7 @@ import org.aspectj.apache.bcel.verifier.structurals.Pass3bVerifier; * A Verifier creates PassVerifier instances to perform the actual verification. * Verifier instances are usually generated by the VerifierFactory. * - * @version $Id: Verifier.java,v 1.4 2004/11/22 08:31:27 aclement Exp $ + * @version $Id: Verifier.java,v 1.2 2008/05/28 23:53:01 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> * @see org.aspectj.apache.bcel.verifier.VerifierFactory * @see org.aspectj.apache.bcel.verifier.PassVerifier diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/VerifierAppFrame.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierAppFrame.java index b59b455dc..b6a483bf8 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/VerifierAppFrame.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierAppFrame.java @@ -83,7 +83,7 @@ import org.aspectj.apache.bcel.classfile.JavaClass; * This class implements a machine-generated frame for use with * the GraphicalVerfifier. * - * @version $Id: VerifierAppFrame.java,v 1.4 2004/11/22 08:31:27 aclement Exp $ + * @version $Id: VerifierAppFrame.java,v 1.2 2008/05/28 23:53:01 aclement Exp $ * @author Enver Haase * @see GraphicalVerifier */ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/VerifierFactory.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierFactory.java index be5dc5eed..9f45c39f8 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/VerifierFactory.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierFactory.java @@ -64,7 +64,7 @@ import java.util.Vector; * operate on. That means, for every class (represented by a unique fully qualified * class name) there is exactly one Verifier. * - * @version $Id: VerifierFactory.java,v 1.4 2005/02/02 09:11:39 aclement Exp $ + * @version $Id: VerifierFactory.java,v 1.2 2008/05/28 23:53:00 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> * @see org.aspectj.apache.bcel.verifier.Verifier */ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/VerifierFactoryListModel.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierFactoryListModel.java index 656f5ffe2..1808a6fca 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/VerifierFactoryListModel.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierFactoryListModel.java @@ -58,7 +58,7 @@ import javax.swing.event.ListDataEvent; * This class implements an adapter; it implements both a Swing ListModel and * a VerifierFactoryObserver. * - * @version $Id: VerifierFactoryListModel.java,v 1.4 2004/11/22 08:31:27 aclement Exp $ + * @version $Id: VerifierFactoryListModel.java,v 1.2 2008/05/28 23:53:01 aclement Exp $ * @author Enver Haase */ public class VerifierFactoryListModel implements org.aspectj.apache.bcel.verifier.VerifierFactoryObserver, javax.swing.ListModel{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/VerifierFactoryObserver.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierFactoryObserver.java index 16750b9b3..b00f4adc2 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/VerifierFactoryObserver.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierFactoryObserver.java @@ -58,7 +58,7 @@ package org.aspectj.apache.bcel.verifier; * VerifierFactoryObserver instances are notified when new Verifier * instances are created. * - * @version $Id: VerifierFactoryObserver.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: VerifierFactoryObserver.java,v 1.2 2008/05/28 23:53:00 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> * * @see VerifierFactory#getVerifier(String) diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/VerifyDialog.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifyDialog.java index cb3dbc9ce..9eb2d37c0 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/VerifyDialog.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifyDialog.java @@ -68,7 +68,7 @@ import org.aspectj.apache.bcel.classfile.JavaClass; * class in your application. * [This class was created using VisualAge for Java, * but it does not work under VAJ itself (Version 3.02 JDK 1.2)] - * @version $Id: VerifyDialog.java,v 1.4 2004/11/22 08:31:27 aclement Exp $ + * @version $Id: VerifyDialog.java,v 1.2 2008/05/28 23:53:01 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> * @see #main(String[]) * @see #VerifyDialog(String) diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/AssertionViolatedException.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/AssertionViolatedException.java index 7fff671a8..dc1a93be5 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/AssertionViolatedException.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/AssertionViolatedException.java @@ -58,7 +58,7 @@ package org.aspectj.apache.bcel.verifier.exc; * Instances of this class should never be thrown. When such an instance is thrown, * this is due to an INTERNAL ERROR of BCEL's class file verifier "JustIce". * - * @version $Id: AssertionViolatedException.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: AssertionViolatedException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public final class AssertionViolatedException extends RuntimeException{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/ClassConstraintException.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/ClassConstraintException.java index c156a9d6b..3378c2ea5 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/ClassConstraintException.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/ClassConstraintException.java @@ -59,7 +59,7 @@ package org.aspectj.apache.bcel.verifier.exc; * when a class file to verify does not pass the verification pass 2 as described * in the Java Virtual Machine specification, 2nd edition. * - * @version $Id: ClassConstraintException.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: ClassConstraintException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public class ClassConstraintException extends VerificationException{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/CodeConstraintException.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/CodeConstraintException.java index 9ef154fd5..e33e4f9ac 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/CodeConstraintException.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/CodeConstraintException.java @@ -58,7 +58,7 @@ package org.aspectj.apache.bcel.verifier.exc; * a class file does not pass the verification pass 3. Note that the pass 3 used by * "JustIce" involves verification that is usually delayed to pass 4. * - * @version $Id: CodeConstraintException.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: CodeConstraintException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public abstract class CodeConstraintException extends VerificationException{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/InvalidMethodException.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/InvalidMethodException.java index 04084567e..eb6099cd4 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/InvalidMethodException.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/InvalidMethodException.java @@ -57,7 +57,7 @@ package org.aspectj.apache.bcel.verifier.exc; * Instances of this class are thrown by BCEL's class file verifier "JustIce" * when the verification of a method is requested that does not exist. * - * @version $Id: InvalidMethodException.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: InvalidMethodException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public class InvalidMethodException extends RuntimeException{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/LinkingConstraintException.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/LinkingConstraintException.java index 41d7187cc..3e63fea83 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/LinkingConstraintException.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/LinkingConstraintException.java @@ -67,7 +67,7 @@ package org.aspectj.apache.bcel.verifier.exc; * and Resolution") of the above mentioned book. * <B>TODO: At this time, this class is not used in JustIce.</B> * - * @version $Id: LinkingConstraintException.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: LinkingConstraintException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public class LinkingConstraintException extends StructuralCodeConstraintException{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/LoadingException.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/LoadingException.java index ab4661639..177ac4c7b 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/LoadingException.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/LoadingException.java @@ -58,7 +58,7 @@ package org.aspectj.apache.bcel.verifier.exc; * When loading a class file, BCEL will throw an instance of LoadingException if * the class file is malformed; so it is not conforming to the "Pass 1" verification * process as described in the Java Virtual Machine specification, 2nd. edition. - * @version $Id: LoadingException.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: LoadingException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public class LoadingException extends VerifierConstraintViolatedException{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/LocalVariableInfoInconsistentException.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/LocalVariableInfoInconsistentException.java index ee52a9b92..b4a44a480 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/LocalVariableInfoInconsistentException.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/LocalVariableInfoInconsistentException.java @@ -61,7 +61,7 @@ package org.aspectj.apache.bcel.verifier.exc; * LocalVariableTable entries in the Code attribute of a certain * Method object. * - * @version $Id: LocalVariableInfoInconsistentException.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: LocalVariableInfoInconsistentException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public class LocalVariableInfoInconsistentException extends ClassConstraintException{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/StaticCodeConstraintException.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/StaticCodeConstraintException.java index e5ed87a0f..5738a48d4 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/StaticCodeConstraintException.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/StaticCodeConstraintException.java @@ -61,7 +61,7 @@ package org.aspectj.apache.bcel.verifier.exc; * 2nd edition, 4.8.1, pages 133-137. The static constraints checking part of pass 3 * is called pass 3a in JustIce. * - * @version $Id: StaticCodeConstraintException.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: StaticCodeConstraintException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public abstract class StaticCodeConstraintException extends CodeConstraintException{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/StaticCodeInstructionConstraintException.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/StaticCodeInstructionConstraintException.java index 629ff6dfe..35c1f1ae2 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/StaticCodeInstructionConstraintException.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/StaticCodeInstructionConstraintException.java @@ -64,7 +64,7 @@ package org.aspectj.apache.bcel.verifier.exc; * pass 3a and are described on page 134 in the Java Virtual Machine Specification, * Second Edition. * - * @version $Id: StaticCodeInstructionConstraintException.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: StaticCodeInstructionConstraintException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public class StaticCodeInstructionConstraintException extends StaticCodeConstraintException{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/StaticCodeInstructionOperandConstraintException.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/StaticCodeInstructionOperandConstraintException.java index 7a5fbabd5..2ddc9e9de 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/StaticCodeInstructionOperandConstraintException.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/StaticCodeInstructionOperandConstraintException.java @@ -64,7 +64,7 @@ package org.aspectj.apache.bcel.verifier.exc; * pass 3a and are described on page 134-137 in the Java Virtual Machine Specification, * Second Edition. * - * @version $Id: StaticCodeInstructionOperandConstraintException.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: StaticCodeInstructionOperandConstraintException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public class StaticCodeInstructionOperandConstraintException extends StaticCodeConstraintException{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/StructuralCodeConstraintException.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/StructuralCodeConstraintException.java index 8f09a91a0..3cbee2e86 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/StructuralCodeConstraintException.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/StructuralCodeConstraintException.java @@ -63,7 +63,7 @@ package org.aspectj.apache.bcel.verifier.exc; * These are the constraints where data-flow analysis is needed to verify if they hold. * The data flow analysis of pass 3 is called pass 3b in JustIce. * - * @version $Id: StructuralCodeConstraintException.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: StructuralCodeConstraintException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public class StructuralCodeConstraintException extends CodeConstraintException{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/Utility.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/Utility.java index 095ec3344..8c5bc966d 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/Utility.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/Utility.java @@ -58,7 +58,7 @@ import java.io.*; /** * A utility class providing convenience methods concerning Throwable instances. - * @version $Id: Utility.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: Utility.java,v 1.2 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> * @see java.lang.Throwable */ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/VerificationException.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/VerificationException.java index 70bca7091..0df4b3d60 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/VerificationException.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/VerificationException.java @@ -63,7 +63,7 @@ package org.aspectj.apache.bcel.verifier.exc; * edition, page 164, 5.4.1 where verification as a part of the linking process is * defined to be the verification happening in passes 2 and 3. * - * @version $Id: VerificationException.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: VerificationException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public abstract class VerificationException extends VerifierConstraintViolatedException{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/VerifierConstraintViolatedException.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/VerifierConstraintViolatedException.java index 15ce45239..3cb718e2f 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/exc/VerifierConstraintViolatedException.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/exc/VerifierConstraintViolatedException.java @@ -62,7 +62,7 @@ package org.aspectj.apache.bcel.verifier.exc; * This is roughly equivalent to the VerifyError the JVM-internal verifiers * throw. * - * @version $Id: VerifierConstraintViolatedException.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: VerifierConstraintViolatedException.java,v 1.2 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public abstract class VerifierConstraintViolatedException extends RuntimeException{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/package.html b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/package.html index b9213e330..7a117a8b7 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/package.html +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/package.html @@ -2,7 +2,7 @@ <html> <head> <!-- -$Id: package.html,v 1.2 2004/11/19 16:45:19 aclement Exp $ +$Id: package.html,v 1.2 2008/05/28 23:53:00 aclement Exp $ --> </head> <body bgcolor="white"> diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/statics/DOUBLE_Upper.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/DOUBLE_Upper.java index ed68a24a8..062d6bbbc 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/statics/DOUBLE_Upper.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/DOUBLE_Upper.java @@ -59,7 +59,7 @@ import org.aspectj.apache.bcel.generic.Type; /** * This class represents the upper half of a DOUBLE variable. - * @version $Id: DOUBLE_Upper.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: DOUBLE_Upper.java,v 1.2 2008/05/28 23:52:54 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public final class DOUBLE_Upper extends Type{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/statics/IntList.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/IntList.java index dce612d48..1b6d4567e 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/statics/IntList.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/IntList.java @@ -59,7 +59,7 @@ import java.util.ArrayList; /** * A small utility class representing a set of basic int values. * - * @version $Id: IntList.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: IntList.java,v 1.2 2008/05/28 23:52:53 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public class IntList{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/statics/LONG_Upper.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/LONG_Upper.java index 9b1bbeae4..55e9052e3 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/statics/LONG_Upper.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/LONG_Upper.java @@ -59,7 +59,7 @@ import org.aspectj.apache.bcel.generic.Type; /** * This class represents the upper half of a LONG variable. - * @version $Id: LONG_Upper.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: LONG_Upper.java,v 1.2 2008/05/28 23:52:54 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public final class LONG_Upper extends Type{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/statics/LocalVariableInfo.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/LocalVariableInfo.java index 443444e2e..2d4e8ec98 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/statics/LocalVariableInfo.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/LocalVariableInfo.java @@ -64,7 +64,7 @@ import java.util.Hashtable; * a given slot (== index). This information * often changes in course of byte code offsets. * - * @version $Id: LocalVariableInfo.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: LocalVariableInfo.java,v 1.2 2008/05/28 23:52:54 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public class LocalVariableInfo{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/statics/LocalVariablesInfo.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/LocalVariablesInfo.java index 6f7a656b8..b094b5867 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/statics/LocalVariablesInfo.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/LocalVariablesInfo.java @@ -62,7 +62,7 @@ import org.aspectj.apache.bcel.verifier.exc.*; * the names and the types of the local variables in * a given method. * - * @version $Id: LocalVariablesInfo.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: LocalVariablesInfo.java,v 1.2 2008/05/28 23:52:54 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public class LocalVariablesInfo{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/statics/Pass1Verifier.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/Pass1Verifier.java index 4583afc8c..fcbddb624 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/statics/Pass1Verifier.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/Pass1Verifier.java @@ -68,7 +68,7 @@ import org.aspectj.apache.bcel.verifier.exc.Utility; * More detailed information is to be found at the do_verify() method's * documentation. * - * @version $Id: Pass1Verifier.java,v 1.3 2004/11/22 08:31:27 aclement Exp $ + * @version $Id: Pass1Verifier.java,v 1.2 2008/05/28 23:52:54 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> * @see #do_verify() */ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/statics/Pass2Verifier.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/Pass2Verifier.java index 1d2995f73..47b8090e6 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/statics/Pass2Verifier.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/Pass2Verifier.java @@ -77,8 +77,6 @@ import org.aspectj.apache.bcel.classfile.ConstantString; import org.aspectj.apache.bcel.classfile.ConstantUtf8; import org.aspectj.apache.bcel.classfile.ConstantValue; import org.aspectj.apache.bcel.classfile.Deprecated; -import org.aspectj.apache.bcel.classfile.DescendingVisitor; -import org.aspectj.apache.bcel.classfile.EmptyVisitor; import org.aspectj.apache.bcel.classfile.ExceptionTable; import org.aspectj.apache.bcel.classfile.Field; import org.aspectj.apache.bcel.classfile.InnerClass; @@ -93,10 +91,12 @@ import org.aspectj.apache.bcel.classfile.Node; import org.aspectj.apache.bcel.classfile.SourceFile; import org.aspectj.apache.bcel.classfile.Synthetic; import org.aspectj.apache.bcel.classfile.Unknown; -import org.aspectj.apache.bcel.classfile.Visitor; +import org.aspectj.apache.bcel.classfile.ClassVisitor; import org.aspectj.apache.bcel.generic.ArrayType; import org.aspectj.apache.bcel.generic.ObjectType; import org.aspectj.apache.bcel.generic.Type; +import org.aspectj.apache.bcel.verifier.DescendingVisitor; +import org.aspectj.apache.bcel.verifier.EmptyClassVisitor; import org.aspectj.apache.bcel.verifier.PassVerifier; import org.aspectj.apache.bcel.verifier.VerificationResult; import org.aspectj.apache.bcel.verifier.Verifier; @@ -112,7 +112,7 @@ import org.aspectj.apache.bcel.verifier.exc.LocalVariableInfoInconsistentExcepti * More detailed information is to be found at the do_verify() * method's documentation. * - * @version $Id: Pass2Verifier.java,v 1.3 2004/11/22 08:31:27 aclement Exp $ + * @version $Id: Pass2Verifier.java,v 1.2 2008/05/28 23:52:54 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> * @see #do_verify() */ @@ -313,7 +313,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants{ * * @see #constant_pool_entries_satisfy_static_constraints() */ - private class CPESSC_Visitor extends org.aspectj.apache.bcel.classfile.EmptyVisitor implements Visitor{ + private class CPESSC_Visitor extends org.aspectj.apache.bcel.verifier.EmptyClassVisitor implements ClassVisitor{ private Class CONST_Class; /* private Class CONST_Fieldref; @@ -521,7 +521,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants{ } } - if ((obj.getAccessFlags() & ~(ACC_PUBLIC|ACC_PRIVATE|ACC_PROTECTED|ACC_STATIC|ACC_FINAL|ACC_VOLATILE|ACC_TRANSIENT)) > 0){ + if ((obj.getModifiers() & ~(ACC_PUBLIC|ACC_PRIVATE|ACC_PROTECTED|ACC_STATIC|ACC_FINAL|ACC_VOLATILE|ACC_TRANSIENT)) > 0){ addMessage("Field '"+tostring(obj)+"' has access flag(s) other than ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_VOLATILE, ACC_TRANSIENT set (ignored)."); } @@ -675,7 +675,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants{ // Class and interface initialization methods... if (name.equals(STATIC_INITIALIZER_NAME)){ - if ((obj.getAccessFlags() & (~ACC_STRICT)) > 0){ + if ((obj.getModifiers() & (~ACC_STRICT)) > 0){ addMessage("Class or interface initialization method '"+tostring(obj)+"' has superfluous access modifier(s) set: everything but ACC_STRICT is ignored."); } if (obj.isAbstract()){ @@ -683,7 +683,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants{ } } - if ((obj.getAccessFlags() & ~(ACC_PUBLIC|ACC_PRIVATE|ACC_PROTECTED|ACC_STATIC|ACC_FINAL|ACC_SYNCHRONIZED|ACC_NATIVE|ACC_ABSTRACT|ACC_STRICT)) > 0){ + if ((obj.getModifiers() & ~(ACC_PUBLIC|ACC_PRIVATE|ACC_PROTECTED|ACC_STATIC|ACC_FINAL|ACC_SYNCHRONIZED|ACC_NATIVE|ACC_ABSTRACT|ACC_STRICT)) > 0){ addMessage("Method '"+tostring(obj)+"' has access flag(s) other than ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT, ACC_STRICT set (ignored)."); } @@ -1126,7 +1126,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants{ * @see #constant_pool_entries_satisfy_static_constraints() * @see org.aspectj.apache.bcel.classfile.ConstantCP */ - private class FAMRAV_Visitor extends EmptyVisitor implements Visitor{ + private class FAMRAV_Visitor extends EmptyClassVisitor implements ClassVisitor{ private final ConstantPool cp; // ==jc.getConstantPool() -- only here to save typing work. private FAMRAV_Visitor(JavaClass _jc){ cp = _jc.getConstantPool(); @@ -1335,7 +1335,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants{ * JustIce cannot repair this; please note that existing verifiers at this * time even fail to detect missing InnerClasses attributes in pass 2. */ - private class InnerClassDetector extends EmptyVisitor{ + private class InnerClassDetector extends EmptyClassVisitor{ private boolean hasInnerClass = false; private JavaClass jc; private ConstantPool cp; diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/statics/Pass3aVerifier.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/Pass3aVerifier.java index 37c50031b..32355e3f7 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/statics/Pass3aVerifier.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/Pass3aVerifier.java @@ -78,51 +78,24 @@ import org.aspectj.apache.bcel.classfile.LineNumberTable; import org.aspectj.apache.bcel.classfile.LocalVariable; import org.aspectj.apache.bcel.classfile.LocalVariableTable; import org.aspectj.apache.bcel.classfile.Method; -import org.aspectj.apache.bcel.generic.ALOAD; -import org.aspectj.apache.bcel.generic.ANEWARRAY; -import org.aspectj.apache.bcel.generic.ASTORE; -import org.aspectj.apache.bcel.generic.ATHROW; import org.aspectj.apache.bcel.generic.ArrayType; -import org.aspectj.apache.bcel.generic.BREAKPOINT; -import org.aspectj.apache.bcel.generic.CHECKCAST; -import org.aspectj.apache.bcel.generic.ConstantPoolGen; -import org.aspectj.apache.bcel.generic.DLOAD; -import org.aspectj.apache.bcel.generic.DSTORE; -import org.aspectj.apache.bcel.generic.FLOAD; -import org.aspectj.apache.bcel.generic.FSTORE; +import org.aspectj.apache.bcel.classfile.ConstantPool; import org.aspectj.apache.bcel.generic.FieldInstruction; -import org.aspectj.apache.bcel.generic.GETSTATIC; -import org.aspectj.apache.bcel.generic.GotoInstruction; import org.aspectj.apache.bcel.generic.IINC; -import org.aspectj.apache.bcel.generic.ILOAD; -import org.aspectj.apache.bcel.generic.IMPDEP1; -import org.aspectj.apache.bcel.generic.IMPDEP2; -import org.aspectj.apache.bcel.generic.INSTANCEOF; import org.aspectj.apache.bcel.generic.INVOKEINTERFACE; -import org.aspectj.apache.bcel.generic.INVOKESPECIAL; -import org.aspectj.apache.bcel.generic.INVOKESTATIC; -import org.aspectj.apache.bcel.generic.INVOKEVIRTUAL; -import org.aspectj.apache.bcel.generic.ISTORE; import org.aspectj.apache.bcel.generic.Instruction; +import org.aspectj.apache.bcel.generic.InstructionBranch; +import org.aspectj.apache.bcel.generic.InstructionByte; import org.aspectj.apache.bcel.generic.InstructionHandle; import org.aspectj.apache.bcel.generic.InstructionList; import org.aspectj.apache.bcel.generic.InvokeInstruction; -import org.aspectj.apache.bcel.generic.JsrInstruction; -import org.aspectj.apache.bcel.generic.LDC; -import org.aspectj.apache.bcel.generic.LDC2_W; -import org.aspectj.apache.bcel.generic.LLOAD; import org.aspectj.apache.bcel.generic.LOOKUPSWITCH; -import org.aspectj.apache.bcel.generic.LSTORE; -import org.aspectj.apache.bcel.generic.LoadClass; import org.aspectj.apache.bcel.generic.MULTIANEWARRAY; -import org.aspectj.apache.bcel.generic.NEW; -import org.aspectj.apache.bcel.generic.NEWARRAY; import org.aspectj.apache.bcel.generic.ObjectType; -import org.aspectj.apache.bcel.generic.PUTSTATIC; import org.aspectj.apache.bcel.generic.RET; -import org.aspectj.apache.bcel.generic.ReturnInstruction; import org.aspectj.apache.bcel.generic.TABLESWITCH; import org.aspectj.apache.bcel.generic.Type; +import org.aspectj.apache.bcel.verifier.EmptyClassVisitor; import org.aspectj.apache.bcel.verifier.PassVerifier; import org.aspectj.apache.bcel.verifier.VerificationResult; import org.aspectj.apache.bcel.verifier.Verifier; @@ -141,7 +114,7 @@ import org.aspectj.apache.bcel.verifier.exc.StaticCodeInstructionOperandConstrai * More detailed information is to be found at the do_verify() * method's documentation. * - * @version $Id: Pass3aVerifier.java,v 1.3 2004/11/22 08:31:27 aclement Exp $ + * @version $Id: Pass3aVerifier.java,v 1.2 2008/05/28 23:52:54 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> * @see #do_verify() */ @@ -370,13 +343,13 @@ public final class Pass3aVerifier extends PassVerifier{ InstructionHandle ih = instructionList.getStart(); while (ih != null){ Instruction i = ih.getInstruction(); - if (i instanceof IMPDEP1){ + if (i.getOpcode()==Constants.IMPDEP1){ throw new StaticCodeInstructionConstraintException("IMPDEP1 must not be in the code, it is an illegal instruction for _internal_ JVM use!"); } - if (i instanceof IMPDEP2){ + if (i.getOpcode()==Constants.IMPDEP2){ throw new StaticCodeInstructionConstraintException("IMPDEP2 must not be in the code, it is an illegal instruction for _internal_ JVM use!"); } - if (i instanceof BREAKPOINT){ + if (i.getOpcode()==Constants.BREAKPOINT){ throw new StaticCodeInstructionConstraintException("BREAKPOINT must not be in the code, it is an illegal instruction for _internal_ JVM use!"); } ih = ih.getNext(); @@ -387,10 +360,10 @@ public final class Pass3aVerifier extends PassVerifier{ // end of the code, which is stupid -- but with the original // verifier's subroutine semantics one cannot predict reachability. Instruction last = instructionList.getEnd().getInstruction(); - if (! ((last instanceof ReturnInstruction) || + if (! ((last.isReturnInstruction()) || (last instanceof RET) || - (last instanceof GotoInstruction) || - (last instanceof ATHROW) )) // JSR / JSR_W would possibly RETurn and then fall off the code! + (last.getOpcode()==Constants.GOTO || last.getOpcode()==Constants.GOTO_W) || + (last.getOpcode()==Constants.ATHROW))) // JSR / JSR_W would possibly RETurn and then fall off the code! throw new StaticCodeInstructionConstraintException("Execution must not fall off the bottom of the code array. This constraint is enforced statically as some existing verifiers do - so it may be a false alarm if the last instruction is not reachable."); } @@ -415,7 +388,7 @@ public final class Pass3aVerifier extends PassVerifier{ // TODO: Implement as much as possible here. BCEL does _not_ check everything. - ConstantPoolGen cpg = new ConstantPoolGen(Repository.lookupClass(myOwner.getClassName()).getConstantPool()); + ConstantPool cpg = new ConstantPool(Repository.lookupClass(myOwner.getClassName()).getConstantPool().getConstantPool()); InstOperandConstraintVisitor v = new InstOperandConstraintVisitor(cpg); // Checks for the things BCEL does _not_ handle itself. @@ -424,12 +397,12 @@ public final class Pass3aVerifier extends PassVerifier{ Instruction i = ih.getInstruction(); // An "own" constraint, due to JustIce's new definition of what "subroutine" means. - if (i instanceof JsrInstruction){ - InstructionHandle target = ((JsrInstruction) i).getTarget(); + if (i.isJsrInstruction()){ + InstructionHandle target = ((InstructionBranch) i).getTarget(); if (target == instructionList.getStart()){ throw new StaticCodeInstructionOperandConstraintException("Due to JustIce's clear definition of subroutines, no JSR or JSR_W may have a top-level instruction (such as the very first instruction, which is targeted by instruction '"+ih+"' as its target."); } - if (!(target.getInstruction() instanceof ASTORE)){ + if (!(target.getInstruction().isASTORE())){ throw new StaticCodeInstructionOperandConstraintException("Due to JustIce's clear definition of subroutines, no JSR or JSR_W may target anything else than an ASTORE instruction. Instruction '"+ih+"' targets '"+target+"'."); } } @@ -459,12 +432,12 @@ public final class Pass3aVerifier extends PassVerifier{ * This visitor class does the actual checking for the instruction * operand's constraints. */ - private class InstOperandConstraintVisitor extends org.aspectj.apache.bcel.generic.EmptyVisitor{ + private class InstOperandConstraintVisitor extends org.aspectj.apache.bcel.verifier.EmptyInstVisitor{ /** The ConstantPoolGen instance this Visitor operates on. */ - private ConstantPoolGen cpg; + private ConstantPool cpg; /** The only Constructor. */ - InstOperandConstraintVisitor(ConstantPoolGen cpg){ + InstOperandConstraintVisitor(ConstantPool cpg){ this.cpg = cpg; } @@ -500,7 +473,7 @@ public final class Pass3aVerifier extends PassVerifier{ * Assures the generic preconditions of a LoadClass instance. * The referenced class is loaded and pass2-verified. */ - public void visitLoadClass(LoadClass o){ + public void visitLoadClass(Instruction o){ ObjectType t = o.getLoadClassType(cpg); if (t != null){// null means "no class is loaded" Verifier v = VerifierFactory.getVerifier(t.getClassName()); @@ -520,7 +493,7 @@ public final class Pass3aVerifier extends PassVerifier{ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ // LDC and LDC_W (LDC_W is a subclass of LDC in BCEL's model) - public void visitLDC(LDC o){ + public void visitLDC(Instruction o){ indexValid(o, o.getIndex()); Constant c = cpg.getConstant(o.getIndex()); if (! ( (c instanceof ConstantInteger) || @@ -532,7 +505,7 @@ public final class Pass3aVerifier extends PassVerifier{ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ // LDC2_W - public void visitLDC2_W(LDC2_W o){ + public void visitLDC2_W(Instruction o){ indexValid(o, o.getIndex()); Constant c = cpg.getConstant(o.getIndex()); if (! ( (c instanceof ConstantLong) || @@ -590,9 +563,9 @@ public final class Pass3aVerifier extends PassVerifier{ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ public void visitInvokeInstruction(InvokeInstruction o){ indexValid(o, o.getIndex()); - if ( (o instanceof INVOKEVIRTUAL) || - (o instanceof INVOKESPECIAL) || - (o instanceof INVOKESTATIC) ){ + if ( (o.getOpcode()==Constants.INVOKEVIRTUAL) || + (o.getOpcode()==Constants.INVOKESPECIAL) || + (o.getOpcode()==Constants.INVOKESTATIC) ){ Constant c = cpg.getConstant(o.getIndex()); if (! (c instanceof ConstantMethodref)){ constraintViolated(o, "Indexing a constant that's not a CONSTANT_Methodref but a '"+c+"'."); @@ -601,7 +574,7 @@ public final class Pass3aVerifier extends PassVerifier{ // Constants are okay due to pass2. ConstantNameAndType cnat = (ConstantNameAndType) (cpg.getConstant(((ConstantMethodref) c).getNameAndTypeIndex())); ConstantUtf8 cutf8 = (ConstantUtf8) (cpg.getConstant(cnat.getNameIndex())); - if (cutf8.getBytes().equals(Constants.CONSTRUCTOR_NAME) && (!(o instanceof INVOKESPECIAL)) ){ + if (cutf8.getBytes().equals(Constants.CONSTRUCTOR_NAME) && (!(o.getOpcode()==Constants.INVOKESPECIAL)) ){ constraintViolated(o, "Only INVOKESPECIAL is allowed to invoke instance initialization methods."); } if ( (! (cutf8.getBytes().equals(Constants.CONSTRUCTOR_NAME)) ) && (cutf8.getBytes().startsWith("<")) ){ @@ -662,7 +635,7 @@ public final class Pass3aVerifier extends PassVerifier{ } /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ - public void visitINSTANCEOF(INSTANCEOF o){ + public void visitINSTANCEOF(Instruction o){ indexValid(o, o.getIndex()); Constant c = cpg.getConstant(o.getIndex()); if (! (c instanceof ConstantClass)){ @@ -671,7 +644,7 @@ public final class Pass3aVerifier extends PassVerifier{ } /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ - public void visitCHECKCAST(CHECKCAST o){ + public void visitCHECKCAST(Instruction o){ indexValid(o, o.getIndex()); Constant c = cpg.getConstant(o.getIndex()); if (! (c instanceof ConstantClass)){ @@ -680,7 +653,7 @@ public final class Pass3aVerifier extends PassVerifier{ } /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ - public void visitNEW(NEW o){ + public void visitNEW(Instruction o){ indexValid(o, o.getIndex()); Constant c = cpg.getConstant(o.getIndex()); if (! (c instanceof ConstantClass)){ @@ -720,7 +693,7 @@ public final class Pass3aVerifier extends PassVerifier{ } /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ - public void visitANEWARRAY(ANEWARRAY o){ + public void visitANEWARRAY(Instruction o){ indexValid(o, o.getIndex()); Constant c = cpg.getConstant(o.getIndex()); if (! (c instanceof ConstantClass)){ @@ -736,8 +709,8 @@ public final class Pass3aVerifier extends PassVerifier{ } /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ - public void visitNEWARRAY(NEWARRAY o){ - byte t = o.getTypecode(); + public void visitNEWARRAY(Instruction o){ + byte t = ((InstructionByte)o).getTypecode(); if (! ( (t == Constants.T_BOOLEAN) || (t == Constants.T_CHAR) || (t == Constants.T_FLOAT) || @@ -751,7 +724,7 @@ public final class Pass3aVerifier extends PassVerifier{ } /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ - public void visitILOAD(ILOAD o){ + public void visitILOAD(Instruction o){ int idx = o.getIndex(); if (idx < 0){ constraintViolated(o, "Index '"+idx+"' must be non-negative."); @@ -765,7 +738,7 @@ public final class Pass3aVerifier extends PassVerifier{ } /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ - public void visitFLOAD(FLOAD o){ + public void visitFLOAD(Instruction o){ int idx = o.getIndex(); if (idx < 0){ constraintViolated(o, "Index '"+idx+"' must be non-negative."); @@ -779,7 +752,7 @@ public final class Pass3aVerifier extends PassVerifier{ } /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ - public void visitALOAD(ALOAD o){ + public void visitALOAD(Instruction o){ int idx = o.getIndex(); if (idx < 0){ constraintViolated(o, "Index '"+idx+"' must be non-negative."); @@ -793,7 +766,7 @@ public final class Pass3aVerifier extends PassVerifier{ } /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ - public void visitISTORE(ISTORE o){ + public void visitISTORE(Instruction o){ int idx = o.getIndex(); if (idx < 0){ constraintViolated(o, "Index '"+idx+"' must be non-negative."); @@ -807,7 +780,7 @@ public final class Pass3aVerifier extends PassVerifier{ } /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ - public void visitFSTORE(FSTORE o){ + public void visitFSTORE(Instruction o){ int idx = o.getIndex(); if (idx < 0){ constraintViolated(o, "Index '"+idx+"' must be non-negative."); @@ -821,7 +794,7 @@ public final class Pass3aVerifier extends PassVerifier{ } /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ - public void visitASTORE(ASTORE o){ + public void visitASTORE(Instruction o){ int idx = o.getIndex(); if (idx < 0){ constraintViolated(o, "Index '"+idx+"' must be non-negative."); @@ -863,7 +836,7 @@ public final class Pass3aVerifier extends PassVerifier{ } /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ - public void visitLLOAD(LLOAD o){ + public void visitLLOAD(Instruction o){ int idx = o.getIndex(); if (idx < 0){ constraintViolated(o, "Index '"+idx+"' must be non-negative. [Constraint by JustIce as an analogon to the single-slot xLOAD/xSTORE instructions; may not happen anyway.]"); @@ -877,7 +850,7 @@ public final class Pass3aVerifier extends PassVerifier{ } /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ - public void visitDLOAD(DLOAD o){ + public void visitDLOAD(Instruction o){ int idx = o.getIndex(); if (idx < 0){ constraintViolated(o, "Index '"+idx+"' must be non-negative. [Constraint by JustIce as an analogon to the single-slot xLOAD/xSTORE instructions; may not happen anyway.]"); @@ -891,7 +864,7 @@ public final class Pass3aVerifier extends PassVerifier{ } /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ - public void visitLSTORE(LSTORE o){ + public void visitLSTORE(Instruction o){ int idx = o.getIndex(); if (idx < 0){ constraintViolated(o, "Index '"+idx+"' must be non-negative. [Constraint by JustIce as an analogon to the single-slot xLOAD/xSTORE instructions; may not happen anyway.]"); @@ -905,7 +878,7 @@ public final class Pass3aVerifier extends PassVerifier{ } /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ - public void visitDSTORE(DSTORE o){ + public void visitDSTORE(Instruction o){ int idx = o.getIndex(); if (idx < 0){ constraintViolated(o, "Index '"+idx+"' must be non-negative. [Constraint by JustIce as an analogon to the single-slot xLOAD/xSTORE instructions; may not happen anyway.]"); @@ -942,7 +915,7 @@ public final class Pass3aVerifier extends PassVerifier{ } /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ - public void visitPUTSTATIC(PUTSTATIC o){ + public void visitPUTSTATIC(FieldInstruction o){ String field_name = o.getFieldName(cpg); JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName()); Field[] fields = jc.getFields(); @@ -976,7 +949,7 @@ public final class Pass3aVerifier extends PassVerifier{ } /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ - public void visitGETSTATIC(GETSTATIC o){ + public void visitGETSTATIC(FieldInstruction o){ String field_name = o.getFieldName(cpg); JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName()); Field[] fields = jc.getFields(); @@ -1033,7 +1006,7 @@ public final class Pass3aVerifier extends PassVerifier{ } /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ - public void visitINVOKESPECIAL(INVOKESPECIAL o){ + public void visitINVOKESPECIAL(InvokeInstruction o){ // INVOKESPECIAL is a LoadClass; the Class where the referenced method is declared in, // is therefore resolved/verified. // INVOKESPECIAL is an InvokeInstruction, the argument and return types are resolved/verified, @@ -1091,7 +1064,7 @@ public final class Pass3aVerifier extends PassVerifier{ } /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ - public void visitINVOKESTATIC(INVOKESTATIC o){ + public void visitINVOKESTATIC(InvokeInstruction o){ // INVOKESTATIC is a LoadClass; the Class where the referenced method is declared in, // is therefore resolved/verified. // INVOKESTATIC is an InvokeInstruction, the argument and return types are resolved/verified, @@ -1120,7 +1093,7 @@ public final class Pass3aVerifier extends PassVerifier{ /** Checks if the constraints of operands of the said instruction(s) are satisfied. */ - public void visitINVOKEVIRTUAL(INVOKEVIRTUAL o){ + public void visitINVOKEVIRTUAL(InvokeInstruction o){ // INVOKEVIRTUAL is a LoadClass; the Class where the referenced method is declared in, // is therefore resolved/verified. // INVOKEVIRTUAL is an InvokeInstruction, the argument and return types are resolved/verified, diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/statics/StringRepresentation.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/StringRepresentation.java index 24337f155..3a6df16c2 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/statics/StringRepresentation.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/StringRepresentation.java @@ -88,7 +88,7 @@ import org.aspectj.apache.bcel.classfile.SourceFile; import org.aspectj.apache.bcel.classfile.StackMap; import org.aspectj.apache.bcel.classfile.Synthetic; import org.aspectj.apache.bcel.classfile.Unknown; -import org.aspectj.apache.bcel.classfile.Visitor; +import org.aspectj.apache.bcel.classfile.ClassVisitor; import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisibleAnnotations; import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisibleParameterAnnotations; import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleAnnotations; @@ -107,10 +107,10 @@ import org.aspectj.apache.bcel.verifier.exc.AssertionViolatedException; * Note that this class also serves as a placeholder for more sophisticated message * handling in future versions of JustIce. * - * @version $Id: StringRepresentation.java,v 1.4 2006/07/04 16:57:42 aclement Exp $ + * @version $Id: StringRepresentation.java,v 1.2 2008/05/28 23:52:54 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ -public class StringRepresentation extends org.aspectj.apache.bcel.classfile.EmptyVisitor implements Visitor{ +public class StringRepresentation extends org.aspectj.apache.bcel.verifier.EmptyClassVisitor implements ClassVisitor{ /** The string representation, created by a visitXXX() method, output by toString(). */ private String tostring; /** The node we ask for its string representation. Not really needed; only for debug output. */ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/statics/package.html b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/package.html index 403d492f8..a354da1b7 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/statics/package.html +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/package.html @@ -2,7 +2,7 @@ <html> <head> <!-- -$Id: package.html,v 1.2 2004/11/19 16:45:19 aclement Exp $ +$Id: package.html,v 1.2 2008/05/28 23:52:54 aclement Exp $ --> </head> <body bgcolor="white"> diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/ControlFlowGraph.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ControlFlowGraph.java index d64e6eb38..203080c3f 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/ControlFlowGraph.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ControlFlowGraph.java @@ -58,23 +58,20 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Hashtable; -import org.aspectj.apache.bcel.generic.ATHROW; -import org.aspectj.apache.bcel.generic.BranchInstruction; -import org.aspectj.apache.bcel.generic.GotoInstruction; +import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.generic.Instruction; +import org.aspectj.apache.bcel.generic.InstructionBranch; import org.aspectj.apache.bcel.generic.InstructionHandle; -import org.aspectj.apache.bcel.generic.JsrInstruction; +import org.aspectj.apache.bcel.generic.InstructionSelect; import org.aspectj.apache.bcel.generic.MethodGen; import org.aspectj.apache.bcel.generic.RET; -import org.aspectj.apache.bcel.generic.ReturnInstruction; -import org.aspectj.apache.bcel.generic.Select; import org.aspectj.apache.bcel.verifier.exc.AssertionViolatedException; import org.aspectj.apache.bcel.verifier.exc.StructuralCodeConstraintException; /** * This class represents a control flow graph of a method. * - * @version $Id: ControlFlowGraph.java,v 1.4 2004/11/22 08:31:27 aclement Exp $ + * @version $Id: ControlFlowGraph.java,v 1.2 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public class ControlFlowGraph{ @@ -318,7 +315,7 @@ public class ControlFlowGraph{ InstructionContextImpl current = (InstructionContextImpl) (executionPredecessors.get(i)); Instruction currentlast = current.getInstruction().getInstruction(); if (currentlast instanceof RET) retcount++; - if (currentlast instanceof JsrInstruction){ + if (currentlast.isJsrInstruction()){ retcount--; if (retcount == -1) return current; } @@ -363,40 +360,40 @@ throw new AssertionViolatedException("DID YOU REALLY WANT TO ASK FOR RET'S SUCCS } // Terminates method normally. - if (inst instanceof ReturnInstruction){ + if (inst.isReturnInstruction()) { return empty; } // Terminates method abnormally, because JustIce mandates // subroutines not to be protected by exception handlers. - if (inst instanceof ATHROW){ + if (inst.getOpcode()==Constants.ATHROW){ return empty; } // See method comment. - if (inst instanceof JsrInstruction){ - single[0] = ((JsrInstruction) inst).getTarget(); + if (inst.isJsrInstruction()){ + single[0] = ((InstructionBranch) inst).getTarget(); return single; } - if (inst instanceof GotoInstruction){ - single[0] = ((GotoInstruction) inst).getTarget(); + if (inst.getOpcode()==Constants.GOTO || inst.getOpcode()==Constants.GOTO_W){ + single[0] = ((InstructionBranch) inst).getTarget(); return single; } - if (inst instanceof BranchInstruction){ - if (inst instanceof Select){ + if (inst instanceof InstructionBranch){ + if (inst instanceof InstructionSelect){ // BCEL's getTargets() returns only the non-default targets, // thanks to Eli Tilevich for reporting. - InstructionHandle[] matchTargets = ((Select) inst).getTargets(); + InstructionHandle[] matchTargets = ((InstructionSelect) inst).getTargets(); InstructionHandle[] ret = new InstructionHandle[matchTargets.length+1]; - ret[0] = ((Select) inst).getTarget(); + ret[0] = ((InstructionSelect) inst).getTarget(); System.arraycopy(matchTargets, 0, ret, 1, matchTargets.length); return ret; } else{ pair[0] = getInstruction().getNext(); - pair[1] = ((BranchInstruction) inst).getTarget(); + pair[1] = ((InstructionBranch) inst).getTarget(); return pair; } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/ExceptionHandler.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ExceptionHandler.java index e715aa605..3853a84dd 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/ExceptionHandler.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ExceptionHandler.java @@ -61,7 +61,7 @@ import org.aspectj.apache.bcel.generic.*; * representing a subclass of java.lang.Throwable and the instruction * the handler starts off (represented by an InstructionContext). * - * @version $Id: ExceptionHandler.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: ExceptionHandler.java,v 1.2 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public class ExceptionHandler{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/ExceptionHandlers.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ExceptionHandlers.java index a0754501d..69e904af0 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/ExceptionHandlers.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ExceptionHandlers.java @@ -61,7 +61,7 @@ import java.util.Hashtable; /** * This class allows easy access to ExceptionHandler objects. * - * @version $Id: ExceptionHandlers.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: ExceptionHandlers.java,v 1.2 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public class ExceptionHandlers{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/ExecutionVisitor.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ExecutionVisitor.java index c4951520c..f6eed74cc 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/ExecutionVisitor.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ExecutionVisitor.java @@ -61,7 +61,24 @@ import org.aspectj.apache.bcel.classfile.ConstantFloat; import org.aspectj.apache.bcel.classfile.ConstantInteger; import org.aspectj.apache.bcel.classfile.ConstantLong; import org.aspectj.apache.bcel.classfile.ConstantString; -import org.aspectj.apache.bcel.generic.*; +import org.aspectj.apache.bcel.classfile.ConstantPool; +import org.aspectj.apache.bcel.generic.ArrayType; +import org.aspectj.apache.bcel.generic.FieldInstruction; +import org.aspectj.apache.bcel.generic.IINC; +import org.aspectj.apache.bcel.generic.INVOKEINTERFACE; +import org.aspectj.apache.bcel.generic.Instruction; +import org.aspectj.apache.bcel.generic.InstructionBranch; +import org.aspectj.apache.bcel.generic.InstructionByte; +import org.aspectj.apache.bcel.generic.InvokeInstruction; +import org.aspectj.apache.bcel.generic.LOOKUPSWITCH; +import org.aspectj.apache.bcel.generic.MULTIANEWARRAY; +import org.aspectj.apache.bcel.generic.ObjectType; +import org.aspectj.apache.bcel.generic.RET; +import org.aspectj.apache.bcel.generic.ReturnaddressType; +import org.aspectj.apache.bcel.generic.TABLESWITCH; +import org.aspectj.apache.bcel.generic.Type; +import org.aspectj.apache.bcel.generic.InstVisitor; +import org.aspectj.apache.bcel.verifier.EmptyInstVisitor; /** * This Visitor class may be used for a type-based Java Virtual Machine @@ -86,13 +103,13 @@ import org.aspectj.apache.bcel.generic.*; * If a two-slot type is stored into a local variable, the next variable * is given the type Type.UNKNOWN. * - * @version $Id: ExecutionVisitor.java,v 1.5 2005/02/02 09:11:39 aclement Exp $ + * @version $Id: ExecutionVisitor.java,v 1.2 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> * @see #visitDSTORE(DSTORE o) * @see InstConstraintVisitor */ -public class ExecutionVisitor extends EmptyVisitor implements Visitor{ - +public class ExecutionVisitor extends EmptyInstVisitor implements InstVisitor { + /** * The executionframe we're operating on. */ @@ -102,7 +119,7 @@ public class ExecutionVisitor extends EmptyVisitor implements Visitor{ * The ConstantPoolGen we're working with. * @see #setConstantPoolGen(ConstantPoolGen) */ - private ConstantPoolGen cpg = null; + private ConstantPool cpg = null; /** * Constructor. Constructs a new instance of this class. @@ -128,7 +145,7 @@ public class ExecutionVisitor extends EmptyVisitor implements Visitor{ /** * Sets the ConstantPoolGen needed for symbolic execution. */ - public void setConstantPoolGen(ConstantPoolGen cpg){ + public void setConstantPoolGen(ConstantPool cpg){ this.cpg = cpg; } @@ -153,7 +170,7 @@ public class ExecutionVisitor extends EmptyVisitor implements Visitor{ //} /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitAALOAD(AALOAD o){ + public void visitAALOAD(Instruction o){ stack().pop(); // pop the index int //System.out.print(stack().peek()); Type t = stack().pop(); // Pop Array type @@ -166,42 +183,42 @@ public class ExecutionVisitor extends EmptyVisitor implements Visitor{ } } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitAASTORE(AASTORE o){ + public void visitAASTORE(Instruction o){ stack().pop(); stack().pop(); stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitACONST_NULL(ACONST_NULL o){ + public void visitACONST_NULL(Instruction o){ stack().push(Type.NULL); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitALOAD(ALOAD o){ + public void visitALOAD(Instruction o){ stack().push(locals().get(o.getIndex())); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitANEWARRAY(ANEWARRAY o){ + public void visitANEWARRAY(Instruction o){ stack().pop(); //count stack().push( new ArrayType(o.getType(cpg), 1) ); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitARETURN(ARETURN o){ + public void visitARETURN(Instruction o){ stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitARRAYLENGTH(ARRAYLENGTH o){ + public void visitARRAYLENGTH(Instruction o){ stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitASTORE(ASTORE o){ + public void visitASTORE(Instruction o){ locals().set(o.getIndex(), stack().pop()); //System.err.println("TODO-DEBUG: set LV '"+o.getIndex()+"' to '"+locals().get(o.getIndex())+"'."); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitATHROW(ATHROW o){ + public void visitATHROW(Instruction o){ Type t = stack().pop(); stack().clear(); if (t.equals(Type.NULL)) @@ -211,38 +228,38 @@ public class ExecutionVisitor extends EmptyVisitor implements Visitor{ } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitBALOAD(BALOAD o){ + public void visitBALOAD(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitBASTORE(BASTORE o){ + public void visitBASTORE(Instruction o){ stack().pop(); stack().pop(); stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitBIPUSH(BIPUSH o){ + public void visitBIPUSH(Instruction o){ stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitCALOAD(CALOAD o){ + public void visitCALOAD(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitCASTORE(CASTORE o){ + public void visitCASTORE(Instruction o){ stack().pop(); stack().pop(); stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitCHECKCAST(CHECKCAST o){ + public void visitCHECKCAST(Instruction o){ // It's possibly wrong to do so, but SUN's // ByteCode verifier seems to do (only) this, too. // TODO: One could use a sophisticated analysis here to check @@ -253,104 +270,104 @@ public class ExecutionVisitor extends EmptyVisitor implements Visitor{ } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitD2F(D2F o){ + public void visitD2F(Instruction o){ stack().pop(); stack().push(Type.FLOAT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitD2I(D2I o){ + public void visitD2I(Instruction o){ stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitD2L(D2L o){ + public void visitD2L(Instruction o){ stack().pop(); stack().push(Type.LONG); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitDADD(DADD o){ + public void visitDADD(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.DOUBLE); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitDALOAD(DALOAD o){ + public void visitDALOAD(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.DOUBLE); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitDASTORE(DASTORE o){ + public void visitDASTORE(Instruction o){ stack().pop(); stack().pop(); stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitDCMPG(DCMPG o){ + public void visitDCMPG(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitDCMPL(DCMPL o){ + public void visitDCMPL(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitDCONST(DCONST o){ + public void visitDCONST(Instruction o){ stack().push(Type.DOUBLE); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitDDIV(DDIV o){ + public void visitDDIV(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.DOUBLE); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitDLOAD(DLOAD o){ + public void visitDLOAD(Instruction o){ stack().push(Type.DOUBLE); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitDMUL(DMUL o){ + public void visitDMUL(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.DOUBLE); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitDNEG(DNEG o){ + public void visitDNEG(Instruction o){ stack().pop(); stack().push(Type.DOUBLE); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitDREM(DREM o){ + public void visitDREM(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.DOUBLE); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitDRETURN(DRETURN o){ + public void visitDRETURN(Instruction o){ stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitDSTORE(DSTORE o){ + public void visitDSTORE(Instruction o){ locals().set(o.getIndex(), stack().pop()); locals().set(o.getIndex()+1, Type.UNKNOWN); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitDSUB(DSUB o){ + public void visitDSUB(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.DOUBLE); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitDUP(DUP o){ + public void visitDUP(Instruction o){ Type t = stack().pop(); stack().push(t); stack().push(t); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitDUP_X1(DUP_X1 o){ + public void visitDUP_X1(Instruction o){ Type w1 = stack().pop(); Type w2 = stack().pop(); stack().push(w1); @@ -358,7 +375,7 @@ public class ExecutionVisitor extends EmptyVisitor implements Visitor{ stack().push(w1); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitDUP_X2(DUP_X2 o){ + public void visitDUP_X2(Instruction o){ Type w1 = stack().pop(); Type w2 = stack().pop(); if (w2.getSize() == 2){ @@ -375,7 +392,7 @@ public class ExecutionVisitor extends EmptyVisitor implements Visitor{ } } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitDUP2(DUP2 o){ + public void visitDUP2(Instruction o){ Type t = stack().pop(); if (t.getSize() == 2){ stack().push(t); @@ -390,7 +407,7 @@ public class ExecutionVisitor extends EmptyVisitor implements Visitor{ } } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitDUP2_X1(DUP2_X1 o){ + public void visitDUP2_X1(Instruction o){ Type t = stack().pop(); if (t.getSize() == 2){ Type u = stack().pop(); @@ -409,7 +426,7 @@ public class ExecutionVisitor extends EmptyVisitor implements Visitor{ } } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitDUP2_X2(DUP2_X2 o){ + public void visitDUP2_X2(Instruction o){ Type t = stack().pop(); if (t.getSize() == 2){ Type u = stack().pop(); @@ -446,97 +463,97 @@ public class ExecutionVisitor extends EmptyVisitor implements Visitor{ } } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitF2D(F2D o){ + public void visitF2D(Instruction o){ stack().pop(); stack().push(Type.DOUBLE); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitF2I(F2I o){ + public void visitF2I(Instruction o){ stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitF2L(F2L o){ + public void visitF2L(Instruction o){ stack().pop(); stack().push(Type.LONG); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitFADD(FADD o){ + public void visitFADD(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.FLOAT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitFALOAD(FALOAD o){ + public void visitFALOAD(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.FLOAT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitFASTORE(FASTORE o){ + public void visitFASTORE(Instruction o){ stack().pop(); stack().pop(); stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitFCMPG(FCMPG o){ + public void visitFCMPG(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitFCMPL(FCMPL o){ + public void visitFCMPL(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitFCONST(FCONST o){ + public void visitFCONST(Instruction o){ stack().push(Type.FLOAT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitFDIV(FDIV o){ + public void visitFDIV(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.FLOAT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitFLOAD(FLOAD o){ + public void visitFLOAD(Instruction o){ stack().push(Type.FLOAT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitFMUL(FMUL o){ + public void visitFMUL(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.FLOAT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitFNEG(FNEG o){ + public void visitFNEG(Instruction o){ stack().pop(); stack().push(Type.FLOAT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitFREM(FREM o){ + public void visitFREM(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.FLOAT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitFRETURN(FRETURN o){ + public void visitFRETURN(Instruction o){ stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitFSTORE(FSTORE o){ + public void visitFSTORE(Instruction o){ locals().set(o.getIndex(), stack().pop()); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitFSUB(FSUB o){ + public void visitFSUB(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.FLOAT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitGETFIELD(GETFIELD o){ + public void visitGETFIELD(FieldInstruction o){ stack().pop(); Type t = o.getFieldType(cpg); if ( t.equals(Type.BOOLEAN) || @@ -547,7 +564,7 @@ public class ExecutionVisitor extends EmptyVisitor implements Visitor{ stack().push(t); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitGETSTATIC(GETSTATIC o){ + public void visitGETSTATIC(FieldInstruction o){ Type t = o.getFieldType(cpg); if ( t.equals(Type.BOOLEAN) || t.equals(Type.CHAR) || @@ -557,147 +574,147 @@ public class ExecutionVisitor extends EmptyVisitor implements Visitor{ stack().push(t); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitGOTO(GOTO o){ + public void visitGOTO(Instruction o){ // no stack changes. } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitGOTO_W(GOTO_W o){ + public void visitGOTO_W(Instruction o){ // no stack changes. } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitI2B(I2B o){ + public void visitI2B(Instruction o){ stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitI2C(I2C o){ + public void visitI2C(Instruction o){ stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitI2D(I2D o){ + public void visitI2D(Instruction o){ stack().pop(); stack().push(Type.DOUBLE); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitI2F(I2F o){ + public void visitI2F(Instruction o){ stack().pop(); stack().push(Type.FLOAT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitI2L(I2L o){ + public void visitI2L(Instruction o){ stack().pop(); stack().push(Type.LONG); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitI2S(I2S o){ + public void visitI2S(Instruction o){ stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIADD(IADD o){ + public void visitIADD(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIALOAD(IALOAD o){ + public void visitIALOAD(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIAND(IAND o){ + public void visitIAND(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIASTORE(IASTORE o){ + public void visitIASTORE(Instruction o){ stack().pop(); stack().pop(); stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitICONST(ICONST o){ + public void visitICONST(Instruction o){ stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIDIV(IDIV o){ + public void visitIDIV(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIF_ACMPEQ(IF_ACMPEQ o){ + public void visitIF_ACMPEQ(Instruction o){ stack().pop(); stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIF_ACMPNE(IF_ACMPNE o){ + public void visitIF_ACMPNE(Instruction o){ stack().pop(); stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIF_ICMPEQ(IF_ICMPEQ o){ + public void visitIF_ICMPEQ(Instruction o){ stack().pop(); stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIF_ICMPGE(IF_ICMPGE o){ + public void visitIF_ICMPGE(Instruction o){ stack().pop(); stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIF_ICMPGT(IF_ICMPGT o){ + public void visitIF_ICMPGT(Instruction o){ stack().pop(); stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIF_ICMPLE(IF_ICMPLE o){ + public void visitIF_ICMPLE(Instruction o){ stack().pop(); stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIF_ICMPLT(IF_ICMPLT o){ + public void visitIF_ICMPLT(Instruction o){ stack().pop(); stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIF_ICMPNE(IF_ICMPNE o){ + public void visitIF_ICMPNE(Instruction o){ stack().pop(); stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIFEQ(IFEQ o){ + public void visitIFEQ(Instruction o){ stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIFGE(IFGE o){ + public void visitIFGE(Instruction o){ stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIFGT(IFGT o){ + public void visitIFGT(Instruction o){ stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIFLE(IFLE o){ + public void visitIFLE(Instruction o){ stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIFLT(IFLT o){ + public void visitIFLT(Instruction o){ stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIFNE(IFNE o){ + public void visitIFNE(Instruction o){ stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIFNONNULL(IFNONNULL o){ + public void visitIFNONNULL(Instruction o){ stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIFNULL(IFNULL o){ + public void visitIFNULL(Instruction o){ stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ @@ -705,22 +722,22 @@ public class ExecutionVisitor extends EmptyVisitor implements Visitor{ // stack is not changed. } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitILOAD(ILOAD o){ + public void visitILOAD(Instruction o){ stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIMUL(IMUL o){ + public void visitIMUL(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitINEG(INEG o){ + public void visitINEG(Instruction o){ stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitINSTANCEOF(INSTANCEOF o){ + public void visitINSTANCEOF(Instruction o){ stack().pop(); stack().push(Type.INT); } @@ -745,7 +762,7 @@ public class ExecutionVisitor extends EmptyVisitor implements Visitor{ } } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitINVOKESPECIAL(INVOKESPECIAL o){ + public void visitINVOKESPECIAL(InvokeInstruction o){ if (o.getMethodName(cpg).equals(Constants.CONSTRUCTOR_NAME)){ UninitializedObjectType t = (UninitializedObjectType) stack().peek(o.getArgumentTypes(cpg).length); if (t == Frame._this){ @@ -773,7 +790,7 @@ public class ExecutionVisitor extends EmptyVisitor implements Visitor{ } } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitINVOKESTATIC(INVOKESTATIC o){ + public void visitINVOKESTATIC(InvokeInstruction o){ for (int i=0; i<o.getArgumentTypes(cpg).length; i++){ stack().pop(); } @@ -792,7 +809,7 @@ public class ExecutionVisitor extends EmptyVisitor implements Visitor{ } } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitINVOKEVIRTUAL(INVOKEVIRTUAL o){ + public void visitINVOKEVIRTUAL(InvokeInstruction o){ stack().pop(); //objectref for (int i=0; i<o.getArgumentTypes(cpg).length; i++){ stack().pop(); @@ -812,118 +829,118 @@ public class ExecutionVisitor extends EmptyVisitor implements Visitor{ } } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIOR(IOR o){ + public void visitIOR(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIREM(IREM o){ + public void visitIREM(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIRETURN(IRETURN o){ + public void visitIRETURN(Instruction o){ stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitISHL(ISHL o){ + public void visitISHL(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitISHR(ISHR o){ + public void visitISHR(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitISTORE(ISTORE o){ + public void visitISTORE(Instruction o){ locals().set(o.getIndex(), stack().pop()); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitISUB(ISUB o){ + public void visitISUB(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIUSHR(IUSHR o){ + public void visitIUSHR(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitIXOR(IXOR o){ + public void visitIXOR(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitJSR(JSR o){ + public void visitJSR(InstructionBranch o){ stack().push(new ReturnaddressType(o.physicalSuccessor())); //System.err.println("TODO-----------:"+o.physicalSuccessor()); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitJSR_W(JSR_W o){ + public void visitJSR_W(InstructionBranch o){ stack().push(new ReturnaddressType(o.physicalSuccessor())); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitL2D(L2D o){ + public void visitL2D(Instruction o){ stack().pop(); stack().push(Type.DOUBLE); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitL2F(L2F o){ + public void visitL2F(Instruction o){ stack().pop(); stack().push(Type.FLOAT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitL2I(L2I o){ + public void visitL2I(Instruction o){ stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitLADD(LADD o){ + public void visitLADD(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.LONG); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitLALOAD(LALOAD o){ + public void visitLALOAD(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.LONG); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitLAND(LAND o){ + public void visitLAND(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.LONG); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitLASTORE(LASTORE o){ + public void visitLASTORE(Instruction o){ stack().pop(); stack().pop(); stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitLCMP(LCMP o){ + public void visitLCMP(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitLCONST(LCONST o){ + public void visitLCONST(Instruction o){ stack().push(Type.LONG); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitLDC(LDC o){ + public void visitLDC(Instruction o){ Constant c = cpg.getConstant(o.getIndex()); if (c instanceof ConstantInteger){ stack().push(Type.INT); @@ -936,7 +953,7 @@ public class ExecutionVisitor extends EmptyVisitor implements Visitor{ } } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitLDC_W(LDC_W o){ + public void visitLDC_W(Instruction o){ Constant c = cpg.getConstant(o.getIndex()); if (c instanceof ConstantInteger){ stack().push(Type.INT); @@ -949,7 +966,7 @@ public class ExecutionVisitor extends EmptyVisitor implements Visitor{ } } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitLDC2_W(LDC2_W o){ + public void visitLDC2_W(Instruction o){ Constant c = cpg.getConstant(o.getIndex()); if (c instanceof ConstantLong){ stack().push(Type.LONG); @@ -959,23 +976,23 @@ public class ExecutionVisitor extends EmptyVisitor implements Visitor{ } } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitLDIV(LDIV o){ + public void visitLDIV(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.LONG); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitLLOAD(LLOAD o){ + public void visitLLOAD(Instruction o){ stack().push(locals().get(o.getIndex())); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitLMUL(LMUL o){ + public void visitLMUL(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.LONG); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitLNEG(LNEG o){ + public void visitLNEG(Instruction o){ stack().pop(); stack().push(Type.LONG); } @@ -984,62 +1001,62 @@ public class ExecutionVisitor extends EmptyVisitor implements Visitor{ stack().pop(); //key } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitLOR(LOR o){ + public void visitLOR(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.LONG); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitLREM(LREM o){ + public void visitLREM(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.LONG); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitLRETURN(LRETURN o){ + public void visitLRETURN(Instruction o){ stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitLSHL(LSHL o){ + public void visitLSHL(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.LONG); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitLSHR(LSHR o){ + public void visitLSHR(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.LONG); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitLSTORE(LSTORE o){ + public void visitLSTORE(Instruction o){ locals().set(o.getIndex(), stack().pop()); locals().set(o.getIndex()+1, Type.UNKNOWN); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitLSUB(LSUB o){ + public void visitLSUB(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.LONG); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitLUSHR(LUSHR o){ + public void visitLUSHR(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.LONG); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitLXOR(LXOR o){ + public void visitLXOR(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.LONG); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitMONITORENTER(MONITORENTER o){ + public void visitMONITORENTER(Instruction o){ stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitMONITOREXIT(MONITOREXIT o){ + public void visitMONITOREXIT(Instruction o){ stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ @@ -1050,35 +1067,35 @@ public class ExecutionVisitor extends EmptyVisitor implements Visitor{ stack().push(o.getType(cpg)); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitNEW(NEW o){ + public void visitNEW(Instruction o){ stack().push(new UninitializedObjectType((ObjectType) (o.getType(cpg)))); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitNEWARRAY(NEWARRAY o){ + public void visitNEWARRAY(Instruction o){ stack().pop(); - stack().push(o.getType()); + stack().push(((InstructionByte)o).getType()); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitNOP(NOP o){ + public void visitNOP(Instruction o){ } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitPOP(POP o){ + public void visitPOP(Instruction o){ stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitPOP2(POP2 o){ + public void visitPOP2(Instruction o){ Type t = stack().pop(); if (t.getSize() == 1){ stack().pop(); } } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitPUTFIELD(PUTFIELD o){ + public void visitPUTFIELD(FieldInstruction o){ stack().pop(); stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitPUTSTATIC(PUTSTATIC o){ + public void visitPUTSTATIC(FieldInstruction o){ stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ @@ -1087,27 +1104,27 @@ public class ExecutionVisitor extends EmptyVisitor implements Visitor{ // is in in the local variables. } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitRETURN(RETURN o){ + public void visitRETURN(Instruction o){ // do nothing. } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitSALOAD(SALOAD o){ + public void visitSALOAD(Instruction o){ stack().pop(); stack().pop(); stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitSASTORE(SASTORE o){ + public void visitSASTORE(Instruction o){ stack().pop(); stack().pop(); stack().pop(); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitSIPUSH(SIPUSH o){ + public void visitSIPUSH(Instruction o){ stack().push(Type.INT); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ - public void visitSWAP(SWAP o){ + public void visitSWAP(Instruction o){ Type t = stack().pop(); Type u = stack().pop(); stack().push(t); diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/Frame.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Frame.java index 781635b88..97ad612ed 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/Frame.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Frame.java @@ -59,7 +59,7 @@ package org.aspectj.apache.bcel.verifier.structurals; * This class represents a JVM execution frame; that means, * a local variable array and an operand stack. * - * @version $Id: Frame.java,v 1.4 2004/11/22 08:31:27 aclement Exp $ + * @version $Id: Frame.java,v 1.2 2008/05/28 23:53:03 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/GenericArray.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/GenericArray.java index bee196904..6b9a6ec25 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/GenericArray.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/GenericArray.java @@ -59,7 +59,7 @@ package org.aspectj.apache.bcel.verifier.structurals; * has some of the properties arrays have. They implement java.lang.Cloneable * and java.io.Serializable and they extend java.lang.Object. * - * @version $Id: GenericArray.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: GenericArray.java,v 1.2 2008/05/28 23:53:03 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public class GenericArray extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/InstConstraintVisitor.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/InstConstraintVisitor.java index 2e39d10fa..f6977d177 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/InstConstraintVisitor.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/InstConstraintVisitor.java @@ -64,11 +64,32 @@ import org.aspectj.apache.bcel.classfile.ConstantFieldref; import org.aspectj.apache.bcel.classfile.ConstantFloat; import org.aspectj.apache.bcel.classfile.ConstantLong; import org.aspectj.apache.bcel.classfile.ConstantString; +import org.aspectj.apache.bcel.classfile.ConstantPool; import org.aspectj.apache.bcel.classfile.Field; import org.aspectj.apache.bcel.classfile.JavaClass; -import org.aspectj.apache.bcel.generic.*; -import org.aspectj.apache.bcel.verifier.*; -import org.aspectj.apache.bcel.verifier.exc.*; +import org.aspectj.apache.bcel.verifier.EmptyInstVisitor; +import org.aspectj.apache.bcel.verifier.VerificationResult; +import org.aspectj.apache.bcel.verifier.Verifier; +import org.aspectj.apache.bcel.verifier.VerifierFactory; +import org.aspectj.apache.bcel.verifier.exc.*; +import org.aspectj.apache.bcel.generic.ArrayType; +import org.aspectj.apache.bcel.generic.FieldInstruction; +import org.aspectj.apache.bcel.generic.IINC; +import org.aspectj.apache.bcel.generic.INVOKEINTERFACE; +import org.aspectj.apache.bcel.generic.Instruction; +import org.aspectj.apache.bcel.generic.InstructionBranch; +import org.aspectj.apache.bcel.generic.InstructionLV; +import org.aspectj.apache.bcel.generic.InvokeInstruction; +import org.aspectj.apache.bcel.generic.LOOKUPSWITCH; +import org.aspectj.apache.bcel.generic.MULTIANEWARRAY; +import org.aspectj.apache.bcel.generic.MethodGen; +import org.aspectj.apache.bcel.generic.ObjectType; +import org.aspectj.apache.bcel.generic.RET; +import org.aspectj.apache.bcel.generic.ReferenceType; +import org.aspectj.apache.bcel.generic.ReturnaddressType; +import org.aspectj.apache.bcel.generic.TABLESWITCH; +import org.aspectj.apache.bcel.generic.Type; +import org.aspectj.apache.bcel.generic.InstVisitor; /** @@ -79,12 +100,12 @@ import org.aspectj.apache.bcel.verifier.exc.*; * TODO: Currently, the JVM's behaviour concerning monitors (MONITORENTER, * MONITOREXIT) is not modeled in JustIce. * - * @version $Id: InstConstraintVisitor.java,v 1.4 2005/02/02 09:11:39 aclement Exp $ + * @version $Id: InstConstraintVisitor.java,v 1.2 2008/05/28 23:53:03 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> * @see org.aspectj.apache.bcel.verifier.exc.StructuralCodeConstraintException * @see org.aspectj.apache.bcel.verifier.exc.LinkingConstraintException */ -public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.apache.bcel.generic.Visitor{ +public class InstConstraintVisitor extends EmptyInstVisitor implements InstVisitor { private static ObjectType GENERIC_ARRAY = new ObjectType("org.aspectj.apache.bcel.verifier.structurals.GenericArray"); @@ -102,12 +123,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a */ private Frame frame = null; - /** - * The ConstantPoolGen we're working on. - * - * @see #setConstantPoolGen(ConstantPoolGen cpg) - */ - private ConstantPoolGen cpg = null; + private ConstantPool cpg = null; /** * The MethodGen we're working on. @@ -163,7 +179,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a * Sets the ConstantPoolGen instance needed for constraint * checking prior to execution. */ - public void setConstantPoolGen(ConstantPoolGen cpg){ + public void setConstantPoolGen(ConstantPool cpg){ this.cpg = cpg; } @@ -253,7 +269,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a * Assures the generic preconditions of a LoadClass instance. * The referenced class is loaded and pass2-verified. */ - public void visitLoadClass(LoadClass o){ + public void visitLoadClass(Instruction o){ ObjectType t = o.getLoadClassType(cpg); if (t != null){// null means "no class is loaded" Verifier v = VerifierFactory.getVerifier(t.getClassName()); @@ -267,15 +283,15 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the general preconditions of a StackConsumer instance. */ - public void visitStackConsumer(StackConsumer o){ - _visitStackAccessor((Instruction) o); + public void visitStackConsumer(Instruction o){ + _visitStackAccessor(o); } /** * Ensures the general preconditions of a StackProducer instance. */ - public void visitStackProducer(StackProducer o){ - _visitStackAccessor((Instruction) o); + public void visitStackProducer(Instruction o){ + _visitStackAccessor(o); } @@ -284,20 +300,14 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /* therefore, we know the order of visiting; we know */ /* these methods are called after the visitXXXX methods above. */ /***************************************************************/ - /** - * Ensures the general preconditions of a CPInstruction instance. - */ - public void visitCPInstruction(CPInstruction o){ + public void visitCPInstruction(Instruction o){ int idx = o.getIndex(); if ((idx < 0) || (idx >= cpg.getSize())){ throw new AssertionViolatedException("Huh?! Constant pool index of instruction '"+o+"' illegal? Pass 3a should have checked this!"); } } - /** - * Ensures the general preconditions of a FieldInstruction instance. - */ - public void visitFieldInstruction(FieldInstruction o){ + public void visitFieldInstruction(Instruction o){ // visitLoadClass(o) has been called before: Every FieldOrMethod // implements LoadClass. // visitCPInstruction(o) has been called before. @@ -318,9 +328,6 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a } } - /** - * Ensures the general preconditions of an InvokeInstruction instance. - */ public void visitInvokeInstruction(InvokeInstruction o){ // visitLoadClass(o) has been called before: Every FieldOrMethod // implements LoadClass. @@ -328,10 +335,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a //TODO } - /** - * Ensures the general preconditions of a StackInstruction instance. - */ - public void visitStackInstruction(StackInstruction o){ + public void visitStackInstruction(Instruction o){ _visitStackAccessor(o); } @@ -339,16 +343,13 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a * Assures the generic preconditions of a LocalVariableInstruction instance. * That is, the index of the local variable must be valid. */ - public void visitLocalVariableInstruction(LocalVariableInstruction o){ + public void visitLocalVariableInstruction(InstructionLV o){ if (locals().maxLocals() <= (o.getType(cpg).getSize()==1? o.getIndex() : o.getIndex()+1) ){ constraintViolated(o, "The 'index' is not a valid index into the local variable array."); } } - /** - * Assures the generic preconditions of a LoadInstruction instance. - */ - public void visitLoadInstruction(LoadInstruction o){ + public void visitLoadInstruction(Instruction o){ //visitLocalVariableInstruction(o) is called before, because it is more generic. // LOAD instructions must not read Type.UNKNOWN @@ -366,7 +367,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a } // LOAD instructions must read the correct type. - if (!(o instanceof ALOAD)){ + if (!o.isALOAD()){ if (locals().get(o.getIndex()) != o.getType(cpg) ){ constraintViolated(o, "Local Variable type and LOADing Instruction type mismatch: Local Variable: '"+locals().get(o.getIndex())+"'; Instruction type: '"+o.getType(cpg)+"'."); } @@ -385,17 +386,14 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a } } - /** - * Assures the generic preconditions of a StoreInstruction instance. - */ - public void visitStoreInstruction(StoreInstruction o){ + public void visitStoreInstruction(Instruction o){ //visitLocalVariableInstruction(o) is called before, because it is more generic. if (stack().isEmpty()){ // Don't bother about 1 or 2 stack slots used. This check is implicitely done below while type checking. constraintViolated(o, "Cannot STORE: Stack to read from is empty."); } - if ( (!(o instanceof ASTORE)) ){ + if (!o.isASTORE() ){ if (! (stack().peek() == o.getType(cpg)) ){// the other xSTORE types are singletons in BCEL. constraintViolated(o, "Stack top type and STOREing Instruction type mismatch: Stack top: '"+stack().peek()+"'; Instruction type: '"+o.getType(cpg)+"'."); } @@ -411,14 +409,11 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a } } - /** - * Assures the generic preconditions of a ReturnInstruction instance. - */ - public void visitReturnInstruction(ReturnInstruction o){ - if (o instanceof RETURN){ + public void visitReturnInstruction(Instruction o){ + if (o.getOpcode()==Constants.RETURN){ return; } - if (o instanceof ARETURN){ + if (o.getOpcode()==Constants.ARETURN){ if (stack().peek() == Type.NULL){ return; } @@ -453,10 +448,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /* "special"visitXXXX methods for one type of instruction each */ /***************************************************************/ - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitAALOAD(AALOAD o){ + public void visitAALOAD(Instruction o){ Type arrayref = stack().peek(1); Type index = stack().peek(0); @@ -472,7 +464,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitAASTORE(AASTORE o){ + public void visitAASTORE(Instruction o){ Type arrayref = stack().peek(2); Type index = stack().peek(1); Type value = stack().peek(0); @@ -495,26 +487,16 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a } } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitACONST_NULL(ACONST_NULL o){ + public void visitACONST_NULL(Instruction o){ // Nothing needs to be done here. } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitALOAD(ALOAD o){ + public void visitALOAD(Instruction o){ //visitLoadInstruction(LoadInstruction) is called before. - // Nothing else needs to be done here. } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitANEWARRAY(ANEWARRAY o){ + public void visitANEWARRAY(Instruction o){ if (!stack().peek().equals(Type.INT)) constraintViolated(o, "The 'count' at the stack top is not of type '"+Type.INT+"' but of type '"+stack().peek()+"'."); // The runtime constant pool item at that index must be a symbolic reference to a class, @@ -524,7 +506,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitARETURN(ARETURN o){ + public void visitARETURN(Instruction o){ if (! (stack().peek() instanceof ReferenceType) ){ constraintViolated(o, "The 'objectref' at the stack top is not of a ReferenceType but of type '"+stack().peek()+"'."); } @@ -542,7 +524,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitARRAYLENGTH(ARRAYLENGTH o){ + public void visitARRAYLENGTH(Instruction o){ Type arrayref = stack().peek(0); arrayrefOfArrayType(o, arrayref); } @@ -550,7 +532,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitASTORE(ASTORE o){ + public void visitASTORE(Instruction o){ if (! ( (stack().peek() instanceof ReferenceType) || (stack().peek() instanceof ReturnaddressType) ) ){ constraintViolated(o, "The 'objectref' is not of a ReferenceType or of ReturnaddressType but of "+stack().peek()+"."); } @@ -562,7 +544,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitATHROW(ATHROW o){ + public void visitATHROW(Instruction o){ // It's stated that 'objectref' must be of a ReferenceType --- but since Throwable is // not derived from an ArrayType, it follows that 'objectref' must be of an ObjectType or Type.NULL. if (! ((stack().peek() instanceof ObjectType) || (stack().peek().equals(Type.NULL))) ){ @@ -582,7 +564,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitBALOAD(BALOAD o){ + public void visitBALOAD(Instruction o){ Type arrayref = stack().peek(1); Type index = stack().peek(0); indexOfInt(o, index); @@ -597,7 +579,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitBASTORE(BASTORE o){ + public void visitBASTORE(Instruction o){ Type arrayref = stack().peek(2); Type index = stack().peek(1); Type value = stack().peek(0); @@ -614,21 +596,21 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitBIPUSH(BIPUSH o){ + public void visitBIPUSH(Instruction o){ // Nothing to do... } /** * Ensures the specific preconditions of the said instruction. */ - public void visitBREAKPOINT(BREAKPOINT o){ + public void visitBREAKPOINT(Instruction o){ throw new AssertionViolatedException("In this JustIce verification pass there should not occur an illegal instruction such as BREAKPOINT."); } /** * Ensures the specific preconditions of the said instruction. */ - public void visitCALOAD(CALOAD o){ + public void visitCALOAD(Instruction o){ Type arrayref = stack().peek(1); Type index = stack().peek(0); @@ -639,7 +621,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitCASTORE(CASTORE o){ + public void visitCASTORE(Instruction o){ Type arrayref = stack().peek(2); Type index = stack().peek(1); Type value = stack().peek(0); @@ -656,7 +638,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitCHECKCAST(CHECKCAST o){ + public void visitCHECKCAST(Instruction o){ // The objectref must be of type reference. Type objectref = stack().peek(0); if (!(objectref instanceof ReferenceType)){ @@ -674,49 +656,18 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a } } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitD2F(D2F o){ - if (stack().peek() != Type.DOUBLE){ - constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); - } - } - - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitD2I(D2I o){ - if (stack().peek() != Type.DOUBLE){ - constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); - } - } - - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitD2L(D2L o){ - if (stack().peek() != Type.DOUBLE){ - constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); - } - } + public void visitD2F(Instruction o) { checkTop(o,Type.DOUBLE); } + public void visitD2I(Instruction o) { checkTop(o,Type.DOUBLE); } + public void visitD2L(Instruction o) { checkTop(o,Type.DOUBLE); } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitDADD(DADD o){ - if (stack().peek() != Type.DOUBLE){ - constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); - } + public void visitDADD(Instruction o){ + checkTop(o,Type.DOUBLE); if (stack().peek(1) != Type.DOUBLE){ constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'."); } } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitDALOAD(DALOAD o){ + public void visitDALOAD(Instruction o){ indexOfInt(o, stack().peek()); if (stack().peek(1) == Type.NULL){ return; @@ -730,10 +681,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a } } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitDASTORE(DASTORE o){ + public void visitDASTORE(Instruction o){ if (stack().peek() != Type.DOUBLE){ constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); } @@ -750,104 +698,71 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a } } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitDCMPG(DCMPG o){ - if (stack().peek() != Type.DOUBLE){ - constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); - } + public void visitDCMPG(Instruction o){ + checkTop(o,Type.DOUBLE); if (stack().peek(1) != Type.DOUBLE){ constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'."); } } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitDCMPL(DCMPL o){ - if (stack().peek() != Type.DOUBLE){ - constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); - } + public void visitDCMPL(Instruction o){ + checkTop(o,Type.DOUBLE); if (stack().peek(1) != Type.DOUBLE){ constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'."); } } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitDCONST(DCONST o){ + public void visitDCONST(Instruction o){ // There's nothing to be done here. } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitDDIV(DDIV o){ - if (stack().peek() != Type.DOUBLE){ - constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); - } + public void visitDDIV(Instruction o){ + checkTop(o,Type.DOUBLE); if (stack().peek(1) != Type.DOUBLE){ constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'."); } } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitDLOAD(DLOAD o){ + public void visitDLOAD(Instruction o){ //visitLoadInstruction(LoadInstruction) is called before. // Nothing else needs to be done here. } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitDMUL(DMUL o){ - if (stack().peek() != Type.DOUBLE){ - constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); - } + public void visitDMUL(Instruction o){ + checkTop(o,Type.DOUBLE); if (stack().peek(1) != Type.DOUBLE){ constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'."); } } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitDNEG(DNEG o){ - if (stack().peek() != Type.DOUBLE){ - constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); - } + public void visitDNEG(Instruction o){ + checkTop(o,Type.DOUBLE); } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitDREM(DREM o){ - if (stack().peek() != Type.DOUBLE){ - constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); - } + public void visitDREM(Instruction o){ + checkTop(o,Type.DOUBLE); if (stack().peek(1) != Type.DOUBLE){ constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'."); } } + + private void checkTop(Instruction o,Type t) { + if (stack().peek()!=t) + constraintViolated(o, "The value at the stack top is not of type '"+t+"', but of type '"+stack().peek()+"'."); + } /** * Ensures the specific preconditions of the said instruction. */ - public void visitDRETURN(DRETURN o){ - if (stack().peek() != Type.DOUBLE){ - constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); - } + public void visitDRETURN(Instruction o){ + checkTop(o,Type.DOUBLE); } /** * Ensures the specific preconditions of the said instruction. */ - public void visitDSTORE(DSTORE o){ + public void visitDSTORE(Instruction o){ //visitStoreInstruction(StoreInstruction) is called before. // Nothing else needs to be done here. @@ -856,7 +771,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitDSUB(DSUB o){ + public void visitDSUB(Instruction o){ if (stack().peek() != Type.DOUBLE){ constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); } @@ -868,7 +783,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitDUP(DUP o){ + public void visitDUP(Instruction o){ if (stack().peek().getSize() != 1){ constraintViolated(o, "Won't DUP type on stack top '"+stack().peek()+"' because it must occupy exactly one slot, not '"+stack().peek().getSize()+"'."); } @@ -877,7 +792,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitDUP_X1(DUP_X1 o){ + public void visitDUP_X1(Instruction o){ if (stack().peek().getSize() != 1){ constraintViolated(o, "Type on stack top '"+stack().peek()+"' should occupy exactly one slot, not '"+stack().peek().getSize()+"'."); } @@ -889,7 +804,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitDUP_X2(DUP_X2 o){ + public void visitDUP_X2(Instruction o){ if (stack().peek().getSize() != 1){ constraintViolated(o, "Stack top type must be of size 1, but is '"+stack().peek()+"' of size '"+stack().peek().getSize()+"'."); } @@ -906,7 +821,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitDUP2(DUP2 o){ + public void visitDUP2(Instruction o){ if (stack().peek().getSize() == 2){ return; // Form 2, okay. } @@ -920,7 +835,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitDUP2_X1(DUP2_X1 o){ + public void visitDUP2_X1(Instruction o){ if (stack().peek().getSize() == 2){ if (stack().peek(1).getSize() != 1){ constraintViolated(o, "If stack top's size is 2, then stack next-to-top's size must be 1. But it is '"+stack().peek(1)+"' of size '"+stack().peek(1).getSize()+"'."); @@ -942,7 +857,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitDUP2_X2(DUP2_X2 o){ + public void visitDUP2_X2(Instruction o){ if (stack().peek(0).getSize() == 2){ if (stack().peek(1).getSize() == 2){ @@ -975,37 +890,25 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitF2D(F2D o){ + public void visitF2D(Instruction o){ if (stack().peek() != Type.FLOAT){ constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); } } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitF2I(F2I o){ - if (stack().peek() != Type.FLOAT){ - constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); - } + public void visitF2I(Instruction o){ + checkTop(o,Type.FLOAT); } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitF2L(F2L o){ - if (stack().peek() != Type.FLOAT){ - constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); - } + public void visitF2L(Instruction o){ + checkTop(o,Type.FLOAT); } /** * Ensures the specific preconditions of the said instruction. */ - public void visitFADD(FADD o){ - if (stack().peek() != Type.FLOAT){ - constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); - } + public void visitFADD(Instruction o){ + checkTop(o,Type.FLOAT); if (stack().peek(1) != Type.FLOAT){ constraintViolated(o, "The value at the stack next-to-top is not of type 'float', but of type '"+stack().peek(1)+"'."); } @@ -1014,7 +917,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitFALOAD(FALOAD o){ + public void visitFALOAD(Instruction o){ indexOfInt(o, stack().peek()); if (stack().peek(1) == Type.NULL){ return; @@ -1031,10 +934,8 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitFASTORE(FASTORE o){ - if (stack().peek() != Type.FLOAT){ - constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); - } + public void visitFASTORE(Instruction o){ + checkTop(o,Type.FLOAT); indexOfInt(o, stack().peek(1)); if (stack().peek(2) == Type.NULL){ return; @@ -1051,10 +952,8 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitFCMPG(FCMPG o){ - if (stack().peek() != Type.FLOAT){ - constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); - } + public void visitFCMPG(Instruction o){ + checkTop(o,Type.FLOAT); if (stack().peek(1) != Type.FLOAT){ constraintViolated(o, "The value at the stack next-to-top is not of type 'float', but of type '"+stack().peek(1)+"'."); } @@ -1063,10 +962,8 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitFCMPL(FCMPL o){ - if (stack().peek() != Type.FLOAT){ - constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); - } + public void visitFCMPL(Instruction o){ + checkTop(o,Type.FLOAT); if (stack().peek(1) != Type.FLOAT){ constraintViolated(o, "The value at the stack next-to-top is not of type 'float', but of type '"+stack().peek(1)+"'."); } @@ -1075,17 +972,15 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitFCONST(FCONST o){ + public void visitFCONST(Instruction o){ // nothing to do here. } /** * Ensures the specific preconditions of the said instruction. */ - public void visitFDIV(FDIV o){ - if (stack().peek() != Type.FLOAT){ - constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); - } + public void visitFDIV(Instruction o){ + checkTop(o,Type.FLOAT); if (stack().peek(1) != Type.FLOAT){ constraintViolated(o, "The value at the stack next-to-top is not of type 'float', but of type '"+stack().peek(1)+"'."); } @@ -1094,7 +989,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitFLOAD(FLOAD o){ + public void visitFLOAD(Instruction o){ //visitLoadInstruction(LoadInstruction) is called before. // Nothing else needs to be done here. @@ -1103,10 +998,8 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitFMUL(FMUL o){ - if (stack().peek() != Type.FLOAT){ - constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); - } + public void visitFMUL(Instruction o){ + checkTop(o,Type.FLOAT); if (stack().peek(1) != Type.FLOAT){ constraintViolated(o, "The value at the stack next-to-top is not of type 'float', but of type '"+stack().peek(1)+"'."); } @@ -1115,19 +1008,15 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitFNEG(FNEG o){ - if (stack().peek() != Type.FLOAT){ - constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); - } + public void visitFNEG(Instruction o){ + checkTop(o,Type.FLOAT); } /** * Ensures the specific preconditions of the said instruction. */ - public void visitFREM(FREM o){ - if (stack().peek() != Type.FLOAT){ - constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); - } + public void visitFREM(Instruction o){ + checkTop(o,Type.FLOAT); if (stack().peek(1) != Type.FLOAT){ constraintViolated(o, "The value at the stack next-to-top is not of type 'float', but of type '"+stack().peek(1)+"'."); } @@ -1136,16 +1025,14 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitFRETURN(FRETURN o){ - if (stack().peek() != Type.FLOAT){ - constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); - } + public void visitFRETURN(Instruction o){ + checkTop(o,Type.FLOAT); } /** * Ensures the specific preconditions of the said instruction. */ - public void visitFSTORE(FSTORE o){ + public void visitFSTORE(Instruction o){ //visitStoreInstruction(StoreInstruction) is called before. // Nothing else needs to be done here. @@ -1154,7 +1041,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitFSUB(FSUB o){ + public void visitFSUB(Instruction o){ if (stack().peek() != Type.FLOAT){ constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); } @@ -1166,7 +1053,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitGETFIELD(GETFIELD o){ + public void visitGETFIELD(FieldInstruction o){ Type objectref = stack().peek(); if (! ( (objectref instanceof ObjectType) || (objectref == Type.NULL) ) ){ constraintViolated(o, "Stack top should be an object reference that's not an array reference, but is '"+objectref+"'."); @@ -1220,28 +1107,28 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitGETSTATIC(GETSTATIC o){ + public void visitGETSTATIC(FieldInstruction o){ // Field must be static: see Pass 3a. } /** * Ensures the specific preconditions of the said instruction. */ - public void visitGOTO(GOTO o){ + public void visitGOTO(Instruction o){ // nothing to do here. } /** * Ensures the specific preconditions of the said instruction. */ - public void visitGOTO_W(GOTO_W o){ + public void visitGOTO_W(Instruction o){ // nothing to do here. } /** * Ensures the specific preconditions of the said instruction. */ - public void visitI2B(I2B o){ + public void visitI2B(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } @@ -1250,7 +1137,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitI2C(I2C o){ + public void visitI2C(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } @@ -1259,46 +1146,18 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitI2D(I2D o){ + public void visitI2D(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitI2F(I2F o){ - if (stack().peek() != Type.INT){ - constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); - } - } + public void visitI2F(Instruction o) { checkTop(o,Type.INT); } + public void visitI2L(Instruction o) { checkTop(o,Type.INT); } + public void visitI2S(Instruction o) { checkTop(o,Type.INT); } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitI2L(I2L o){ - if (stack().peek() != Type.INT){ - constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); - } - } - - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitI2S(I2S o){ - if (stack().peek() != Type.INT){ - constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); - } - } - - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitIADD(IADD o){ - if (stack().peek() != Type.INT){ - constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); - } + public void visitIADD(Instruction o){ + checkTop(o,Type.INT); if (stack().peek(1) != Type.INT){ constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'."); } @@ -1307,7 +1166,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitIALOAD(IALOAD o){ + public void visitIALOAD(Instruction o){ indexOfInt(o, stack().peek()); if (stack().peek(1) == Type.NULL){ return; @@ -1324,7 +1183,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitIAND(IAND o){ + public void visitIAND(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } @@ -1336,7 +1195,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitIASTORE(IASTORE o){ + public void visitIASTORE(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } @@ -1356,17 +1215,15 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitICONST(ICONST o){ + public void visitICONST(Instruction o){ //nothing to do here. } /** * Ensures the specific preconditions of the said instruction. */ - public void visitIDIV(IDIV o){ - if (stack().peek() != Type.INT){ - constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); - } + public void visitIDIV(Instruction o){ + checkTop(o,Type.INT); if (stack().peek(1) != Type.INT){ constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'."); } @@ -1375,7 +1232,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitIF_ACMPEQ(IF_ACMPEQ o){ + public void visitIF_ACMPEQ(Instruction o){ if (!(stack().peek() instanceof ReferenceType)){ constraintViolated(o, "The value at the stack top is not of a ReferenceType, but of type '"+stack().peek()+"'."); } @@ -1391,7 +1248,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitIF_ACMPNE(IF_ACMPNE o){ + public void visitIF_ACMPNE(Instruction o){ if (!(stack().peek() instanceof ReferenceType)){ constraintViolated(o, "The value at the stack top is not of a ReferenceType, but of type '"+stack().peek()+"'."); referenceTypeIsInitialized(o, (ReferenceType) (stack().peek()) ); @@ -1405,7 +1262,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitIF_ICMPEQ(IF_ICMPEQ o){ + public void visitIF_ICMPEQ(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } @@ -1417,7 +1274,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitIF_ICMPGE(IF_ICMPGE o){ + public void visitIF_ICMPGE(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } @@ -1429,7 +1286,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitIF_ICMPGT(IF_ICMPGT o){ + public void visitIF_ICMPGT(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } @@ -1441,7 +1298,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitIF_ICMPLE(IF_ICMPLE o){ + public void visitIF_ICMPLE(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } @@ -1453,7 +1310,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitIF_ICMPLT(IF_ICMPLT o){ + public void visitIF_ICMPLT(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } @@ -1465,7 +1322,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitIF_ICMPNE(IF_ICMPNE o){ + public void visitIF_ICMPNE(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } @@ -1477,7 +1334,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitIFEQ(IFEQ o){ + public void visitIFEQ(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } @@ -1486,7 +1343,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitIFGE(IFGE o){ + public void visitIFGE(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } @@ -1495,7 +1352,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitIFGT(IFGT o){ + public void visitIFGT(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } @@ -1504,7 +1361,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitIFLE(IFLE o){ + public void visitIFLE(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } @@ -1513,7 +1370,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitIFLT(IFLT o){ + public void visitIFLT(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } @@ -1522,7 +1379,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitIFNE(IFNE o){ + public void visitIFNE(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } @@ -1531,7 +1388,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitIFNONNULL(IFNONNULL o){ + public void visitIFNONNULL(Instruction o){ if (!(stack().peek() instanceof ReferenceType)){ constraintViolated(o, "The value at the stack top is not of a ReferenceType, but of type '"+stack().peek()+"'."); } @@ -1541,7 +1398,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitIFNULL(IFNULL o){ + public void visitIFNULL(Instruction o){ if (!(stack().peek() instanceof ReferenceType)){ constraintViolated(o, "The value at the stack top is not of a ReferenceType, but of type '"+stack().peek()+"'."); } @@ -1563,28 +1420,28 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitILOAD(ILOAD o){ + public void visitILOAD(Instruction o){ // All done by visitLocalVariableInstruction(), visitLoadInstruction() } /** * Ensures the specific preconditions of the said instruction. */ - public void visitIMPDEP1(IMPDEP1 o){ + public void visitIMPDEP1(Instruction o){ throw new AssertionViolatedException("In this JustIce verification pass there should not occur an illegal instruction such as IMPDEP1."); } /** * Ensures the specific preconditions of the said instruction. */ - public void visitIMPDEP2(IMPDEP2 o){ + public void visitIMPDEP2(Instruction o){ throw new AssertionViolatedException("In this JustIce verification pass there should not occur an illegal instruction such as IMPDEP2."); } /** * Ensures the specific preconditions of the said instruction. */ - public void visitIMUL(IMUL o){ + public void visitIMUL(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } @@ -1596,7 +1453,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitINEG(INEG o){ + public void visitINEG(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } @@ -1605,7 +1462,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitINSTANCEOF(INSTANCEOF o){ + public void visitINSTANCEOF(Instruction o){ // The objectref must be of type reference. Type objectref = stack().peek(0); if (!(objectref instanceof ReferenceType)){ @@ -1715,7 +1572,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitINVOKESPECIAL(INVOKESPECIAL o){ + public void visitINVOKESPECIAL(InvokeInstruction o){ // Don't init an object twice. if ( (o.getMethodName(cpg).equals(Constants.CONSTRUCTOR_NAME)) && (!(stack().peek(o.getArgumentTypes(cpg).length) instanceof UninitializedObjectType)) ){ constraintViolated(o, "Possibly initializing object twice. A valid instruction sequence must not have an uninitialized object on the operand stack or in a local variable during a backwards branch, or in a local variable in code protected by an exception handler. Please see The Java Virtual Machine Specification, Second Edition, 4.9.4 (pages 147 and 148) for details."); @@ -1801,7 +1658,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitINVOKESTATIC(INVOKESTATIC o){ + public void visitINVOKESTATIC(InvokeInstruction o){ // Method is not native, otherwise pass 3 would not happen. Type t = o.getType(cpg); @@ -1846,7 +1703,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitINVOKEVIRTUAL(INVOKEVIRTUAL o){ + public void visitINVOKEVIRTUAL(InvokeInstruction o){ // the o.getClassType(cpg) type has passed pass 2; see visitLoadClass(o). Type t = o.getType(cpg); @@ -1917,7 +1774,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitIOR(IOR o){ + public void visitIOR(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } @@ -1929,7 +1786,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitIREM(IREM o){ + public void visitIREM(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } @@ -1941,7 +1798,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitIRETURN(IRETURN o){ + public void visitIRETURN(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } @@ -1950,10 +1807,8 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitISHL(ISHL o){ - if (stack().peek() != Type.INT){ - constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); - } + public void visitISHL(Instruction o){ + checkTop(o,Type.INT); if (stack().peek(1) != Type.INT){ constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'."); } @@ -1962,10 +1817,8 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitISHR(ISHR o){ - if (stack().peek() != Type.INT){ - constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); - } + public void visitISHR(Instruction o){ + checkTop(o,Type.INT); if (stack().peek(1) != Type.INT){ constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'."); } @@ -1974,7 +1827,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitISTORE(ISTORE o){ + public void visitISTORE(Instruction o){ //visitStoreInstruction(StoreInstruction) is called before. // Nothing else needs to be done here. @@ -1983,10 +1836,8 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitISUB(ISUB o){ - if (stack().peek() != Type.INT){ - constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); - } + public void visitISUB(Instruction o){ + checkTop(o,Type.INT); if (stack().peek(1) != Type.INT){ constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'."); } @@ -1995,10 +1846,8 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitIUSHR(IUSHR o){ - if (stack().peek() != Type.INT){ - constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); - } + public void visitIUSHR(Instruction o){ + checkTop(o,Type.INT); if (stack().peek(1) != Type.INT){ constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'."); } @@ -2007,7 +1856,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitIXOR(IXOR o){ + public void visitIXOR(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } @@ -2019,21 +1868,21 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitJSR(JSR o){ + public void visitJSR(InstructionBranch o){ // nothing to do here. } /** * Ensures the specific preconditions of the said instruction. */ - public void visitJSR_W(JSR_W o){ + public void visitJSR_W(InstructionBranch o){ // nothing to do here. } /** * Ensures the specific preconditions of the said instruction. */ - public void visitL2D(L2D o){ + public void visitL2D(Instruction o){ if (stack().peek() != Type.LONG){ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'."); } @@ -2042,7 +1891,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitL2F(L2F o){ + public void visitL2F(Instruction o){ if (stack().peek() != Type.LONG){ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'."); } @@ -2051,7 +1900,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitL2I(L2I o){ + public void visitL2I(Instruction o){ if (stack().peek() != Type.LONG){ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'."); } @@ -2060,7 +1909,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitLADD(LADD o){ + public void visitLADD(Instruction o){ if (stack().peek() != Type.LONG){ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'."); } @@ -2072,7 +1921,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitLALOAD(LALOAD o){ + public void visitLALOAD(Instruction o){ indexOfInt(o, stack().peek()); if (stack().peek(1) == Type.NULL){ return; @@ -2089,7 +1938,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitLAND(LAND o){ + public void visitLAND(Instruction o){ if (stack().peek() != Type.LONG){ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'."); } @@ -2101,7 +1950,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitLASTORE(LASTORE o){ + public void visitLASTORE(Instruction o){ if (stack().peek() != Type.LONG){ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'."); } @@ -2121,7 +1970,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitLCMP(LCMP o){ + public void visitLCMP(Instruction o){ if (stack().peek() != Type.LONG){ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'."); } @@ -2133,14 +1982,14 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitLCONST(LCONST o){ + public void visitLCONST(Instruction o){ // Nothing to do here. } /** * Ensures the specific preconditions of the said instruction. */ - public void visitLDC(LDC o){ + public void visitLDC(Instruction o){ // visitCPInstruction is called first. Constant c = cpg.getConstant(o.getIndex()); @@ -2154,7 +2003,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitLDC_W(LDC_W o){ + public void visitLDC_W(Instruction o){ // visitCPInstruction is called first. Constant c = cpg.getConstant(o.getIndex()); @@ -2168,7 +2017,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitLDC2_W(LDC2_W o){ + public void visitLDC2_W(Instruction o){ // visitCPInstruction is called first. Constant c = cpg.getConstant(o.getIndex()); @@ -2181,7 +2030,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitLDIV(LDIV o){ + public void visitLDIV(Instruction o){ if (stack().peek() != Type.LONG){ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'."); } @@ -2193,7 +2042,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitLLOAD(LLOAD o){ + public void visitLLOAD(Instruction o){ //visitLoadInstruction(LoadInstruction) is called before. // Nothing else needs to be done here. @@ -2202,7 +2051,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitLMUL(LMUL o){ + public void visitLMUL(Instruction o){ if (stack().peek() != Type.LONG){ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'."); } @@ -2211,29 +2060,16 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a } } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitLNEG(LNEG o){ - if (stack().peek() != Type.LONG){ - constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'."); - } + public void visitLNEG(Instruction o){ + checkTop(o,Type.LONG); } - /** - * Ensures the specific preconditions of the said instruction. - */ public void visitLOOKUPSWITCH(LOOKUPSWITCH o){ - if (stack().peek() != Type.INT){ - constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); - } + checkTop(o,Type.INT); // See also pass 3a. } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitLOR(LOR o){ + public void visitLOR(Instruction o){ if (stack().peek() != Type.LONG){ constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'."); } @@ -2242,34 +2078,16 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a } } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitLREM(LREM o){ - if (stack().peek() != Type.LONG){ - constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'."); - } + public void visitLREM(Instruction o){ + checkTop(o,Type.LONG); if (stack().peek(1) != Type.LONG){ constraintViolated(o, "The value at the stack next-to-top is not of type 'long', but of type '"+stack().peek(1)+"'."); } } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitLRETURN(LRETURN o){ - if (stack().peek() != Type.LONG){ - constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'."); - } - } - - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitLSHL(LSHL o){ - if (stack().peek() != Type.INT){ - constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); - } + public void visitLRETURN(Instruction o) { checkTop(o,Type.LONG); } + public void visitLSHL(Instruction o){ + checkTop(o,Type.INT); if (stack().peek(1) != Type.LONG){ constraintViolated(o, "The value at the stack next-to-top is not of type 'long', but of type '"+stack().peek(1)+"'."); } @@ -2278,7 +2096,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitLSHR(LSHR o){ + public void visitLSHR(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } @@ -2286,11 +2104,11 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a constraintViolated(o, "The value at the stack next-to-top is not of type 'long', but of type '"+stack().peek(1)+"'."); } } - + /** * Ensures the specific preconditions of the said instruction. */ - public void visitLSTORE(LSTORE o){ + public void visitLSTORE(Instruction o){ //visitStoreInstruction(StoreInstruction) is called before. // Nothing else needs to be done here. @@ -2299,10 +2117,8 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitLSUB(LSUB o){ - if (stack().peek() != Type.LONG){ - constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'."); - } + public void visitLSUB(Instruction o){ + checkTop(o,Type.LONG); if (stack().peek(1) != Type.LONG){ constraintViolated(o, "The value at the stack next-to-top is not of type 'long', but of type '"+stack().peek(1)+"'."); } @@ -2311,10 +2127,8 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitLUSHR(LUSHR o){ - if (stack().peek() != Type.INT){ - constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); - } + public void visitLUSHR(Instruction o){ + checkTop(o,Type.INT); if (stack().peek(1) != Type.LONG){ constraintViolated(o, "The value at the stack next-to-top is not of type 'long', but of type '"+stack().peek(1)+"'."); } @@ -2323,10 +2137,8 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitLXOR(LXOR o){ - if (stack().peek() != Type.LONG){ - constraintViolated(o, "The value at the stack top is not of type 'long', but of type '"+stack().peek()+"'."); - } + public void visitLXOR(Instruction o){ + checkTop(o,Type.LONG); if (stack().peek(1) != Type.LONG){ constraintViolated(o, "The value at the stack next-to-top is not of type 'long', but of type '"+stack().peek(1)+"'."); } @@ -2335,7 +2147,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitMONITORENTER(MONITORENTER o){ + public void visitMONITORENTER(Instruction o){ if (! ((stack().peek()) instanceof ReferenceType)){ constraintViolated(o, "The stack top should be of a ReferenceType, but is '"+stack().peek()+"'."); } @@ -2345,7 +2157,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitMONITOREXIT(MONITOREXIT o){ + public void visitMONITOREXIT(Instruction o){ if (! ((stack().peek()) instanceof ReferenceType)){ constraintViolated(o, "The stack top should be of a ReferenceType, but is '"+stack().peek()+"'."); } @@ -2370,7 +2182,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitNEW(NEW o){ + public void visitNEW(Instruction o){ //visitCPInstruction(CPInstruction) has been called before. //visitLoadClass(LoadClass) has been called before. @@ -2389,26 +2201,10 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a } } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitNEWARRAY(NEWARRAY o){ - if (stack().peek() != Type.INT){ - constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); - } - } - - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitNOP(NOP o){ - // nothing is to be done here. - } + public void visitNEWARRAY(Instruction o) { checkTop(o,Type.INT); } + public void visitNOP(Instruction o){ /* nothing is to be done here */ } - /** - * Ensures the specific preconditions of the said instruction. - */ - public void visitPOP(POP o){ + public void visitPOP(Instruction o){ if (stack().peek().getSize() != 1){ constraintViolated(o, "Stack top size should be 1 but stack top is '"+stack().peek()+"' of size '"+stack().peek().getSize()+"'."); } @@ -2417,7 +2213,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitPOP2(POP2 o){ + public void visitPOP2(Instruction o){ if (stack().peek().getSize() != 2){ constraintViolated(o, "Stack top size should be 2 but stack top is '"+stack().peek()+"' of size '"+stack().peek().getSize()+"'."); } @@ -2426,7 +2222,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitPUTFIELD(PUTFIELD o){ + public void visitPUTFIELD(FieldInstruction o){ Type objectref = stack().peek(1); if (! ( (objectref instanceof ObjectType) || (objectref == Type.NULL) ) ){ @@ -2509,7 +2305,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitPUTSTATIC(PUTSTATIC o){ + public void visitPUTSTATIC(FieldInstruction o){ String field_name = o.getFieldName(cpg); JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName()); Field[] fields = jc.getFields(); @@ -2574,7 +2370,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitRETURN(RETURN o){ + public void visitRETURN(Instruction o){ if (mg.getName().equals(Constants.CONSTRUCTOR_NAME)){// If we leave an <init> method if ((Frame._this != null) && (!(mg.getClassName().equals(Type.OBJECT.getClassName()))) ) { constraintViolated(o, "Leaving a constructor that itself did not call a constructor."); @@ -2585,7 +2381,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitSALOAD(SALOAD o){ + public void visitSALOAD(Instruction o){ indexOfInt(o, stack().peek()); if (stack().peek(1) == Type.NULL){ return; @@ -2602,7 +2398,7 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitSASTORE(SASTORE o){ + public void visitSASTORE(Instruction o){ if (stack().peek() != Type.INT){ constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } @@ -2622,14 +2418,14 @@ public class InstConstraintVisitor extends EmptyVisitor implements org.aspectj.a /** * Ensures the specific preconditions of the said instruction. */ - public void visitSIPUSH(SIPUSH o){ + public void visitSIPUSH(Instruction o){ // nothing to do here. Generic visitXXX() methods did the trick before. } /** * Ensures the specific preconditions of the said instruction. */ - public void visitSWAP(SWAP o){ + public void visitSWAP(Instruction o){ if (stack().peek().getSize() != 1){ constraintViolated(o, "The value at the stack top is not of size '1', but of size '"+stack().peek().getSize()+"'."); } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/InstructionContext.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/InstructionContext.java index c1aee86c9..eb366d7ea 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/InstructionContext.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/InstructionContext.java @@ -63,7 +63,7 @@ import org.aspectj.apache.bcel.generic.InstructionHandle; * to information like control flow successors and * such. * - * @version $Id: InstructionContext.java,v 1.4 2004/11/22 08:31:27 aclement Exp $ + * @version $Id: InstructionContext.java,v 1.2 2008/05/28 23:53:03 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public interface InstructionContext{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/LocalVariables.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/LocalVariables.java index 44a690886..e665575c6 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/LocalVariables.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/LocalVariables.java @@ -62,7 +62,7 @@ import org.aspectj.apache.bcel.verifier.exc.*; * This class implements an array of local variables used for symbolic JVM * simulation. * - * @version $Id: LocalVariables.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: LocalVariables.java,v 1.2 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public class LocalVariables{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/OperandStack.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/OperandStack.java index 5d41008b2..6b7b7b0df 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/OperandStack.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/OperandStack.java @@ -63,7 +63,7 @@ import java.util.*; * [It's used an an operand stack substitute.] * Elements of this stack are org.aspectj.apache.bcel.generic.Type objects. * - * @version $Id: OperandStack.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: OperandStack.java,v 1.2 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public class OperandStack{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/Pass3bVerifier.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Pass3bVerifier.java index b2375a9c6..224de27c9 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/Pass3bVerifier.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Pass3bVerifier.java @@ -64,13 +64,12 @@ import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.Repository; import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.Method; -import org.aspectj.apache.bcel.generic.ConstantPoolGen; +import org.aspectj.apache.bcel.classfile.ConstantPool; +import org.aspectj.apache.bcel.generic.InstructionBranch; import org.aspectj.apache.bcel.generic.InstructionHandle; -import org.aspectj.apache.bcel.generic.JsrInstruction; import org.aspectj.apache.bcel.generic.MethodGen; import org.aspectj.apache.bcel.generic.ObjectType; import org.aspectj.apache.bcel.generic.RET; -import org.aspectj.apache.bcel.generic.ReturnInstruction; import org.aspectj.apache.bcel.generic.ReturnaddressType; import org.aspectj.apache.bcel.generic.Type; import org.aspectj.apache.bcel.verifier.PassVerifier; @@ -86,7 +85,7 @@ import org.aspectj.apache.bcel.verifier.exc.VerifierConstraintViolatedException; * More detailed information is to be found at the do_verify() method's * documentation. * - * @version $Id: Pass3bVerifier.java,v 1.5 2005/02/02 09:11:39 aclement Exp $ + * @version $Id: Pass3bVerifier.java,v 1.2 2008/05/28 23:53:03 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> * @see #do_verify() */ @@ -207,7 +206,7 @@ public final class Pass3bVerifier extends PassVerifier{ throw new AssertionViolatedException("More RET than JSR in execution chain?!"); } //System.err.println("+"+oldchain.get(ss)); - if (((InstructionContext) oldchain.get(ss)).getInstruction().getInstruction() instanceof JsrInstruction){ + if (((InstructionContext) oldchain.get(ss)).getInstruction().getInstruction().isJsrInstruction()) { if (skip_jsr == 0){ lastJSR = (InstructionContext) oldchain.get(ss); break; @@ -223,7 +222,7 @@ public final class Pass3bVerifier extends PassVerifier{ if (lastJSR == null){ throw new AssertionViolatedException("RET without a JSR before in ExecutionChain?! EC: '"+oldchain+"'."); } - JsrInstruction jsr = (JsrInstruction) (lastJSR.getInstruction().getInstruction()); + InstructionBranch jsr = (InstructionBranch) (lastJSR.getInstruction().getInstruction()); if ( theSuccessor != (cfg.contextOf(jsr.physicalSuccessor())) ){ throw new AssertionViolatedException("RET '"+u.getInstruction()+"' info inconsistent: jump back to '"+theSuccessor+"' or '"+cfg.contextOf(jsr.physicalSuccessor())+"'?"); } @@ -268,7 +267,7 @@ public final class Pass3bVerifier extends PassVerifier{ InstructionHandle ih = start.getInstruction(); do{ - if ((ih.getInstruction() instanceof ReturnInstruction) && (!(cfg.isDead(ih)))) { + if ((ih.getInstruction().isReturnInstruction()) && (!(cfg.isDead(ih)))) { InstructionContext ic = cfg.contextOf(ih); Frame f = ic.getOutFrame(new ArrayList()); // TODO: This is buggy, we check only the top-level return instructions this way. Maybe some maniac returns from a method when in a subroutine? LocalVariables lvs = f.getLocals(); @@ -307,7 +306,7 @@ public final class Pass3bVerifier extends PassVerifier{ // in the BCEL repository. JavaClass jc = Repository.lookupClass(myOwner.getClassName()); - ConstantPoolGen constantPoolGen = new ConstantPoolGen(jc.getConstantPool()); + ConstantPool constantPoolGen = new ConstantPool(jc.getConstantPool().getConstantPool()); // Init Visitors InstConstraintVisitor icv = new InstConstraintVisitor(); icv.setConstantPoolGen(constantPoolGen); diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/Subroutine.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Subroutine.java index 36a381ae6..be35a451e 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/Subroutine.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Subroutine.java @@ -61,7 +61,7 @@ import org.aspectj.apache.bcel.generic.*; * Note that it is 'abused' to maintain the top-level code in a * consistent fashion, too. * - * @version $Id: Subroutine.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: Subroutine.java,v 1.2 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public interface Subroutine{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/Subroutines.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Subroutines.java index 6afbee473..267d1394d 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/Subroutines.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Subroutines.java @@ -54,6 +54,7 @@ package org.aspectj.apache.bcel.verifier.structurals; * <http://www.apache.org/>. */ +import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.generic.*; import org.aspectj.apache.bcel.verifier.exc.*; import java.awt.Color; @@ -83,7 +84,7 @@ import java.util.Iterator; * * TODO: refer to the paper. * - * @version $Id: Subroutines.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: Subroutines.java,v 1.2 2008/05/28 23:53:02 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> * @see #getTopLevel() */ @@ -200,7 +201,7 @@ public class Subroutines{ * Adds a new JSR or JSR_W that has this subroutine as its target. */ public void addEnteringJsrInstruction(InstructionHandle jsrInst){ - if ( (jsrInst == null) || (! (jsrInst.getInstruction() instanceof JsrInstruction))){ + if ( (jsrInst == null) || (! (jsrInst.getInstruction().isJsrInstruction()))){ throw new AssertionViolatedException("Expecting JsrInstruction InstructionHandle."); } if (localVariable == UNSET){ @@ -210,7 +211,7 @@ public class Subroutines{ // Something is wrong when an ASTORE is targeted that does not operate on the same local variable than the rest of the // JsrInstruction-targets and the RET. // (We don't know out leader here so we cannot check if we're really targeted!) - if (localVariable != ((ASTORE) (((JsrInstruction) jsrInst.getInstruction()).getTarget().getInstruction())).getIndex()){ + if (localVariable != ( (((InstructionBranch) jsrInst.getInstruction()).getTarget().getInstruction())).getIndex()){ throw new AssertionViolatedException("Setting a wrong JsrInstruction."); } } @@ -294,15 +295,15 @@ public class Subroutines{ while (i.hasNext()){ InstructionHandle ih = (InstructionHandle) i.next(); // RET is not a LocalVariableInstruction in the current version of BCEL. - if (ih.getInstruction() instanceof LocalVariableInstruction || ih.getInstruction() instanceof RET){ - int idx = ((IndexedInstruction) (ih.getInstruction())).getIndex(); + if (ih.getInstruction() instanceof InstructionLV || ih.getInstruction() instanceof RET){ + int idx = ((ih.getInstruction())).getIndex(); acc.add(new Integer(idx)); // LONG? DOUBLE?. try{ // LocalVariableInstruction instances are typed without the need to look into // the constant pool. - if (ih.getInstruction() instanceof LocalVariableInstruction){ - int s = ((LocalVariableInstruction) ih.getInstruction()).getType(null).getSize(); + if (ih.getInstruction() instanceof InstructionLV){ + int s = ((InstructionLV) ih.getInstruction()).getType(null).getSize(); if (s==2) acc.add(new Integer(idx+1)); } } @@ -331,8 +332,8 @@ public class Subroutines{ Iterator i = instructions.iterator(); while (i.hasNext()){ Instruction inst = ((InstructionHandle) i.next()).getInstruction(); - if (inst instanceof JsrInstruction){ - InstructionHandle targ = ((JsrInstruction) inst).getTarget(); + if (inst.isJsrInstruction()){ + InstructionHandle targ = ((InstructionBranch) inst).getTarget(); h.add(getSubroutine(targ)); } } @@ -396,8 +397,8 @@ public class Subroutines{ InstructionHandle ih = all[0]; for (int i=0; i<all.length; i++){ Instruction inst = all[i].getInstruction(); - if (inst instanceof JsrInstruction){ - sub_leaders.add(((JsrInstruction) inst).getTarget()); + if (inst.isJsrInstruction()){ + sub_leaders.add(((InstructionBranch) inst).getTarget()); } } @@ -406,7 +407,7 @@ public class Subroutines{ while (iter.hasNext()){ SubroutineImpl sr = new SubroutineImpl(); InstructionHandle astore = (InstructionHandle) (iter.next()); - sr.setLocalVariable( ((ASTORE) (astore.getInstruction())).getIndex() ); + sr.setLocalVariable( ( (astore.getInstruction())).getIndex() ); subroutines.put(astore, sr); } @@ -421,8 +422,8 @@ public class Subroutines{ // disallowed and checked below, after the BFS. for (int i=0; i<all.length; i++){ Instruction inst = all[i].getInstruction(); - if (inst instanceof JsrInstruction){ - InstructionHandle leader = ((JsrInstruction) inst).getTarget(); + if (inst.isJsrInstruction()){ + InstructionHandle leader = ((InstructionBranch) inst).getTarget(); ((SubroutineImpl) getSubroutine(leader)).addEnteringJsrInstruction(all[i]); } } @@ -616,40 +617,40 @@ System.err.println("DEBUG: Please verify '"+any+"' lies in dead code."); } // Terminates method normally. - if (inst instanceof ReturnInstruction){ + if (inst.isReturnInstruction()){ return empty; } // Terminates method abnormally, because JustIce mandates // subroutines not to be protected by exception handlers. - if (inst instanceof ATHROW){ + if (inst.getOpcode()==Constants.ATHROW){ return empty; } // See method comment. - if (inst instanceof JsrInstruction){ + if (inst.isJsrInstruction()){ single[0] = instruction.getNext(); return single; } - if (inst instanceof GotoInstruction){ - single[0] = ((GotoInstruction) inst).getTarget(); + if (inst.getOpcode()==Constants.GOTO || inst.getOpcode()==Constants.GOTO_W){ + single[0] = ((InstructionBranch) inst).getTarget(); return single; } - if (inst instanceof BranchInstruction){ - if (inst instanceof Select){ + if (inst instanceof InstructionBranch){ + if (inst instanceof InstructionSelect){ // BCEL's getTargets() returns only the non-default targets, // thanks to Eli Tilevich for reporting. - InstructionHandle[] matchTargets = ((Select) inst).getTargets(); + InstructionHandle[] matchTargets = ((InstructionSelect) inst).getTargets(); InstructionHandle[] ret = new InstructionHandle[matchTargets.length+1]; - ret[0] = ((Select) inst).getTarget(); + ret[0] = ((InstructionSelect) inst).getTarget(); System.arraycopy(matchTargets, 0, ret, 1, matchTargets.length); return ret; } else{ pair[0] = instruction.getNext(); - pair[1] = ((BranchInstruction) inst).getTarget(); + pair[1] = ((InstructionBranch) inst).getTarget(); return pair; } } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/UninitializedObjectType.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/UninitializedObjectType.java index 39d2405e4..72fe44e94 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/UninitializedObjectType.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/UninitializedObjectType.java @@ -62,7 +62,7 @@ import org.aspectj.apache.bcel.generic.*; * Virtual Machine Specification, Second Edition, page 147: 4.9.4 for * more details. * - * @version $Id: UninitializedObjectType.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: UninitializedObjectType.java,v 1.2 2008/05/28 23:53:03 aclement Exp $ * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> */ public class UninitializedObjectType extends ReferenceType implements Constants{ diff --git a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/package.html b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/package.html index 3376b9613..84af3bb93 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/verifier/structurals/package.html +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/package.html @@ -2,7 +2,7 @@ <html> <head> <!-- -$Id: package.html,v 1.6 2008/04/25 17:58:27 aclement Exp $ +$Id: package.html,v 1.2 2008/05/28 23:53:02 aclement Exp $ --> </head> <body bgcolor="white"> diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/BCELFactory.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/util/BCELFactory.java index 9402f0a96..846628733 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/BCELFactory.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/util/BCELFactory.java @@ -1,8 +1,27 @@ -package org.aspectj.apache.bcel.util; +package org.aspectj.apache.bcel.verifier.util; -import org.aspectj.apache.bcel.generic.*; +import org.aspectj.apache.bcel.verifier.EmptyClassVisitor; import org.aspectj.apache.bcel.classfile.Utility; import org.aspectj.apache.bcel.Constants; +import org.aspectj.apache.bcel.classfile.ConstantPool; +import org.aspectj.apache.bcel.generic.BranchHandle; +import org.aspectj.apache.bcel.generic.CodeExceptionGen; +import org.aspectj.apache.bcel.generic.FieldInstruction; +import org.aspectj.apache.bcel.generic.IINC; +import org.aspectj.apache.bcel.generic.Instruction; +import org.aspectj.apache.bcel.generic.InstructionBranch; +import org.aspectj.apache.bcel.generic.InstructionByte; +import org.aspectj.apache.bcel.generic.InstructionCP; +import org.aspectj.apache.bcel.generic.InstructionConstants; +import org.aspectj.apache.bcel.generic.InstructionHandle; +import org.aspectj.apache.bcel.generic.InstructionSelect; +import org.aspectj.apache.bcel.generic.InvokeInstruction; +import org.aspectj.apache.bcel.generic.MULTIANEWARRAY; +import org.aspectj.apache.bcel.generic.MethodGen; +import org.aspectj.apache.bcel.generic.ObjectType; +import org.aspectj.apache.bcel.generic.RET; +import org.aspectj.apache.bcel.generic.Type; + import java.io.PrintWriter; import java.util.*; @@ -65,13 +84,13 @@ import java.util.*; * A helper class for BCELifier. * * @see BCELifier - * @version $Id: BCELFactory.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: BCELFactory.java,v 1.2 2008/05/28 23:53:04 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ -class BCELFactory extends EmptyVisitor { +class BCELFactory extends org.aspectj.apache.bcel.verifier.EmptyInstVisitor { private MethodGen _mg; private PrintWriter _out; - private ConstantPoolGen _cp; + private ConstantPool _cp; BCELFactory(MethodGen mg, PrintWriter out) { _mg = mg; @@ -87,12 +106,12 @@ class BCELFactory extends EmptyVisitor { ih != null; ih = ih.getNext()) { Instruction i = ih.getInstruction(); - if(i instanceof BranchInstruction) { + if(i instanceof InstructionBranch) { branch_map.put(i, ih); // memorize container } if(ih.hasTargeters()) { - if(i instanceof BranchInstruction) { + if(i instanceof InstructionBranch) { _out.println(" InstructionHandle ih_" + ih.getPosition() + ";"); } else { _out.print(" InstructionHandle ih_" + ih.getPosition() + " = "); @@ -114,8 +133,8 @@ class BCELFactory extends EmptyVisitor { short opcode = i.getOpcode(); if((InstructionConstants.INSTRUCTIONS[opcode] != null) && - !(i instanceof ConstantPushInstruction) && - !(i instanceof ReturnInstruction)) { // Handled below + !(i.isConstantInstruction()) && + !(i.isReturnInstruction())) { // Handled below _out.println("il.append(InstructionConstants." + i.getName().toUpperCase() + ");"); return true; @@ -124,7 +143,7 @@ class BCELFactory extends EmptyVisitor { return false; } - public void visitLocalVariableInstruction(LocalVariableInstruction i) { + public void visitLocalVariableInstruction(Instruction i) { short opcode = i.getOpcode(); Type type = i.getType(_cp); @@ -139,7 +158,7 @@ class BCELFactory extends EmptyVisitor { } } - public void visitArrayInstruction(ArrayInstruction i) { + public void visitArrayInstruction(Instruction i) { short opcode = i.getOpcode(); Type type = i.getType(_cp); String kind = (opcode < Constants.IASTORE)? "Load" : "Store"; @@ -177,13 +196,13 @@ class BCELFactory extends EmptyVisitor { "));"); } - public void visitAllocationInstruction(AllocationInstruction i) { + public void visitAllocationInstruction(Instruction i) { Type type; - if(i instanceof CPInstruction) { - type = ((CPInstruction)i).getType(_cp); + if(i.isConstantPoolInstruction()) { + type = ((InstructionCP)i).getType(_cp); } else { - type = ((NEWARRAY)i).getType(); + type = ((InstructionByte)i).getType(); } short opcode = ((Instruction)i).getOpcode(); @@ -220,33 +239,33 @@ class BCELFactory extends EmptyVisitor { _out.println("il.append(new PUSH(_cp, " + embed + "));"); } - public void visitLDC(LDC i) { + public void visitLDC(Instruction i) { createConstant(i.getValue(_cp)); } - public void visitLDC2_W(LDC2_W i) { + public void visitLDC2_W(Instruction i) { createConstant(i.getValue(_cp)); } - public void visitConstantPushInstruction(ConstantPushInstruction i) { + public void visitConstantPushInstruction(Instruction i) { createConstant(i.getValue()); } - public void visitINSTANCEOF(INSTANCEOF i) { + public void visitINSTANCEOF(Instruction i) { Type type = i.getType(_cp); _out.println("il.append(new INSTANCEOF(_cp.addClass(" + BCELifier.printType(type) + ")));"); } - public void visitCHECKCAST(CHECKCAST i) { + public void visitCHECKCAST(Instruction i) { Type type = i.getType(_cp); _out.println("il.append(_factory.createCheckCast(" + BCELifier.printType(type) + "));"); } - public void visitReturnInstruction(ReturnInstruction i) { + public void visitReturnInstruction(Instruction i) { Type type = i.getType(_cp); _out.println("il.append(_factory.createReturn(" + @@ -256,13 +275,13 @@ class BCELFactory extends EmptyVisitor { // Memorize BranchInstructions that need an update private ArrayList branches = new ArrayList(); - public void visitBranchInstruction(BranchInstruction bi) { + public void visitBranchInstruction(InstructionBranch bi) { BranchHandle bh = (BranchHandle)branch_map.get(bi); int pos = bh.getPosition(); String name = bi.getName() + "_" + pos; - if(bi instanceof Select) { - Select s = (Select)bi; + if(bi instanceof InstructionSelect) { + InstructionSelect s = (InstructionSelect)bi; branches.add(bi); StringBuffer args = new StringBuffer("new int[] { "); @@ -318,7 +337,7 @@ class BCELFactory extends EmptyVisitor { private void updateBranchTargets() { for(Iterator i = branches.iterator(); i.hasNext(); ) { - BranchInstruction bi = (BranchInstruction)i.next(); + InstructionBranch bi = (InstructionBranch)i.next(); BranchHandle bh = (BranchHandle)branch_map.get(bi); int pos = bh.getPosition(); String name = bi.getName() + "_" + pos; @@ -326,8 +345,8 @@ class BCELFactory extends EmptyVisitor { _out.println(" " + name + ".setTarget(ih_" + t_pos + ");"); - if(bi instanceof Select) { - InstructionHandle[] ihs = ((Select)bi).getTargets(); + if(bi instanceof InstructionSelect) { + InstructionHandle[] ihs = ((InstructionSelect)bi).getTargets(); for(int j = 0; j < ihs.length; j++) { t_pos = ihs[j].getPosition(); diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/BCELifier.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/util/BCELifier.java index 0c2c37013..2b0fb010b 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/BCELifier.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/util/BCELifier.java @@ -1,4 +1,4 @@ -package org.aspectj.apache.bcel.util; +package org.aspectj.apache.bcel.verifier.util; /* ==================================================================== * The Apache Software License, Version 1.1 @@ -65,7 +65,7 @@ import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.Method; import org.aspectj.apache.bcel.classfile.Utility; import org.aspectj.apache.bcel.generic.ArrayType; -import org.aspectj.apache.bcel.generic.ConstantPoolGen; +import org.aspectj.apache.bcel.classfile.ConstantPool; import org.aspectj.apache.bcel.generic.MethodGen; import org.aspectj.apache.bcel.generic.Type; @@ -76,13 +76,13 @@ import org.aspectj.apache.bcel.generic.Type; * are done with BCEL. It does not cover all features of BCEL, * but tries to mimic hand-written code as close as possible. * - * @version $Id: BCELifier.java,v 1.3 2004/11/22 08:31:27 aclement Exp $ + * @version $Id: BCELifier.java,v 1.2 2008/05/28 23:53:04 aclement Exp $ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> */ -public class BCELifier extends org.aspectj.apache.bcel.classfile.EmptyVisitor { +public class BCELifier extends org.aspectj.apache.bcel.verifier.EmptyClassVisitor { private JavaClass _clazz; private PrintWriter _out; - private ConstantPoolGen _cp; + private ConstantPool _cp; /** @param clazz Java class to "decompile" * @param out where to output Java program @@ -90,7 +90,7 @@ public class BCELifier extends org.aspectj.apache.bcel.classfile.EmptyVisitor { public BCELifier(JavaClass clazz, OutputStream out) { _clazz = clazz; _out = new PrintWriter(out); - _cp = new ConstantPoolGen(_clazz.getConstantPool()); + _cp = new ConstantPool(_clazz.getConstantPool().getConstantPool()); } /** Start Java code generation @@ -104,7 +104,7 @@ public class BCELifier extends org.aspectj.apache.bcel.classfile.EmptyVisitor { String class_name = clazz.getClassName(); String super_name = clazz.getSuperclassName(); String package_name = clazz.getPackageName(); - String inter = Utility.printArray(clazz.getInterfaceNames(), + String inter = BCELifier.printArray(clazz.getInterfaceNames(), false, true); if(!"".equals(package_name)) { class_name = class_name.substring(package_name.length() + 1); @@ -127,7 +127,7 @@ public class BCELifier extends org.aspectj.apache.bcel.classfile.EmptyVisitor { package_name + "." + class_name) + "\", \"" + super_name + "\", " + "\"" + clazz.getSourceFileName() + "\", " + - printFlags(clazz.getAccessFlags(), true) + ", " + + printFlags(clazz.getModifiers(), true) + ", " + "new String[] { " + inter + " });\n"); _out.println(" _cp = _cg.getConstantPool();"); @@ -193,7 +193,7 @@ public class BCELifier extends org.aspectj.apache.bcel.classfile.EmptyVisitor { public void visitField(Field field) { _out.println("\n field = new FieldGen(" + - printFlags(field.getAccessFlags()) + + printFlags(field.getModifiers()) + ", " + printType(field.getSignature()) + ", \"" + field.getName() + "\", _cp);"); @@ -215,11 +215,11 @@ public class BCELifier extends org.aspectj.apache.bcel.classfile.EmptyVisitor { _out.println(" InstructionList il = new InstructionList();"); _out.println(" MethodGen method = new MethodGen(" + - printFlags(method.getAccessFlags()) + + printFlags(method.getModifiers()) + ", " + printType(result_type) + ", " + printArgumentTypes(arg_types) + ", " + "new String[] { " + - Utility.printArray(mg.getArgumentNames(), false, true) + + BCELifier.printArray(mg.getArgumentNames(), false, true) + " }, \"" + method.getName() + "\", \"" + _clazz.getClassName() + "\", il, _cp);\n"); @@ -232,7 +232,34 @@ public class BCELifier extends org.aspectj.apache.bcel.classfile.EmptyVisitor { _out.println(" il.dispose();"); } - static String printFlags(int flags) { + public static final String printArray(Object[] obj, boolean braces, + boolean quote) { + if(obj == null) + return null; + + StringBuffer buf = new StringBuffer(); + if(braces) + buf.append('{'); + + for(int i=0; i < obj.length; i++) { + if(obj[i] != null) { + buf.append((quote? "\"" : "") + obj[i].toString() + (quote? "\"" : "")); + } else { + buf.append("null"); + } + + if(i < obj.length - 1) { + buf.append(", "); + } + } + + if(braces) + buf.append('}'); + + return buf.toString(); + } + +static String printFlags(int flags) { return printFlags(flags, false); } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/InstructionFinder.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/util/InstructionFinder.java index c0eb6e9db..6fad9bcb7 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/InstructionFinder.java +++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/util/InstructionFinder.java @@ -1,4 +1,4 @@ -package org.aspectj.apache.bcel.util; +package org.aspectj.apache.bcel.verifier.util; /* ==================================================================== * The Apache Software License, Version 1.1 @@ -81,7 +81,7 @@ import org.apache.regexp.*; ... } </pre> - * @version $Id: InstructionFinder.java,v 1.2 2004/11/19 16:45:19 aclement Exp $ + * @version $Id: InstructionFinder.java,v 1.2 2008/05/28 23:53:04 aclement Exp $ * @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A> * @see Instruction * @see InstructionList @@ -388,7 +388,7 @@ public class InstructionFinder { StringBuffer buf = new StringBuffer("("); for(short i=0; i < NO_OPCODES; i++) { - if(Constants.NO_OF_OPERANDS[i] != Constants.UNDEFINED) { // Not an invalid opcode + if(Constants.iLen[i] != Constants.UNDEFINED_LENGTH) { // Not an invalid opcode buf.append(makeChar(i)); if(i < NO_OPCODES - 1) |