summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2017-10-05 10:27:40 -0700
committerAndy Clement <aclement@pivotal.io>2017-10-05 10:27:40 -0700
commit3d85b130f5409e259795f2e685d17d9ff1604a22 (patch)
treeee3d03804eafe3b0553d2596a90ea75c946b2d85
parent189eb5a07a3120ac1c89222d5e01e47c0b730f33 (diff)
downloadaspectj-3d85b130f5409e259795f2e685d17d9ff1604a22.tar.gz
aspectj-3d85b130f5409e259795f2e685d17d9ff1604a22.zip
Ensure we can disassemble invokedynamic
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
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantPool.java5
-rw-r--r--bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/BcelTestCase.java2
-rw-r--r--lib/bcel/bcel-src.zipbin327092 -> 327095 bytes
-rw-r--r--lib/bcel/bcel-verifier-src.zipbin183372 -> 183372 bytes
-rw-r--r--lib/bcel/bcel-verifier.jarbin161556 -> 161556 bytes
-rw-r--r--lib/bcel/bcel.jarbin285489 -> 285503 bytes
-rw-r--r--tests/src/org/aspectj/systemtest/ajc186/Ajc186Tests.java17
7 files changed, 22 insertions, 2 deletions
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 4e160ba3d..0b4874234 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantPool.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantPool.java
@@ -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);
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 3311c5386..a4247a92c 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
@@ -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;
diff --git a/lib/bcel/bcel-src.zip b/lib/bcel/bcel-src.zip
index 58136055b..35b5a1104 100644
--- a/lib/bcel/bcel-src.zip
+++ b/lib/bcel/bcel-src.zip
Binary files differ
diff --git a/lib/bcel/bcel-verifier-src.zip b/lib/bcel/bcel-verifier-src.zip
index c6a16a60b..1ef0bc277 100644
--- a/lib/bcel/bcel-verifier-src.zip
+++ b/lib/bcel/bcel-verifier-src.zip
Binary files differ
diff --git a/lib/bcel/bcel-verifier.jar b/lib/bcel/bcel-verifier.jar
index 05c04d096..55fa6e43d 100644
--- a/lib/bcel/bcel-verifier.jar
+++ b/lib/bcel/bcel-verifier.jar
Binary files differ
diff --git a/lib/bcel/bcel.jar b/lib/bcel/bcel.jar
index fdfd8deda..bf9f8d956 100644
--- a/lib/bcel/bcel.jar
+++ b/lib/bcel/bcel.jar
Binary files differ
diff --git a/tests/src/org/aspectj/systemtest/ajc186/Ajc186Tests.java b/tests/src/org/aspectj/systemtest/ajc186/Ajc186Tests.java
index 1625f96d1..3f6ce949d 100644
--- a/tests/src/org/aspectj/systemtest/ajc186/Ajc186Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc186/Ajc186Tests.java
@@ -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);
}