@@ -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; | |||
} | |||
} | |||
} | |||
@@ -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, |
@@ -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 |
@@ -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++) { |
@@ -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); |
@@ -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 { |
@@ -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; | |||
} |
@@ -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; |
@@ -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; |
@@ -1020,7 +1020,8 @@ public final class LazyMethodGen implements Traceable { | |||
} else { | |||
packBody(gen); | |||
} | |||
gen.setMaxLocals(); | |||
gen.setMaxLocals(true); | |||
gen.setMaxStack(); | |||
} else { | |||
gen.setInstructionList(null); |
@@ -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()); |
@@ -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; |