From 87856659869b9dbf72e1b329986fb2d727cfad18 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Fri, 29 Jul 2016 10:05:50 -0700 Subject: Fix ambiguous binding problem on anonymous types If an anonymous class calls a method ITD'd onto one of its own supertypes (e.g. new A() { xx(null); }) then it can be reported as an ambiguous method invocation on Java8. There is different handling for Java8 that is revealing an issue. The intertype method declarations are recorded in a member finder attached to the target type (A in this case). When the local type binding is built it gets all the methods from supertypes added to it - this unfortunately includes the ITD method. Then later when something asks for all 'xx' methods on A, it finds the ITD method from when A was constructed and an additional copy from the member finder. The quick fix is for the member finder to use a set rather than list when answering 'what are the xx methods'. If this proves a problem down the line the deeper fix would be to avoid including ITDs when the local type binding is built. --- .../internal/compiler/lookup/InterTypeMemberFinder.java | 4 +++- tests/bugs1810/ambig/Code.java | 8 ++++++++ tests/bugs1810/ambig/X.java | 13 +++++++++++++ tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java | 8 ++++++++ tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml | 7 +++++++ 5 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tests/bugs1810/ambig/Code.java create mode 100644 tests/bugs1810/ambig/X.java diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberFinder.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberFinder.java index 97221b2aa..9784710f4 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberFinder.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberFinder.java @@ -16,8 +16,10 @@ package org.aspectj.ajdt.internal.compiler.lookup; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Set; import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation; import org.aspectj.org.eclipse.jdt.core.compiler.IProblem; @@ -298,7 +300,7 @@ public class InterTypeMemberFinder implements IMemberFinder { return orig; } - List ret = new ArrayList(Arrays.asList(orig)); + Set ret = new HashSet(Arrays.asList(orig)); // System.err.println("declared method: " + ret + " inters = " + interTypeMethods); for (int i = 0, len = interTypeMethods.size(); i < len; i++) { diff --git a/tests/bugs1810/ambig/Code.java b/tests/bugs1810/ambig/Code.java new file mode 100644 index 000000000..dab8d6f09 --- /dev/null +++ b/tests/bugs1810/ambig/Code.java @@ -0,0 +1,8 @@ +import java.util.List; + +aspect F { void A.xx(List x) { xx(null);this.xx(null);};} +class A {} +class B extends A { void xx(List x) { xx(null); this.xx(null); super.xx(null); }} +class C implements D { public void xx(List x) { xx(null); new A().xx(null); new B().xx(null); }} +interface D { void xx(List x); } +class E { void foo() { new B().xx(null); new A() {}.xx(null); } } diff --git a/tests/bugs1810/ambig/X.java b/tests/bugs1810/ambig/X.java new file mode 100644 index 000000000..6f0a73d97 --- /dev/null +++ b/tests/bugs1810/ambig/X.java @@ -0,0 +1,13 @@ +import java.util.List; + +aspect F { + void A.xx(List x) { } +} +class A { + //void xx(List x) {} +} +class E { + void foo() { + new A() {}.xx(null); + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java b/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java index cff7a3b7b..3af4bb79c 100644 --- a/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java @@ -34,6 +34,14 @@ public class Ajc1810Tests extends org.aspectj.testing.XMLBasedAjcTestCase { runTest("indy"); } + public void testAmbigMessage17() throws Exception { + runTest("ambiguous message - 17"); + } + + public void testAmbigMessage18() throws Exception { + runTest("ambiguous message - 18"); + } + // http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.6 public void testInnerClassesAttributeStructure_493554() throws Exception { runTest("pertarget"); diff --git a/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml b/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml index dd4237d22..e53b8aabe 100644 --- a/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml +++ b/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml @@ -11,5 +11,12 @@ + + + + + + + -- cgit v1.2.3 From 64c97807a20105644f604fe9b5263acdb63bd41d Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Fri, 28 Oct 2016 09:04:08 -0700 Subject: Fixing generics warnings --- .../src/org/aspectj/weaver/World.java | 2 +- .../ReflectionBasedReferenceTypeDelegate.java | 37 ++++--------------- .../org/aspectj/weaver/tools/AbstractTrace.java | 4 +-- util/src/org/aspectj/util/LangUtil.java | 4 +-- util/src/org/aspectj/util/PartialOrder.java | 42 +++++++++++----------- util/testsrc/org/aspectj/util/FileUtilTest.java | 28 +++++++-------- 6 files changed, 46 insertions(+), 71 deletions(-) diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/World.java b/org.aspectj.matcher/src/org/aspectj/weaver/World.java index 31b978028..8af6cc528 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/World.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/World.java @@ -1293,7 +1293,7 @@ public abstract class World implements Dump.INode { if (!memoryProfiling) { return; } - Reference r = null; + Reference r = null; while ((r=rq.poll()) != null) { collectedTypes++; } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java b/org.aspectj.matcher/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java index 6110e6ceb..2aa83c957 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java @@ -23,6 +23,7 @@ import java.util.Collections; import org.aspectj.weaver.AjAttribute.WeaverVersionInfo; import org.aspectj.weaver.AnnotationAJ; import org.aspectj.weaver.AnnotationTargetKind; +import org.aspectj.weaver.ConcreteTypeMunger; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ReferenceType; import org.aspectj.weaver.ReferenceTypeDelegate; @@ -34,6 +35,7 @@ import org.aspectj.weaver.UnresolvedType; import org.aspectj.weaver.WeakClassLoaderReference; import org.aspectj.weaver.WeaverStateInfo; import org.aspectj.weaver.World; +import org.aspectj.weaver.patterns.Declare; import org.aspectj.weaver.patterns.PerClause; /** @@ -62,7 +64,7 @@ public class ReflectionBasedReferenceTypeDelegate implements ReferenceTypeDelega public ReflectionBasedReferenceTypeDelegate() { } - public void initialize(ReferenceType aType, Class aClass, ClassLoader aClassLoader, World aWorld) { + public void initialize(ReferenceType aType, Class aClass, ClassLoader aClassLoader, World aWorld) { this.myClass = aClass; this.resolvedType = aType; this.world = aWorld; @@ -302,22 +304,12 @@ public class ReflectionBasedReferenceTypeDelegate implements ReferenceTypeDelega return null; } - /* - * (non-Javadoc) - * - * @see org.aspectj.weaver.ReferenceTypeDelegate#getDeclares() - */ - public Collection getDeclares() { - // no declares - return Collections.EMPTY_SET; + public Collection getDeclares() { + return Collections.emptySet(); } - /* - * @see org.aspectj.weaver.ReferenceTypeDelegate#getTypeMungers() - */ - public Collection getTypeMungers() { - // no type mungers - return Collections.EMPTY_SET; + public Collection getTypeMungers() { + return Collections.emptySet(); } /* @@ -363,29 +355,14 @@ public class ReflectionBasedReferenceTypeDelegate implements ReferenceTypeDelega return null; } - /* - * (non-Javadoc) - * - * @see org.aspectj.weaver.ReferenceTypeDelegate#getResolvedTypeX() - */ public ReferenceType getResolvedTypeX() { return this.resolvedType; } - /* - * (non-Javadoc) - * - * @see org.aspectj.weaver.ReferenceTypeDelegate#doesNotExposeShadowMungers() - */ public boolean doesNotExposeShadowMungers() { return false; } - /* - * (non-Javadoc) - * - * @see org.aspectj.weaver.ReferenceTypeDelegate#getDeclaredGenericSignature() - */ public String getDeclaredGenericSignature() { // no generic sig in 1.4 return null; diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/tools/AbstractTrace.java b/org.aspectj.matcher/src/org/aspectj/weaver/tools/AbstractTrace.java index c736de886..52217f880 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/tools/AbstractTrace.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/tools/AbstractTrace.java @@ -166,11 +166,11 @@ public abstract class AbstractTrace implements Trace { } } - protected String formatArray (Object obj) { + protected String formatArray(Object obj) { return obj.getClass().getComponentType().getName() + "[" + Array.getLength(obj) + "]"; } - protected String formatCollection (Collection c) { + protected String formatCollection(Collection c) { return c.getClass().getName() + "(" + c.size() + ")"; } diff --git a/util/src/org/aspectj/util/LangUtil.java b/util/src/org/aspectj/util/LangUtil.java index cf929b7b5..b0bf14522 100644 --- a/util/src/org/aspectj/util/LangUtil.java +++ b/util/src/org/aspectj/util/LangUtil.java @@ -929,11 +929,11 @@ public class LangUtil { * @param array the Object[] to convert (may be null) * @return the List corresponding to array (never null) */ - public static List arrayAsList(Object[] array) { + public static List arrayAsList(T[] array) { if ((null == array) || (1 > array.length)) { return Collections.emptyList(); } - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); list.addAll(Arrays.asList(array)); return list; } diff --git a/util/src/org/aspectj/util/PartialOrder.java b/util/src/org/aspectj/util/PartialOrder.java index 5dd870205..8bb9f3b77 100644 --- a/util/src/org/aspectj/util/PartialOrder.java +++ b/util/src/org/aspectj/util/PartialOrder.java @@ -49,12 +49,12 @@ public class PartialOrder { public int fallbackCompareTo(Object other); } - private static class SortObject { - PartialComparable object; - List smallerObjects = new LinkedList(); - List biggerObjects = new LinkedList(); + private static class SortObject { + T object; + List> smallerObjects = new LinkedList>(); + List> biggerObjects = new LinkedList>(); - public SortObject(PartialComparable o) { + public SortObject(T o) { object = o; } @@ -62,12 +62,12 @@ public class PartialOrder { return smallerObjects.size() == 0; } - boolean removeSmallerObject(SortObject o) { + boolean removeSmallerObject(SortObject o) { smallerObjects.remove(o); return hasNoSmallerObjects(); } - void addDirectedLinks(SortObject other) { + void addDirectedLinks(SortObject other) { int cmp = object.compareTo(other.object); if (cmp == 0) { return; @@ -86,18 +86,18 @@ public class PartialOrder { } } - private static void addNewPartialComparable(List graph, PartialComparable o) { - SortObject so = new SortObject(o); - for (Iterator i = graph.iterator(); i.hasNext();) { - SortObject other = i.next(); + private static void addNewPartialComparable(List> graph, T o) { + SortObject so = new SortObject(o); + for (Iterator> i = graph.iterator(); i.hasNext();) { + SortObject other = i.next(); so.addDirectedLinks(other); } graph.add(so); } - private static void removeFromGraph(List graph, SortObject o) { - for (Iterator i = graph.iterator(); i.hasNext();) { - SortObject other = i.next(); + private static void removeFromGraph(List> graph, SortObject o) { + for (Iterator> i = graph.iterator(); i.hasNext();) { + SortObject other = i.next(); if (o == other) { i.remove(); @@ -114,7 +114,7 @@ public class PartialOrder { * @returns the same members as objects, but sorted according to their partial order. returns null if the objects are cyclical * */ - public static List sort(List objects) { + public static List sort(List objects) { // lists of size 0 or 1 don't need any sorting if (objects.size() < 2) { return objects; @@ -124,9 +124,9 @@ public class PartialOrder { // ??? I don't like creating this data structure, but it does give good // ??? separation of concerns. - List sortList = new LinkedList(); // objects.size()); - for (Iterator i = objects.iterator(); i.hasNext();) { - addNewPartialComparable(sortList, (PartialComparable) i.next()); + List> sortList = new LinkedList>(); + for (Iterator i = objects.iterator(); i.hasNext();) { + addNewPartialComparable(sortList, i.next()); } // System.out.println(sortList); @@ -140,11 +140,9 @@ public class PartialOrder { // System.out.println(sortList); // System.out.println("-->" + ret); - SortObject leastWithNoSmallers = null; + SortObject leastWithNoSmallers = null; - for (Iterator i = sortList.iterator(); i.hasNext();) { - SortObject so = (SortObject) i.next(); - // System.out.println(so); + for (SortObject so: sortList) { if (so.hasNoSmallerObjects()) { if (leastWithNoSmallers == null || so.object.fallbackCompareTo(leastWithNoSmallers.object) < 0) { leastWithNoSmallers = so; diff --git a/util/testsrc/org/aspectj/util/FileUtilTest.java b/util/testsrc/org/aspectj/util/FileUtilTest.java index 3f065278b..8ce18c700 100644 --- a/util/testsrc/org/aspectj/util/FileUtilTest.java +++ b/util/testsrc/org/aspectj/util/FileUtilTest.java @@ -62,7 +62,7 @@ public class FileUtilTest extends TestCase { * @throws AssertionFailedError if any names are not in dir */ public static String[] dirContains(File dir, final String[] filenames) { - final ArrayList sought = new ArrayList(LangUtil.arrayAsList(filenames)); + final ArrayList sought = new ArrayList<>(LangUtil.arrayAsList(filenames)); FilenameFilter filter = new FilenameFilter() { public boolean accept(File d, String name) { return !sought.remove(name); @@ -129,11 +129,11 @@ public class FileUtilTest extends TestCase { * @return sorted String[] of all paths to all files under dir ending with one of the listed suffixes but not starting with "." */ public static String[] dirPaths(File dir, String[] suffixes) { - ArrayList result = new ArrayList(); + ArrayList result = new ArrayList(); doDirPaths(dir, result); // if suffixes required, remove those without suffixes if (!LangUtil.isEmpty(suffixes)) { - for (ListIterator iter = result.listIterator(); iter.hasNext();) { + for (ListIterator iter = result.listIterator(); iter.hasNext();) { String path = iter.next().toString(); boolean hasSuffix = false; for (int i = 0; !hasSuffix && (i < suffixes.length); i++) { @@ -161,7 +161,7 @@ public class FileUtilTest extends TestCase { * @param dir the File to read - ignored if null, not a directory, or has "CVS" in its path * @param useSuffix if true, then use dir as suffix to path */ - private static void doDirPaths(File dir, ArrayList paths) { + private static void doDirPaths(File dir, ArrayList paths) { if ((null == dir) || !dir.canRead() || (-1 != dir.getPath().indexOf("CVS"))) { return; } @@ -188,15 +188,15 @@ public class FileUtilTest extends TestCase { } /** List of File files or directories to delete when exiting */ - final ArrayList tempFiles; + final ArrayList tempFiles; public FileUtilTest(String s) { super(s); - tempFiles = new ArrayList(); + tempFiles = new ArrayList(); } public void tearDown() { - for (ListIterator iter = tempFiles.listIterator(); iter.hasNext();) { + for (ListIterator iter = tempFiles.listIterator(); iter.hasNext();) { File dir = (File) iter.next(); log("removing " + dir); FileUtil.deleteContents(dir); @@ -236,7 +236,7 @@ public class FileUtilTest extends TestCase { public void testCopyFiles() { // bad input - Class iaxClass = IllegalArgumentException.class; + Class iaxClass = IllegalArgumentException.class; checkCopyFiles(null, null, iaxClass, false); @@ -388,7 +388,7 @@ public class FileUtilTest extends TestCase { } public void testRandomFileString() { - ArrayList results = new ArrayList(); + ArrayList results = new ArrayList<>(); for (int i = 0; i < 1000; i++) { String s = FileUtil.randomFileString(); if (results.contains(s)) { @@ -469,7 +469,7 @@ public class FileUtilTest extends TestCase { } }; for (int i = 0; i < 10; i++) { - List result = FileUtil.lineSeek("" + i, sourceList, true, errorSink); + List result = FileUtil.lineSeek("" + i, sourceList, true, errorSink); assertEquals(2, result.size()); assertEquals(path + ":1:" + i, result.get(0)); assertEquals(path + ":2:" + i, result.get(1)); @@ -502,19 +502,19 @@ public class FileUtilTest extends TestCase { tempFiles.add(file); } // now test - final ArrayList errors = new ArrayList(); + final ArrayList errors = new ArrayList<>(); final PrintStream errorSink = new PrintStream(System.err, true) { public void println(String error) { errors.add(error); } }; - List sourceList = new ArrayList(); + List sourceList = new ArrayList<>(); sourceList.addAll(Arrays.asList(sources)); sourceList = Collections.unmodifiableList(sourceList); for (int k = 0; k < sources.length; k++) { - List result = FileUtil.lineSeek("" + k, sourceList, true, errorSink); + List result = FileUtil.lineSeek("" + k, sourceList, true, errorSink); // number k found in every other line of every file at index k - Iterator iter = result.iterator(); + Iterator iter = result.iterator(); for (int i = 0; i < MAX; i++) { // for each file for (int j = 1; j < (MAX + 1); j++) { // for every other line assertTrue(iter.hasNext()); -- cgit v1.2.3 From de34df77ea7f7372894cf1e2352766118a798e98 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Mon, 7 Nov 2016 13:04:55 -0800 Subject: Upgraded to new JDT compiler - neon.1 and a bit --- build/.isJava5 | 1 + .../internal/tools/ant/taskdefs/AntBuilder.java | 37 ++++++------ .../internal/tools/ant/taskdefs/Checklics.java | 12 ++-- .../tools/ant/taskdefs/ConditionalTask.java | 12 ++-- .../org/aspectj/internal/tools/build/Builder.java | 25 ++++---- .../org/aspectj/internal/tools/build/Module.java | 63 +++++++++++---------- .../org/aspectj/internal/tools/build/Modules.java | 2 +- .../org/aspectj/internal/tools/build/Result.java | 61 ++++++++++---------- .../internal/tools/build/SampleGatherer.java | 24 ++++---- .../org/aspectj/build/BuildModuleTests.java | 19 +++---- .../aspectj/internal/build/BuildModuleTest.java | 2 +- .../org/aspectj/internal/build/ModulesTest.java | 14 ++--- lib/build/build.jar | Bin 155908 -> 192810 bytes lib/build/build.old.jar | Bin 0 -> 155908 bytes .../src/org/aspectj/ajdt/ajc/messages.properties | 2 +- .../compiler/ast/AccessForInlineVisitor.java | 1 + .../internal/compiler/ast/AdviceDeclaration.java | 2 +- .../compiler/problem/AjProblemReporter.java | 5 ++ .../ajdt/internal/core/builder/AjBuildManager.java | 2 +- .../internal/core/builder/AjCompilerOptions.java | 2 +- .../CompactTypeStructureRepresentation.java | 4 ++ .../internal/compiler/batch/BcweaverJarMaker.java | 30 +++++----- .../compiler/batch/BinaryFormsTestCase.java | 2 +- .../core/builder/AjCompilerOptionsTest.java | 4 +- .../aspectj/weaver/patterns/VisitorTestCase.java | 13 ++--- org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip | Bin 4567287 -> 5207300 bytes org.eclipse.jdt.core/jdtcore-for-aspectj.jar | Bin 14023531 -> 10253487 bytes testing-client/src/org/aspectj/testing/Tester.java | 17 +++--- .../src/org/aspectj/testing/server/TestServer.java | 6 +- .../testsrc/org/aspectj/testing/TesterTest.java | 9 ++- tests/bugs1810/502807/TestCollectors.java | 36 ++++++++++++ tests/src/org/aspectj/systemtest/ajc150/ajc150.xml | 4 +- .../aspectj/systemtest/ajc1810/Ajc1810Tests.java | 4 ++ .../src/org/aspectj/systemtest/ajc1810/ajc1810.xml | 6 ++ .../src/org/aspectj/weaver/bcel/LazyMethodGen.java | 4 +- .../org/aspectj/weaver/bcel/ArgsWeaveTestCase.java | 5 +- .../org/aspectj/weaver/MemberTestCase15.java | 2 - 37 files changed, 236 insertions(+), 196 deletions(-) create mode 100644 build/.isJava5 create mode 100644 lib/build/build.old.jar create mode 100644 tests/bugs1810/502807/TestCollectors.java diff --git a/build/.isJava5 b/build/.isJava5 new file mode 100644 index 000000000..136d06384 --- /dev/null +++ b/build/.isJava5 @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java b/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java index c1323bb58..253e49fb1 100644 --- a/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java +++ b/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java @@ -84,7 +84,7 @@ public class AntBuilder extends Builder { /** * Ensure targets exist for this module and all antecedants, so topoSort can work. */ - private static void makeTargetsForResult(final Result result, final Hashtable targets) { + private static void makeTargetsForResult(final Result result, final Hashtable targets) { final String resultTargetName = resultToTargetName(result); Target target = (Target) targets.get(resultTargetName); if (null == target) { @@ -196,7 +196,7 @@ public class AntBuilder extends Builder { return copy; } - protected void dumpMinFile(Result result, File classesDir, List errors) { + protected void dumpMinFile(Result result, File classesDir, List errors) { String name = result.getName() + "-empty"; File minFile = new File(classesDir, name); FileWriter fw = null; @@ -211,8 +211,8 @@ public class AntBuilder extends Builder { } - protected boolean compile(Result result, File classesDir, boolean useExistingClasses, List errors) { - + @Override + protected boolean compile(Result result, File classesDir, boolean useExistingClasses, List errors) { if (!classesDir.exists() && !classesDir.mkdirs()) { errors.add("compile - unable to create " + classesDir); return false; @@ -224,8 +224,9 @@ public class AntBuilder extends Builder { Path path = new Path(project); boolean hasSourceDirectories = false; boolean isJava5Compile = false; - for (Iterator iter = result.getSrcDirs().iterator(); iter.hasNext();) { - File file = (File) iter.next(); + for (File file: result.getSrcDirs()) { +// for (Iterator iter = result.getSrcDirs().iterator(); iter.hasNext();) { +// File file = (File) iter.next(); path.createPathElement().setLocation(file); if (!isJava5Compile && (Util.Constants.JAVA5_SRC.equals(file.getName()) || Util.Constants.JAVA5_TESTSRC.equals(file.getName()) || new File( @@ -268,8 +269,8 @@ public class AntBuilder extends Builder { javac.setTarget("1.1"); // 1.1 class files - Javac in 1.4 uses 1.4 javac.setSource("1.3"); } else { - javac.setSource("1.5"); - javac.setTarget("1.5"); + javac.setSource("1.8"); + javac.setTarget("1.8"); } // compile boolean passed = false; @@ -330,7 +331,8 @@ public class AntBuilder extends Builder { * Merge classes directory and any merge jars into module jar with any specified manifest file. META-INF directories are * excluded. */ - protected boolean assemble(Result result, File classesDir, List errors) { + @Override + protected boolean assemble(Result result, File classesDir, List errors) { if (!buildingEnabled) { return false; } @@ -400,18 +402,18 @@ public class AntBuilder extends Builder { * @see org.aspectj.internal.tools.build.Builder#buildAntecedants(Module) */ protected Result[] getAntecedantResults(Result moduleResult) { - Hashtable targets = new Hashtable(); + Hashtable targets = new Hashtable<>(); makeTargetsForResult(moduleResult, targets); String targetName = resultToTargetName(moduleResult); // bug: doc says topoSort returns String, but returns Target - Collection result = project.topoSort(targetName, targets); + Collection result = project.topoSort(targetName, targets); // fyi, we don't rely on topoSort to detect cycles - see buildAll int size = result.size(); if (0 == result.size()) { return new Result[0]; } - ArrayList toReturn = new ArrayList(); - for (Iterator iter = result.iterator(); iter.hasNext();) { + ArrayList toReturn = new ArrayList<>(); + for (Iterator iter = result.iterator(); iter.hasNext();) { Target target = (Target) iter.next(); String name = target.getName(); if (null == name) { @@ -450,11 +452,10 @@ public class AntBuilder extends Builder { zip.setDestFile(result.getOutputFile()); ZipFileSet zipfileset = null; final Module module = result.getModule(); - List known = result.findJarRequirements(); + List known = result.findJarRequirements(); removeLibraryFilesToSkip(module, known); // -- merge any antecedents, less any manifest - for (Iterator iter = known.iterator(); iter.hasNext();) { - File jarFile = (File) iter.next(); + for (File jarFile: known) { zipfileset = new ZipFileSet(); zipfileset.setProject(project); zipfileset.setSrc(jarFile); @@ -541,8 +542,7 @@ public class AntBuilder extends Builder { /** @return true if aspectjrt.jar is on classpath */ private static boolean runtimeJarOnClasspath(Result result) { - for (Iterator iter = result.getLibJars().iterator(); iter.hasNext();) { - File file = (File) iter.next(); + for (File file: result.getLibJars()) { if ("aspectjrt.jar".equals(file.getName())) { return true; } @@ -582,6 +582,7 @@ public class AntBuilder extends Builder { * @param runtimeJar the Path to the aspectjrt.jar * @return javac or another Task invoking the AspectJ compiler */ + @SuppressWarnings("unchecked") static Task aspectJTask(Javac javac, Path toolsJar, Path runtimeJar) { Object task = null; String url = null; diff --git a/build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java b/build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java index 0cefa7952..819673cff 100644 --- a/build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java +++ b/build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java @@ -54,7 +54,7 @@ public class Checklics extends MatchingTask { public static final String EPL_CPL_IBM_PARC_XEROX_OTHERS_TAG = "epl-cpl-ibm|parc|xerox|vmware|others"; public static final String DEFAULT = EPL_CPL_IBM_PARC_XEROX_OTHERS_TAG; - static final Map LICENSES; // unmodifiable Map + static final Map LICENSES; // unmodifiable Map static { final String CONTRIBUTORS = "Contributors"; @@ -82,7 +82,7 @@ public class Checklics extends MatchingTask { License MPL_ONLY = new License(MPL_ONLY_TAG, LIC_MPL); License MPL_PARC = new License(MPL_PARC_TAG, LIC_MPL, PARC); License PARC_COPYRIGHT = new License(PARC_COPYRIGHT_TAG, null, PARC); - LICENSES = new Hashtable(); + LICENSES = new Hashtable<>(); LICENSES.put(APL.tag, APL); LICENSES.put(MPL.tag, MPL); LICENSES.put(MPL_PARC.tag, MPL_PARC); @@ -458,11 +458,11 @@ class HeaderInfo { /** last line of license */ public final boolean hasLicense; - public HeaderInfo(File file, int lastLine, List years, boolean hasLicense) { + public HeaderInfo(File file, int lastLine, List years, boolean hasLicense) { this.lastLine = lastLine; this.file = file; this.hasLicense = hasLicense; - List newYears = new ArrayList(); + List newYears = new ArrayList<>(); newYears.addAll(years); Collections.sort(newYears); this.years = Collections.unmodifiableList(newYears); @@ -610,7 +610,7 @@ class Header { } public static HeaderInfo checkFile(final File file) { - ArrayList years = new ArrayList(); + ArrayList years = new ArrayList<>(); int endLine = 0; BufferedReader input = null; int lineNum = 0; @@ -647,7 +647,7 @@ class Header { * * @return true if this line has end-of-comment */ - private static boolean checkLine(String line, ArrayList years) { + private static boolean checkLine(String line, ArrayList years) { if ((null == line) || (0 == line.length())) { return false; } diff --git a/build/src/org/aspectj/internal/tools/ant/taskdefs/ConditionalTask.java b/build/src/org/aspectj/internal/tools/ant/taskdefs/ConditionalTask.java index 99ab1ab44..7a9092352 100644 --- a/build/src/org/aspectj/internal/tools/ant/taskdefs/ConditionalTask.java +++ b/build/src/org/aspectj/internal/tools/ant/taskdefs/ConditionalTask.java @@ -25,9 +25,9 @@ public abstract class ConditionalTask extends Task { public final static String TRUE = "true"; - private List ifs; - protected List ifs() { - return ifs != null ? ifs : (ifs = new Vector()); + private List ifs; + protected List ifs() { + return ifs != null ? ifs : (ifs = new Vector()); } public If createIf() { @@ -166,9 +166,9 @@ public abstract class ConditionalTask extends Task { return getFalses().size() == 0; } - protected List getFalses() { - Iterator iter = ifs().iterator(); - List result = new Vector(); + protected List getFalses() { + Iterator iter = ifs().iterator(); + List result = new Vector<>(); while (iter.hasNext()) { If next = (If) iter.next(); String name = next.getName(); diff --git a/build/src/org/aspectj/internal/tools/build/Builder.java b/build/src/org/aspectj/internal/tools/build/Builder.java index 2bd49ac61..4fe47ced4 100644 --- a/build/src/org/aspectj/internal/tools/build/Builder.java +++ b/build/src/org/aspectj/internal/tools/build/Builder.java @@ -104,14 +104,14 @@ public abstract class Builder { private static final String SKIP_LIBRARIES_KEY = "skip.libraries"; /** List (String) names of libraries to skip during assembly */ - private static final List SKIP_LIBRARIES; + private static final List SKIP_LIBRARIES; private static final String ERROR_KEY = "error loading properties"; private static final Properties PROPS; static { PROPS = new Properties(); - List skips = Collections.EMPTY_LIST; + List skips = Collections.emptyList(); String resourcePattern = "**/*.txt,**/*.rsc,**/*.gif,**/*.properties"; String allPattern = "**/*"; String binarySourcePattern = "**/*.rsc,**/*.gif,**/*.jar,**/*.zip"; @@ -149,7 +149,7 @@ public abstract class Builder { if ((null == text) || (0 == text.length())) { return Collections.EMPTY_LIST; } - List strings = new ArrayList(); + List strings = new ArrayList<>(); StringTokenizer tok = new StringTokenizer(text, ","); while (tok.hasMoreTokens()) { String token = tok.nextToken().trim(); @@ -275,13 +275,13 @@ public abstract class Builder { return buildProduct(buildSpec); } Result result = specifyResultFor(buildSpec); - ArrayList errors = new ArrayList(); + ArrayList errors = new ArrayList<>(); try { return buildAll(result, errors); } finally { if (0 < errors.size()) { String label = "error building " + buildSpec + ": "; - for (Iterator iter = errors.iterator(); iter.hasNext();) { + for (Iterator iter = errors.iterator(); iter.hasNext();) { String m = label + iter.next(); handler.error(m); } @@ -340,7 +340,7 @@ public abstract class Builder { */ protected final boolean buildAll(Result result, List errors) { Result[] buildList = skipUptodate(getAntecedantResults(result)); - ArrayList doneList = new ArrayList(); + ArrayList doneList = new ArrayList<>(); if ((null != buildList) && (0 < buildList.length)) { if (isLogging()) { handler.log("modules to build: " + Arrays.asList(buildList)); @@ -371,7 +371,7 @@ public abstract class Builder { * the List sink for errors, if any * @return false after successful build, when module jar should exist */ - protected final boolean buildOnly(Result result, List errors) { + protected final boolean buildOnly(Result result, List errors) { if (!result.outOfDate()) { return true; } @@ -545,7 +545,7 @@ public abstract class Builder { * deliverables. */ protected ProductModule[] discoverModules(File productDir, Modules modules) { - final ArrayList found = new ArrayList(); + final ArrayList found = new ArrayList<>(); FileFilter filter = new FileFilter() {// empty jar files public boolean accept(File file) { if ((null != file) && file.canRead() @@ -557,9 +557,8 @@ public abstract class Builder { } }; Util.visitFiles(productDir, filter); - ArrayList results = new ArrayList(); - for (Iterator iter = found.iterator(); iter.hasNext();) { - File file = (File) iter.next(); + ArrayList results = new ArrayList<>(); + for (File file: found) { String jarName = moduleAliasFor(file.getName().toLowerCase()); if (jarName.endsWith(".jar") || jarName.endsWith(".zip")) { // XXXFileLiteral jarName = jarName.substring(0, jarName.length() - 4); @@ -625,7 +624,7 @@ public abstract class Builder { * the List to add error messages to */ abstract protected boolean compile(Result result, File classesDir, - boolean useExistingClasses, List errors); + boolean useExistingClasses, List errors); /** * Assemble the module distribution from the classesDir, saving String @@ -634,7 +633,7 @@ public abstract class Builder { * @see #removeLibraryFilesToSkip(Module, File) */ abstract protected boolean assemble(Result result, File classesDir, - List errors); + List errors); /** * Assemble the module distribution from the classesDir and all diff --git a/build/src/org/aspectj/internal/tools/build/Module.java b/build/src/org/aspectj/internal/tools/build/Module.java index 02209e22e..8df660e2a 100644 --- a/build/src/org/aspectj/internal/tools/build/Module.java +++ b/build/src/org/aspectj/internal/tools/build/Module.java @@ -68,13 +68,13 @@ public class Module { } /** @return all source files under srcDir */ - private static Iterator sourceFiles(File srcDir) { - ArrayList result = new ArrayList(); + private static Iterator sourceFiles(File srcDir) { + ArrayList result = new ArrayList<>(); sourceFiles(srcDir, result); return result.iterator(); } - private static void sourceFiles(File srcDir, List result) { + private static void sourceFiles(File srcDir, List result) { if ((null == srcDir) || !srcDir.canRead() || !srcDir.isDirectory()) { return; } @@ -88,9 +88,8 @@ public class Module { } } - private static void addIfNew(List source, List sink) { - for (Iterator iter = source.iterator(); iter.hasNext();) { - Object item = iter.next(); + private static void addIfNew(List source, List sink) { + for (File item: source) { if (!sink.contains(item)) { sink.add(item); } @@ -102,7 +101,7 @@ public class Module { * * @see findKnownJarAntecedants() */ - static void doFindJarRequirements(Result result, List known) { + static void doFindJarRequirements(Result result, List known) { Util.iaxIfNull(result, "result"); Util.iaxIfNull(known, "known"); addIfNew(result.getLibJars(), known); @@ -170,25 +169,25 @@ public class Module { private final File moduleJar; /** File list of library jars */ - private final List libJars; + private final List libJars; - /** String list of classpath variables */ - private final List classpathVariables; + /** List of classpath variables */ + private final List classpathVariables; /** - * File list of library jars exported to clients (duplicates some libJars + * List of library jars exported to clients (duplicates some libJars * entries) */ - private final List exportedLibJars; + private final List exportedLibJars; /** File list of source directories */ - private final List srcDirs; + private final List srcDirs; /** properties from the modules {name}.properties file */ private final Properties properties; - /** Module list of required modules */ - private final List requiredModules; + /** List of required modules */ + private final List requiredModules; /** logger */ private final Messager messager; @@ -200,11 +199,11 @@ public class Module { Util.iaxIfNull(name, "name"); Util.iaxIfNull(modules, "modules"); this.moduleDir = moduleDir; - this.libJars = new ArrayList(); - this.exportedLibJars = new ArrayList(); - this.requiredModules = new ArrayList(); - this.srcDirs = new ArrayList(); - this.classpathVariables = new ArrayList(); + this.libJars = new ArrayList<>(); + this.exportedLibJars = new ArrayList<>(); + this.requiredModules = new ArrayList<>(); + this.srcDirs = new ArrayList<>(); + this.classpathVariables = new ArrayList<>(); this.properties = new Properties(); this.name = name; this.modules = modules; @@ -239,10 +238,10 @@ public class Module { } final long time = outputFile.lastModified(); File file; - for (Iterator iter = result.getSrcDirs().iterator(); iter.hasNext();) { - File srcDir = (File) iter.next(); - for (Iterator srcFiles = sourceFiles(srcDir); srcFiles.hasNext();) { - file = (File) srcFiles.next(); + for (Iterator iter = result.getSrcDirs().iterator(); iter.hasNext();) { + File srcDir = iter.next(); + for (Iterator srcFiles = sourceFiles(srcDir); srcFiles.hasNext();) { + file = srcFiles.next(); if (outOfDate(time, file)) { return true; } @@ -284,23 +283,27 @@ public class Module { : (kind.normal ? release : test); } - List srcDirs(Result result) { + List srcDirs(Result result) { myResult(result); return srcDirs; } - List libJars(Result result) { + + List libJars(Result result) { myResult(result); return libJars; } - List classpathVariables(Result result) { + + List classpathVariables(Result result) { myResult(result); return classpathVariables; } - List exportedLibJars(Result result) { + + List exportedLibJars(Result result) { myResult(result); return exportedLibJars; } - List requiredModules(Result result) { + + List requiredModules(Result result) { myResult(result); return requiredModules; } @@ -610,7 +613,7 @@ public class Module { String[] tokenize(String line) { final String DELIM = " \n\t\\<>\"="; StringTokenizer st = new StringTokenizer(line, DELIM, true); - ArrayList result = new ArrayList(); + ArrayList result = new ArrayList<>(); StringBuffer quote = new StringBuffer(); boolean inQuote = false; while (st.hasMoreTokens()) { diff --git a/build/src/org/aspectj/internal/tools/build/Modules.java b/build/src/org/aspectj/internal/tools/build/Modules.java index 49391fe68..ca2b50aac 100644 --- a/build/src/org/aspectj/internal/tools/build/Modules.java +++ b/build/src/org/aspectj/internal/tools/build/Modules.java @@ -24,7 +24,7 @@ import java.util.Hashtable; */ public class Modules { - private final Hashtable modules = new Hashtable(); + private final Hashtable modules = new Hashtable<>(); public final File baseDir; public final File jarDir; private final Messager handler; diff --git a/build/src/org/aspectj/internal/tools/build/Result.java b/build/src/org/aspectj/internal/tools/build/Result.java index 672ba561b..3b5a4e141 100644 --- a/build/src/org/aspectj/internal/tools/build/Result.java +++ b/build/src/org/aspectj/internal/tools/build/Result.java @@ -40,7 +40,7 @@ public class Result { private static final Kind[] KINDS = { RELEASE, TEST, RELEASE_ALL, TEST_ALL }; - private static final HashMap nameToResult = new HashMap(); + private static final HashMap nameToResult = new HashMap<>(); public static boolean isTestingJar(String name) { name = name.toLowerCase(); @@ -141,25 +141,25 @@ public class Result { /** path to output jar - may not exist */ private final File outputFile; - /** list of required Result */ - private final List requiredResults; + /** List of required Result */ + private final List requiredResults; - /** File list of library jars */ - private final List libJars; + /** List of library jars */ + private final List libJars; - /** String list of classpath variables */ - private final List classpathVariables; + /** List of classpath variables */ + private final List classpathVariables; transient String toLongString; /** - * File list of library jars exported to clients (duplicates some libJars + * List of library jars exported to clients (duplicates some libJars * entries) */ - private final List exportedLibJars; + private final List exportedLibJars; - /** File list of source directories */ - private final List srcDirs; + /** List of source directories */ + private final List srcDirs; /** true if this has calculated List fields. */ private boolean requiredDone; @@ -179,11 +179,11 @@ public class Result { Result(Kind kind, Module module, File jarDir) { this.kind = kind; this.module = module; - this.libJars = new ArrayList(); - this.exportedLibJars = new ArrayList(); - this.srcDirs = new ArrayList(); - this.classpathVariables = new ArrayList(); - this.requiredResults = new ArrayList(); + this.libJars = new ArrayList<>(); + this.exportedLibJars = new ArrayList<>(); + this.srcDirs = new ArrayList<>(); + this.classpathVariables = new ArrayList<>(); + this.requiredResults = new ArrayList<>(); String name = module.name; if (!kind.normal) { name += "-test"; @@ -218,14 +218,14 @@ public class Result { } /** @return List (File) of jar's required */ - public List findJarRequirements() { - ArrayList result = new ArrayList(); + public List findJarRequirements() { + ArrayList result = new ArrayList<>(); Module.doFindJarRequirements(this, result); return result; } /** @return unmodifiable List of String classpath variables */ - public List getClasspathVariables() { + public List getClasspathVariables() { return safeList(classpathVariables); } @@ -238,14 +238,14 @@ public class Result { /** * @return unmodifiable list of exported library files, guaranteed readable */ - public List getExportedLibJars() { + public List getExportedLibJars() { return safeList(exportedLibJars); } /** * @return unmodifiable list of required library files, guaranteed readable */ - public List getLibJars() { + public List getLibJars() { requiredDone(); return safeList(libJars); } @@ -258,7 +258,7 @@ public class Result { // return safeList(merges); // } /** @return unmodifiable list of source directories, guaranteed readable */ - public List getSrcDirs() { + public List getSrcDirs() { return safeList(srcDirs); } @@ -283,12 +283,12 @@ public class Result { return name; } - private List safeList(List l) { + private List safeList(List l) { requiredDone(); return Collections.unmodifiableList(l); } - private Result[] safeResults(List list) { + private Result[] safeResults(List list) { requiredDone(); if (null == list) { return new Result[0]; @@ -300,8 +300,8 @@ public class Result { srcDirs.addAll(getModule().srcDirs(this)); if (getKind().normal) { // trim testing source directories - for (ListIterator iter = srcDirs.listIterator(); iter.hasNext();) { - File srcDir = (File) iter.next(); + for (ListIterator iter = srcDirs.listIterator(); iter.hasNext();) { + File srcDir = iter.next(); if (isTestingDir(srcDir.getName())) { iter.remove(); } @@ -313,8 +313,8 @@ public class Result { libJars.addAll(getModule().libJars(this)); if (getKind().normal && !isTestingModule(getModule())) { // trim testing libraries - for (ListIterator iter = libJars.listIterator(); iter.hasNext();) { - File libJar = (File) iter.next(); + for (ListIterator iter = libJars.listIterator(); iter.hasNext();) { + File libJar = iter.next(); if (isTestingJar(libJar.getName())) { iter.remove(); } @@ -348,10 +348,9 @@ public class Result { assertKind(RELEASE); } // externally-required: - List modules = module.requiredModules(this); + List modules = module.requiredModules(this); final boolean adoptTests = !kind.normal || isTestingModule(module); - for (Iterator iter = modules.iterator(); iter.hasNext();) { - Module required = (Module) iter.next(); + for (Module required: modules) { if (adoptTests) { // testing builds can rely on other release and test results requiredResults.add(required.getResult(TEST)); diff --git a/build/src/org/aspectj/internal/tools/build/SampleGatherer.java b/build/src/org/aspectj/internal/tools/build/SampleGatherer.java index f95b43b5b..a9d29af6b 100644 --- a/build/src/org/aspectj/internal/tools/build/SampleGatherer.java +++ b/build/src/org/aspectj/internal/tools/build/SampleGatherer.java @@ -268,10 +268,8 @@ class Sample { public static final String ASPECTJ_TEAM = "The AspectJ Team"; /** sort by anchorName, file path, and start/end location */ - static Comparator NAME_SOURCE_COMPARER = new Comparator() { - public int compare(Object lhs, Object rhs) { - Sample left = (Sample) lhs; - Sample right = (Sample) rhs; + static Comparator NAME_SOURCE_COMPARER = new Comparator() { + public int compare(Sample left, Sample right) { if (null == left) { return (null == right ? 0 : -1); } @@ -295,10 +293,8 @@ class Sample { }; /** sort by author, then NAME_SOURCE_COMPARER */ - static Comparator AUTHOR_NAME_SOURCE_COMPARER = new Comparator() { - public int compare(Object lhs, Object rhs) { - Sample left = (Sample) lhs; - Sample right = (Sample) rhs; + static Comparator AUTHOR_NAME_SOURCE_COMPARER = new Comparator() { + public int compare(Sample left, Sample right) { if (null == left) { return (null == right ? 0 : -1); } @@ -309,7 +305,7 @@ class Sample { if (0 != result) { return result; } - return NAME_SOURCE_COMPARER.compare(lhs, rhs); + return NAME_SOURCE_COMPARER.compare(left,right); } }; @@ -395,7 +391,7 @@ class Sample { * type-safe Collection of samples. */ class Samples { - private ArrayList samples = new ArrayList(); + private ArrayList samples = new ArrayList<>(); int size() { return samples.size(); } @@ -405,12 +401,12 @@ class Samples { /** * @return List copy, sorted by Sample.NAME_SOURCE_COMPARER */ - List getSortedSamples() { + List getSortedSamples() { return getSortedSamples(Sample.NAME_SOURCE_COMPARER); } - List getSortedSamples(Comparator comparer) { - ArrayList result = new ArrayList(); + List getSortedSamples(Comparator comparer) { + ArrayList result = new ArrayList<>(); result.addAll(samples); Collections.sort(result, comparer); return result; @@ -961,7 +957,7 @@ class SampleUtil { } public static String[] splitAnchorName(String anchorName) { - ArrayList result = new ArrayList(); + ArrayList result = new ArrayList<>(); int start = 0; int loc = anchorName.indexOf("-", start); String next; diff --git a/build/testsrc/org/aspectj/build/BuildModuleTests.java b/build/testsrc/org/aspectj/build/BuildModuleTests.java index bfc6b58cc..073cf0f39 100644 --- a/build/testsrc/org/aspectj/build/BuildModuleTests.java +++ b/build/testsrc/org/aspectj/build/BuildModuleTests.java @@ -27,7 +27,6 @@ import java.io.FileFilter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.StringTokenizer; @@ -62,7 +61,7 @@ public class BuildModuleTests extends TestCase { return null; // use permissive default } - final static List SOURCE_NAMES = Collections.unmodifiableList( + final static List SOURCE_NAMES = Collections.unmodifiableList( Arrays.asList(new String[]{"src", "testsrc", "java5-src", "java5-testsrc", "aspectj-src"})); /** @@ -70,9 +69,8 @@ public class BuildModuleTests extends TestCase { * @return */ private static File[] findSourceRoots(File moduleDir) { - ArrayList result = new ArrayList(); - for (Iterator iter = SOURCE_NAMES.iterator(); iter.hasNext();) { - String name = (String) iter.next(); + ArrayList result = new ArrayList<>(); + for (String name: SOURCE_NAMES) { File srcDir = new File(moduleDir, name); if (srcDir.canRead() && srcDir.isDirectory()) { result.add(srcDir); @@ -219,12 +217,12 @@ public class BuildModuleTests extends TestCase { */ static class UnknownFileCheck implements FileFilter { private static final UnknownFileCheck SINGLETON = new UnknownFileCheck(); - private static final ArrayList STATIC_ERRORS = new ArrayList(); + private static final ArrayList STATIC_ERRORS = new ArrayList<>(); // Builder.BINARY_SOURCE_PATTERN and Builder.RESOURCE_PATTERN - public static final List KNOWN_SUFFIXES; + public static final List KNOWN_SUFFIXES; static { - List suffixes = new ArrayList(); + List suffixes = new ArrayList<>(); // sources from org.aspectj.util.FileUtil.SOURCE_SUFFIXES suffixes.add(".aj"); suffixes.add(".java"); @@ -278,8 +276,7 @@ public class BuildModuleTests extends TestCase { return false; } // to do not accepting uppercase suffixes... - for (Iterator iter = KNOWN_SUFFIXES.iterator(); iter.hasNext();) { - String suffix = (String) iter.next(); + for (String suffix: KNOWN_SUFFIXES) { if (name.endsWith(suffix)) { return false; } @@ -287,7 +284,7 @@ public class BuildModuleTests extends TestCase { return true; } - void unknownFiles(File dir, ArrayList results) { + void unknownFiles(File dir, ArrayList results) { File[] files = dir.listFiles(this); for (int j = 0; j < files.length; j++) { File file = files[j]; diff --git a/build/testsrc/org/aspectj/internal/build/BuildModuleTest.java b/build/testsrc/org/aspectj/internal/build/BuildModuleTest.java index d513c1b71..d0dfb55f2 100644 --- a/build/testsrc/org/aspectj/internal/build/BuildModuleTest.java +++ b/build/testsrc/org/aspectj/internal/build/BuildModuleTest.java @@ -80,7 +80,7 @@ public class BuildModuleTest extends TestCase { } } - ArrayList tempFiles = new ArrayList(); + ArrayList tempFiles = new ArrayList<>(); private File jarDir; private boolean deleteJars; boolean building; // must be enabled for tests to run diff --git a/build/testsrc/org/aspectj/internal/build/ModulesTest.java b/build/testsrc/org/aspectj/internal/build/ModulesTest.java index c482950c6..0478c44c2 100644 --- a/build/testsrc/org/aspectj/internal/build/ModulesTest.java +++ b/build/testsrc/org/aspectj/internal/build/ModulesTest.java @@ -41,7 +41,7 @@ import org.aspectj.internal.tools.build.Result.Kind; * */ public class ModulesTest extends TestCase { - public static final List /*String*/ MODULE_NAMES; + public static final List MODULE_NAMES; private static final File BASE_DIR = new File(".."); static { String[] names = { @@ -49,7 +49,7 @@ public class ModulesTest extends TestCase { "bridge", "loadtime", "loadtime5", "org.aspectj.ajdt.core", "runtime", "taskdefs", "testing-client", "testing-util", "tests", "util", "weaver"}; - List list = Arrays.asList(names); + List list = Arrays.asList(names); MODULE_NAMES = Collections.unmodifiableList(list); } @@ -80,7 +80,7 @@ public class ModulesTest extends TestCase { protected void tearDown() throws Exception { super.tearDown(); - for (Iterator iter = tempFiles.iterator(); iter.hasNext();) { + for (Iterator iter = tempFiles.iterator(); iter.hasNext();) { File file = (File) iter.next(); if (!ModulesTest.delete(file)) { System.err.println("warning: ModulesTest unable to delete " + file); @@ -101,9 +101,8 @@ public class ModulesTest extends TestCase { } public void testAllModulesCreation() { - ArrayList badModules = new ArrayList(); - for (Iterator iter = MODULE_NAMES.iterator(); iter.hasNext();) { - String name = (String) iter.next(); + ArrayList badModules = new ArrayList<>(); + for (String name: MODULE_NAMES) { File dir = new File(BASE_DIR, name); if (dir.isDirectory()) { File classpath = new File(dir, ".classpath"); @@ -118,8 +117,7 @@ public class ModulesTest extends TestCase { } if (!badModules.isEmpty()) { StringBuffer sb = new StringBuffer(); - for (Iterator iter = badModules.iterator(); iter.hasNext();) { - Module module = (Module) iter.next(); + for (Module module: badModules) { System.err.println(module.toLongString()); sb.append("\n"); sb.append(module); diff --git a/lib/build/build.jar b/lib/build/build.jar index d08b25042..f48ce3390 100644 Binary files a/lib/build/build.jar and b/lib/build/build.jar differ diff --git a/lib/build/build.old.jar b/lib/build/build.old.jar new file mode 100644 index 000000000..d08b25042 Binary files /dev/null and b/lib/build/build.old.jar differ diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties index 185ab046c..630fedb7a 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties @@ -5,7 +5,7 @@ org/aspectj/weaver/XlintDefault.properties for the default behavior and a template to copy. ### AspectJ-specific messages compiler.name = AspectJ Compiler 1.8.10 -compiler.version = Eclipse Compiler Mars.2 #A7BBA8B1, 3.12 +compiler.version = Eclipse Compiler Neon.1 #5925A0B5, 3.12 compiler.copyright = ## this next one superceded by above... diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java index 0755476e9..ad50e430c 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java @@ -181,6 +181,7 @@ public class AccessForInlineVisitor extends ASTVisitor { } FieldBinding ret = new InlineAccessFieldBinding(inAspect, binding, m); inAspect.accessForInline.put(m, ret); + System.out.println(">>"+m); return ret; } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java index 73e539e71..0d6e90d4c 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java @@ -65,7 +65,7 @@ public class AdviceDeclaration extends AjMethodDeclaration { public int adviceSequenceNumberInType; public MethodBinding proceedMethodBinding; // set during this.resolveStaments, referenced by Proceed - public List proceedCalls = new ArrayList(2); // populated during Proceed.findEnclosingAround + public List proceedCalls = new ArrayList<>(2); // populated during Proceed.findEnclosingAround private boolean proceedInInners; private ResolvedMember[] proceedCallSignatures; diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java index 88556fccf..2cb035a70 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java @@ -757,6 +757,11 @@ public class AjProblemReporter extends ProblemReporter { public String getSupplementaryMessageInfo() { return delegate.getSupplementaryMessageInfo(); } + + @Override + public boolean isInfo() { + return delegate.isInfo(); + } } public void duplicateMethodInType(AbstractMethodDeclaration methodDecl, boolean equalParameters, int severity) { diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java index 0dda15cb1..164af6629 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java @@ -1021,7 +1021,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour } org.aspectj.ajdt.internal.compiler.CompilerAdapter.setCompilerAdapterFactory(this); - final Map settings = buildConfig.getOptions().getMap(); + final Map settings = buildConfig.getOptions().getMap(); final BuildArgParser bMain = buildConfig.getBuildArgParser(); final org.aspectj.org.eclipse.jdt.internal.compiler.Compiler compiler = new org.aspectj.org.eclipse.jdt.internal.compiler.Compiler( diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjCompilerOptions.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjCompilerOptions.java index ceba72e30..ffe2f4761 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjCompilerOptions.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjCompilerOptions.java @@ -128,7 +128,7 @@ public class AjCompilerOptions extends CompilerOptions { * * @see org.eclipse.jdt.internal.compiler.impl.CompilerOptions#getMap() */ - public Map getMap() { + public Map getMap() { Map map = super.getMap(); // now add AspectJ additional options map.put(OPTION_ReportInvalidAbsoluteTypeName, getSeverityString(InvalidAbsoluteTypeName)); diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/CompactTypeStructureRepresentation.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/CompactTypeStructureRepresentation.java index 1a88cb3c6..e9d367abd 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/CompactTypeStructureRepresentation.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/CompactTypeStructureRepresentation.java @@ -20,6 +20,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryNestedType; import org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryType; import org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryTypeAnnotation; import org.aspectj.org.eclipse.jdt.internal.compiler.env.ITypeAnnotationWalker; +import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.ExternalAnnotationStatus; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment; /** @@ -189,4 +190,7 @@ public class CompactTypeStructureRepresentation implements IBinaryType { return walker; } + public ExternalAnnotationStatus getExternalAnnotationStatus() { + return ExternalAnnotationStatus.NOT_EEA_CONFIGURED; + } } \ No newline at end of file diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BcweaverJarMaker.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BcweaverJarMaker.java index b7468d552..9d4cc3cec 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BcweaverJarMaker.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BcweaverJarMaker.java @@ -49,7 +49,7 @@ public class BcweaverJarMaker { } public static void makeJar0() throws IOException { - List args = new ArrayList(); + List args = new ArrayList<>(); args.add("-outjar"); args.add("../weaver/testdata/tracing.jar"); @@ -63,7 +63,7 @@ public class BcweaverJarMaker { } public static void makeJar1() throws IOException { - List args = new ArrayList(); + List args = new ArrayList<>(); args.add("-outjar"); args.add("../weaver/testdata/megatrace.jar"); @@ -78,7 +78,7 @@ public class BcweaverJarMaker { public static void makeJarObviousNothing() throws IOException { - List args = new ArrayList(); + List args = new ArrayList<>(); args.add("-outjar"); args.add("../weaver/testdata/megatrace0easy.jar"); @@ -92,7 +92,7 @@ public class BcweaverJarMaker { } public static void makeJarHardNothing() throws IOException { - List args = new ArrayList(); + List args = new ArrayList<>(); args.add("-outjar"); args.add("../weaver/testdata/megatrace0hard.jar"); @@ -107,7 +107,7 @@ public class BcweaverJarMaker { public static void makeJar1a() throws IOException { - List args = new ArrayList(); + List args = new ArrayList<>(); args.add("-outjar"); args.add("../weaver/testdata/megatraceNoweave.jar"); @@ -124,7 +124,7 @@ public class BcweaverJarMaker { public static void makeJar2() throws IOException { - List args = new ArrayList(); + List args = new ArrayList<>(); args.add("-outjar"); args.add("../weaver/testdata/dummyAspect.jar"); @@ -137,7 +137,7 @@ public class BcweaverJarMaker { } public static void makeTestJars() throws IOException { - List args = new ArrayList(); + List args = new ArrayList<>(); args.add("-classpath"); args.add("../lib/test/aspectjrt.jar;../lib/test/testing-client.jar" + @@ -148,7 +148,7 @@ public class BcweaverJarMaker { CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS); - args = new ArrayList(); + args = new ArrayList<>(); args.add("-classpath"); args.add("../lib/test/aspectjrt.jar;../lib/test/testing-client.jar" + @@ -159,7 +159,7 @@ public class BcweaverJarMaker { CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS); - args = new ArrayList(); + args = new ArrayList<>(); args.add("-classpath"); args.add("../lib/test/aspectjrt.jar;../lib/test/testing-client.jar" + @@ -196,7 +196,7 @@ public class BcweaverJarMaker { } public static void makeURLWeavingClassLoaderJars() throws IOException { - List args = new ArrayList(); + List args = new ArrayList<>(); /* * Vanilla classes @@ -302,7 +302,7 @@ public class BcweaverJarMaker { private static void buildJarWithClasspath(String outjar,String input,String deps,boolean nodebug) { System.out.println(" Building "+outjar); - List args = new ArrayList(); + List args = new ArrayList<>(); if (nodebug) args.add("-g:none"); args.add("-classpath"); args.add("../lib/test/aspectjrt.jar;../lib/test/testing-client.jar" + @@ -332,7 +332,7 @@ public class BcweaverJarMaker { } public static void makeDuplicateManifestTestJars() throws IOException { - List args = new ArrayList(); + List args = new ArrayList<>(); /* * injar @@ -360,7 +360,7 @@ public class BcweaverJarMaker { } public static void makeAspectPathTestJars() throws IOException { - List args = new ArrayList(); + List args = new ArrayList<>(); args.clear(); args.add("-classpath"); @@ -372,7 +372,7 @@ public class BcweaverJarMaker { } public static void makeAjc11TestJars() throws IOException { - List args = new ArrayList(); + List args = new ArrayList<>(); args.clear(); args.add("-classpath"); @@ -384,7 +384,7 @@ public class BcweaverJarMaker { } public static void makeOutjarTestJars() throws IOException { - List args = new ArrayList(); + List args = new ArrayList<>(); /* * parent diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BinaryFormsTestCase.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BinaryFormsTestCase.java index d69906cdf..d43a3f340 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BinaryFormsTestCase.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BinaryFormsTestCase.java @@ -32,7 +32,7 @@ public class BinaryFormsTestCase extends CommandTestCase { public void testJar1() throws IOException { String library = getSandboxName() + "/lib.jar"; - List args = new ArrayList(); + List args = new ArrayList<>(); args.add("-outjar"); args.add(library); diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjCompilerOptionsTest.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjCompilerOptionsTest.java index 818bee537..1e94e300a 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjCompilerOptionsTest.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjCompilerOptionsTest.java @@ -46,9 +46,9 @@ public class AjCompilerOptionsTest extends TestCase { assertFalse(options.generateEmacsSymFiles); assertFalse(options.noAtAspectJProcessing); - Map map = options.getMap(); + Map map = options.getMap(); assertEquals(CompilerOptions.WARNING,map.get(AjCompilerOptions.OPTION_ReportInvalidAbsoluteTypeName)); - assertEquals(CompilerOptions.IGNORE,map.get(AjCompilerOptions.OPTION_ReportInvalidWildcardTypeName)); + assertEquals(CompilerOptions.WARNING,map.get(AjCompilerOptions.OPTION_ReportInvalidWildcardTypeName)); assertEquals(CompilerOptions.WARNING,map.get(AjCompilerOptions.OPTION_ReportUnresolvableMember)); assertEquals(CompilerOptions.WARNING,map.get(AjCompilerOptions.OPTION_ReportTypeNotExposedToWeaver)); assertEquals(CompilerOptions.IGNORE,map.get(AjCompilerOptions.OPTION_ReportShadowNotInStructure)); diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/VisitorTestCase.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/VisitorTestCase.java index 40d39359e..7fd131528 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/VisitorTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/VisitorTestCase.java @@ -15,7 +15,6 @@ import junit.framework.TestCase; import java.util.HashSet; import java.util.Set; -import java.util.Iterator; import java.io.LineNumberReader; import java.io.FileReader; @@ -28,8 +27,8 @@ import org.aspectj.weaver.patterns.TypePattern; */ public class VisitorTestCase extends TestCase { - private Set pointcuts = new HashSet(); - private Set typePatterns = new HashSet(); + private Set pointcuts = new HashSet<>(); + private Set typePatterns = new HashSet<>(); protected void setUp() throws Exception { super.setUp(); @@ -41,7 +40,7 @@ public class VisitorTestCase extends TestCase { rt.close(); } - private void feed(LineNumberReader r, Set set) throws Exception { + private void feed(LineNumberReader r, Set set) throws Exception { for (String line = r.readLine(); line != null; line = r.readLine()) { set.add(line); } @@ -51,8 +50,7 @@ public class VisitorTestCase extends TestCase { if (pointcuts.isEmpty()) { fail("Empty pointcuts file!"); } - for (Iterator iterator = pointcuts.iterator(); iterator.hasNext();) { - String pointcut = (String) iterator.next(); + for (String pointcut: pointcuts) { try { DumpPointcutVisitor.check(pointcut); } catch (Throwable t) { @@ -66,8 +64,7 @@ public class VisitorTestCase extends TestCase { if (typePatterns.isEmpty()) { fail("Empty typePatterns file!"); } - for (Iterator iterator = typePatterns.iterator(); iterator.hasNext();) { - String tp = (String) iterator.next(); + for (String tp: typePatterns) { try { TypePattern p = new PatternParser(tp).parseTypePattern(); DumpPointcutVisitor.check(p, true); diff --git a/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip b/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip index f950bd813..29a5eb821 100644 Binary files a/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip and b/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip differ diff --git a/org.eclipse.jdt.core/jdtcore-for-aspectj.jar b/org.eclipse.jdt.core/jdtcore-for-aspectj.jar index 63115ed1f..6aa41c4c1 100644 Binary files a/org.eclipse.jdt.core/jdtcore-for-aspectj.jar and b/org.eclipse.jdt.core/jdtcore-for-aspectj.jar differ diff --git a/testing-client/src/org/aspectj/testing/Tester.java b/testing-client/src/org/aspectj/testing/Tester.java index afd37a492..500c4c363 100644 --- a/testing-client/src/org/aspectj/testing/Tester.java +++ b/testing-client/src/org/aspectj/testing/Tester.java @@ -51,10 +51,10 @@ public class Tester { private static Set notes; /** List to hold events submitted. */ - private static List actualEvents = new ArrayList(); + private static List actualEvents = new ArrayList<>(); /** List to hold events we expect. */ - private static List expectedEvents = new ArrayList(); + private static List expectedEvents = new ArrayList<>(); static { setBASEDIR(new File(".")); @@ -103,8 +103,8 @@ public class Tester { /** XXX deprecated #clear() */ public static void clearEvents() { - actualEvents = new ArrayList(); - expectedEvents = new ArrayList(); + actualEvents = new ArrayList<>(); + expectedEvents = new ArrayList<>(); } @@ -707,10 +707,10 @@ public class Tester { } /** @return String[] of differences '{un}expected msg "..." {not} found' */ - private static String[] diffIgnoreDups(Collection set, String[] expected, String msg, + private static String[] diffIgnoreDups(Collection set, String[] expected, String msg, boolean ignoreDups) { - ArrayList result = new ArrayList(); - ArrayList actual = new ArrayList(set); + ArrayList result = new ArrayList<>(); + ArrayList actual = new ArrayList<>(set); BitSet hits = new BitSet(); for (int i = 0; i < expected.length; i++) { if (!actual.remove(expected[i])) { @@ -722,8 +722,7 @@ public class Tester { } } } - for (Iterator iter = actual.iterator(); iter.hasNext();) { - String act = (String) iter.next(); + for (String act: actual) { result.add(" unexpected " + msg + " \"" + act + "\" found"); } return (String[]) result.toArray(new String[0]); diff --git a/testing-client/src/org/aspectj/testing/server/TestServer.java b/testing-client/src/org/aspectj/testing/server/TestServer.java index b7b0d762b..12e8d097e 100644 --- a/testing-client/src/org/aspectj/testing/server/TestServer.java +++ b/testing-client/src/org/aspectj/testing/server/TestServer.java @@ -32,7 +32,7 @@ public class TestServer implements Runnable { private boolean exitOnError = true; private File workingDirectory; private ClassLoader rootLoader; - private Map loaders = new HashMap(); + private Map loaders = new HashMap<>(); private String mainClass = "UnknownClass"; private String mainLoader = "UnknownLoader"; @@ -75,7 +75,7 @@ public class TestServer implements Runnable { if (parent == null) error("No such loader: " + parentName); } - List urlList = new ArrayList(); + List urlList = new ArrayList<>(); st = new StringTokenizer(classpath,";"); while (st.hasMoreTokens()) { String fileName = st.nextToken(); @@ -93,7 +93,7 @@ public class TestServer implements Runnable { } private void createRootLoader () throws IOException { - List urlList = new ArrayList(); + List urlList = new ArrayList(); /* Sandbox */ URL url = workingDirectory.getCanonicalFile().toURL(); diff --git a/testing-client/testsrc/org/aspectj/testing/TesterTest.java b/testing-client/testsrc/org/aspectj/testing/TesterTest.java index c2fceb81a..d538a63f7 100644 --- a/testing-client/testsrc/org/aspectj/testing/TesterTest.java +++ b/testing-client/testsrc/org/aspectj/testing/TesterTest.java @@ -167,8 +167,8 @@ public class TesterTest extends TestCase { * @author isberg */ public static class MyTestReporter implements IMessageHandler { - public ArrayList failures = new ArrayList(); - public ArrayList passes = new ArrayList(); + public ArrayList failures = new ArrayList<>(); + public ArrayList passes = new ArrayList<>(); public void clear() { failures.clear(); @@ -188,9 +188,8 @@ public class TesterTest extends TestCase { return gotItem(failures, substring); } - boolean gotItem(List list, String substring) { - for (Iterator iterator = list.iterator(); iterator.hasNext(); ) { - IMessage element = (IMessage) iterator.next(); + boolean gotItem(List list, String substring) { + for (IMessage element: list) { String s = element.getMessage(); if ((null != s) && (-1 != s.indexOf(substring))) { return true; diff --git a/tests/bugs1810/502807/TestCollectors.java b/tests/bugs1810/502807/TestCollectors.java new file mode 100644 index 000000000..323fb76ce --- /dev/null +++ b/tests/bugs1810/502807/TestCollectors.java @@ -0,0 +1,36 @@ +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Collectors; + +public class TestCollectors { + Set ids; + + public TestCollectors(Set inners) { + ids = inners.stream().collect(Collectors.toList(Inner::getId)); +// ids = inners.stream().map(Inner::getId).collect(Collectors.toSet()); + } + + public static void main() { + Set inners = new HashSet<>(); + inners.add(new Inner(1, "a")); + inners.add(new Inner(1, "a")); + + new TestCollectors(inners); + } + + + public static class Inner { + private int id; + private String name; + + public Inner(int id, String name) { + this.id = id; + this.name = name; + } + + public int getId() { return id; } + + public String getName() { return name; } + } +} + diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index c8a068c78..b368e77e0 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -4545,8 +4545,8 @@ - - + + diff --git a/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java b/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java index 3af4bb79c..6122b1638 100644 --- a/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java @@ -30,6 +30,10 @@ import org.aspectj.testing.XMLBasedAjcTestCase; */ public class Ajc1810Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + public void testAIOOBE_502807() { + runTest("unexpected aioobe"); + } + public void testInvokeDynamic_490315() { runTest("indy"); } diff --git a/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml b/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml index e53b8aabe..065420da3 100644 --- a/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml +++ b/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml @@ -18,5 +18,11 @@ + + + + + + diff --git a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java index 869ed5819..0b02041ab 100644 --- a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java +++ b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java @@ -24,7 +24,6 @@ import java.util.List; import java.util.ListIterator; import java.util.Map; import java.util.Set; -import java.util.Stack; import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.classfile.Attribute; @@ -688,8 +687,7 @@ public final class LazyMethodGen implements Traceable { } } int ecounter = 0; - for (Iterator i = exnTable.iterator(); i.hasNext();) { - ExceptionRange er = (ExceptionRange) i.next(); + for (ExceptionRange er: exnTable) { String exceptionLabel = "E" + ecounter++; labelMap.put(Range.getRealStart(er.getHandler()), exceptionLabel); labelMap.put(er.getHandler(), exceptionLabel); diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/ArgsWeaveTestCase.java b/weaver/testsrc/org/aspectj/weaver/bcel/ArgsWeaveTestCase.java index 3148cbdaf..8e7f72f4f 100644 --- a/weaver/testsrc/org/aspectj/weaver/bcel/ArgsWeaveTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/bcel/ArgsWeaveTestCase.java @@ -22,6 +22,7 @@ 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.Type; +import org.aspectj.weaver.Advice; import org.aspectj.weaver.AdviceKind; import org.aspectj.weaver.MemberImpl; import org.aspectj.weaver.ResolvedType; @@ -54,8 +55,7 @@ public class ArgsWeaveTestCase extends WeaveTestCase { } public void testLots() throws IOException { - List l = new ArrayList(); - + List l = new ArrayList(); BcelAdvice p1 = makeArgsMunger("before"); @@ -70,7 +70,6 @@ public class ArgsWeaveTestCase extends WeaveTestCase { l.add(p2); l.add(p3); - weaveTest("HelloWorld", "ArgsBeforeAfterHelloWorld", addLexicalOrder(l)); } diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/MemberTestCase15.java b/weaver5/java5-testsrc/org/aspectj/weaver/MemberTestCase15.java index 7838c0696..f44095a0e 100644 --- a/weaver5/java5-testsrc/org/aspectj/weaver/MemberTestCase15.java +++ b/weaver5/java5-testsrc/org/aspectj/weaver/MemberTestCase15.java @@ -11,8 +11,6 @@ * ******************************************************************/ package org.aspectj.weaver; -import java.util.List; - import org.aspectj.weaver.bcel.BcelWorld; import junit.framework.TestCase; -- cgit v1.2.3 From 611e04a9e1f3f2368f3ce3237b6288b119ac9943 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Mon, 7 Nov 2016 16:18:54 -0800 Subject: Fix 500796: Allow for kotlin creating 'synthetic' local variable table entries --- .../org/aspectj/apache/bcel/generic/MethodGen.java | 21 +++++++++++++++++---- lib/bcel/bcel-src.zip | Bin 326975 -> 327092 bytes lib/bcel/bcel-verifier-src.zip | Bin 183372 -> 183372 bytes lib/bcel/bcel-verifier.jar | Bin 161556 -> 161556 bytes lib/bcel/bcel.jar | Bin 285423 -> 285489 bytes .../systemtest/ajc150/AnnotationBinding.java | 7 ++++--- .../systemtest/ajc150/GenericITDsDesign.java | 13 +++++++------ .../aspectj/systemtest/ajc150/GenericsTests.java | 12 +++++------- .../org/aspectj/systemtest/ajc160/SanityTests.java | 1 + .../aspectj/systemtest/ajc1610/NewFeatures.java | 1 + .../org/aspectj/systemtest/ajc163/Ajc163Tests.java | 6 ++---- weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java | 1 - .../org/aspectj/weaver/bcel/BcelTypeMunger.java | 1 - .../src/org/aspectj/weaver/bcel/LazyMethodGen.java | 3 ++- .../org/aspectj/weaver/bcel/UnwovenClassFile.java | 4 ++-- .../org/aspectj/weaver/bcel/WorldTestCase.java | 2 -- 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 Binary files a/lib/bcel/bcel-src.zip and b/lib/bcel/bcel-src.zip differ diff --git a/lib/bcel/bcel-verifier-src.zip b/lib/bcel/bcel-verifier-src.zip index bf5a86a3e..c6a16a60b 100644 Binary files a/lib/bcel/bcel-verifier-src.zip and b/lib/bcel/bcel-verifier-src.zip differ diff --git a/lib/bcel/bcel-verifier.jar b/lib/bcel/bcel-verifier.jar index 7ca7ec48b..05c04d096 100644 Binary files a/lib/bcel/bcel-verifier.jar and b/lib/bcel/bcel-verifier.jar differ diff --git a/lib/bcel/bcel.jar b/lib/bcel/bcel.jar index 5da57de72..fdfd8deda 100644 Binary files a/lib/bcel/bcel.jar and b/lib/bcel/bcel.jar 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 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 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 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 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 tmungers = cmembers.getTypeMungers(); return tmungers; } @@ -100,9 +101,9 @@ public class GenericITDsDesign extends XMLBasedAjcTestCase { return null; } - public Hashtable getMeTheFields(String classname) { + public Hashtable getMeTheFields(String classname) { JavaClass theClass = getClassFromDisk(ajc, classname); - Hashtable retval = new Hashtable(); + Hashtable 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 fields = getMeTheFields("C"); // Declared in src as: List C.list1; and List C.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 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 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[] 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 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.emptyList()); } - public void writeWovenBytes(byte[] bytes, List childClasses) throws IOException { + public void writeWovenBytes(byte[] bytes, List 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; -- cgit v1.2.3 From f33db67c2e3d840b19896f4ec45dd1078eb412dc Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Thu, 10 Nov 2016 12:13:43 -0800 Subject: Fix 404345: another occurence of broken annotation building in JDT --- org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip | Bin 5207300 -> 5207302 bytes org.eclipse.jdt.core/jdtcore-for-aspectj.jar | Bin 10253487 -> 10253519 bytes .../pr404345/base/src/org/Constants.java | 5 ++ .../pr404345/base/src/org/FetchProfile.java | 16 +++++++ .../pr404345/base/src/org/FetchProfileName.java | 5 ++ .../pr404345/base/src/org/FetchProfiles.java | 10 ++++ .../pr404345/base/src/org/package-info.java | 9 ++++ .../pr404345/inc1/src/org/Constants.java | 3 ++ .../pr404345/inc1/src/org/FetchProfileName.java | 5 ++ .../pr404345/inc2/src/org/package-info.java | 2 + .../incremental/tools/AjdeInteractionTestbed.java | 7 ++- .../tools/MultiProjTestCompilerConfiguration.java | 36 +++++++-------- .../tools/MultiProjTestMessageHandler.java | 10 ++-- .../tools/MultiProjectIncrementalTests.java | 51 +++++++++++---------- 14 files changed, 107 insertions(+), 52 deletions(-) create mode 100644 tests/multiIncremental/pr404345/base/src/org/Constants.java create mode 100644 tests/multiIncremental/pr404345/base/src/org/FetchProfile.java create mode 100644 tests/multiIncremental/pr404345/base/src/org/FetchProfileName.java create mode 100644 tests/multiIncremental/pr404345/base/src/org/FetchProfiles.java create mode 100644 tests/multiIncremental/pr404345/base/src/org/package-info.java create mode 100644 tests/multiIncremental/pr404345/inc1/src/org/Constants.java create mode 100644 tests/multiIncremental/pr404345/inc1/src/org/FetchProfileName.java create mode 100644 tests/multiIncremental/pr404345/inc2/src/org/package-info.java diff --git a/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip b/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip index 29a5eb821..76d1be79c 100644 Binary files a/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip and b/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip differ diff --git a/org.eclipse.jdt.core/jdtcore-for-aspectj.jar b/org.eclipse.jdt.core/jdtcore-for-aspectj.jar index 6aa41c4c1..3ef06f537 100644 Binary files a/org.eclipse.jdt.core/jdtcore-for-aspectj.jar and b/org.eclipse.jdt.core/jdtcore-for-aspectj.jar differ diff --git a/tests/multiIncremental/pr404345/base/src/org/Constants.java b/tests/multiIncremental/pr404345/base/src/org/Constants.java new file mode 100644 index 000000000..c09fdf3db --- /dev/null +++ b/tests/multiIncremental/pr404345/base/src/org/Constants.java @@ -0,0 +1,5 @@ +package org; + +public class Constants { + public static final String MISSING="missing"; +} diff --git a/tests/multiIncremental/pr404345/base/src/org/FetchProfile.java b/tests/multiIncremental/pr404345/base/src/org/FetchProfile.java new file mode 100644 index 000000000..5ad345d35 --- /dev/null +++ b/tests/multiIncremental/pr404345/base/src/org/FetchProfile.java @@ -0,0 +1,16 @@ +package org; + +public @interface FetchProfile { + String name(); + FetchProfile.FetchOverride[] fetchOverrides(); + + @interface FetchOverride { + Class entity(); + String association() default ""; + } +} + +//@FetchProfiles({ +//@FetchProfile(name = FetchProfileName.LOCATION, fetchOverrides = { +// @FetchProfile.FetchOverride(entity = Location.class, association = Location.PROPERTY_SYSTEMSTATE), +// @FetchProfile.FetchOverride(entity = Location.class, association = Location.PROPERTY_KEYVAULT) }), diff --git a/tests/multiIncremental/pr404345/base/src/org/FetchProfileName.java b/tests/multiIncremental/pr404345/base/src/org/FetchProfileName.java new file mode 100644 index 000000000..b7d9af0c7 --- /dev/null +++ b/tests/multiIncremental/pr404345/base/src/org/FetchProfileName.java @@ -0,0 +1,5 @@ +package org; + +public class FetchProfileName { + public static final String LOCATION="missing"; +} diff --git a/tests/multiIncremental/pr404345/base/src/org/FetchProfiles.java b/tests/multiIncremental/pr404345/base/src/org/FetchProfiles.java new file mode 100644 index 000000000..bba90b09c --- /dev/null +++ b/tests/multiIncremental/pr404345/base/src/org/FetchProfiles.java @@ -0,0 +1,10 @@ +package org; + +public @interface FetchProfiles { + FetchProfile[] value(); +} + +//@FetchProfiles({ +//@FetchProfile(name = FetchProfileName.LOCATION, fetchOverrides = { +// @FetchProfile.FetchOverride(entity = Location.class, association = Location.PROPERTY_SYSTEMSTATE), +// @FetchProfile.FetchOverride(entity = Location.class, association = Location.PROPERTY_KEYVAULT) }), \ No newline at end of file diff --git a/tests/multiIncremental/pr404345/base/src/org/package-info.java b/tests/multiIncremental/pr404345/base/src/org/package-info.java new file mode 100644 index 000000000..c1e4ee1b8 --- /dev/null +++ b/tests/multiIncremental/pr404345/base/src/org/package-info.java @@ -0,0 +1,9 @@ +//@FetchProfiles({ + @FetchProfile(name = FetchProfileName.LOCATION, fetchOverrides = { +// @FetchProfile.FetchOverride(entity = Location.class, association = Location.PROPERTY_SYSTEMSTATE), + @FetchProfile.FetchOverride(entity = Location.class, association = Location.PROPERTY_KEYVAULT) +}) +//}) +package org; + + diff --git a/tests/multiIncremental/pr404345/inc1/src/org/Constants.java b/tests/multiIncremental/pr404345/inc1/src/org/Constants.java new file mode 100644 index 000000000..851d68292 --- /dev/null +++ b/tests/multiIncremental/pr404345/inc1/src/org/Constants.java @@ -0,0 +1,3 @@ +package org; +class Constants { +} diff --git a/tests/multiIncremental/pr404345/inc1/src/org/FetchProfileName.java b/tests/multiIncremental/pr404345/inc1/src/org/FetchProfileName.java new file mode 100644 index 000000000..b7d9af0c7 --- /dev/null +++ b/tests/multiIncremental/pr404345/inc1/src/org/FetchProfileName.java @@ -0,0 +1,5 @@ +package org; + +public class FetchProfileName { + public static final String LOCATION="missing"; +} diff --git a/tests/multiIncremental/pr404345/inc2/src/org/package-info.java b/tests/multiIncremental/pr404345/inc2/src/org/package-info.java new file mode 100644 index 000000000..9ffa9f10f --- /dev/null +++ b/tests/multiIncremental/pr404345/inc2/src/org/package-info.java @@ -0,0 +1,2 @@ +@Foo(Constants.MISSING) +package org; diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java b/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java index 9b6c11e90..cfe4495a4 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java @@ -335,9 +335,8 @@ public class AjdeInteractionTestbed extends TestCase { MultiProjTestMessageHandler handler = (MultiProjTestMessageHandler) compiler.getMessageHandler(); if (handler.hasErrorMessages()) { System.err.println("Build errors:"); - for (Iterator iter = handler.getErrorMessages().iterator(); iter.hasNext();) { - IMessage element = iter.next(); - System.err.println(element); + for (IMessage message: handler.getErrorMessages()) { + System.err.println(message); } System.err.println("---------"); } @@ -358,7 +357,7 @@ public class AjdeInteractionTestbed extends TestCase { return ((MultiProjTestMessageHandler) compiler.getMessageHandler()).getWeavingMessages(); } - public List getCompilerErrorMessages(String projectName) { + public List getCompilerErrorMessages(String projectName) { AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); return ((MultiProjTestMessageHandler) compiler.getMessageHandler()).getCompilerErrors(); } diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java index 562291c69..86302bfba 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java @@ -13,7 +13,6 @@ package org.aspectj.systemtest.incremental.tools; import java.io.File; import java.util.ArrayList; import java.util.Hashtable; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -30,11 +29,11 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio private boolean verbose = false; private String classPath = ""; - private Set aspectPath = null; - private Map sourcePathResources = null; + private Set aspectPath = null; + private Map sourcePathResources = null; private IOutputLocationManager outputLocationManager = null; private List dependants; - private Map javaOptionsMap; + private Map javaOptionsMap; private Set inpath; private String encoding = null; private String outjar; @@ -43,8 +42,8 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio private String nonstandardoptions; private List modifiedFiles; private List modifiedDirs; - private List projectSourceFiles = new ArrayList(); - private List xmlConfigFiles = new ArrayList(); + private List projectSourceFiles = new ArrayList<>(); + private List xmlConfigFiles = new ArrayList<>(); private String projectPath; int changed; @@ -53,7 +52,7 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio this.projectPath = projectPath; } - public Set getAspectPath() { + public Set getAspectPath() { log("ICompilerConfiguration.getAspectPath(" + aspectPath + ")"); return aspectPath; } @@ -62,9 +61,8 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio log("ICompilerConfiguration.getClasspath()"); // AJDT has all the output directories on it's classpath StringBuffer sb = new StringBuffer(); - List allOutputPaths = getOutputLocationManager().getAllOutputLocations(); - for (Iterator iterator = allOutputPaths.iterator(); iterator.hasNext();) { - File dir = (File) iterator.next(); + List allOutputPaths = getOutputLocationManager().getAllOutputLocations(); + for (File dir: allOutputPaths) { sb.append(File.pathSeparator + dir.getAbsolutePath()); } String cp = sb.toString() + File.pathSeparator + new File(AjdeInteractionTestbed.testdataSrcDir) + File.pathSeparator @@ -77,8 +75,8 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio // look at dependant projects if (dependants != null) { - for (Iterator iter = dependants.iterator(); iter.hasNext();) { - cp = AjdeInteractionTestbed.getFile((String) iter.next(), "bin") + File.pathSeparator + cp; + for (String dependant: dependants) { + cp = AjdeInteractionTestbed.getFile(dependant, "bin") + File.pathSeparator + cp; } } // System.err.println("For project "+projectPath+" getClasspath() returning "+cp); @@ -120,12 +118,12 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio return outputLocationManager; } - public List getProjectSourceFiles() { + public List getProjectSourceFiles() { log("ICompilerConfiguration.getProjectSourceFiles()"); return projectSourceFiles; } - public List getProjectXmlConfigFiles() { + public List getProjectXmlConfigFiles() { return xmlConfigFiles; } @@ -134,7 +132,7 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio return modifiedFiles; } - public Map getSourcePathResources() { + public Map getSourcePathResources() { log("ICompilerConfiguration.getSourcePathResources()"); return sourcePathResources; } @@ -152,7 +150,7 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio } // -------------------- setter methods useful for testing --------------- - public void setAspectPath(Set aspectPath) { + public void setAspectPath(Set aspectPath) { this.aspectPath = aspectPath; this.changed |= ICompilerConfiguration.ASPECTPATH_CHANGED; } @@ -177,7 +175,7 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio this.changed |= ICompilerConfiguration.PROCESSOR_CHANGED; } - public void setJavaOptions(Map javaOptions) { + public void setJavaOptions(Map javaOptions) { this.javaOptionsMap = javaOptions; this.changed |= ICompilerConfiguration.JAVAOPTIONS_CHANGED; } @@ -215,7 +213,7 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio } } - public void setSourcePathResources(Map sourcePathResources) { + public void setSourcePathResources(Map sourcePathResources) { this.sourcePathResources = sourcePathResources; this.changed |= ICompilerConfiguration.PROJECTSOURCERESOURCES_CHANGED; } @@ -240,7 +238,7 @@ public class MultiProjTestCompilerConfiguration implements ICompilerConfiguratio modifiedDirs = null; } - public List getClasspathElementsWithModifiedContents() { + public List getClasspathElementsWithModifiedContents() { return modifiedDirs; } diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestMessageHandler.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestMessageHandler.java index 26afbf882..fa66bede7 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestMessageHandler.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestMessageHandler.java @@ -32,15 +32,15 @@ public class MultiProjTestMessageHandler implements IBuildMessageHandler { private List errorMessages; private List warningMessages; private List weavingMessages; - private List compilerErrors; - private List ignoring; + private List compilerErrors; + private List ignoring; public MultiProjTestMessageHandler() { - ignoring = new ArrayList(); + ignoring = new ArrayList<>(); errorMessages = new ArrayList(); warningMessages = new ArrayList(); weavingMessages = new ArrayList(); - compilerErrors = new ArrayList(); + compilerErrors = new ArrayList<>(); ignore(IMessage.INFO); ignore(IMessage.WEAVEINFO); } @@ -112,7 +112,7 @@ public class MultiProjTestMessageHandler implements IBuildMessageHandler { return weavingMessages; } - public List getCompilerErrors() { + public List getCompilerErrors() { return compilerErrors; } diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java index 7080c03c9..36001fe6a 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java @@ -14,8 +14,6 @@ package org.aspectj.systemtest.incremental.tools; import java.io.File; import java.io.IOException; import java.io.PrintWriter; -import java.net.URL; -import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -101,7 +99,16 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa runMethod(p, "demo.ConverterTest", "run"); } - + public void testRogueConstantReference() throws Exception { + String p = "pr404345"; + initialiseProject(p); + setProjectEncoding(p, "UTF-8"); + build(p); + checkWasFullBuild(); + // Should both indicate that Location cannot be resolved + assertEquals(2,getErrorMessages(p).size()); + } + public void testIncrementalITDInners4() throws Exception { String p = "prInner4"; initialiseProject(p); @@ -1150,7 +1157,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa alter(p, "inc1"); build(p); checkWasntFullBuild(); - List l = getCompilerErrorMessages(p); + List l = getCompilerErrorMessages(p); assertEquals("Unexpected compiler error", 0, l.size()); } @@ -1159,14 +1166,14 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa String p = "pr298504"; initialiseProject(p); build(p); - List l = getErrorMessages(p); + List l = getErrorMessages(p); assertTrue(l.toString().indexOf("ManagedResource cannot be resolved to a type") != -1); // checkWasFullBuild(); alter(p, "inc1"); build(p); // checkWasntFullBuild(); - l = getCompilerErrorMessages(p); - assertTrue(l.toString().indexOf("NullPointerException") == -1); + List compilerErrors = getCompilerErrorMessages(p); + assertTrue(compilerErrors.toString().indexOf("NullPointerException") == -1); l = getErrorMessages(p); assertTrue(l.toString().indexOf("ManagedResource cannot be resolved to a type") != -1); } @@ -1210,7 +1217,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // "src/q/Asp.java")); build(p); checkWasntFullBuild(); - List l = getCompilerErrorMessages(p); + List l = getCompilerErrorMessages(p); assertEquals("Unexpected compiler error", 0, l.size()); } @@ -1245,7 +1252,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa alter(p, "inc1"); build(p); checkWasntFullBuild(); - List l = getCompilerErrorMessages(p); + List l = getCompilerErrorMessages(p); assertEquals("Unexpected compiler error", 0, l.size()); } @@ -1263,7 +1270,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa checkWasFullBuild(); alter(p, "inc1"); build(p); - List l = getCompilerErrorMessages(p); + List l = getCompilerErrorMessages(p); assertEquals("Unexpected compiler error", 0, l.size()); } @@ -1909,7 +1916,6 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa + "ms second=" + timeTakenForSimpleIncBuild + "ms", timeTakenForSimpleIncBuild < timeTakenForFullBuildAndWeave); } - @SuppressWarnings("rawtypes") public void testBuildingTwoProjectsInTurns() { initialiseProject("P1"); initialiseProject("P2"); @@ -2114,7 +2120,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa long stime = System.currentTimeMillis(); try { ZipFile zf = new ZipFile("c:/jvms/jdk1.6.0_06/jre/lib/rt.jar"); - Enumeration e = zf.entries(); + Enumeration e = zf.entries(); while (e.hasMoreElements()) { ZipEntry ze = (ZipEntry) e.nextElement(); String n = ze.getName(); @@ -3052,12 +3058,11 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa getWarningMessages("PR133117").size() == 1); alter("PR133117", "inc1"); build("PR133117"); - List warnings = getWarningMessages("PR133117"); - List noGuardWarnings = new ArrayList(); - for (Iterator iter = warnings.iterator(); iter.hasNext();) { - IMessage element = (IMessage) iter.next(); - if (element.getMessage().indexOf("Xlint:noGuardForLazyTjp") != -1) { - noGuardWarnings.add(element); + List warnings = getWarningMessages("PR133117"); + List noGuardWarnings = new ArrayList<>(); + for (IMessage warning: warnings) { + if (warning.getMessage().indexOf("Xlint:noGuardForLazyTjp") != -1) { + noGuardWarnings.add(warning); } } assertTrue("There should only be two Xlint:noGuardForLazyTjp warning message reported:\n" + noGuardWarnings, @@ -3687,7 +3692,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa configureJavaOptionsMap("PR164384", javaOptions); build("PR164384"); - List errors = getErrorMessages("PR164384"); + List errors = getErrorMessages("PR164384"); if (getCompilerForProjectWithName("PR164384").isJava6Compatible()) { assertTrue("There should be no errros:\n" + errors, errors.isEmpty()); @@ -3957,9 +3962,8 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa return ipe; } } - List kids = ipe.getChildren(); - for (Iterator iter = kids.iterator(); iter.hasNext();) { - IProgramElement kid = (IProgramElement) iter.next(); + List kids = ipe.getChildren(); + for (IProgramElement kid: kids) { IProgramElement found = findAdvice(kid, whichOne); if (found != null) { return found; @@ -3986,8 +3990,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } } List kids = ipe.getChildren(); - for (Iterator iter = kids.iterator(); iter.hasNext();) { - IProgramElement kid = (IProgramElement) iter.next(); + for (IProgramElement kid: kids) { IProgramElement found = findCode(kid, linenumber); if (found != null) { return found; -- cgit v1.2.3 From e8be95bbfd291f93319d1a1e9920e44cd7eb7569 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Thu, 10 Nov 2016 14:07:57 -0800 Subject: Fix 502119: InterTypeFieldBinding.java:122 - NullPointerException --- .../aspectj/ajdt/internal/compiler/lookup/InterTypeFieldBinding.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeFieldBinding.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeFieldBinding.java index 14f08f79a..c71d8e821 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeFieldBinding.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeFieldBinding.java @@ -60,6 +60,9 @@ public class InterTypeFieldBinding extends FieldBinding { // System.out.println("receiver: " + receiverType + ", " + invocationType); ReferenceBinding declaringType = declaringClass; + if (invocationType == null) // static import call + return !isPrivate() && scope.getCurrentPackage() == receiverType.getPackage(); + // FIXME asc what about parameterized types and private ITD generic fields on interfaces? // Don't work with a raw type, work with the generic type -- cgit v1.2.3 From b6f2b6337fbaf95b78c20862cd90f0e027509531 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Fri, 18 Nov 2016 09:00:28 -0800 Subject: Fix 500035: handling target only binding in @AJ pointcut --- ajde/src/org/aspectj/ajde/Ajde.java | 2 +- .../org/aspectj/apache/bcel/generic/MethodGen.java | 2 +- .../bcel/util/NonCachingClassLoaderRepository.java | 6 +- .../classfile/tests/ParameterAnnotationsTest.java | 2 +- bridge/src/org/aspectj/bridge/Version.java | 4 +- .../bridge/context/PinpointingMessageHandler.java | 15 ++- .../org/aspectj/build/BuildModuleTests.java | 2 +- .../aspectj/internal/build/BuildModuleTest.java | 2 +- .../org/aspectj/internal/build/ModulesTest.java | 2 +- lib/aspectj/lib/aspectjrt.jar | Bin 117093 -> 118776 bytes lib/test/aspectjrt.jar | Bin 117093 -> 118776 bytes .../aspectj/weaver/patterns/DeclareParents.java | 4 +- .../org/aspectj/runtime/reflect/JoinPointImpl.java | 14 ++- .../internal/tools/ant/taskdefs/Ajctest.java | 124 ++++++++++----------- .../internal/tools/ant/taskdefs/MainWrapper.java | 4 +- .../testing/harness/bridge/AbstractRunSpec.java | 14 +-- .../testing/harness/bridge/AjcMessageHandler.java | 6 +- .../aspectj/testing/harness/bridge/DirChanges.java | 22 ++-- .../testing/harness/bridge/FlatSuiteReader.java | 16 ++- tests/bugs1810/500035/Code.java | 30 +++++ tests/bugs1810/500035/Code2.java | 30 +++++ tests/bugs1810/500035/Code3.java | 76 +++++++++++++ tests/bugs1810/500035/Code4.java | 35 ++++++ tests/bugs1810/501656/ApplicationException.java | 9 ++ .../501656/ApplicationExceptionHandler.java | 17 +++ tests/bugs1810/501656/Code.java | 4 + .../out/com/myapp/ApplicationException.class | Bin 0 -> 499 bytes .../aspectj/systemtest/ajc150/GenericsTests.java | 5 +- .../org/aspectj/systemtest/ajc151/Ajc151Tests.java | 7 +- .../systemtest/ajc151/NewarrayJoinpointTests.java | 7 +- .../ajc152/SynchronizationTransformTests.java | 13 +-- .../systemtest/ajc180/AllTestsAspectJ180.java | 2 - .../aspectj/systemtest/ajc1810/Ajc1810Tests.java | 30 +++-- .../src/org/aspectj/systemtest/ajc1810/ajc1810.xml | 68 +++++++++++ .../systemtest/ajc182/AllTestsAspectJ182.java | 1 - .../org/aspectj/systemtest/ajc185/Ajc185Tests.java | 9 +- .../org/aspectj/systemtest/ajc187/Ajc187Tests.java | 7 +- .../systemtest/ajc187/AllTestsAspectJ187.java | 1 - .../systemtest/ajc188/AllTestsAspectJ188.java | 1 - .../incremental/tools/AjdeInteractionTestbed.java | 14 +-- .../IncrementalOutputLocationManagerTests.java | 10 +- .../tools/MoreOutputLocationManagerTests.java | 55 +++++---- .../tools/MultiProjTestOutputLocationManager.java | 6 +- .../tools/MultiProjectIncrementalTests.java | 13 +-- .../tools/OutputLocationManagerTests.java | 12 +- weaver/src/org/aspectj/weaver/bcel/BcelShadow.java | 16 +-- 46 files changed, 486 insertions(+), 233 deletions(-) create mode 100644 tests/bugs1810/500035/Code.java create mode 100644 tests/bugs1810/500035/Code2.java create mode 100644 tests/bugs1810/500035/Code3.java create mode 100644 tests/bugs1810/500035/Code4.java create mode 100644 tests/bugs1810/501656/ApplicationException.java create mode 100644 tests/bugs1810/501656/ApplicationExceptionHandler.java create mode 100644 tests/bugs1810/501656/Code.java create mode 100644 tests/bugs1810/501656/out/com/myapp/ApplicationException.class diff --git a/ajde/src/org/aspectj/ajde/Ajde.java b/ajde/src/org/aspectj/ajde/Ajde.java index bd1e77f42..2e25e50fc 100644 --- a/ajde/src/org/aspectj/ajde/Ajde.java +++ b/ajde/src/org/aspectj/ajde/Ajde.java @@ -101,7 +101,7 @@ public class Ajde { INSTANCE.compilerConfig = compilerConfig; INSTANCE.uiBuildMsgHandler = uiBuildMessageHandler; INSTANCE.buildProgressMonitor = monitor; - INSTANCE.asm = AsmManager.createNewStructureModel(Collections.EMPTY_MAP); + INSTANCE.asm = AsmManager.createNewStructureModel(Collections.emptyMap()); INSTANCE.iconRegistry = iconRegistry; INSTANCE.ideUIAdapter = ideUIAdapter; 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 21673dec0..3938beb35 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/MethodGen.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/MethodGen.java @@ -1082,7 +1082,7 @@ public class MethodGen extends FieldGenOrMethodGen { /** * Return a list of AnnotationGen objects representing parameter annotations */ - public List getAnnotationsOnParameter(int i) { + public List 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 loadedClasses = new SoftHashMap(); // CLASSNAME X JAVACLASS + private final Map loadedClasses = new SoftHashMap(); public static class SoftHashMap extends AbstractMap { private Map map; @@ -96,10 +96,10 @@ public class NonCachingClassLoaderRepository implements Repository { } public SoftHashMap() { - this(new HashMap()); + this(new HashMap()); } - public SoftHashMap(Map map, boolean b) { + public SoftHashMap(Map 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 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 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); diff --git a/bridge/src/org/aspectj/bridge/Version.java b/bridge/src/org/aspectj/bridge/Version.java index 028cdd96d..835127c75 100644 --- a/bridge/src/org/aspectj/bridge/Version.java +++ b/bridge/src/org/aspectj/bridge/Version.java @@ -37,13 +37,13 @@ public class Version { * Time text set by build script using SIMPLE_DATE_FORMAT. * (if DEVELOPMENT version, invalid) */ - public static final String time_text = ""; + public static final String time_text = "Friday Nov 18, 2016 at 16:34:52 GMT"; /** * time in seconds-since-... format, used by programmatic clients. * (if DEVELOPMENT version, NOTIME) */ - private static long time = -1; // -1 = uninitialized + private static long time = -1; // -1 == uninitialized /** format used by build script to set time_text */ public static final String SIMPLE_DATE_FORMAT = "EEEE MMM d, yyyy 'at' HH:mm:ss z"; diff --git a/bridge/src/org/aspectj/bridge/context/PinpointingMessageHandler.java b/bridge/src/org/aspectj/bridge/context/PinpointingMessageHandler.java index d9465c322..c54ff6789 100644 --- a/bridge/src/org/aspectj/bridge/context/PinpointingMessageHandler.java +++ b/bridge/src/org/aspectj/bridge/context/PinpointingMessageHandler.java @@ -102,15 +102,14 @@ public class PinpointingMessageHandler implements IMessageHandler { public Throwable getThrown() { return delegate.getThrown();} public ISourceLocation getSourceLocation() { return delegate.getSourceLocation();} public String getDetails() { return delegate.getDetails();} - public List getExtraSourceLocations() { return delegate.getExtraSourceLocations();} + public List getExtraSourceLocations() { return delegate.getExtraSourceLocations();} } - - private static class MessageIssued extends RuntimeException { - private static final long serialVersionUID = 1L; - public String getMessage() { - return "message issued..."; - } - } + private static class MessageIssued extends RuntimeException { + private static final long serialVersionUID = 1L; + public String getMessage() { + return "message issued..."; + } + } } diff --git a/build/testsrc/org/aspectj/build/BuildModuleTests.java b/build/testsrc/org/aspectj/build/BuildModuleTests.java index 073cf0f39..6c2e63dc4 100644 --- a/build/testsrc/org/aspectj/build/BuildModuleTests.java +++ b/build/testsrc/org/aspectj/build/BuildModuleTests.java @@ -196,7 +196,7 @@ public class BuildModuleTests extends TestCase { // separate check to verify all file types (suffixes) are known if (!"testsrc".equals(srcDir.getName())) { - ArrayList unknownFiles = new ArrayList(); + ArrayList unknownFiles = new ArrayList<>(); UnknownFileCheck.SINGLETON.unknownFiles(srcDir, unknownFiles); if (!unknownFiles.isEmpty()) { String s = "unknown files (see readme-build-module.html to " diff --git a/build/testsrc/org/aspectj/internal/build/BuildModuleTest.java b/build/testsrc/org/aspectj/internal/build/BuildModuleTest.java index d0dfb55f2..c06e678e2 100644 --- a/build/testsrc/org/aspectj/internal/build/BuildModuleTest.java +++ b/build/testsrc/org/aspectj/internal/build/BuildModuleTest.java @@ -343,7 +343,7 @@ public class BuildModuleTest extends TestCase { try { zipFile = new ZipFile(weaverAllJar); Enumeration e = zipFile.entries(); - ArrayList entryNames = new ArrayList(); + ArrayList entryNames = new ArrayList<>(); while (e.hasMoreElements()) { ZipEntry entry = (ZipEntry) e.nextElement(); String name = entry.getName(); diff --git a/build/testsrc/org/aspectj/internal/build/ModulesTest.java b/build/testsrc/org/aspectj/internal/build/ModulesTest.java index 0478c44c2..51a58142a 100644 --- a/build/testsrc/org/aspectj/internal/build/ModulesTest.java +++ b/build/testsrc/org/aspectj/internal/build/ModulesTest.java @@ -72,7 +72,7 @@ public class ModulesTest extends TestCase { } } - ArrayList tempFiles = new ArrayList(); + ArrayList tempFiles = new ArrayList<>(); public ModulesTest(String name) { super(name); diff --git a/lib/aspectj/lib/aspectjrt.jar b/lib/aspectj/lib/aspectjrt.jar index 536f947e6..ef06aa7fd 100644 Binary files a/lib/aspectj/lib/aspectjrt.jar and b/lib/aspectj/lib/aspectjrt.jar differ diff --git a/lib/test/aspectjrt.jar b/lib/test/aspectjrt.jar index 536f947e6..ef06aa7fd 100644 Binary files a/lib/test/aspectjrt.jar and b/lib/test/aspectjrt.jar differ diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareParents.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareParents.java index c11967fca..cf6ffbaab 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareParents.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareParents.java @@ -319,9 +319,9 @@ public class DeclareParents extends Declare { } ResolvedType newParentGenericType = newParent.getGenericType(); - Iterator iter = typeToVerify.getDirectSupertypes(); + Iterator iter = typeToVerify.getDirectSupertypes(); while (iter.hasNext()) { - ResolvedType supertype = (ResolvedType) iter.next(); + ResolvedType supertype = iter.next(); if (((supertype.isRawType() && newParent.isParameterizedType()) || (supertype.isParameterizedType() && newParent .isRawType())) && newParentGenericType.equals(supertype.getGenericType())) { diff --git a/runtime/src/org/aspectj/runtime/reflect/JoinPointImpl.java b/runtime/src/org/aspectj/runtime/reflect/JoinPointImpl.java index cae6cf577..69bff1e3c 100644 --- a/runtime/src/org/aspectj/runtime/reflect/JoinPointImpl.java +++ b/runtime/src/org/aspectj/runtime/reflect/JoinPointImpl.java @@ -197,9 +197,17 @@ class JoinPointImpl implements ProceedingJoinPoint { } else { // need to replace the target, and it is different to this, whether // that means replacing state[0] or state[1] depends on whether - // the join point has a this - firstArgumentIndexIntoAdviceBindings = (hasThis ? 1 : 0) + 1; - state[hasThis ? 1 : 0] = adviceBindings[hasThis ? 1 : 0]; + // the join point has a this + + // This previous variant doesn't seem to cope with only binding target at a joinpoint + // which has both this and target. It forces you to supply this even if you didn't bind + // it. +// firstArgumentIndexIntoAdviceBindings = (hasThis ? 1 : 0) + 1; +// state[hasThis ? 1 : 0] = adviceBindings[hasThis ? 1 : 0]; + + int targetPositionInAdviceBindings = (hasThis && bindsThis) ? 1 : 0; + firstArgumentIndexIntoAdviceBindings = ((hasThis&&bindsThis)?1:0)+((hasTarget&&bindsTarget&&!thisTargetTheSame)?1:0); + state[hasThis ? 1 : 0] = adviceBindings[targetPositionInAdviceBindings]; } } else { // leave state[0]/state[1] alone, they are OK diff --git a/testing/src/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java b/testing/src/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java index c3c93729c..2502bca0d 100644 --- a/testing/src/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java +++ b/testing/src/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java @@ -123,19 +123,19 @@ public class Ajctest extends Task implements PropertyChangeListener { //fields private String testId = NO_TESTID; - private List args = new Vector(); - private List testsets = new Vector(); + private List args = new Vector<>(); + private List testsets = new Vector<>(); private Path classpath; private Path internalclasspath; private File destdir; private File dir; private File errorfile; - private List testclasses = new Vector(); + private List testclasses = new Vector<>(); private boolean nocompile; private Ajdoc ajdoc = null; private boolean noclean; private boolean noverify; - private List depends = new Vector(); + private List depends = new Vector<>(); //end-fields public Argfile createArgfile() { @@ -321,7 +321,7 @@ public class Ajctest extends Task implements PropertyChangeListener { public static class Argument { private String name; - private List values = new Vector(); + private List values = new Vector<>(); private boolean always = true; final boolean isj; public Argument(boolean isj) { @@ -332,14 +332,14 @@ public class Ajctest extends Task implements PropertyChangeListener { ("-" + (str.startsWith("J") ? str.substring(1) : str)); } public void setValues(String str) { - values = new Vector(); + values = new Vector<>(); StringTokenizer tok = new StringTokenizer(str, ", ", false); while (tok.hasMoreTokens()) { values.add(tok.nextToken().trim()); } } public void setValue(String value) { - (values = new Vector()).add(value); + (values = new Vector<>()).add(value); } public void setAlways(boolean always) { this.always = always; @@ -401,30 +401,30 @@ public class Ajctest extends Task implements PropertyChangeListener { } public class Testset extends FileSet { - private List argfileNames = new Vector(); - public List argfiles; - public List files; - public List args = new Vector(); + private List argfileNames = new Vector<>(); + public List argfiles; + public List files; + public List args = new Vector<>(); public String classname; private boolean havecludes = false; - private List testclasses = new Vector(); + private List testclasses = new Vector<>(); private Path classpath; private Path internalclasspath; private Ajdoc ajdoc = null; private boolean fork = false; private boolean noclean; - private List depends = new Vector(); + private List depends = new Vector<>(); public String toString() { String str = ""; if (files.size() > 0) { str += "files:" + "\n"; - for (Iterator i = files.iterator(); i.hasNext();) { + for (Iterator i = files.iterator(); i.hasNext();) { str += "\t" + i.next() + "\n"; } } if (argfiles.size() > 0) { str += "argfiles:" + "\n"; - for (Iterator i = argfiles.iterator(); i.hasNext();) { + for (Iterator i = argfiles.iterator(); i.hasNext();) { str += "\t" + i.next() + "\n"; } } @@ -578,10 +578,10 @@ public class Ajctest extends Task implements PropertyChangeListener { public void resolve() throws BuildException { if (dir != null) this.setDir(dir); File src = getDir(project); - argfiles = new Vector(); - files = new Vector(); - for(Iterator iter = argfileNames.iterator(); iter.hasNext();) { - String name = ((Argfile)iter.next()).name; + argfiles = new Vector<>(); + files = new Vector<>(); + for(Iterator iter = argfileNames.iterator(); iter.hasNext();) { + String name = iter.next().name; File argfile = new File(src, name); if (check(argfile, name, location)) argfiles.add(argfile); } @@ -610,8 +610,8 @@ public class Ajctest extends Task implements PropertyChangeListener { this.ajdoc = Ajctest.this.ajdoc; } if (this.fork) { - for (Iterator i = this.testclasses.iterator(); i.hasNext();) { - ((Run)i.next()).setFork(fork); + for (Iterator i = this.testclasses.iterator(); i.hasNext();) { + i.next().setFork(fork); } } if (!this.noclean) { @@ -687,40 +687,36 @@ public class Ajctest extends Task implements PropertyChangeListener { } - private void log(String space, List list, String title) { + private void log(String space, List list, String title) { if (list == null || list.size() < 1) return; log(space + title); - for (Iterator i = list.iterator(); i.hasNext();) { + for (Iterator i = list.iterator(); i.hasNext();) { log(space + " " + i.next()); } } - private void execute(Testset testset, List args) throws BuildException { + private void execute(Testset testset, List args) throws BuildException { if (testset.files.size() > 0) { log("\tfiles:"); - for (Iterator i = testset.files.iterator(); - i.hasNext();) { + for (Iterator i = testset.files.iterator(); i.hasNext();) { log("\t " + i.next()); } } if (testset.argfiles.size() > 0) { log("\targfiles:"); - for (Iterator i = testset.argfiles.iterator(); - i.hasNext();) { + for (Iterator i = testset.argfiles.iterator(); i.hasNext();) { log("\t " + i.next()); } } if (args.size() > 0) { log("\targs:"); - for (Iterator i = args.iterator(); - i.hasNext();) { + for (Iterator i = args.iterator(); i.hasNext();) { log("\t " + i.next()); } } if (testset.testclasses.size() > 0) { log("\tclasses:"); - for (Iterator i = testset.testclasses.iterator(); - i.hasNext();) { + for (Iterator i = testset.testclasses.iterator(); i.hasNext();) { log("\t " + i.next()); } } @@ -731,7 +727,7 @@ public class Ajctest extends Task implements PropertyChangeListener { } delete(workingdir); make(workingdir); - for (Iterator i = testset.depends.iterator(); i.hasNext();) { + for (Iterator i = testset.depends.iterator(); i.hasNext();) { String target = i.next()+""; // todo: capture failures here? project.executeTarget(target); @@ -788,9 +784,8 @@ public class Ajctest extends Task implements PropertyChangeListener { -1, "run"); } else if (!isSet("norun")) { - for (Iterator i = testset.testclasses.iterator(); - i.hasNext();) { - Run testclass = (Run)i.next(); + for (Iterator i = testset.testclasses.iterator(); i.hasNext();) { + Run testclass = i.next(); log("\ttest..." + testclass.classname()); if (null != destdir) { testclass.setClassesDir(destdir.getAbsolutePath()); @@ -812,27 +807,26 @@ public class Ajctest extends Task implements PropertyChangeListener { prepare(); log(testsets.size() + " testset" + s(testsets), Project.MSG_VERBOSE); - Map testsetToArgcombo = new HashMap(); - List argcombos = new Vector(); - for (Iterator iter = testsets.iterator(); iter.hasNext();) { - Testset testset = (Testset)iter.next(); + Map>> testsetToArgcombo = new HashMap<>(); + List argcombos = new Vector<>(); + for (Testset testset: testsets) { testset.resolve(); - List bothargs = new Vector(args); + List bothargs = new Vector<>(args); bothargs.addAll(testset.args); - List argcombo = argcombo(bothargs); + List> argcombo = argcombo(bothargs); argcombos.add(new Integer(argcombo.size())); testsetToArgcombo.put(testset, argcombo); } while (!testsetToArgcombo.isEmpty()) { int _ = 1; - for (Iterator iter = testsets.iterator(); iter.hasNext(); _++) { - Testset testset = (Testset)iter.next(); - List argcombo = (List)testsetToArgcombo.get(testset); + for (Iterator iter = testsets.iterator(); iter.hasNext(); _++) { + Testset testset = iter.next(); + List> argcombo = testsetToArgcombo.get(testset); if (argcombo.size() == 0) { testsetToArgcombo.remove(testset); continue; } - List args = (List)argcombo.remove(0); + List args = argcombo.remove(0); final String startStr = "Testset " + _ + " of " + testsets.size(); String str = startStr + " / Combo " + _ + " of " + argcombos.size(); log("---------- " + str + " ----------"); @@ -1085,7 +1079,7 @@ public class Ajctest extends Task implements PropertyChangeListener { // } private static List allErrors = new Vector(); - private List errors = new Vector(); + private List errors = new Vector<>(); private void post(Testset testset, List args, String msgs, int exit, String type) { @@ -1290,11 +1284,11 @@ public class Ajctest extends Task implements PropertyChangeListener { } } - private List argcombo(List arguments) { - List combos = new Vector(); - List always = new Vector(); - for (Iterator iter = arguments.iterator(); iter.hasNext();) { - Argument arg = (Argument)iter.next(); + private List> argcombo(List arguments) { + List combos = new Vector<>(); + List always = new Vector<>(); + for (Iterator iter = arguments.iterator(); iter.hasNext();) { + Argument arg = iter.next(); if (arg.values.size() == 0) arg.values.add(""); if (!arg.always && !arg.values.contains(null)) arg.values.add(null); if (arg.values.size() > 0) { @@ -1303,11 +1297,11 @@ public class Ajctest extends Task implements PropertyChangeListener { always.add(new Arg(arg.name, arg.values.get(0)+"", arg.isj)); } } - List argcombo = combinations(combos); - for (Iterator iter = always.iterator(); iter.hasNext();) { - Arg arg = (Arg)iter.next(); - for (Iterator comboiter = argcombo.iterator(); comboiter.hasNext();) { - ((List)comboiter.next()).add(arg); + List> argcombo = combinations(combos); + for (Iterator iter = always.iterator(); iter.hasNext();) { + Arg arg = iter.next(); + for (Iterator> comboiter = argcombo.iterator(); comboiter.hasNext();) { + comboiter.next().add(arg); } } return argcombo; @@ -1624,16 +1618,16 @@ public class Ajctest extends Task implements PropertyChangeListener { log("done handling " + t); } - private List combinations(List arglist) { - List result = new Vector(); - result.add(new Vector()); - for (Iterator iter = arglist.iterator(); iter.hasNext();) { - Argument arg = (Argument)iter.next(); + private List> combinations(List arglist) { + List> result = new Vector<>(); + result.add(new Vector()); + for (Iterator iter = arglist.iterator(); iter.hasNext();) { + Argument arg = iter.next(); int N = result.size(); for (int i = 0; i < N; i++) { - List to = (List)result.remove(0); - for (Iterator valiter = arg.values.iterator(); valiter.hasNext();) { - List newlist = new Vector(to); + List to = result.remove(0); + for (Iterator valiter = arg.values.iterator(); valiter.hasNext();) { + List newlist = new Vector<>(to); Object val = valiter.next(); if (val != null) newlist.add(new Arg(arg.name, val+"", arg.isj)); result.add(newlist); diff --git a/testing/src/org/aspectj/internal/tools/ant/taskdefs/MainWrapper.java b/testing/src/org/aspectj/internal/tools/ant/taskdefs/MainWrapper.java index 55d8dbed1..6ce22df24 100644 --- a/testing/src/org/aspectj/internal/tools/ant/taskdefs/MainWrapper.java +++ b/testing/src/org/aspectj/internal/tools/ant/taskdefs/MainWrapper.java @@ -81,8 +81,8 @@ public class MainWrapper { // access classname from jvm arg classname = System.getProperty(PROP_NAME); // this will fail if the class is not available from this classloader - Class cl = Class.forName(classname); - final Class[] argTypes = new Class[] {String[].class}; + Class cl = Class.forName(classname); + final Class[] argTypes = new Class[] {String[].class}; // will fail if no main method main = cl.getMethod("main", argTypes); if (!Modifier.isStatic(main.getModifiers())) { diff --git a/testing/src/org/aspectj/testing/harness/bridge/AbstractRunSpec.java b/testing/src/org/aspectj/testing/harness/bridge/AbstractRunSpec.java index d45037aac..4e61a512c 100644 --- a/testing/src/org/aspectj/testing/harness/bridge/AbstractRunSpec.java +++ b/testing/src/org/aspectj/testing/harness/bridge/AbstractRunSpec.java @@ -257,7 +257,7 @@ abstract public class AbstractRunSpec implements IRunSpec { // --------------- (String) paths /** @return ArrayList of String paths */ - public ArrayList getPathsList() { + public ArrayList getPathsList() { return makeList(paths); } @@ -572,7 +572,7 @@ abstract public class AbstractRunSpec implements IRunSpec { */ protected void writeChildren(XMLWriter out) { if (0 < children.size()) { - for (Iterator iter = children.iterator(); iter.hasNext();) { + for (Iterator iter = children.iterator(); iter.hasNext();) { IXmlWritable self = (IXmlWritable) iter.next(); self.writeXml(out); } @@ -583,7 +583,7 @@ abstract public class AbstractRunSpec implements IRunSpec { public void printAll(PrintStream out, String prefix) { out.println(prefix + toString()); - for (Iterator iter = children.iterator(); iter.hasNext();) { + for (Iterator iter = children.iterator(); iter.hasNext();) { AbstractRunSpec child = (AbstractRunSpec) iter.next(); // IRunSpec child.printAll(out, prefix + " "); } @@ -614,7 +614,7 @@ abstract public class AbstractRunSpec implements IRunSpec { addListCount("options", options, result); addListCount("paths", paths, result); // XXXXXunused addListCount("sourceLocations", sourceLocations, result); - List messagesList = messages.getUnmodifiableListView(); + List messagesList = messages.getUnmodifiableListView(); addListCount("messages", messagesList, result); return result.toString().trim(); @@ -634,7 +634,7 @@ abstract public class AbstractRunSpec implements IRunSpec { addListEntries("options", options, result); addListEntries("paths", paths, result); // XXXXXunused addListEntries("sourceLocations", sourceLocations, result); - List messagesList = messages.getUnmodifiableListView(); + List messagesList = messages.getUnmodifiableListView(); addListEntries("messages", messagesList, result); return result.toString(); @@ -683,7 +683,7 @@ abstract public class AbstractRunSpec implements IRunSpec { spec.xmlNames = ((AbstractRunSpec.XMLNames) xmlNames.clone()); } - private static void addListCount(String name, List list, StringBuffer sink) { + private static void addListCount(String name, List list, StringBuffer sink) { int size = list.size(); if ((null != list) && (0 < size)) { sink.append(" " + size + " "); @@ -691,7 +691,7 @@ abstract public class AbstractRunSpec implements IRunSpec { } } - private static void addListEntries(String name, List list, StringBuffer sink) { + private static void addListEntries(String name, List list, StringBuffer sink) { if ((null != list) && (0 < list.size())) { sink.append(" " + list.size() + " "); sink.append(name); diff --git a/testing/src/org/aspectj/testing/harness/bridge/AjcMessageHandler.java b/testing/src/org/aspectj/testing/harness/bridge/AjcMessageHandler.java index 1b147ebc4..f4a88c3b2 100644 --- a/testing/src/org/aspectj/testing/harness/bridge/AjcMessageHandler.java +++ b/testing/src/org/aspectj/testing/harness/bridge/AjcMessageHandler.java @@ -135,8 +135,8 @@ public class AjcMessageHandler extends MessageHandler { /** Generate differences between expected and actual errors and warnings */ public CompilerDiffs getCompilerDiffs() { if (null == diffs) { - final List expected; - final List actual; + final List expected; + final List actual; if (!ignoreWarnings) { expected = expectedMessages.getUnmodifiableListView(); actual = this.getUnmodifiableListView(); @@ -269,7 +269,7 @@ public class AjcMessageHandler extends MessageHandler { private IMessage[] getMessagesWithoutExpectedFails() { IMessage[] result = super.getMessages(null, true); // remove all expected fail+ (COSTLY) - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); int leftToFilter = numExpectedFailed; for (int i = 0; i < result.length; i++) { if ((0 == leftToFilter) diff --git a/testing/src/org/aspectj/testing/harness/bridge/DirChanges.java b/testing/src/org/aspectj/testing/harness/bridge/DirChanges.java index a57dde62d..13281607b 100644 --- a/testing/src/org/aspectj/testing/harness/bridge/DirChanges.java +++ b/testing/src/org/aspectj/testing/harness/bridge/DirChanges.java @@ -469,25 +469,25 @@ public class DirChanges { boolean fastFail; /** relative paths (String) of expected files added */ - final ArrayList added; + final ArrayList added; /** relative paths (String) of expected files removed/deleted */ - final ArrayList removed; + final ArrayList removed; /** relative paths (String) of expected files updated/changed */ - final ArrayList updated; + final ArrayList updated; /** relative paths (String) of expected files NOT * added, removed, or changed * XXX unchanged unimplemented */ - final ArrayList unchanged; + final ArrayList unchanged; public Spec() { - added = new ArrayList(); - removed = new ArrayList(); - updated = new ArrayList(); - unchanged = new ArrayList(); + added = new ArrayList<>(); + removed = new ArrayList<>(); + updated = new ArrayList<>(); + unchanged = new ArrayList<>(); } /** @@ -595,13 +595,13 @@ public class DirChanges { * @param out XMLWriter output sink * @param dirChanges List of DirChanges.Spec to write */ - public static void writeXml(XMLWriter out, List dirChanges) { + public static void writeXml(XMLWriter out, List dirChanges) { if (LangUtil.isEmpty(dirChanges)) { return; } LangUtil.throwIaxIfNull(out, "out"); - for (Iterator iter = dirChanges.iterator(); iter.hasNext();) { - DirChanges.Spec spec = (DirChanges.Spec) iter.next(); + for (Iterator iter = dirChanges.iterator(); iter.hasNext();) { + DirChanges.Spec spec = iter.next(); if (null == spec) { continue; } diff --git a/testing/src/org/aspectj/testing/harness/bridge/FlatSuiteReader.java b/testing/src/org/aspectj/testing/harness/bridge/FlatSuiteReader.java index 5de765d1b..8d75d5620 100644 --- a/testing/src/org/aspectj/testing/harness/bridge/FlatSuiteReader.java +++ b/testing/src/org/aspectj/testing/harness/bridge/FlatSuiteReader.java @@ -17,7 +17,6 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; -import java.util.Iterator; import java.util.List; import org.aspectj.bridge.AbortException; @@ -151,7 +150,7 @@ public class FlatSuiteReader implements SFileReader.Maker { throw new AbortException("expected sources at " + reader); } - ArrayList exp = new ArrayList(); + ArrayList exp = new ArrayList<>(); // !compile || noerrors || className {runOption..} String first = words[0]; if ("!compile".equals(first)) { @@ -290,10 +289,9 @@ public class FlatSuiteReader implements SFileReader.Maker { } result.description = input; - ArrayList newOptions = new ArrayList(); - ArrayList optionsCopy = result.getOptionsList(); - for (Iterator iter = optionsCopy.iterator(); iter.hasNext();) { - String option = (String) iter.next(); + ArrayList newOptions = new ArrayList<>(); + ArrayList optionsCopy = result.getOptionsList(); + for (String option: optionsCopy) { if (option.startsWith("-")) { newOptions.add("!" + option.substring(1)); } else { @@ -325,9 +323,9 @@ public class FlatSuiteReader implements SFileReader.Maker { * @param lastFile default file for source location if the input does not specify * @return List */ - private List makeMessages(// XXX weak - also support expected exceptions, etc. + private List makeMessages(// XXX weak - also support expected exceptions, etc. Kind kind, String[] words, int start, File lastFile) { - ArrayList result = new ArrayList(); + ArrayList result = new ArrayList<>(); for (int i = start; i < words.length; i++) { ISourceLocation sl = BridgeUtil.makeSourceLocation(words[i], lastFile); @@ -340,7 +338,7 @@ public class FlatSuiteReader implements SFileReader.Maker { result.add(new Message(text, kind, null, sl)); } } - return (0 == result.size() ? Collections.EMPTY_LIST : result); + return (0 == result.size() ? Collections.emptyList() : result); } /** diff --git a/tests/bugs1810/500035/Code.java b/tests/bugs1810/500035/Code.java new file mode 100644 index 000000000..58e738da4 --- /dev/null +++ b/tests/bugs1810/500035/Code.java @@ -0,0 +1,30 @@ +import org.aspectj.lang.annotation.*; +import org.aspectj.lang.*; + +@Aspect +public class Code { + + @Around(value = "args(regex, replacement) && target(targetObject) " + + "&& call(public String String.replaceFirst(String, String)) " +//, argNames = "proceedingJoinPoint,targetObject,regex,replacement,thisJoinPoint" +) + public String replaceFirstAspect(ProceedingJoinPoint proceedingJoinPoint, String targetObject, String regex, String replacement) throws Throwable { +System.out.println("targetObject = "+targetObject); +System.out.println("regex = "+regex); +System.out.println("replacement = "+replacement); + String returnObject = (String) proceedingJoinPoint.proceed(new Object[]{ targetObject, regex, replacement}); + return returnObject; + } + + + public static void main(String []argv) { + new Code().run(); + } + + public void run() { + String s = "hello"; + s = s.replaceFirst("l","7"); + System.out.println(s); + } + +} diff --git a/tests/bugs1810/500035/Code2.java b/tests/bugs1810/500035/Code2.java new file mode 100644 index 000000000..23eddce7e --- /dev/null +++ b/tests/bugs1810/500035/Code2.java @@ -0,0 +1,30 @@ +import org.aspectj.lang.annotation.*; +import org.aspectj.lang.*; + +@Aspect +public class Code2 { + + @Around(value = "args(regex, replacement) && target(targetObject) " + + "&& call(public String String.replaceFirst(String, String)) && this(c)" +//, argNames = "proceedingJoinPoint,targetObject,regex,replacement,thisJoinPoint" +) + public String replaceFirstAspect(ProceedingJoinPoint proceedingJoinPoint, Code2 c, String targetObject, String regex, String replacement) throws Throwable { +System.out.println("targetObject = "+targetObject); +System.out.println("regex = "+regex); +System.out.println("replacement = "+replacement); + String returnObject = (String) proceedingJoinPoint.proceed(new Object[]{ c, targetObject, regex, replacement}); + return returnObject; + } + + + public static void main(String []argv) { + new Code2().run(); + } + + public void run() { + String s = "hello"; + s = s.replaceFirst("l","8"); + System.out.println(s); + } + +} diff --git a/tests/bugs1810/500035/Code3.java b/tests/bugs1810/500035/Code3.java new file mode 100644 index 000000000..48f672991 --- /dev/null +++ b/tests/bugs1810/500035/Code3.java @@ -0,0 +1,76 @@ +import org.aspectj.lang.annotation.*; +import org.aspectj.lang.*; + +@Aspect +public class Code3 { + + @Around(value = "args(s) && target(targeto) && call(* Foo.run1(String))") + public void first(ProceedingJoinPoint proceedingJoinPoint, Foo targeto, String s) throws Throwable { + System.out.println("first: binding target, just passing everything through: target=Foo(1)"); + proceedingJoinPoint.proceed(new Object[]{ targeto, s}); + } + + @Around(value = "args(s) && this(thiso) && target(targeto) && call(* run2(String))") + public void second(ProceedingJoinPoint proceedingJoinPoint, Foo thiso, Foo targeto, String s) throws Throwable { + System.out.println("second: binding this and target, just passing everything through: this=Foo(0) target=Foo(1)"); + proceedingJoinPoint.proceed(new Object[]{ thiso, targeto, s}); + } + + @Around(value = "args(s) && this(thiso) && call(* run3(String))") + public void third(ProceedingJoinPoint proceedingJoinPoint, Foo thiso, String s) throws Throwable { + System.out.println("third: binding this, just passing everything through: this=Foo(0)"); + proceedingJoinPoint.proceed(new Object[]{ thiso, s}); + } + + @Around(value = "args(s) && this(thiso) && call(* run4(String))") + public void fourth(ProceedingJoinPoint proceedingJoinPoint, Foo thiso, String s) throws Throwable { + System.out.println("fourth: binding this, switching from Foo(0) to Foo(3)"); + proceedingJoinPoint.proceed(new Object[]{ new Foo(3), s}); + } + + @Around(value = "args(s) && target(targeto) && call(* run5(String))") + public void fifth(ProceedingJoinPoint proceedingJoinPoint, Foo targeto, String s) throws Throwable { + System.out.println("fifth: binding target, switching from Foo(1) to Foo(4)"); + proceedingJoinPoint.proceed(new Object[]{ new Foo(4), s}); + } + + @Around(value = "args(s) && this(thiso) && target(targeto) && call(* run6(String))") + public void sixth(ProceedingJoinPoint proceedingJoinPoint, Foo thiso, Foo targeto, String s) throws Throwable { + System.out.println("sixth: binding this and target, switching them around (before this=Foo(0) target=Foo(1))"); + proceedingJoinPoint.proceed(new Object[]{ targeto, thiso, s}); + } + + public static void main(String []argv) { + new Foo(0).execute1(); + new Foo(0).execute2(); + new Foo(0).execute3(); + new Foo(0).execute4(); + new Foo(0).execute5(); + new Foo(0).execute6(); + } +} + +class Foo { + int i; + public Foo(int i) { + this.i = i; + } + + public void execute1() { new Foo(1).run1("abc"); } + public void execute2() { new Foo(1).run2("abc"); } + public void execute3() { new Foo(1).run3("abc"); } + public void execute4() { new Foo(1).run4("abc"); } + public void execute5() { new Foo(1).run5("abc"); } + public void execute6() { new Foo(1).run6("abc"); } + + public void run1(String s) { System.out.println("Executing run("+s+") on "+this.toString()); } + public void run2(String s) { System.out.println("Executing run("+s+") on "+this.toString()); } + public void run3(String s) { System.out.println("Executing run("+s+") on "+this.toString()); } + public void run4(String s) { System.out.println("Executing run("+s+") on "+this.toString()); } + public void run5(String s) { System.out.println("Executing run("+s+") on "+this.toString()); } + public void run6(String s) { System.out.println("Executing run("+s+") on "+this.toString()); } + + public String toString() { + return ("Foo(i="+i+")"); + } +} diff --git a/tests/bugs1810/500035/Code4.java b/tests/bugs1810/500035/Code4.java new file mode 100644 index 000000000..176ce2011 --- /dev/null +++ b/tests/bugs1810/500035/Code4.java @@ -0,0 +1,35 @@ +import org.aspectj.lang.annotation.*; +import org.aspectj.lang.*; + +public aspect Code4 { + + void around(Foo targeto, String s): call(* Foo.run(String)) && args(s) && target(targeto) { + System.out.println("first: binding target, just passing everything through"); + proceed(targeto, s); + } + + public static void main(String []argv) { + new Foo(0).execute(); + } +} + +class Foo { + int i; + public Foo(int i) { + this.i = i; + } + + public void execute() { + Foo f1 = new Foo(1); + Foo f2 = new Foo(2); + f1.run("abc"); + } + + public void run(String s) { + System.out.println("Executing run("+s+") on "+this.toString()); + } + + public String toString() { + return ("Foo(i="+i+")"); + } +} diff --git a/tests/bugs1810/501656/ApplicationException.java b/tests/bugs1810/501656/ApplicationException.java new file mode 100644 index 000000000..5392eeaef --- /dev/null +++ b/tests/bugs1810/501656/ApplicationException.java @@ -0,0 +1,9 @@ +package com.myapp; + +public class ApplicationException extends Exception { + private static final long serialVersionUID = 1L; + + public ApplicationException(String message) { + super(message); + } +} diff --git a/tests/bugs1810/501656/ApplicationExceptionHandler.java b/tests/bugs1810/501656/ApplicationExceptionHandler.java new file mode 100644 index 000000000..bd96e1c27 --- /dev/null +++ b/tests/bugs1810/501656/ApplicationExceptionHandler.java @@ -0,0 +1,17 @@ +package com.myapp.aspect; + +import org.aspectj.lang.annotation.AfterThrowing; +import org.aspectj.lang.annotation.Aspect; + +import com.myapp.ApplicationException; + +@Aspect +public abstract class ApplicationExceptionHandler { + @AfterThrowing( + pointcut = "execution(* com.myapp.*.facade.*.*(..))", + throwing = "exception" +, argNames="exception" + ) + public abstract void handleFacadeException(EX exception); + +} diff --git a/tests/bugs1810/501656/Code.java b/tests/bugs1810/501656/Code.java new file mode 100644 index 000000000..c8e603a9e --- /dev/null +++ b/tests/bugs1810/501656/Code.java @@ -0,0 +1,4 @@ +public abstract class Code { + public void m(String str1) {} + public abstract void m2(String str2); +} diff --git a/tests/bugs1810/501656/out/com/myapp/ApplicationException.class b/tests/bugs1810/501656/out/com/myapp/ApplicationException.class new file mode 100644 index 000000000..fbbbdda19 Binary files /dev/null and b/tests/bugs1810/501656/out/com/myapp/ApplicationException.class differ diff --git a/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java b/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java index 1ec2b21c1..ff08047d1 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/GenericsTests.java @@ -5,11 +5,8 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.HashSet; -import java.util.Iterator; import java.util.Set; -import junit.framework.Test; - import org.aspectj.apache.bcel.classfile.Attribute; import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.Signature; @@ -19,6 +16,8 @@ import org.aspectj.testing.XMLBasedAjcTestCase; import org.aspectj.tools.ajc.Ajc; import org.aspectj.util.LangUtil; +import junit.framework.Test; + public class GenericsTests extends XMLBasedAjcTestCase { /*========================================== diff --git a/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java b/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java index 5b3c795d4..8928678c8 100644 --- a/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java @@ -12,17 +12,14 @@ package org.aspectj.systemtest.ajc151; import java.io.File; import java.io.IOException; -import java.io.PrintWriter; -import junit.framework.Test; - -import org.aspectj.ajdt.internal.core.builder.AsmHierarchyBuilder; import org.aspectj.asm.AsmManager; import org.aspectj.asm.IHierarchy; import org.aspectj.asm.IProgramElement; import org.aspectj.systemtest.ajc150.GenericsTests; import org.aspectj.testing.XMLBasedAjcTestCase; -import org.aspectj.weaver.UnresolvedType.TypeKind; + +import junit.framework.Test; public class Ajc151Tests extends org.aspectj.testing.XMLBasedAjcTestCase { diff --git a/tests/src/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java b/tests/src/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java index 4b21319d0..9c92f8488 100644 --- a/tests/src/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java +++ b/tests/src/org/aspectj/systemtest/ajc151/NewarrayJoinpointTests.java @@ -17,6 +17,7 @@ import junit.framework.Test; import org.aspectj.asm.AsmManager; import org.aspectj.asm.IProgramElement; +import org.aspectj.asm.IRelationship; import org.aspectj.testing.XMLBasedAjcTestCase; /* @@ -102,14 +103,14 @@ public class NewarrayJoinpointTests extends XMLBasedAjcTestCase { runTest("structure model"); IProgramElement ipe = AsmManager.lastActiveStructureModel.getHierarchy().findElementForType("", "Five"); assertTrue("Couldnt find 'Five' type in the model", ipe != null); - List kids = ipe.getChildren(); + List kids = ipe.getChildren(); assertTrue("Couldn't find 'main' method in the 'Five' type", kids != null && kids.size() == 1); - List codenodes = ((IProgramElement) kids.get(0)).getChildren(); + List codenodes = ((IProgramElement) kids.get(0)).getChildren(); assertTrue("Couldn't find nodes below 'main' method", codenodes != null && codenodes.size() == 1); IProgramElement arrayCtorCallNode = (IProgramElement) codenodes.get(0); String exp = "constructor-call(void java.lang.Integer[].(int))"; assertTrue("Expected '" + exp + "' but found " + arrayCtorCallNode.toString(), arrayCtorCallNode.toString().equals(exp)); - List rels = AsmManager.lastActiveStructureModel.getRelationshipMap().get(arrayCtorCallNode); + List rels = AsmManager.lastActiveStructureModel.getRelationshipMap().get(arrayCtorCallNode); assertTrue("Should have a relationship from the ctorcall node, but didn't find one?", rels != null && rels.size() == 1); } diff --git a/tests/src/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java b/tests/src/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java index 64fa5a174..922f4c5b4 100644 --- a/tests/src/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java +++ b/tests/src/org/aspectj/systemtest/ajc152/SynchronizationTransformTests.java @@ -181,9 +181,8 @@ public class SynchronizationTransformTests extends XMLBasedAjcTestCase { private LazyMethodGen getMethod(String typename, String methodname) { BcelObjectType type = getBcelObjectFor(typename); LazyClassGen lcg = type.getLazyClassGen(); - List /* LazyMethodGen */methods = lcg.getMethodGens(); - for (Iterator iter = methods.iterator(); iter.hasNext();) { - LazyMethodGen element = (LazyMethodGen) iter.next(); + List methods = lcg.getMethodGens(); + for (LazyMethodGen element: methods) { if (element.getName().equals(methodname)) { return element; } @@ -234,7 +233,7 @@ public class SynchronizationTransformTests extends XMLBasedAjcTestCase { // Load the file in fr = new BufferedReader(new FileReader(f)); String line = null; - List originalFileContents = new ArrayList(); + List originalFileContents = new ArrayList<>(); while ((line = fr.readLine()) != null) originalFileContents.add(line); String[] fileContents = (String[]) originalFileContents.toArray(new String[] {}); @@ -256,10 +255,10 @@ public class SynchronizationTransformTests extends XMLBasedAjcTestCase { } } - private String stringify(List l) { + private String stringify(List l) { StringBuffer result = new StringBuffer(); - for (Iterator iter = l.iterator(); iter.hasNext();) { - String str = (String) iter.next(); + for (Iterator iter = l.iterator(); iter.hasNext();) { + String str = iter.next(); result.append(str); result.append("\n"); } diff --git a/tests/src/org/aspectj/systemtest/ajc180/AllTestsAspectJ180.java b/tests/src/org/aspectj/systemtest/ajc180/AllTestsAspectJ180.java index 6feff4445..453c057eb 100644 --- a/tests/src/org/aspectj/systemtest/ajc180/AllTestsAspectJ180.java +++ b/tests/src/org/aspectj/systemtest/ajc180/AllTestsAspectJ180.java @@ -10,8 +10,6 @@ *******************************************************************************/ package org.aspectj.systemtest.ajc180; -import org.aspectj.systemtest.ajc181.Ajc181Tests; - import junit.framework.Test; import junit.framework.TestSuite; diff --git a/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java b/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java index 6122b1638..3cae1378c 100644 --- a/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java @@ -12,24 +12,38 @@ package org.aspectj.systemtest.ajc1810; import java.io.File; -import junit.framework.Test; - import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.classfile.Attribute; -import org.aspectj.apache.bcel.classfile.Constant; -import org.aspectj.apache.bcel.classfile.ConstantClass; -import org.aspectj.apache.bcel.classfile.ConstantPool; -import org.aspectj.apache.bcel.classfile.ConstantUtf8; -import org.aspectj.apache.bcel.classfile.InnerClass; -import org.aspectj.apache.bcel.classfile.InnerClasses; import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.testing.XMLBasedAjcTestCase; +import junit.framework.Test; + /** * @author Andy Clement */ public class Ajc1810Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + public void testBinding_500035() { + runTest("ataspectj binding"); + } + + public void testBinding_500035_2() { + runTest("ataspectj binding 2"); + } + + public void testBinding_500035_3() { + runTest("ataspectj binding 3 -XnoInline"); + } + + public void testBinding_500035_4() { + runTest("ataspectj binding 4"); + } + + public void testGenericsException_501656() { + runTest("generics exception"); + } + public void testAIOOBE_502807() { runTest("unexpected aioobe"); } diff --git a/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml b/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml index 065420da3..7485c1c20 100644 --- a/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml +++ b/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml @@ -2,6 +2,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/org/aspectj/systemtest/ajc182/AllTestsAspectJ182.java b/tests/src/org/aspectj/systemtest/ajc182/AllTestsAspectJ182.java index 10551687d..c0323f0ef 100644 --- a/tests/src/org/aspectj/systemtest/ajc182/AllTestsAspectJ182.java +++ b/tests/src/org/aspectj/systemtest/ajc182/AllTestsAspectJ182.java @@ -12,7 +12,6 @@ package org.aspectj.systemtest.ajc182; import junit.framework.Test; import junit.framework.TestSuite; -import org.aspectj.systemtest.apt.AptTests; public class AllTestsAspectJ182 { diff --git a/tests/src/org/aspectj/systemtest/ajc185/Ajc185Tests.java b/tests/src/org/aspectj/systemtest/ajc185/Ajc185Tests.java index cc9800043..77b453188 100644 --- a/tests/src/org/aspectj/systemtest/ajc185/Ajc185Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc185/Ajc185Tests.java @@ -10,17 +10,12 @@ *******************************************************************************/ package org.aspectj.systemtest.ajc185; -import java.io.BufferedInputStream; import java.io.File; -import java.io.FileInputStream; -import junit.framework.Test; - -import org.aspectj.apache.bcel.classfile.JavaClass; -import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; -import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; import org.aspectj.testing.XMLBasedAjcTestCase; +import junit.framework.Test; + /** * @author Andy Clement */ diff --git a/tests/src/org/aspectj/systemtest/ajc187/Ajc187Tests.java b/tests/src/org/aspectj/systemtest/ajc187/Ajc187Tests.java index 754864fd7..4ff34b28e 100644 --- a/tests/src/org/aspectj/systemtest/ajc187/Ajc187Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc187/Ajc187Tests.java @@ -11,14 +11,11 @@ package org.aspectj.systemtest.ajc187; import java.io.File; -import java.lang.reflect.Method; -import java.net.URL; -import java.net.URLClassLoader; - -import junit.framework.Test; import org.aspectj.testing.XMLBasedAjcTestCase; +import junit.framework.Test; + /** * @author Andy Clement */ diff --git a/tests/src/org/aspectj/systemtest/ajc187/AllTestsAspectJ187.java b/tests/src/org/aspectj/systemtest/ajc187/AllTestsAspectJ187.java index 79634df8c..ef8ff0a1c 100644 --- a/tests/src/org/aspectj/systemtest/ajc187/AllTestsAspectJ187.java +++ b/tests/src/org/aspectj/systemtest/ajc187/AllTestsAspectJ187.java @@ -12,7 +12,6 @@ package org.aspectj.systemtest.ajc187; import junit.framework.Test; import junit.framework.TestSuite; -import org.aspectj.systemtest.apt.AptTests; public class AllTestsAspectJ187 { diff --git a/tests/src/org/aspectj/systemtest/ajc188/AllTestsAspectJ188.java b/tests/src/org/aspectj/systemtest/ajc188/AllTestsAspectJ188.java index 8867d9174..32d3c12bf 100644 --- a/tests/src/org/aspectj/systemtest/ajc188/AllTestsAspectJ188.java +++ b/tests/src/org/aspectj/systemtest/ajc188/AllTestsAspectJ188.java @@ -12,7 +12,6 @@ package org.aspectj.systemtest.ajc188; import junit.framework.Test; import junit.framework.TestSuite; -import org.aspectj.systemtest.apt.AptTests; public class AllTestsAspectJ188 { diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java b/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java index cfe4495a4..01426d923 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java @@ -99,7 +99,7 @@ public class AjdeInteractionTestbed extends TestCase { ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setNonStandardOptions(options); } - public void configureAspectPath(String projectName, Set aspectpath) { + public void configureAspectPath(String projectName, Set aspectpath) { AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setAspectPath(aspectpath); } @@ -121,12 +121,12 @@ public class AjdeInteractionTestbed extends TestCase { ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setAspectPath(s); } - public void configureResourceMap(String projectName, Map resourcesMap) { + public void configureResourceMap(String projectName, Map resourcesMap) { AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setSourcePathResources(resourcesMap); } - public void configureJavaOptionsMap(String projectName, Map options) { + public void configureJavaOptionsMap(String projectName, Map options) { AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName); ((MultiProjTestCompilerConfiguration) compiler.getCompilerConfiguration()).setJavaOptions(options); } @@ -240,7 +240,7 @@ public class AjdeInteractionTestbed extends TestCase { private void addSourceFilesToBuild(String pname, AjCompiler compiler) { File projectBase = new File(sandboxDir, pname); ICompilerConfiguration icc = compiler.getCompilerConfiguration(); - List currentFiles = icc.getProjectSourceFiles(); + List currentFiles = icc.getProjectSourceFiles(); List filesForCompilation = new ArrayList(); collectUpFiles(projectBase, projectBase, filesForCompilation); boolean changed = false; @@ -392,12 +392,10 @@ public class AjdeInteractionTestbed extends TestCase { if (getCompiledFiles(projectName).size() == 0 && getWovenClasses(projectName).size() == 0) { sb.append("No files were compiled or woven\n"); } - for (Iterator iter = getCompiledFiles(projectName).iterator(); iter.hasNext();) { - Object element = iter.next(); + for (String element: getCompiledFiles(projectName)) { sb.append("compiled: " + element + "\n"); } - for (Iterator iter = getWovenClasses(projectName).iterator(); iter.hasNext();) { - Object element = iter.next(); + for (String element: getWovenClasses(projectName)) { sb.append("woven: " + element + "\n"); } return sb.toString(); diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/IncrementalOutputLocationManagerTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/IncrementalOutputLocationManagerTests.java index 0c13b154b..3f2afc409 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/IncrementalOutputLocationManagerTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/IncrementalOutputLocationManagerTests.java @@ -40,7 +40,7 @@ public class IncrementalOutputLocationManagerTests extends AbstractMultiProjectI private String projectDir; private int numberOfSrcDirs; - private List allOutputDirs; + private List allOutputDirs; public MyOutputLocationManager(String projectName, int numberOfSrcDirs) { projectDir = getWorkingDir() + File.separator + projectName; @@ -53,8 +53,8 @@ public class IncrementalOutputLocationManagerTests extends AbstractMultiProjectI public void reportFileRemove(String outputfile, int filetype) { } - public Map getInpathMap() { - return Collections.EMPTY_MAP; + public Map getInpathMap() { + return Collections.emptyMap(); } public File getOutputLocationForClass(File compilationUnit) { @@ -72,9 +72,9 @@ public class IncrementalOutputLocationManagerTests extends AbstractMultiProjectI return getOutputLocationForClass(resource); } - public List getAllOutputLocations() { + public List getAllOutputLocations() { if (allOutputDirs == null) { - allOutputDirs = new ArrayList(); + allOutputDirs = new ArrayList<>(); for (int i = 0; i < numberOfSrcDirs + 1; i++) { File f = null; if (i == 0) { diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java index 3299ee833..308ed42d5 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java @@ -64,12 +64,12 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen build("inpathTesting"); AjState state = getState(); - Map classNameToFileMap = state.getClassNameToFileMap(); + Map classNameToFileMap = state.getClassNameToFileMap(); assertFalse("expected there to be classes ", classNameToFileMap.isEmpty()); - Set entrySet = classNameToFileMap.entrySet(); - for (Iterator iterator = entrySet.iterator(); iterator.hasNext();) { - Map.Entry entry = (Map.Entry) iterator.next(); - String className = (String) entry.getKey(); + Set> entrySet = classNameToFileMap.entrySet(); + for (Iterator> iterator = entrySet.iterator(); iterator.hasNext();) { + Map.Entry entry = iterator.next(); + String className = entry.getKey(); String fullClassName = expectedOutputDir + File.separator + className.replace('.', File.separatorChar) + ".class"; File file = (File) entry.getValue(); assertEquals("expected file to have path \n" + fullClassName + ", but" + " found path \n" + file.getAbsolutePath(), @@ -105,15 +105,14 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen // the classes onthe inpath are recorded against the AjBuildManager // (they are deleted from the ajstate whilst cleaning up after a build) - Map binarySources = state.getAjBuildManager().getBinarySourcesForThisWeave(); + Map> binarySources = state.getAjBuildManager().getBinarySourcesForThisWeave(); assertFalse("expected there to be binary sources from the inpath setting but didn't find any", binarySources.isEmpty()); - List unwovenClassFiles = (List) binarySources.get(inpathDir + File.separator + "InpathClass.class"); - List fileNames = new ArrayList(); + List unwovenClassFiles = binarySources.get(inpathDir + File.separator + "InpathClass.class"); + List fileNames = new ArrayList<>(); // the unwovenClassFiles should have filenames that point to the output dir // (which in this case is the sandbox dir) and not where they came from. - for (Iterator iterator = unwovenClassFiles.iterator(); iterator.hasNext();) { - UnwovenClassFile ucf = (UnwovenClassFile) iterator.next(); + for (UnwovenClassFile ucf: unwovenClassFiles) { if (ucf.getFilename().indexOf(expectedOutputDir) == -1) { fileNames.add(ucf.getFilename()); } @@ -145,15 +144,14 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen AjBuildConfig buildConfig = state.getBuildConfig(); state.prepareForNextBuild(buildConfig); - Map binarySources = state.getBinaryFilesToCompile(true); + Map> binarySources = state.getBinaryFilesToCompile(true); assertFalse("expected there to be binary sources from the inpath setting but didn't find any", binarySources.isEmpty()); - List unwovenClassFiles = (List) binarySources.get(inpathDir + File.separator + "InpathClass.class"); - List fileNames = new ArrayList(); + List unwovenClassFiles = binarySources.get(inpathDir + File.separator + "InpathClass.class"); + List fileNames = new ArrayList<>(); // the unwovenClassFiles should have filenames that point to the output dir // (which in this case is the sandbox dir) and not where they came from. - for (Iterator iterator = unwovenClassFiles.iterator(); iterator.hasNext();) { - UnwovenClassFile ucf = (UnwovenClassFile) iterator.next(); + for (UnwovenClassFile ucf: unwovenClassFiles) { if (ucf.getFilename().indexOf(expectedOutputDir) == -1) { fileNames.add(ucf.getFilename()); } @@ -177,14 +175,13 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen AjState state = getState(); // tests AjState.createUnwovenClassFile(BinarySourceFile) - Map binarySources = state.getAjBuildManager().getBinarySourcesForThisWeave(); + Map> binarySources = state.getAjBuildManager().getBinarySourcesForThisWeave(); assertFalse("expected there to be binary sources from the inpath setting but didn't find any", binarySources.isEmpty()); - List unwovenClassFiles = (List) binarySources.get(inpathDir); - List fileNames = new ArrayList(); + List unwovenClassFiles = binarySources.get(inpathDir); + List fileNames = new ArrayList<>(); - for (Iterator iterator = unwovenClassFiles.iterator(); iterator.hasNext();) { - UnwovenClassFile ucf = (UnwovenClassFile) iterator.next(); + for (UnwovenClassFile ucf: unwovenClassFiles) { if (ucf.getFilename().indexOf(expectedOutputDir) == -1) { fileNames.add(ucf.getFilename()); } @@ -312,7 +309,7 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen return; } File f = new File(entry); - Set s = new HashSet(); + Set s = new HashSet<>(); s.add(f); configureInPath("inpathTesting", s); } @@ -325,14 +322,14 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen private File classOutputLoc; private File resourceOutputLoc; private String testProjectOutputPath; - private List allOutputLocations; + private List allOutputLocations; private File outputLoc; public SingleDirOutputLocMgr(String testProjectPath) { this.testProjectOutputPath = testProjectPath + File.separator + "bin"; outputLoc = new File(testProjectOutputPath); - allOutputLocations = new ArrayList(); + allOutputLocations = new ArrayList<>(); allOutputLocations.add(outputLoc); } @@ -340,8 +337,8 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen return outputLoc; } - public Map getInpathMap() { - return Collections.EMPTY_MAP; + public Map getInpathMap() { + return Collections.emptyMap(); } @@ -349,7 +346,7 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen return outputLoc; } - public List /* File */getAllOutputLocations() { + public List getAllOutputLocations() { return allOutputLocations; } @@ -364,13 +361,11 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen } public String getSourceFolderForFile(File sourceFile) { - // TODO Auto-generated method stub - return null; + return null; // no impl } public int discoverChangesSince(File dir, long buildtime) { - // TODO Auto-generated method stub - return 0; + return 0; // no impl } } diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestOutputLocationManager.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestOutputLocationManager.java index a5e93a824..bb04e515b 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestOutputLocationManager.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjTestOutputLocationManager.java @@ -31,7 +31,7 @@ public class MultiProjTestOutputLocationManager implements IOutputLocationManage private File classOutputLoc; private File resourceOutputLoc; private final Map sourceFolders = new HashMap(); - private List allOutputLocations; + private List allOutputLocations; public MultiProjTestOutputLocationManager(String testProjectPath) { this.testProjectOutputPath = testProjectPath + File.separator + "bin"; @@ -52,9 +52,9 @@ public class MultiProjTestOutputLocationManager implements IOutputLocationManage return resourceOutputLoc; } - public List getAllOutputLocations() { + public List getAllOutputLocations() { if (allOutputLocations == null) { - allOutputLocations = new ArrayList(); + allOutputLocations = new ArrayList<>(); initLocations(); allOutputLocations.add(classOutputLoc); if (!classOutputLoc.equals(resourceOutputLoc)) { diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java index 36001fe6a..779143bd1 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java @@ -1233,7 +1233,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa alter(p, "inc2"); // whitespace change on affected file build(p); checkWasntFullBuild(); - List l = getCompilerErrorMessages(p); + List l = getCompilerErrorMessages(p); assertEquals("Unexpected compiler error", 0, l.size()); } @@ -2646,7 +2646,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa configureShowWeaveInfoMessages("PR157054", true); build("PR157054"); checkWasFullBuild(); - List weaveMessages = getWeavingMessages("PR157054"); + List weaveMessages = getWeavingMessages("PR157054"); assertTrue("Should be two weaving messages but there are " + weaveMessages.size(), weaveMessages.size() == 2); alter("PR157054", "inc1"); build("PR157054"); @@ -2827,7 +2827,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa initialiseProject("PR152257"); configureNonStandardCompileOptions("PR152257", "-XnoInline"); build("PR152257"); - List errors = getErrorMessages("PR152257"); + List errors = getErrorMessages("PR152257"); assertTrue("Should be no warnings, but there are #" + errors.size(), errors.size() == 0); checkWasFullBuild(); alter("PR152257", "inc1"); @@ -2965,10 +2965,9 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa } private void checkCompiled(String projectName, String typeNameSubstring) { - List files = getCompiledFiles(projectName); + List files = getCompiledFiles(projectName); boolean found = false; - for (Iterator iterator = files.iterator(); iterator.hasNext();) { - String object = (String) iterator.next(); + for (String object: files) { if (object.indexOf(typeNameSubstring) != -1) { found = true; } @@ -3302,7 +3301,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa // Step2. Quick check that the advice points to something... IProgramElement nodeForTypeA = checkForNode(model, "pkg", "A", true); IProgramElement nodeForAdvice = findAdvice(nodeForTypeA); - List relatedElements = getRelatedElements(model, nodeForAdvice, 1); + List relatedElements = getRelatedElements(model, nodeForAdvice, 1); // Step3. Check the advice applying at the first 'code' join point // in pkg.C is from aspect pkg.A, line 7 diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/OutputLocationManagerTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/OutputLocationManagerTests.java index 2de3976db..333495399 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/OutputLocationManagerTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/OutputLocationManagerTests.java @@ -50,7 +50,7 @@ public class OutputLocationManagerTests extends AbstractMultiProjectIncrementalA } public void testResourceCopying() { - Map resourceMap = new HashMap(); + Map resourceMap = new HashMap<>(); resourceMap.put("resourceOne.txt", new File(getFile(PROJECT_NAME, "srcRootOne/resourceOne.txt"))); resourceMap.put("resourceTwo.txt", new File(getFile(PROJECT_NAME, "srcRootTwo/resourceTwo.txt"))); configureResourceMap(PROJECT_NAME, resourceMap); @@ -93,7 +93,7 @@ public class OutputLocationManagerTests extends AbstractMultiProjectIncrementalA private static class MyOutputLocationManager implements IOutputLocationManager { private File projectHome; - private List allOutputDirs; + private List allOutputDirs; public MyOutputLocationManager(File projectHome) { this.projectHome = projectHome; @@ -106,8 +106,8 @@ public class OutputLocationManagerTests extends AbstractMultiProjectIncrementalA public void reportFileRemove(String outputfile, int filetype) { } - public Map getInpathMap() { - return Collections.EMPTY_MAP; + public Map getInpathMap() { + return Collections.emptyMap(); } @@ -132,9 +132,9 @@ public class OutputLocationManagerTests extends AbstractMultiProjectIncrementalA return getOutputLocationForClass(resource); } - public List getAllOutputLocations() { + public List getAllOutputLocations() { if (allOutputDirs == null) { - allOutputDirs = new ArrayList(); + allOutputDirs = new ArrayList<>(); allOutputDirs.add(new File(projectHome, "target/main/classes")); allOutputDirs.add(new File(projectHome, "target/test/classes")); allOutputDirs.add(new File(projectHome, "target/anotherTest/classes")); diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java index 94462d5ff..10fdbd05c 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java @@ -2586,11 +2586,11 @@ public class BcelShadow extends Shadow { ret.append(InstructionFactory.createArrayLoad(Type.OBJECT)); ret.append(Utility.createConversion(fact, Type.OBJECT, callbackMethod.getArgumentTypes()[0])); } else { - int position = (hasThis()/* && pointcutBindsThis */? 1 : 0); + int position = (hasThis() && pointcutBindsThis)? 1 : 0; ret.append(InstructionFactory.createLoad(objectArrayType, theObjectArrayLocalNumber)); ret.append(Utility.createConstant(fact, position)); ret.append(InstructionFactory.createArrayLoad(Type.OBJECT)); - ret.append(Utility.createConversion(fact, Type.OBJECT, callbackMethod.getArgumentTypes()[position])); + ret.append(Utility.createConversion(fact, Type.OBJECT, callbackMethod.getArgumentTypes()[nextArgumentToProvideForCallback])); } nextArgumentToProvideForCallback++; } else { @@ -3048,13 +3048,10 @@ public class BcelShadow extends Shadow { } /** - * * * @param callbackMethod the method we will call back to when our run method gets called. - * * @param proceedMap A map from state position to proceed argument position. May be non covering on state position. */ - private LazyMethodGen makeClosureClassAndReturnConstructor(String closureClassName, LazyMethodGen callbackMethod, IntMap proceedMap) { String superClassName = "org.aspectj.runtime.internal.AroundClosure"; @@ -3076,7 +3073,7 @@ public class BcelShadow extends Shadow { closureClass.addMethodGen(constructor); - // method + // Create the 'Object run(Object[])' method LazyMethodGen runMethod = new LazyMethodGen(Modifier.PUBLIC, Type.OBJECT, "run", new Type[] { objectArrayType }, new String[] {}, closureClass); InstructionList mbody = runMethod.getBody(); @@ -3092,12 +3089,11 @@ public class BcelShadow extends Shadow { Type[] stateTypes = callbackMethod.getArgumentTypes(); for (int i = 0, len = stateTypes.length; i < len; i++) { - Type stateType = stateTypes[i]; - ResolvedType stateTypeX = BcelWorld.fromBcel(stateType).resolve(world); + ResolvedType resolvedStateType = BcelWorld.fromBcel(stateTypes[i]).resolve(world); if (proceedMap.hasKey(i)) { - mbody.append(proceedVar.createConvertableArrayLoad(fact, proceedMap.get(i), stateTypeX)); + mbody.append(proceedVar.createConvertableArrayLoad(fact, proceedMap.get(i), resolvedStateType)); } else { - mbody.append(stateVar.createConvertableArrayLoad(fact, i, stateTypeX)); + mbody.append(stateVar.createConvertableArrayLoad(fact, i, resolvedStateType)); } } -- cgit v1.2.3 From 821f7d4c71c1025dae6990a65fb9549a8530b1ac Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Fri, 2 Dec 2016 10:37:28 -0800 Subject: added 2016/2017 to years --- build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java b/build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java index 819673cff..c05ee23ba 100644 --- a/build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java +++ b/build/src/org/aspectj/internal/tools/ant/taskdefs/Checklics.java @@ -338,7 +338,8 @@ public class Checklics extends MatchingTask { public static class License { /** acceptable years for copyright prefix to company - append " " */ static final String[] YEARS = // remove older after license xfer? - new String[] { "2002 ", "2003 ", "2004 ", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015", "2001 ", "2000 ", + new String[] { "2002 ", "2003 ", "2004 ", "2005", "2006", "2007", "2008", + "2009", "2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2001 ", "2000 ", "1999 " }; public final String tag; public final String license; -- cgit v1.2.3 From b5df397fa8f28c52bb02e489d0e1f821c0054a48 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Thu, 8 Dec 2016 08:43:16 -0800 Subject: Adjust from nasty exception to messages --- weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java index e3e97517a..d534405da 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java @@ -215,12 +215,15 @@ public class BcelWeaver { } return type; } else { - // FIXME AV - better warning upon no such aspect from aop.xml - RuntimeException ex = new RuntimeException("Cannot register non aspect: " + type.getName() + " , " + aspectName); - if (trace.isTraceEnabled()) { - trace.exit("addLibraryAspect", ex); - } - throw ex; + if (type.isMissing()) { + // May not be found if not visible to the classloader that can see the aop.xml during LTW + IMessage message = new Message("The specified aspect '"+aspectName+"' cannot be found", null, true); + world.getMessageHandler().handleMessage(message); + } else { + IMessage message = new Message("Cannot register '"+aspectName+"' because the type found with that name is not an aspect", null, true); + world.getMessageHandler().handleMessage(message); + } + return null; } } -- cgit v1.2.3 From 2c9e594e4c55230e120c3af55ef68ac8dcf309c5 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Thu, 8 Dec 2016 12:40:19 -0800 Subject: Update to latest JDT (neon 2) --- docs/dist/doc/README-1810.html | 44 +++++++++++++++++++++ docs/dist/doc/index.html | 3 +- .../src/org/aspectj/ajdt/ajc/messages.properties | 2 +- org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip | Bin 5207302 -> 5215519 bytes org.eclipse.jdt.core/jdtcore-for-aspectj.jar | Bin 10253519 -> 10270059 bytes .../src/org/aspectj/systemtest/ajc1612/ajc1612.xml | 2 +- 6 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 docs/dist/doc/README-1810.html diff --git a/docs/dist/doc/README-1810.html b/docs/dist/doc/README-1810.html new file mode 100644 index 000000000..bf0b24a9a --- /dev/null +++ b/docs/dist/doc/README-1810.html @@ -0,0 +1,44 @@ + + +AspectJ 1.8.10 Readme + + + + +
+© Copyright 2016 Contributors. +All rights reserved. +
+ +

AspectJ 1.8.10 Readme

+ +

The full list of resolved issues in 1.8.10 is available +here.

+ +
    +
  • 1.8.10 available 9-Dec-2016 +
+ +

Notable changes

+ +

The JDT compiler inside AspectJ has been upgraded to the Eclipse Neon.2 level (JDT commit #75dbfad0).

+ +
+

Bug 500035 +

A long standing issue that has been lurking in the handling of arguments passed to proceed for annotation style +aspects has been fixed. If, at a joinpoint where 'this'/'target' differ (for example at some call joinpoints), the pointcut +bound either 'this' or 'target' (but not both), then the system would still expect the advice to pass both 'this' and 'target' into the proceed +call. With the fix here you only need to pass what you bind. So if you bind only 'this' you don't need to pass 'target' (and vice versa). +This will affect users that have been working around this quirk by passing both 'this' and 'target'. That isn't necessary anymore. +This fix is in aspectjrt.jar so you will need to be using the 1.8.10 version of aspectjrt.jar at runtime to pickup this change. + + + diff --git a/docs/dist/doc/index.html b/docs/dist/doc/index.html index 513dc12db..b42262a1a 100644 --- a/docs/dist/doc/index.html +++ b/docs/dist/doc/index.html @@ -138,7 +138,8 @@ README's Changes and porting guide for AspectJ - 1.8.8, + 1.8.10, + 1.8.9, 1.8.8, 1.8.7, 1.8.6, diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties index 630fedb7a..f59300075 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties @@ -5,7 +5,7 @@ org/aspectj/weaver/XlintDefault.properties for the default behavior and a template to copy. ### AspectJ-specific messages compiler.name = AspectJ Compiler 1.8.10 -compiler.version = Eclipse Compiler Neon.1 #5925A0B5, 3.12 +compiler.version = Eclipse Compiler Neon.2 #75dbfad0, 3.12 compiler.copyright = ## this next one superceded by above... diff --git a/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip b/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip index 76d1be79c..89aedd312 100644 Binary files a/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip and b/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip differ diff --git a/org.eclipse.jdt.core/jdtcore-for-aspectj.jar b/org.eclipse.jdt.core/jdtcore-for-aspectj.jar index 3ef06f537..7714061a6 100644 Binary files a/org.eclipse.jdt.core/jdtcore-for-aspectj.jar and b/org.eclipse.jdt.core/jdtcore-for-aspectj.jar differ diff --git a/tests/src/org/aspectj/systemtest/ajc1612/ajc1612.xml b/tests/src/org/aspectj/systemtest/ajc1612/ajc1612.xml index c02a99886..11746e122 100644 --- a/tests/src/org/aspectj/systemtest/ajc1612/ajc1612.xml +++ b/tests/src/org/aspectj/systemtest/ajc1612/ajc1612.xml @@ -655,7 +655,7 @@ - + -- cgit v1.2.3 From 2365f957eea267377b703d6c35e678d55a87ae2d Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Thu, 8 Dec 2016 14:45:51 -0800 Subject: Polishing for 1.8.10 release - reduced build level from 8 to 7 so that the weaver can be used on Java7. - minor readme tweaks --- .../internal/tools/ant/taskdefs/AntBuilder.java | 4 ++-- docs/dist/doc/README-1810.html | 8 ++++++-- lib/build/build.jar | Bin 192810 -> 162970 bytes 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java b/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java index 253e49fb1..379016a6f 100644 --- a/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java +++ b/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java @@ -269,8 +269,8 @@ public class AntBuilder extends Builder { javac.setTarget("1.1"); // 1.1 class files - Javac in 1.4 uses 1.4 javac.setSource("1.3"); } else { - javac.setSource("1.8"); - javac.setTarget("1.8"); + javac.setSource("1.7"); + javac.setTarget("1.7"); } // compile boolean passed = false; diff --git a/docs/dist/doc/README-1810.html b/docs/dist/doc/README-1810.html index bf0b24a9a..73e88069b 100644 --- a/docs/dist/doc/README-1810.html +++ b/docs/dist/doc/README-1810.html @@ -29,10 +29,14 @@ All rights reserved.

Notable changes

+

JDT Upgrade

The JDT compiler inside AspectJ has been upgraded to the Eclipse Neon.2 level (JDT commit #75dbfad0).

-
-

Bug 500035 +

Java8

+

The Eclipse JDT compiler embedded inside AspectJ now requires Java 8, so that is the minimum required level to compile sources with AspectJ. +However, if only doing weaving and no compilation then it is possible to use Java 7. + +

Annotation style around advice and proceed (Bug 500035)

A long standing issue that has been lurking in the handling of arguments passed to proceed for annotation style aspects has been fixed. If, at a joinpoint where 'this'/'target' differ (for example at some call joinpoints), the pointcut bound either 'this' or 'target' (but not both), then the system would still expect the advice to pass both 'this' and 'target' into the proceed diff --git a/lib/build/build.jar b/lib/build/build.jar index f48ce3390..36d2da115 100644 Binary files a/lib/build/build.jar and b/lib/build/build.jar differ -- cgit v1.2.3 From 90aa179e2c0b2870d8678f8e9948bf631840c93b Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Fri, 9 Dec 2016 09:04:56 -0800 Subject: 508661: testcode --- tests/bugs1810/508661/A_yes.java | 8 ++++++++ tests/bugs1810/508661/B_no.java | 7 +++++++ tests/bugs1810/508661/CacheMethodResult.java | 4 ++++ tests/bugs1810/508661/CacheMethodResultAspect.java | 10 ++++++++++ tests/bugs1810/508661/Run.java | 6 ++++++ tests/bugs1810/508661/aop.xml | 10 ++++++++++ tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java | 4 ++++ tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml | 14 ++++++++++++++ 8 files changed, 63 insertions(+) create mode 100644 tests/bugs1810/508661/A_yes.java create mode 100644 tests/bugs1810/508661/B_no.java create mode 100644 tests/bugs1810/508661/CacheMethodResult.java create mode 100644 tests/bugs1810/508661/CacheMethodResultAspect.java create mode 100644 tests/bugs1810/508661/Run.java create mode 100644 tests/bugs1810/508661/aop.xml diff --git a/tests/bugs1810/508661/A_yes.java b/tests/bugs1810/508661/A_yes.java new file mode 100644 index 000000000..9920f069a --- /dev/null +++ b/tests/bugs1810/508661/A_yes.java @@ -0,0 +1,8 @@ +public class A_yes { + @CacheMethodResult + public void m() { + System.out.println("A_yes.m()"); + Class[] itfs = A_yes.class.getInterfaces(); + System.out.println("A_yes has interface? "+((itfs==null||itfs.length==0)?"no":itfs[0].getName())); + } +} diff --git a/tests/bugs1810/508661/B_no.java b/tests/bugs1810/508661/B_no.java new file mode 100644 index 000000000..e65d63377 --- /dev/null +++ b/tests/bugs1810/508661/B_no.java @@ -0,0 +1,7 @@ +class B_no { + public void m() { + System.out.println("B_no.m()"); + Class[] itfs = B_no.class.getInterfaces(); + System.out.println("B_no has interface? "+((itfs==null||itfs.length==0)?"no":itfs[0].getName())); + } +} diff --git a/tests/bugs1810/508661/CacheMethodResult.java b/tests/bugs1810/508661/CacheMethodResult.java new file mode 100644 index 000000000..fd919bd5b --- /dev/null +++ b/tests/bugs1810/508661/CacheMethodResult.java @@ -0,0 +1,4 @@ +import java.lang.annotation.*; + +@Retention(RetentionPolicy.RUNTIME) +@interface CacheMethodResult {} diff --git a/tests/bugs1810/508661/CacheMethodResultAspect.java b/tests/bugs1810/508661/CacheMethodResultAspect.java new file mode 100644 index 000000000..d7626a917 --- /dev/null +++ b/tests/bugs1810/508661/CacheMethodResultAspect.java @@ -0,0 +1,10 @@ +aspect CacheMethodResultAspect perthis(cache()) { + + pointcut cache() : execution(@CacheMethodResult * *.*(..)); + + Object around() : cache() { + System.out.println("around: "+thisJoinPointStaticPart.getSignature()); + return proceed(); + } +} + diff --git a/tests/bugs1810/508661/Run.java b/tests/bugs1810/508661/Run.java new file mode 100644 index 000000000..176e5a499 --- /dev/null +++ b/tests/bugs1810/508661/Run.java @@ -0,0 +1,6 @@ +public class Run { + public static void main(String []argv) { + new A_yes().m(); + new B_no().m(); + } +} diff --git a/tests/bugs1810/508661/aop.xml b/tests/bugs1810/508661/aop.xml new file mode 100644 index 000000000..5b89e6614 --- /dev/null +++ b/tests/bugs1810/508661/aop.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java b/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java index 3cae1378c..37896b42f 100644 --- a/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java @@ -24,6 +24,10 @@ import junit.framework.Test; */ public class Ajc1810Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + public void testBinding_508661() { + runTest("various ltw"); + } + public void testBinding_500035() { runTest("ataspectj binding"); } diff --git a/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml b/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml index 7485c1c20..0171f5b55 100644 --- a/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml +++ b/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml @@ -2,6 +2,20 @@ + + + + + + + + + + + + + + -- cgit v1.2.3 From 3714f91628b7c83e2333895370b7b9a3a160a8a9 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Fri, 9 Dec 2016 09:46:10 -0800 Subject: fix warnings in build - support .isJava8 option in build --- .../org/aspectj/tools/ajdoc/CoverageTestCase.java | 3 --- .../internal/tools/ant/taskdefs/AntBuilder.java | 18 ++++++++++++++---- lib/build/build.jar | Bin 162970 -> 163038 bytes testing-client/.isJava5 | 1 + .../internal/tools/ant/taskdefs/Ajctest.java | 8 ++++---- .../weaver/tools/Java15PointcutExpressionTest.java | 10 +++++----- 6 files changed, 24 insertions(+), 16 deletions(-) create mode 100644 testing-client/.isJava5 diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java index afa27b319..6ee7f7a88 100644 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java +++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java @@ -14,11 +14,8 @@ import java.io.File; import java.util.List; -import org.aspectj.util.FileUtil; import org.aspectj.util.LangUtil; -import com.sun.org.apache.xml.internal.serializer.utils.Utils; - /** * A long way to go until full coverage, but this is the place to add more. diff --git a/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java b/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java index 379016a6f..107905231 100644 --- a/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java +++ b/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java @@ -224,15 +224,20 @@ public class AntBuilder extends Builder { Path path = new Path(project); boolean hasSourceDirectories = false; boolean isJava5Compile = false; + boolean isJava8Compile = false; for (File file: result.getSrcDirs()) { // for (Iterator iter = result.getSrcDirs().iterator(); iter.hasNext();) { // File file = (File) iter.next(); path.createPathElement().setLocation(file); if (!isJava5Compile - && (Util.Constants.JAVA5_SRC.equals(file.getName()) || Util.Constants.JAVA5_TESTSRC.equals(file.getName()) || new File( - file.getParent(), ".isJava5").exists())) { + && (Util.Constants.JAVA5_SRC.equals(file.getName()) || + Util.Constants.JAVA5_TESTSRC.equals(file.getName()) || + new File(file.getParent(), ".isJava5").exists())) { isJava5Compile = true; } + if (new File(file.getParent(),".isJava8").exists()) { + isJava8Compile = true; + } if (!hasSourceDirectories) { hasSourceDirectories = true; } @@ -269,8 +274,13 @@ public class AntBuilder extends Builder { javac.setTarget("1.1"); // 1.1 class files - Javac in 1.4 uses 1.4 javac.setSource("1.3"); } else { - javac.setSource("1.7"); - javac.setTarget("1.7"); + if (isJava8Compile) { + javac.setSource("1.8"); + javac.setTarget("1.8"); + } else { + javac.setSource("1.7"); + javac.setTarget("1.7"); + } } // compile boolean passed = false; diff --git a/lib/build/build.jar b/lib/build/build.jar index 36d2da115..28a3fea05 100644 Binary files a/lib/build/build.jar and b/lib/build/build.jar differ diff --git a/testing-client/.isJava5 b/testing-client/.isJava5 new file mode 100644 index 000000000..136d06384 --- /dev/null +++ b/testing-client/.isJava5 @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/testing/src/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java b/testing/src/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java index 2502bca0d..8fb274176 100644 --- a/testing/src/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java +++ b/testing/src/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java @@ -818,8 +818,8 @@ public class Ajctest extends Task implements PropertyChangeListener { testsetToArgcombo.put(testset, argcombo); } while (!testsetToArgcombo.isEmpty()) { - int _ = 1; - for (Iterator iter = testsets.iterator(); iter.hasNext(); _++) { + int testsetCounter = 1; + for (Iterator iter = testsets.iterator(); iter.hasNext(); testsetCounter++) { Testset testset = iter.next(); List> argcombo = testsetToArgcombo.get(testset); if (argcombo.size() == 0) { @@ -827,8 +827,8 @@ public class Ajctest extends Task implements PropertyChangeListener { continue; } List args = argcombo.remove(0); - final String startStr = "Testset " + _ + " of " + testsets.size(); - String str = startStr + " / Combo " + _ + " of " + argcombos.size(); + final String startStr = "Testset " + testsetCounter + " of " + testsets.size(); + String str = startStr + " / Combo " + testsetCounter + " of " + argcombos.size(); log("---------- " + str + " ----------"); execute(testset, args); } diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java b/weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java index 9b155df3e..f651a2f29 100644 --- a/weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java +++ b/weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java @@ -105,11 +105,11 @@ public class Java15PointcutExpressionTest extends TestCase { PointcutExpression pexpr = null; ShadowMatch match = null; - Method n = test.AnnoValues.class.getMethod("none",null); - Method r = test.AnnoValues.class.getMethod("redMethod",null); - Method g = test.AnnoValues.class.getMethod("greenMethod",null); - Method b = test.AnnoValues.class.getMethod("blueMethod",null); - Method d = test.AnnoValues.class.getMethod("defaultMethod",null); + Method n = test.AnnoValues.class.getMethod("none"); + Method r = test.AnnoValues.class.getMethod("redMethod"); + Method g = test.AnnoValues.class.getMethod("greenMethod"); + Method b = test.AnnoValues.class.getMethod("blueMethod"); + Method d = test.AnnoValues.class.getMethod("defaultMethod"); pexpr = p.parsePointcutExpression("execution(@test.A3(test.Color.RED) public void *(..))"); assertTrue("Should match", pexpr.matchesMethodExecution(n).neverMatches()); // default value RED -- cgit v1.2.3 From 8e079ecde2315294e16de8304899d19acdd15c36 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Fri, 16 Dec 2016 15:46:48 -0800 Subject: 509327: Minor fixes to improve the situation, wip --- .../org/aspectj/weaver/patterns/ArgsPointcut.java | 3 +- .../JavaLangTypeToResolvedTypeConverter.java | 12 +- .../weaver/reflect/ReflectionWorldTest.java | 162 ++++++++++++++++++++- 3 files changed, 173 insertions(+), 4 deletions(-) diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ArgsPointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ArgsPointcut.java index 4898a92b5..56b1a4dc5 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ArgsPointcut.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ArgsPointcut.java @@ -57,7 +57,7 @@ public class ArgsPointcut extends NameBindingPointcut { return arguments; } - public Pointcut parameterizeWith(Map typeVariableMap, World w) { + public Pointcut parameterizeWith(Map typeVariableMap, World w) { ArgsPointcut ret = new ArgsPointcut(this.arguments.parameterizeWith(typeVariableMap, w)); ret.copyLocationFrom(this); return ret; @@ -114,7 +114,6 @@ public class ArgsPointcut extends NameBindingPointcut { argumentsToMatchAgainst = argsSubset; } } - return argumentsToMatchAgainst; } diff --git a/weaver5/java5-src/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java b/weaver5/java5-src/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java index 51a9a4e84..41ab968a7 100644 --- a/weaver5/java5-src/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java +++ b/weaver5/java5-src/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java @@ -66,10 +66,20 @@ public class JavaLangTypeToResolvedTypeConverter { return getWorld().resolve(name); } } else if (type instanceof ParameterizedType) { + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=509327 + // TODO should deal with the ownerType if it set, indicating this is possibly an inner type of a parameterized type +// Type ownerType = ((ParameterizedType) type).getOwnerType(); ParameterizedType parameterizedType = (ParameterizedType) type; ResolvedType baseType = fromType(parameterizedType.getRawType()); - if (!baseType.isRawType()) throw new IllegalStateException("Expected raw type form of "+parameterizedType.getRawType().getTypeName()); Type[] typeArguments = parameterizedType.getActualTypeArguments(); + if (baseType.isSimpleType() && typeArguments.length == 0) { + // 'type' is an inner type of some outer parameterized type + // For now just return the base type - in future create the parameterized form of the outer + // and use it with the inner. We return the base type to be compatible with what the + // code does that accesses the info from the bytecode (unlike this code which accesses it + // reflectively). + return baseType; + } ResolvedType[] resolvedTypeArguments = fromTypes(typeArguments); return TypeFactory.createParameterizedType(baseType, resolvedTypeArguments, getWorld()); } else if (type instanceof java.lang.reflect.TypeVariable) { diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldTest.java b/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldTest.java index 5c08cf892..3dcbf45b2 100644 --- a/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldTest.java +++ b/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldTest.java @@ -11,11 +11,18 @@ * ******************************************************************/ package org.aspectj.weaver.reflect; -import junit.framework.TestCase; +import java.lang.reflect.Method; +import java.lang.reflect.Type; +import org.aspectj.bridge.IMessageHandler; +import org.aspectj.weaver.ReferenceType; +import org.aspectj.weaver.ResolvedMember; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.UnresolvedType; import org.aspectj.weaver.World; +import org.aspectj.weaver.bcel.BcelWorld; + +import junit.framework.TestCase; public class ReflectionWorldTest extends TestCase { @@ -38,5 +45,158 @@ public class ReflectionWorldTest extends TestCase { assertEquals("int", UnresolvedType.INT, world.resolve(int.class)); assertEquals("void", UnresolvedType.VOID, world.resolve(void.class)); } + + public void testTypeConversions_509327() throws Exception { + ReflectionWorld rWorld = new ReflectionWorld(getClass().getClassLoader()); + JavaLangTypeToResolvedTypeConverter converter = new JavaLangTypeToResolvedTypeConverter(rWorld); + + // Check basic conversion of String to String + Method method = TestClass.class.getDeclaredMethod("m"); + Type stringType = method.getGenericReturnType(); + assertEquals("java.lang.String",stringType.getTypeName()); + ResolvedType stringResolvedType = converter.fromType(stringType); + assertEquals("java.lang.String",stringResolvedType.getName()); + + // public String m() { return ""; } + method = TestClass2.class.getDeclaredMethod("m"); + stringType = method.getGenericReturnType(); + assertEquals("java.lang.String",stringType.getTypeName()); + stringResolvedType = converter.fromType(stringType); + assertEquals("java.lang.String",stringResolvedType.getName()); + + // Verify that the conversion process creates the same thing as the bcel unpacking + + // Here the return type is a non-static inner of a generic class + // public Inner m2() { return null; } + method = TestClass2.class.getDeclaredMethod("m2"); + Type innerType = method.getGenericReturnType(); + assertEquals("org.aspectj.weaver.reflect.ReflectionWorldTest.org.aspectj.weaver.reflect.ReflectionWorldTest$TestClass2.Inner",innerType.getTypeName()); + ResolvedType rType_Inner = converter.fromType(innerType); + assertEquals("Lorg/aspectj/weaver/reflect/ReflectionWorldTest$TestClass2$Inner;",rType_Inner.getSignature()); + assertEquals(UnresolvedType.TypeKind.SIMPLE,rType_Inner.getTypekind()); + ResolvedType rType_Outer = rType_Inner.getOuterClass(); + assertEquals("Lorg/aspectj/weaver/reflect/ReflectionWorldTest$TestClass2;",rType_Outer.getSignature()); + + BcelWorld bWorld = new BcelWorld(getClass().getClassLoader(), IMessageHandler.THROW, null); + bWorld.setBehaveInJava5Way(true); + UnresolvedType javaUtilHashMap = UnresolvedType.forName("java.util.HashMap"); + ReferenceType rawType = (ReferenceType) bWorld.resolve(javaUtilHashMap); + assertNotNull(rawType); + + // Now use bcel to resolve the same m2 method, and compare the signatures of the return types + ResolvedType bResolved_TestClass2 = bWorld.resolve(UnresolvedType.forName(TestClass2.class.getName())); + assertNotNull(bResolved_TestClass2); + ResolvedMember bMethod_m2 = findMethod(bResolved_TestClass2,"m2"); + ResolvedType bType_Inner = (ResolvedType) bMethod_m2.getReturnType(); + assertEquals("Lorg/aspectj/weaver/reflect/ReflectionWorldTest$TestClass2$Inner;",bType_Inner.getSignature()); + assertEquals(UnresolvedType.TypeKind.SIMPLE,bType_Inner.getTypekind()); + ResolvedType bType_Outer = bType_Inner.getOuterClass(); + assertEquals("Lorg/aspectj/weaver/reflect/ReflectionWorldTest$TestClass2;",bType_Outer.getSignature()); + + assertEquals(bType_Inner.getSignature(),rType_Inner.getSignature()); + assertEquals(bType_Outer.getSignature(),rType_Outer.getSignature()); + } + + + public void testTypeConversions_509327_2() throws Exception { + ReflectionWorld world = new ReflectionWorld(getClass().getClassLoader()); + JavaLangTypeToResolvedTypeConverter converter = new JavaLangTypeToResolvedTypeConverter(world); + BcelWorld bWorld = new BcelWorld(getClass().getClassLoader(), IMessageHandler.THROW, null); + bWorld.setBehaveInJava5Way(true); + + // Slightly more advanced, now the method is returning a parameterized form of the outer + // generic class + + // public TestClass2.Inner m3() { return new TestClass2.Inner("Foo"); } + Method method = TestClass2.class.getDeclaredMethod("m3"); + Type type_ParameterizedInner = method.getGenericReturnType(); + assertEquals("org.aspectj.weaver.reflect.ReflectionWorldTest.org.aspectj.weaver.reflect.ReflectionWorldTest$TestClass2.Inner",type_ParameterizedInner.getTypeName()); + ResolvedType rType_ParameterizedInner = converter.fromType(type_ParameterizedInner); + // NOTE: DECLARED PARAMETERIZATION OF OUTER IS LOST + assertEquals("Lorg/aspectj/weaver/reflect/ReflectionWorldTest$TestClass2$Inner;",rType_ParameterizedInner.getSignature()); + + ResolvedType bResolved_TestClass2 = bWorld.resolve(UnresolvedType.forName(TestClass2.class.getName())); + assertNotNull(bResolved_TestClass2); + ResolvedMember bMethod_m3 = findMethod(bResolved_TestClass2,"m3"); + ResolvedType bType_Inner = (ResolvedType) bMethod_m3.getReturnType(); + // NOTE: DECLARED PARAMETERIZATION OF OUTER IS LOST + assertEquals("Lorg/aspectj/weaver/reflect/ReflectionWorldTest$TestClass2$Inner;",bType_Inner.getSignature()); + + assertEquals(UnresolvedType.TypeKind.SIMPLE,bType_Inner.getTypekind()); + ResolvedType bType_Outer = bType_Inner.getOuterClass(); + + // Fields seem to lose it too, although the backinggenericmember has the info +// ResolvedMember bField_f = findField(bResolved_TestClass2,"f"); +// ResolvedMember backingGenericMember = bField_f.getBackingGenericMember(); +// System.out.println(backingGenericMember); +// System.out.println(backingGenericMember.getGenericReturnType()); +// System.out.println(bField_f); +// System.out.println(bField_f.getSignature()); +// System.out.println(bField_f.getGenericReturnType()); + } + +// public void testbar() throws Exception { +// ReflectionWorld world = new ReflectionWorld(getClass().getClassLoader()); +// JavaLangTypeToResolvedTypeConverter converter = new JavaLangTypeToResolvedTypeConverter(world); +// +// // public TestClass2.Inner m3() { return new TestClass2.Inner("Foo"); } +// Method method = TestClass2.class.getDeclaredMethod("m3"); +// Type type_ParameterizedInner = method.getGenericReturnType(); +// assertEquals("org.aspectj.weaver.reflect.ReflectionWorldTest.org.aspectj.weaver.reflect.ReflectionWorldTest$TestClass2.Inner",type_ParameterizedInner.getTypeName()); +// ResolvedType rType_ParameterizedInner = converter.fromType(type_ParameterizedInner); +// System.out.println(rType_ParameterizedInner); +// System.out.println(type_ParameterizedInner.getTypeName()); +// } +// +// public void testfoo() { +// ReflectionWorld world = new ReflectionWorld(getClass().getClassLoader()); +// JavaLangTypeToResolvedTypeConverter converter = new JavaLangTypeToResolvedTypeConverter(world); +// BcelWorld bWorld = new BcelWorld(getClass().getClassLoader(), IMessageHandler.THROW, null); +// bWorld.setBehaveInJava5Way(true); +// +// +// ResolvedType bResolved_TestClass2 = bWorld.resolve(UnresolvedType.forName(TestClass2.class.getName())); +// ResolvedMember bField_f = findField(bResolved_TestClass2,"f"); +// System.out.println(bField_f); +// System.out.println(bField_f.getGenericReturnType()); +// System.out.println(bField_f.getReturnType()); +// System.out.println(bField_f.getBackingGenericMember().getGenericReturnType()); +// } + + static class TestClass { + public String m() { return ""; } + } + + static class TestClass2 { + class Inner { + T t; + Inner(T t) { + this.t = t; + } + } + public String m() { return ""; } + public Inner m2() { return null; } + public TestClass2 f; + public TestClass2.Inner m3() { return new TestClass2.Inner("Foo"); } + } + + private ResolvedMember findMethod(ResolvedType resolvedType, String methodName) { + for (ResolvedMember method: resolvedType.getDeclaredMethods()) { + if (method.getName().equals(methodName)) { + return method; + } + } + return null; + } + + private ResolvedMember findField(ResolvedType resolvedType, String fieldName) { + for (ResolvedMember field: resolvedType.getDeclaredFields()) { + if (field.getName().equals(fieldName)) { + return field; + } + } + return null; + } + } -- cgit v1.2.3 From ab4df7e110b0a4ddfc9cc1ec1653d3433c9605c4 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Fri, 16 Dec 2016 15:47:37 -0800 Subject: 1.8.11 test setup and wip tests --- tests/bugs1811/509235/Code.java | 17 +++++ tests/bugs1811/509235/Code2.java | 17 +++++ tests/bugs1811/parameterizedWithInner/Code.java | 20 +++++ tests/src/org/aspectj/systemtest/AllTests18.java | 2 + .../aspectj/systemtest/ajc1811/Ajc1811Tests.java | 86 ++++++++++++++++++++++ .../systemtest/ajc1811/AllTestsAspectJ1811.java | 25 +++++++ .../src/org/aspectj/systemtest/ajc1811/ajc1811.xml | 29 ++++++++ 7 files changed, 196 insertions(+) create mode 100644 tests/bugs1811/509235/Code.java create mode 100644 tests/bugs1811/509235/Code2.java create mode 100644 tests/bugs1811/parameterizedWithInner/Code.java create mode 100644 tests/src/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java create mode 100644 tests/src/org/aspectj/systemtest/ajc1811/AllTestsAspectJ1811.java create mode 100644 tests/src/org/aspectj/systemtest/ajc1811/ajc1811.xml diff --git a/tests/bugs1811/509235/Code.java b/tests/bugs1811/509235/Code.java new file mode 100644 index 000000000..be7bb10e0 --- /dev/null +++ b/tests/bugs1811/509235/Code.java @@ -0,0 +1,17 @@ +public class Code { + public static void main(String []argv) { + foo("fooname"); + bar("crap","barname"); + } + + public static void foo(String username) {} + + public static void bar(String a, String username) { } +} + +aspect X { + before(String username): (execution(public static * foo(..)) && args(username,..)) || + (execution(public static * bar(..)) && args(*,username,..)) { + System.out.println("username = "+username); + } +} diff --git a/tests/bugs1811/509235/Code2.java b/tests/bugs1811/509235/Code2.java new file mode 100644 index 000000000..67765c1cb --- /dev/null +++ b/tests/bugs1811/509235/Code2.java @@ -0,0 +1,17 @@ +public class Code2 { + public static void main(String []argv) { + foo("fooname"); + bar("crap","barname"); + } + + public static void foo(String username) {} + + public static void bar(String a, String username) { } +} + +aspect X { + before(String username): (execution(public static * foo(..)) && args(username)) || + (execution(public static * bar(..)) && args(*,username)) { + System.out.println("username = "+username); + } +} diff --git a/tests/bugs1811/parameterizedWithInner/Code.java b/tests/bugs1811/parameterizedWithInner/Code.java new file mode 100644 index 000000000..182a01d88 --- /dev/null +++ b/tests/bugs1811/parameterizedWithInner/Code.java @@ -0,0 +1,20 @@ +public class Code { + public static void main(String []argv) { + } +} + +class Outer { + class Inner { + T t; + Inner(T t) { + this.t =t ; + } + } + + public Inner m() {return null;} + public Outer.Inner m2() { + Outer os = new Outer(); + return os.new Inner("foo"); + } + public Outer.Inner m3() {return null;} +} diff --git a/tests/src/org/aspectj/systemtest/AllTests18.java b/tests/src/org/aspectj/systemtest/AllTests18.java index 2eadcb823..9c2387b0d 100644 --- a/tests/src/org/aspectj/systemtest/AllTests18.java +++ b/tests/src/org/aspectj/systemtest/AllTests18.java @@ -13,6 +13,7 @@ package org.aspectj.systemtest; import org.aspectj.systemtest.ajc180.AllTestsAspectJ180; import org.aspectj.systemtest.ajc181.AllTestsAspectJ181; import org.aspectj.systemtest.ajc1810.AllTestsAspectJ1810; +import org.aspectj.systemtest.ajc1811.AllTestsAspectJ1811; import org.aspectj.systemtest.ajc182.AllTestsAspectJ182; import org.aspectj.systemtest.ajc183.AllTestsAspectJ183; import org.aspectj.systemtest.ajc184.AllTestsAspectJ184; @@ -30,6 +31,7 @@ public class AllTests18 { public static Test suite() { TestSuite suite = new TestSuite("AspectJ System Test Suite - 1.8"); // $JUnit-BEGIN$ + suite.addTest(AllTestsAspectJ1811.suite()); suite.addTest(AllTestsAspectJ1810.suite()); suite.addTest(AllTestsAspectJ189.suite()); suite.addTest(AllTestsAspectJ188.suite()); diff --git a/tests/src/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java b/tests/src/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java new file mode 100644 index 000000000..0c6663692 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (c) 2016 Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc1811; + +import java.io.File; + +import org.aspectj.apache.bcel.Constants; +import org.aspectj.apache.bcel.classfile.Attribute; +import org.aspectj.apache.bcel.classfile.JavaClass; +import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.weaver.ResolvedMember; +import org.aspectj.weaver.ResolvedType; +import org.aspectj.weaver.UnresolvedType; +import org.aspectj.weaver.bcel.BcelWorld; + +import junit.framework.Test; + +/** + * @author Andy Clement + */ +public class Ajc1811Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + +// public void testParameterizedWithInner() throws Exception { +// runTest("parameterized with inner"); +// JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "Outer"); +// assertNotNull(jc); +// BcelWorld world = new BcelWorld(ajc.getSandboxDirectory().toString()); +// +// ResolvedType outerType = world.resolve(UnresolvedType.forName("Outer")); +// ResolvedMember m = findMethod(outerType,"m"); +// +// UnresolvedType type = m.getReturnType(); +// assertEquals("LOuter$Inner;",type.getSignature()); +// +// type = m.getGenericReturnType(); +// assertEquals("LOuter$Inner;",type.getSignature()); +// +// ResolvedType resolvedType = world.resolve(type); +// ResolvedType outerResolvedType = resolvedType.getOuterClass(); +// assertEquals("LOuter;",outerResolvedType.getSignature()); +// +// ResolvedMember m2 = findMethod(outerType,"m2"); +// type = m2.getReturnType(); +// assertEquals("LOuter$Inner;",type.getSignature()); +// +// type = m2.getGenericReturnType(); +// assertEquals("LOuter$Inner;",type.getSignature()); +// +// // public Inner m() { ... } +// Method m = findMethod(jc,"m"); +// System.out.println(m); +// System.out.println(">"+m.getReturnType()); +// assertNotNull(returnType); +// +// // public Outer.Inner m2() { ... } +// } +// +// public void testMultiArgs_509235() { +// runTest("multiargs"); +// } +// +// public void testMultiArgs_509235_2() { +// runTest("multiargs - no ellipsis"); +// } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc1811Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc1811.xml"); + } + +} diff --git a/tests/src/org/aspectj/systemtest/ajc1811/AllTestsAspectJ1811.java b/tests/src/org/aspectj/systemtest/ajc1811/AllTestsAspectJ1811.java new file mode 100644 index 000000000..b8aca6712 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc1811/AllTestsAspectJ1811.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2016 Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc1811; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ1811 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.8.11 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc1811Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc1811/ajc1811.xml b/tests/src/org/aspectj/systemtest/ajc1811/ajc1811.xml new file mode 100644 index 000000000..f4e321e5c --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc1811/ajc1811.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From 4243d0e9edb48b03746657a8e419944faf3c62a2 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Fri, 16 Dec 2016 15:47:55 -0800 Subject: polish --- weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java | 30 ++++++++-------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java index d534405da..1a66c72b3 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java @@ -697,8 +697,7 @@ public class BcelWeaver { // if numFormals > 0 then every branch of a disjunction must bind each // formal once and only once. // in addition, the left and right branches of a disjunction must hold on - // join point kinds in - // common. + // join point kinds in common. private void validateBindings(Pointcut dnfPointcut, Pointcut userPointcut, int numFormals, String[] names) { if (numFormals == 0) { return; // nothing to check @@ -740,8 +739,7 @@ public class BcelWeaver { int kindsInCommon = left.couldMatchKinds() & right.couldMatchKinds(); if (kindsInCommon != Shadow.NO_SHADOW_KINDS_BITS && couldEverMatchSameJoinPoints(left, right)) { // we know that every branch binds every formal, so there is no - // ambiguity - // if each branch binds it in exactly the same way... + // ambiguity if each branch binds it in exactly the same way... List ambiguousNames = new ArrayList(); for (int i = 0; i < numFormals; i++) { if (leftBindings[i] == null) { @@ -802,10 +800,9 @@ public class BcelWeaver { validateSingleBranchRecursion(and.getLeft(), userPointcut, foundFormals, names, bindings); validateSingleBranchRecursion(and.getRight(), userPointcut, foundFormals, names, bindings); } else if (pc instanceof NameBindingPointcut) { - List/* BindingTypePattern */btps = ((NameBindingPointcut) pc).getBindingTypePatterns(); - for (Iterator iter = btps.iterator(); iter.hasNext();) { - BindingTypePattern btp = (BindingTypePattern) iter.next(); - int index = btp.getFormalIndex(); + List bindingTypePatterns = ((NameBindingPointcut) pc).getBindingTypePatterns(); + for (BindingTypePattern bindingTypePattern: bindingTypePatterns) { + int index = bindingTypePattern.getFormalIndex(); bindings[index] = pc; if (foundFormals[index]) { raiseAmbiguousBindingError(names[index], userPointcut); @@ -813,10 +810,9 @@ public class BcelWeaver { foundFormals[index] = true; } } - List/* BindingPattern */baps = ((NameBindingPointcut) pc).getBindingAnnotationTypePatterns(); - for (Iterator iter = baps.iterator(); iter.hasNext();) { - BindingPattern bap = (BindingPattern) iter.next(); - int index = bap.getFormalIndex(); + List bindingAnnotationTypePatterns = ((NameBindingPointcut) pc).getBindingAnnotationTypePatterns(); + for (BindingPattern bindingAnnotationTypePattern: bindingAnnotationTypePatterns) { + int index = bindingAnnotationTypePattern.getFormalIndex(); bindings[index] = pc; if (foundFormals[index]) { raiseAmbiguousBindingError(names[index], userPointcut); @@ -912,13 +908,9 @@ public class BcelWeaver { .getSourceContext().makeSourceLocation(userPointcut), null); } - /** - * @param name - * @param userPointcut - */ - private void raiseAmbiguousBindingError(String name, Pointcut userPointcut) { - world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.AMBIGUOUS_BINDING, name), userPointcut - .getSourceContext().makeSourceLocation(userPointcut), null); + private void raiseAmbiguousBindingError(String name, Pointcut pointcut) { + world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.AMBIGUOUS_BINDING, name), pointcut + .getSourceContext().makeSourceLocation(pointcut), null); } /** -- cgit v1.2.3 From 4a07d09f36126bc829204644536ed29b864cef46 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Fri, 16 Dec 2016 16:32:49 -0800 Subject: reduced min Java version to 1.6 --- .../internal/tools/ant/taskdefs/AntBuilder.java | 5 ++-- lib/build/build.jar | Bin 163038 -> 163040 bytes .../internal/compiler/ast/AdviceDeclaration.java | 2 +- .../org/aspectj/testing/XMLBasedAjcTestCase.java | 28 ++++++++++++++++++--- util/src/org/aspectj/util/LangUtil.java | 2 +- 5 files changed, 29 insertions(+), 8 deletions(-) diff --git a/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java b/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java index 107905231..aeb9b11b7 100644 --- a/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java +++ b/build/src/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java @@ -278,8 +278,9 @@ public class AntBuilder extends Builder { javac.setSource("1.8"); javac.setTarget("1.8"); } else { - javac.setSource("1.7"); - javac.setTarget("1.7"); + // min + javac.setSource("1.6"); + javac.setTarget("1.6"); } } // compile diff --git a/lib/build/build.jar b/lib/build/build.jar index 28a3fea05..8a6f93714 100644 Binary files a/lib/build/build.jar and b/lib/build/build.jar differ diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java index 0d6e90d4c..f833c0007 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java @@ -65,7 +65,7 @@ public class AdviceDeclaration extends AjMethodDeclaration { public int adviceSequenceNumberInType; public MethodBinding proceedMethodBinding; // set during this.resolveStaments, referenced by Proceed - public List proceedCalls = new ArrayList<>(2); // populated during Proceed.findEnclosingAround + public List proceedCalls = new ArrayList(2); // populated during Proceed.findEnclosingAround private boolean proceedInInners; private ResolvedMember[] proceedCallSignatures; diff --git a/testing/newsrc/org/aspectj/testing/XMLBasedAjcTestCase.java b/testing/newsrc/org/aspectj/testing/XMLBasedAjcTestCase.java index 6705a5847..18b9233dc 100644 --- a/testing/newsrc/org/aspectj/testing/XMLBasedAjcTestCase.java +++ b/testing/newsrc/org/aspectj/testing/XMLBasedAjcTestCase.java @@ -24,10 +24,6 @@ import java.util.List; import java.util.Map; import java.util.Stack; -import junit.extensions.TestSetup; -import junit.framework.Test; -import junit.framework.TestSuite; - import org.apache.commons.digester.Digester; import org.aspectj.apache.bcel.classfile.Attribute; import org.aspectj.apache.bcel.classfile.JavaClass; @@ -39,6 +35,12 @@ import org.aspectj.apache.bcel.util.SyntheticRepository; import org.aspectj.tools.ajc.AjcTestCase; import org.aspectj.tools.ajc.CompilationResult; import org.aspectj.util.FileUtil; +import org.aspectj.weaver.ResolvedMember; +import org.aspectj.weaver.ResolvedType; + +import junit.extensions.TestSetup; +import junit.framework.Test; +import junit.framework.TestSuite; /** * Root class for all Test suites that are based on an AspectJ XML test suite file. Extends AjcTestCase allowing a mix of @@ -463,5 +465,23 @@ public abstract class XMLBasedAjcTestCase extends AjcTestCase { return new File(getClass().getResource(resourceName).getFile()); } + protected Method findMethod(JavaClass jc, String string) { + for (Method m : jc.getMethods()) { + if (m.getName().equals(string)) { + return m; + } + } + return null; + } + + protected ResolvedMember findMethod(ResolvedType outerType, String string) { + for (ResolvedMember method: outerType.getDeclaredMethods()) { + if (method.getName().equals(string)) { + return method; + } + } + return null; + } + } diff --git a/util/src/org/aspectj/util/LangUtil.java b/util/src/org/aspectj/util/LangUtil.java index b0bf14522..1d832508b 100644 --- a/util/src/org/aspectj/util/LangUtil.java +++ b/util/src/org/aspectj/util/LangUtil.java @@ -933,7 +933,7 @@ public class LangUtil { if ((null == array) || (1 > array.length)) { return Collections.emptyList(); } - ArrayList list = new ArrayList<>(); + ArrayList list = new ArrayList(); list.addAll(Arrays.asList(array)); return list; } -- cgit v1.2.3 From 6d6738cfece6328027916681e67e54225531db38 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Fri, 16 Dec 2016 17:23:41 -0800 Subject: 509327: extended the test slightly --- .../aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/weaver5/java5-src/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java b/weaver5/java5-src/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java index 41ab968a7..30983e38f 100644 --- a/weaver5/java5-src/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java +++ b/weaver5/java5-src/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java @@ -68,11 +68,11 @@ public class JavaLangTypeToResolvedTypeConverter { } else if (type instanceof ParameterizedType) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=509327 // TODO should deal with the ownerType if it set, indicating this is possibly an inner type of a parameterized type -// Type ownerType = ((ParameterizedType) type).getOwnerType(); + Type ownerType = ((ParameterizedType) type).getOwnerType(); ParameterizedType parameterizedType = (ParameterizedType) type; ResolvedType baseType = fromType(parameterizedType.getRawType()); Type[] typeArguments = parameterizedType.getActualTypeArguments(); - if (baseType.isSimpleType() && typeArguments.length == 0) { + if (baseType.isSimpleType() && typeArguments.length == 0 && ownerType != null) { // 'type' is an inner type of some outer parameterized type // For now just return the base type - in future create the parameterized form of the outer // and use it with the inner. We return the base type to be compatible with what the -- cgit v1.2.3