]> source.dussan.org Git - aspectj.git/commitdiff
436531: fix for weaving when method parameters around
authorAndy Clement <aclement@gopivotal.com>
Tue, 17 Jun 2014 22:05:43 +0000 (15:05 -0700)
committerAndy Clement <aclement@gopivotal.com>
Tue, 17 Jun 2014 22:05:43 +0000 (15:05 -0700)
bcel-builder/src/org/aspectj/apache/bcel/classfile/MethodParameters.java
lib/bcel/bcel-src.zip
lib/bcel/bcel-verifier.jar
lib/bcel/bcel.jar
tests/bugs181/436531/Azpect.java [new file with mode: 0644]
tests/bugs181/436531/Code.class [new file with mode: 0644]
tests/bugs181/436531/Code.java [new file with mode: 0644]
tests/bugs181/436531/code.jar [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc181/Ajc181Tests.java
tests/src/org/aspectj/systemtest/ajc181/ajc181.xml

index 9cbbbf7fb5a2013179b7f6f1e07b4a3c7a8a6f1b..76f1642d574176db6accfa7e593ff1c01be8f4a5 100644 (file)
@@ -29,6 +29,8 @@ public class MethodParameters extends Attribute {
        public final static int ACCESS_FLAGS_SYNTHETIC = 0x1000;
        public final static int ACCESS_FLAGS_MANDATED  = 0x8000;
        
+       // if 'isInPackedState' then this data needs unpacking
+       private boolean isInPackedState = false;
        private byte[] data;
        private int[] names;
        private int[] accessFlags;
@@ -37,6 +39,7 @@ public class MethodParameters extends Attribute {
                super(Constants.ATTR_METHOD_PARAMETERS,index,length,cpool);
                data = new byte[length];
                dis.read(data,0,length);
+               isInPackedState = true;
        }
        
        private void ensureInflated() {
@@ -55,6 +58,7 @@ public class MethodParameters extends Attribute {
                                        accessFlags[i] = dis.readUnsignedShort();
                                }
                        }
+                       isInPackedState = false;
                } catch (IOException ioe) {
                        throw new RuntimeException("Unabled to inflate type annotation data, badly formed?");
                }
@@ -62,10 +66,14 @@ public class MethodParameters extends Attribute {
        
        public void dump(DataOutputStream dos) throws IOException {
                super.dump(dos);
-               dos.writeByte(names.length);
-               for (int i=0;i<names.length;i++) {
-                       dos.writeShort(names[i]);
-                       dos.writeShort(accessFlags[i]);
+               if (isInPackedState) {
+                       dos.write(data);
+               } else {
+                       dos.writeByte(names.length);
+                       for (int i=0;i<names.length;i++) {
+                               dos.writeShort(names[i]);
+                               dos.writeShort(accessFlags[i]);
+                       }
                }
        }
        
index 090f7083aef6d92b0f512b328084f6cb90e643c7..d6745a98128d36b854dc83ffd136c141a8219706 100644 (file)
Binary files a/lib/bcel/bcel-src.zip and b/lib/bcel/bcel-src.zip differ
index c407530cf93fb336a5a5e394925e703335567c8e..1863f1ece224f750d22a6b7aa90b8d3d0f56e24a 100644 (file)
Binary files a/lib/bcel/bcel-verifier.jar and b/lib/bcel/bcel-verifier.jar differ
index 20e2af40c2e5d34523be6acfe193a927623e9149..2db4a9983ad4398de2cae0cb09f82ac570e0e1fe 100644 (file)
Binary files a/lib/bcel/bcel.jar and b/lib/bcel/bcel.jar differ
diff --git a/tests/bugs181/436531/Azpect.java b/tests/bugs181/436531/Azpect.java
new file mode 100644 (file)
index 0000000..f9b70ed
--- /dev/null
@@ -0,0 +1,4 @@
+public aspect Azpect {
+  before(): execution(* method(..)) {}
+}
+
diff --git a/tests/bugs181/436531/Code.class b/tests/bugs181/436531/Code.class
new file mode 100644 (file)
index 0000000..75248e0
Binary files /dev/null and b/tests/bugs181/436531/Code.class differ
diff --git a/tests/bugs181/436531/Code.java b/tests/bugs181/436531/Code.java
new file mode 100644 (file)
index 0000000..dfd1f3c
--- /dev/null
@@ -0,0 +1,7 @@
+public class Code {
+  public void method(String string1, int param2, boolean b3) {
+  }
+  public void method2(String string1, int param2, boolean b3) {
+  }
+}
+
diff --git a/tests/bugs181/436531/code.jar b/tests/bugs181/436531/code.jar
new file mode 100644 (file)
index 0000000..ecb4543
Binary files /dev/null and b/tests/bugs181/436531/code.jar differ
index 5c298300e0f9e492ba7aa82f3e31aefc88fb8b11..57ed6b6dfc1da56522aaa485bbe872cf09d29e47 100644 (file)
@@ -21,6 +21,10 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
  * @author Andy Clement
  */
 public class Ajc181Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
+
+       public void testParameterNamesAttribute_436531() {
+               runTest("parameter names attribute");
+       }
        
        public void testVariableNotInitialized_431976() {
                runTest("variable not initialized");
index 5d091ca8c5644259b2fdfae2cf700d1196b5d329..1a8b1acfcb538cb13d6f241c8dd02bfa718bef8d 100644 (file)
@@ -2,6 +2,10 @@
 
 <suite>
 
+       <ajc-test dir="bugs181/436531" title="parameter names attribute">
+               <compile options="-1.8" files="Azpect.java" inpath="code.jar"/>
+       </ajc-test>
+
        <ajc-test dir="bugs181/431976" title="variable not initialized">
                <compile options="-1.8" files="AbstractDependencyInjectionAspect.aj"/>
        </ajc-test>