diff options
author | Andy Clement <aclement@pivotal.io> | 2017-09-21 10:48:59 -0700 |
---|---|---|
committer | Andy Clement <aclement@pivotal.io> | 2017-09-21 10:48:59 -0700 |
commit | 26712118bad08e60c66237e6aa2cfbd6f275cbbe (patch) | |
tree | 64531f485c94c9f6e7f1acb8506bf51cc8343cf1 /bcel-builder | |
parent | 39b70af69b0b086f82da8ac032de5e5a5e0cdc45 (diff) | |
parent | 6d6738cfece6328027916681e67e54225531db38 (diff) | |
download | aspectj-26712118bad08e60c66237e6aa2cfbd6f275cbbe.tar.gz aspectj-26712118bad08e60c66237e6aa2cfbd6f275cbbe.zip |
Bring Java9 branch in line with 1.8.11 progress
Diffstat (limited to 'bcel-builder')
3 files changed, 22 insertions, 9 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..3938beb35 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; + } } } @@ -1069,7 +1082,7 @@ public class MethodGen extends FieldGenOrMethodGen { /** * Return a list of AnnotationGen objects representing parameter annotations */ - public List getAnnotationsOnParameter(int i) { + public List<AnnotationGen> getAnnotationsOnParameter(int i) { ensureExistingParameterAnnotationsUnpacked(); if (!hasParameterAnnotations || i > parameterTypes.length) { return null; diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/NonCachingClassLoaderRepository.java b/bcel-builder/src/org/aspectj/apache/bcel/util/NonCachingClassLoaderRepository.java index 7a8c06224..a53b9dc35 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/NonCachingClassLoaderRepository.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/util/NonCachingClassLoaderRepository.java @@ -85,7 +85,7 @@ public class NonCachingClassLoaderRepository implements Repository { private static java.lang.ClassLoader bootClassLoader = null; private final ClassLoaderReference loaderRef; - private final Map<String, JavaClass> loadedClasses = new SoftHashMap(); // CLASSNAME X JAVACLASS + private final Map<String, JavaClass> loadedClasses = new SoftHashMap(); public static class SoftHashMap extends AbstractMap { private Map<Object, SpecialValue> map; @@ -96,10 +96,10 @@ public class NonCachingClassLoaderRepository implements Repository { } public SoftHashMap() { - this(new HashMap()); + this(new HashMap<Object,SpecialValue>()); } - public SoftHashMap(Map map, boolean b) { + public SoftHashMap(Map<Object,SpecialValue> map, boolean b) { this(map); } diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java index 7dd83ddb7..093a4b6e4 100644 --- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java @@ -262,7 +262,7 @@ public class ParameterAnnotationsTest extends BcelTestCase { mg = new MethodGen(m,clg.getClassName(),clg.getConstantPool()); List<Attribute> as = mg.getAttributes(); assertTrue("Should be 2 (RIPA and RVPA) but there are "+mg.getAttributes().size(),mg.getAttributes().size()==2); - List l = mg.getAnnotationsOnParameter(0); + List<AnnotationGen> l = mg.getAnnotationsOnParameter(0); assertTrue("Should be 2 annotations on first parameter but there is only "+l.size()+":"+l.toString(), l.size()==2); assertTrue("Should be 0 but there are "+mg.getAttributes().size(),mg.getAttributes().size()==0); |