summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2016-11-07 16:18:54 -0800
committerAndy Clement <aclement@pivotal.io>2016-11-07 16:18:54 -0800
commit611e04a9e1f3f2368f3ce3237b6288b119ac9943 (patch)
tree8664f783ff4eae5ba78e6c356b2f3a9c3c800825
parentde34df77ea7f7372894cf1e2352766118a798e98 (diff)
downloadaspectj-611e04a9e1f3f2368f3ce3237b6288b119ac9943.tar.gz
aspectj-611e04a9e1f3f2368f3ce3237b6288b119ac9943.zip
Fix 500796: Allow for kotlin creating 'synthetic' local variable table entries
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/generic/MethodGen.java21
-rw-r--r--lib/bcel/bcel-src.zipbin326975 -> 327092 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.jarbin285423 -> 285489 bytes
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java7
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/GenericITDsDesign.java13
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java12
-rw-r--r--tests/src/org/aspectj/systemtest/ajc160/SanityTests.java1
-rw-r--r--tests/src/org/aspectj/systemtest/ajc1610/NewFeatures.java1
-rw-r--r--tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java6
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java1
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java1
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java3
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/UnwovenClassFile.java4
-rw-r--r--weaver/testsrc/org/aspectj/weaver/bcel/WorldTestCase.java2
16 files changed, 41 insertions, 31 deletions
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 59cf7397e..21673dec0 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/generic/MethodGen.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/MethodGen.java
@@ -880,9 +880,19 @@ public class MethodGen extends FieldGenOrMethodGen {
}
/**
- * Compute maximum number of local variables.
+ * Compute maximum number of local variables based on the parameter count and bytecode usage of variables.
*/
public void setMaxLocals() {
+ setMaxLocals(false);
+ }
+
+ /**
+ * Compute maximum number of local variables.
+ *
+ * @param respectLocalVariableTable if true and the local variable table indicates more are in use
+ * than the code suggests, respect the higher value from the local variable table data.
+ */
+ public void setMaxLocals(boolean respectLocalVariableTable) {
if (il != null) {
int max = isStatic() ? 0 : 1;
@@ -903,10 +913,13 @@ public class MethodGen extends FieldGenOrMethodGen {
}
}
}
-
- maxLocals = max;
+ if (!respectLocalVariableTable || max > maxLocals) {
+ maxLocals = max;
+ }
} else {
- maxLocals = 0;
+ if (!respectLocalVariableTable) {
+ maxLocals = 0;
+ }
}
}
diff --git a/lib/bcel/bcel-src.zip b/lib/bcel/bcel-src.zip
index c96574cdf..58136055b 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 bf5a86a3e..c6a16a60b 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 7ca7ec48b..05c04d096 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 5da57de72..fdfd8deda 100644
--- a/lib/bcel/bcel.jar
+++ b/lib/bcel/bcel.jar
Binary files differ
diff --git a/tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java b/tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java
index 63cebdb06..466567641 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java
+++ b/tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java
@@ -18,6 +18,7 @@ import junit.framework.Test;
import org.aspectj.asm.AsmManager;
import org.aspectj.asm.IHierarchy;
import org.aspectj.asm.IProgramElement;
+import org.aspectj.asm.IRelationship;
import org.aspectj.asm.internal.Relationship;
import org.aspectj.testing.XMLBasedAjcTestCase;
@@ -313,7 +314,7 @@ public class AnnotationBinding extends XMLBasedAjcTestCase {
"declare @method: int A.m() : @Fruit(\"orange\")");
assertTrue("Couldn't find 'declare @method' element in the tree", ipe != null);
- List l = asm.getRelationshipMap().get(ipe);
+ List<IRelationship> l = asm.getRelationshipMap().get(ipe);
assertTrue("Should have a relationship but does not ", l.size() > 0);
ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_ANNOTATION_AT_METHOD,
@@ -343,7 +344,7 @@ public class AnnotationBinding extends XMLBasedAjcTestCase {
"declare @field: int A.i : @Fruit(\"orange\")");
assertTrue("Couldn't find 'declare @type' element in the tree", ipe != null);
- List l = asm.getRelationshipMap().get(ipe);
+ List<IRelationship> l = asm.getRelationshipMap().get(ipe);
assertTrue("Should have a relationship but does not ", l.size() > 0);
ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_ANNOTATION_AT_FIELD,
@@ -375,7 +376,7 @@ public class AnnotationBinding extends XMLBasedAjcTestCase {
"declare @constructor: A.new(java.lang.String) : @Fruit(\"pear\")");
assertTrue("Couldn't find 'declare @constructor' element in the tree", ipe != null);
- List l = asm.getRelationshipMap().get(ipe);
+ List<IRelationship> l = asm.getRelationshipMap().get(ipe);
assertTrue("Should have a relationship but does not ", l.size() > 0);
ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_ANNOTATION_AT_CONSTRUCTOR,
diff --git a/tests/src/org/aspectj/systemtest/ajc150/GenericITDsDesign.java b/tests/src/org/aspectj/systemtest/ajc150/GenericITDsDesign.java
index dfedf65a0..6209298c1 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/GenericITDsDesign.java
+++ b/tests/src/org/aspectj/systemtest/ajc150/GenericITDsDesign.java
@@ -15,6 +15,7 @@ import org.aspectj.apache.bcel.util.ClassPath;
import org.aspectj.apache.bcel.util.SyntheticRepository;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.tools.ajc.Ajc;
+import org.aspectj.weaver.ConcreteTypeMunger;
import org.aspectj.weaver.CrosscuttingMembers;
import org.aspectj.weaver.ReferenceType;
import org.aspectj.weaver.ResolvedMember;
@@ -75,12 +76,12 @@ public class GenericITDsDesign extends XMLBasedAjcTestCase {
.equals(sig));
}
- public List /* BcelTypeMunger */getTypeMunger(String classname) {
+ public List<ConcreteTypeMunger> getTypeMunger(String classname) {
ClassPath cp = new ClassPath(ajc.getSandboxDirectory() + File.pathSeparator + System.getProperty("java.class.path"));
recentWorld = new BcelWorld(cp.toString());
ReferenceType resolvedType = (ReferenceType) recentWorld.resolve(classname);
CrosscuttingMembers cmembers = resolvedType.collectCrosscuttingMembers(true);
- List tmungers = cmembers.getTypeMungers();
+ List<ConcreteTypeMunger> tmungers = cmembers.getTypeMungers();
return tmungers;
}
@@ -100,9 +101,9 @@ public class GenericITDsDesign extends XMLBasedAjcTestCase {
return null;
}
- public Hashtable getMeTheFields(String classname) {
+ public Hashtable<String,Field> getMeTheFields(String classname) {
JavaClass theClass = getClassFromDisk(ajc, classname);
- Hashtable retval = new Hashtable();
+ Hashtable<String,Field> retval = new Hashtable<>();
org.aspectj.apache.bcel.classfile.Field[] fs = theClass.getFields();
for (int i = 0; i < fs.length; i++) {
Field field = fs[i];
@@ -206,7 +207,7 @@ public class GenericITDsDesign extends XMLBasedAjcTestCase {
// Verifying what gets into a class targetted with a field ITD
public void testDesignF() {
runTest("generic itds - design F");
- Hashtable fields = getMeTheFields("C");
+ Hashtable<String,Field> fields = getMeTheFields("C");
// Declared in src as: List C.list1; and List<Z> C<Z>.list2;
Field list1 = (Field) fields.get("list1");// ajc$interField$$list1");
@@ -229,7 +230,7 @@ public class GenericITDsDesign extends XMLBasedAjcTestCase {
// Verifying what gets into a class when an interface it implements was targetted with a field ITD
public void testDesignG() {
runTest("generic itds - design G");
- Hashtable fields = getMeTheFields("C");
+ Hashtable<String,Field> fields = getMeTheFields("C");
// The ITDs are targetting an interface. That interface is generic and is parameterized with
// 'String' when implemented in the class C. This means the fields that make it into C should
diff --git a/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java b/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java
index 21efa3328..1ec2b21c1 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java
+++ b/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java
@@ -875,11 +875,11 @@ public class GenericsTests extends XMLBasedAjcTestCase {
* bridge methods have been created.
*/
public void checkMethodsExist(String classname,String[] methods) {
- Set methodsFound = new HashSet();
+ Set<String> methodsFound = new HashSet<>();
StringBuffer debugString = new StringBuffer();
try {
ClassLoader cl = new URLClassLoader(new URL[]{ajc.getSandboxDirectory().toURL()});
- Class clz = Class.forName(classname,false,cl);
+ Class<?> clz = Class.forName(classname,false,cl);
java.lang.reflect.Method[] ms = clz.getDeclaredMethods();
if (ms!=null) {
for (int i =0;i<ms.length;i++) {
@@ -905,8 +905,7 @@ public class GenericsTests extends XMLBasedAjcTestCase {
}
StringBuffer unexpectedMethods = new StringBuffer();
if (!methodsFound.isEmpty()) {
- for (Iterator iter = methodsFound.iterator(); iter.hasNext();) {
- String element = (String) iter.next();
+ for (String element: methodsFound) {
unexpectedMethods.append("[").append(element).append("]");
}
fail("These methods weren't expected: "+unexpectedMethods);
@@ -924,7 +923,7 @@ public class GenericsTests extends XMLBasedAjcTestCase {
return false;
}
try {
- final Class[] noparms = new Class[0];
+ final Class<?>[] noparms = new Class[0];
java.lang.reflect.Method isBridge
= java.lang.reflect.Method.class.getMethod("isBridge", noparms);
Boolean result = (Boolean) isBridge.invoke(m, new Object[0]);
@@ -959,7 +958,6 @@ public class GenericsTests extends XMLBasedAjcTestCase {
public static void checkOneSignatureAttribute(Ajc ajc,String classname) {
JavaClass clazz = getClass(ajc,classname);
- Signature sigAttr = null;
Attribute[] attrs = clazz.getAttributes();
int signatureCount = 0;
StringBuffer sb = new StringBuffer();
@@ -981,7 +979,7 @@ public class GenericsTests extends XMLBasedAjcTestCase {
sigAttr.getSignature().equals(sig));
}
- private static String stringify(Class[] clazzes) {
+ private static String stringify(Class<?>[] clazzes) {
if (clazzes==null) return "";
StringBuffer sb = new StringBuffer();
for (int i = 0; i < clazzes.length; i++) {
diff --git a/tests/src/org/aspectj/systemtest/ajc160/SanityTests.java b/tests/src/org/aspectj/systemtest/ajc160/SanityTests.java
index 5d0462c99..45eac49ce 100644
--- a/tests/src/org/aspectj/systemtest/ajc160/SanityTests.java
+++ b/tests/src/org/aspectj/systemtest/ajc160/SanityTests.java
@@ -94,6 +94,7 @@ public class SanityTests extends org.aspectj.testing.XMLBasedAjcTestCase {
// }
/* For the specified class, check that each method has a stackmap attribute */
+ @SuppressWarnings("unused")
private void checkStackMapExistence(String classname, String toIgnore) throws ClassNotFoundException {
toIgnore = "_" + (toIgnore == null ? "" : toIgnore) + "_";
JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname);
diff --git a/tests/src/org/aspectj/systemtest/ajc1610/NewFeatures.java b/tests/src/org/aspectj/systemtest/ajc1610/NewFeatures.java
index b9de3dff7..588d71186 100644
--- a/tests/src/org/aspectj/systemtest/ajc1610/NewFeatures.java
+++ b/tests/src/org/aspectj/systemtest/ajc1610/NewFeatures.java
@@ -31,6 +31,7 @@ public class NewFeatures extends org.aspectj.testing.XMLBasedAjcTestCase {
}
}
+ @SuppressWarnings("unused")
public void testMakeSJPOptimizationCollapsedSJPYes14() {
this.runTest("makeSJP optimization - Collapsed SJP - Yes 1.4");
try {
diff --git a/tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java b/tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java
index 224f695ef..15abc8921 100644
--- a/tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java
@@ -11,7 +11,6 @@
package org.aspectj.systemtest.ajc163;
import java.io.File;
-import java.util.Iterator;
import java.util.List;
import junit.framework.Test;
@@ -174,9 +173,8 @@ public class Ajc163Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
if (whereToLook.getSourceLocation() != null && whereToLook.getSourceLocation().getLine() == line) {
return whereToLook;
}
- List kids = whereToLook.getChildren();
- for (Iterator iterator = kids.iterator(); iterator.hasNext();) {
- IProgramElement object = (IProgramElement) iterator.next();
+ List<IProgramElement> kids = whereToLook.getChildren();
+ for (IProgramElement object: kids) {
if (object.getSourceLocation() != null && object.getSourceLocation().getLine() == line) {
return object;
}
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java b/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java
index a9f214723..d22b17d12 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java
@@ -26,7 +26,6 @@ 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.InstructionList;
-import org.aspectj.apache.bcel.generic.InvokeDynamic;
import org.aspectj.apache.bcel.generic.LineNumberTag;
import org.aspectj.apache.bcel.generic.LocalVariableTag;
import org.aspectj.bridge.ISourceLocation;
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
index 8d5d26499..9768cb9e4 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
@@ -44,7 +44,6 @@ import org.aspectj.bridge.MessageUtil;
import org.aspectj.bridge.WeaveMessage;
import org.aspectj.bridge.context.CompilationAndWeavingContext;
import org.aspectj.bridge.context.ContextToken;
-import org.aspectj.weaver.AjAttribute;
import org.aspectj.weaver.AjcMemberMaker;
import org.aspectj.weaver.AnnotationAJ;
import org.aspectj.weaver.AnnotationOnTypeMunger;
diff --git a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
index 0b02041ab..2655a3456 100644
--- a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
+++ b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
@@ -1020,7 +1020,8 @@ public final class LazyMethodGen implements Traceable {
} else {
packBody(gen);
}
- gen.setMaxLocals();
+
+ gen.setMaxLocals(true);
gen.setMaxStack();
} else {
gen.setInstructionList(null);
diff --git a/weaver/src/org/aspectj/weaver/bcel/UnwovenClassFile.java b/weaver/src/org/aspectj/weaver/bcel/UnwovenClassFile.java
index 79a96c775..d02c90130 100644
--- a/weaver/src/org/aspectj/weaver/bcel/UnwovenClassFile.java
+++ b/weaver/src/org/aspectj/weaver/bcel/UnwovenClassFile.java
@@ -71,10 +71,10 @@ public class UnwovenClassFile implements IUnwovenClassFile {
}
public void writeUnchangedBytes() throws IOException {
- writeWovenBytes(getBytes(), Collections.EMPTY_LIST);
+ writeWovenBytes(getBytes(), Collections.<ChildClass>emptyList());
}
- public void writeWovenBytes(byte[] bytes, List childClasses) throws IOException {
+ public void writeWovenBytes(byte[] bytes, List<ChildClass> childClasses) throws IOException {
writeChildClasses(childClasses);
// System.err.println("should write: " + getClassName());
diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/WorldTestCase.java b/weaver/testsrc/org/aspectj/weaver/bcel/WorldTestCase.java
index 1fb756852..3d21b57ad 100644
--- a/weaver/testsrc/org/aspectj/weaver/bcel/WorldTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/bcel/WorldTestCase.java
@@ -13,8 +13,6 @@
package org.aspectj.weaver.bcel;
import java.lang.reflect.Modifier;
-import java.util.Objects;
-import java.util.function.Consumer;
import org.aspectj.weaver.Advice;
import org.aspectj.weaver.BcweaverTests;