]> source.dussan.org Git - aspectj.git/commitdiff
Ensure we can disassemble invokedynamic
authorAndy Clement <aclement@pivotal.io>
Thu, 5 Oct 2017 17:27:40 +0000 (10:27 -0700)
committerAndy Clement <aclement@pivotal.io>
Thu, 5 Oct 2017 17:27:40 +0000 (10:27 -0700)
If there are problems at weave time the weaver may attempt to
disassemble some code to produce a nice error message. Until this
change that disassembly code did not understand invokedynamic.
This would make it fail to disassemble and instead of seeing the
real problem you see a disassembly problem. With this fix we
should now see the underlying problem in the issue.

Issue: #525541

bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantPool.java
bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/BcelTestCase.java
lib/bcel/bcel-src.zip
lib/bcel/bcel-verifier-src.zip
lib/bcel/bcel-verifier.jar
lib/bcel/bcel.jar
tests/src/org/aspectj/systemtest/ajc186/Ajc186Tests.java

index 4e160ba3d648992573224c88fd4a8b5503326f94..0b4874234580c90d73f9c2ad0ffde2a3c321191c 100644 (file)
@@ -207,6 +207,11 @@ public class ConstantPool implements Node {
                        str = (constantToString(((ConstantCP) c).getClassIndex(), Constants.CONSTANT_Class) + "." + constantToString(
                                        ((ConstantCP) c).getNameAndTypeIndex(), Constants.CONSTANT_NameAndType));
                        break;
+                       
+               case Constants.CONSTANT_InvokeDynamic:
+                       ConstantInvokeDynamic cid = (ConstantInvokeDynamic)c;
+                       str = cid.toString();
+                       break;
 
                default: // Never reached
                        throw new RuntimeException("Unknown constant type " + c.tag);
index 3311c538675afdeebbf57acf26e4aa1dffdc4499..a4247a92cc3d552072fd495db31806570c4e9f21 100644 (file)
@@ -35,7 +35,7 @@ import org.aspectj.apache.bcel.util.SyntheticRepository;
  * Super class for the Java5 tests, includes various helper methods.
  */
 
-public class BcelTestCase extends TestCase {
+public abstract class BcelTestCase extends TestCase {
 
        private boolean verbose = false;
 
index 58136055bbc8790991d69d0e6604d41abdc827de..35b5a11043b9074392b189ba56b1dd80c9d13418 100644 (file)
Binary files a/lib/bcel/bcel-src.zip and b/lib/bcel/bcel-src.zip differ
index c6a16a60b7a62a1b38130804577adc227213288e..1ef0bc277e5bd42fe52880555961ffa077f57707 100644 (file)
Binary files a/lib/bcel/bcel-verifier-src.zip and b/lib/bcel/bcel-verifier-src.zip differ
index 05c04d096c44d1f52e8ebbdbd1e50b5a20b9b68a..55fa6e43ddf2e5695d0aa9c0093e9747ce76a4db 100644 (file)
Binary files a/lib/bcel/bcel-verifier.jar and b/lib/bcel/bcel-verifier.jar differ
index fdfd8dedae8fcd6393accd25eea986c2525d6d09..bf9f8d956d1e7f6c09bc4ce345ab5f859157b352 100644 (file)
Binary files a/lib/bcel/bcel.jar and b/lib/bcel/bcel.jar differ
index 1625f96d174a3b2a56534b4557e636fc77b49c33..3f6ce949d280a11babb83f72a8fdc127e7c2503e 100644 (file)
@@ -17,6 +17,9 @@ import java.net.URLClassLoader;
 
 import junit.framework.Test;
 
+import org.aspectj.apache.bcel.classfile.JavaClass;
+import org.aspectj.apache.bcel.classfile.Utility;
+import org.aspectj.apache.bcel.util.ByteSequence;
 import org.aspectj.testing.XMLBasedAjcTestCase;
 import org.aspectj.weaver.tools.ContextBasedMatcher;
 import org.aspectj.weaver.tools.DefaultMatchingContext;
@@ -117,7 +120,6 @@ public class Ajc186Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
                Runnable r2 = (Runnable) fails.invoke(instance);                
                // r2.getClass().getName() == Application$$Lambda$1/1652149987
                
-//             JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "Application");
                PointcutParser parser = PointcutParser
                                .getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(ucl);
                FooDesignatorHandler beanHandler = new FooDesignatorHandler();
@@ -137,6 +139,19 @@ public class Ajc186Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
                
                context.addContextBinding("beanName", "yourBean");
                assertFalse(pc.couldMatchJoinPointsInType(r2.getClass()));
+               JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "Application");
+               System.out.println("XXXX");
+               assertNotNull(jc);
+               // 525541: Checking that we can disassemble invokedynamic:
+               boolean checkedInvokeDynamic = false;
+               for (org.aspectj.apache.bcel.classfile.Method m: jc.getMethods()) {
+                       if (m.getName().equals("fromLambdaExpression")) {
+                               String code = m.getCode().getCodeString();
+                               assertTrue(code.contains("invokedynamic"));
+                               checkedInvokeDynamic = true;
+                       }
+               }
+               assertTrue(checkedInvokeDynamic);
        }