]> source.dussan.org Git - aspectj.git/commitdiff
Fix up tests and reduce verbosity on J11
authorAndy Clement <aclement@pivotal.io>
Fri, 14 Aug 2020 17:56:10 +0000 (10:56 -0700)
committerAndy Clement <aclement@pivotal.io>
Fri, 14 Aug 2020 17:56:10 +0000 (10:56 -0700)
13 files changed:
ajde.core/src/main/java/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java
ajde.core/src/test/java/org/aspectj/ajde/core/TestBuildProgressMonitor.java
ajde.core/src/test/java/org/aspectj/ajde/core/tests/OutxmlTest.java
ajde.core/src/test/java/org/aspectj/ajde/core/tests/ShowWeaveMessagesTest.java
ajde.core/src/test/java/org/aspectj/ajde/core/tests/model/AsmDeclarationsTest.java
ajde.core/src/test/java/org/aspectj/ajde/core/tests/model/AsmRelationshipsTest.java
ajde.core/src/test/java/org/aspectj/ajde/core/tests/model/StructureModelTest.java
org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java
org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java
tests/bugs170/xmldefs/Hello5.java
tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java
tests/src/test/resources/org/aspectj/systemtest/ajc170/ajc170.xml
weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java

index 6547d101ce4cb67fb4de6cf978aeab3ea1cfa5d5..49948db46511a77f14b8018957daa42bb4c816cd 100644 (file)
@@ -1,11 +1,11 @@
 /********************************************************************
- * Copyright (c) 2007 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://eclipse.org/legal/epl-v10.html 
- *  
- * Contributors: IBM Corporation - initial API and implementation 
+ * Copyright (c) 2007 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://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
  *                              Helen Hawkins   - initial version (bug 148190)
  *******************************************************************/
 package org.aspectj.ajde.core.internal;
@@ -13,7 +13,6 @@ package org.aspectj.ajde.core.internal;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.StringTokenizer;
@@ -70,7 +69,7 @@ public class AjdeCoreBuildManager {
 
        /**
         * Execute a full or incremental build
-        * 
+        *
         * @param fullBuild true if requesting a full build, false if requesting to try an incremental build
         */
        public void performBuild(boolean fullBuild) {
@@ -160,12 +159,12 @@ public class AjdeCoreBuildManager {
        private String getFormattedOptionsString() {
                ICompilerConfiguration compilerConfig = compiler.getCompilerConfiguration();
                return "Building with settings: " + "\n-> output paths: "
-                               + formatCollection(compilerConfig.getOutputLocationManager().getAllOutputLocations()) + "\n-> classpath: "
-                               + compilerConfig.getClasspath() + "\n-> -inpath " + formatCollection(compilerConfig.getInpath()) + "\n-> -outjar "
-                               + formatOptionalString(compilerConfig.getOutJar()) + "\n-> -aspectpath "
-                               + formatCollection(compilerConfig.getAspectPath()) + "\n-> -sourcePathResources "
-                               + formatMap(compilerConfig.getSourcePathResources()) + "\n-> non-standard options: "
-                               + compilerConfig.getNonStandardOptions() + "\n-> javaoptions:" + formatMap(compilerConfig.getJavaOptionsMap());
+               + formatCollection(compilerConfig.getOutputLocationManager().getAllOutputLocations()) + "\n-> classpath: "
+               + compilerConfig.getClasspath() + "\n-> -inpath " + formatCollection(compilerConfig.getInpath()) + "\n-> -outjar "
+               + formatOptionalString(compilerConfig.getOutJar()) + "\n-> -aspectpath "
+               + formatCollection(compilerConfig.getAspectPath()) + "\n-> -sourcePathResources "
+               + formatMap(compilerConfig.getSourcePathResources()) + "\n-> non-standard options: "
+               + compilerConfig.getNonStandardOptions() + "\n-> javaoptions:" + formatMap(compilerConfig.getJavaOptionsMap());
        }
 
        private String formatCollection(Collection<?> options) {
@@ -209,7 +208,7 @@ public class AjdeCoreBuildManager {
        /**
         * Generate a new AjBuildConfig from the compiler configuration associated with this AjdeCoreBuildManager or from a
         * configuration file.
-        * 
+        *
         * @return null if invalid configuration, corresponding AjBuildConfig otherwise
         */
        public AjBuildConfig generateAjBuildConfig() {
index f732d2acb011b9fe346e70a38ac888c94a418cda..5269a586a7eb41ef91c45d4b436d5c7016094470 100644 (file)
@@ -1,11 +1,11 @@
 /********************************************************************
- * Copyright (c) 2007 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://eclipse.org/legal/epl-v10.html 
- *  
- * Contributors: IBM Corporation - initial API and implementation 
+ * Copyright (c) 2007 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://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
  *                              Helen Hawkins   - initial version
  *******************************************************************/
 package org.aspectj.ajde.core;
@@ -19,19 +19,20 @@ import java.util.List;
  * after a specified string has been printed.
  */
 public class TestBuildProgressMonitor implements IBuildProgressMonitor {
-       
+
+       private static boolean verbose = System.getProperty("aspectj.tests.verbose","false").equalsIgnoreCase("true");
        private static boolean debugTests = false;
-       
+
        public int numWovenClassMessages = 0;
-    public int numWovenAspectMessages = 0;
-    public int numCompiledMessages = 0;
-    
+       public int numWovenAspectMessages = 0;
+       public int numCompiledMessages = 0;
+
        private String programmableString;
        private int count;
        private List<String> messagesReceived = new ArrayList<>();
        private int currentVal;
        private boolean isCancelRequested = false;
-               
+
        public void finish(boolean wasFullBuild) {
                System.out.println("build finished. Was full build: " + wasFullBuild);
        }
@@ -45,14 +46,16 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor {
        }
 
        public void setProgressText(String text) {
-               System.out.println("progress text: " + text);
+               if (verbose) {
+                       System.out.println("progress text: " + text);
+               }
                String newText = text+" [Percentage="+currentVal+"%]";
                messagesReceived.add(newText);
                if (text.startsWith("woven aspect ")) numWovenAspectMessages++;
                if (text.startsWith("woven class ")) numWovenClassMessages++;
                if (text.startsWith("compiled:")) numCompiledMessages++;
                if (programmableString != null
-                       && text.contains(programmableString)) {
+                               && text.contains(programmableString)) {
                        count--;
                        if (count==0) {
                                if (debugTests) System.out.println("Just got message '"+newText+"' - asking build to cancel");
@@ -63,7 +66,9 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor {
        }
 
        public void begin() {
-               System.out.println("build started");
+               if (verbose) {
+                       System.out.println("build started");
+               }
                currentVal = 0;
        }
 
@@ -72,7 +77,7 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor {
                programmableString = string;
                this.count = count;
        }
-       
+
        public boolean containsMessage(String prefix,String distinguishingMarks) {
                for (String element: messagesReceived) {
                        if (element.startsWith(prefix) &&
@@ -80,12 +85,14 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor {
                }
                return false;
        }
-       
+
        public void dumpMessages() {
-               System.out.println("ProgressMonitorMessages");
+               if (verbose) {
+                       System.out.println("ProgressMonitorMessages");
+               }
                for (String element: messagesReceived) {
                        System.out.println(element);
                }
        }
-       
+
 }
index 6434629bf80711ea1d268641cc7104f76ce8aa17..64417e84cf9a3a0602bef0e49364e39162bb9e30 100644 (file)
@@ -1,11 +1,11 @@
 /********************************************************************
- * Copyright (c) 2003 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: 
+ * Copyright (c) 2003 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:
  *     Matthew Webster     initial implementation
  *     Helen Hawkins       Converted to new interface (bug 148190)
  *******************************************************************/
@@ -29,9 +29,9 @@ public class OutxmlTest extends AjdeCoreTestCase {
 
        public static final String PROJECT_DIR = "OutxmlTest";
        public static final String BIN_DIR = "bin";
-       public static final String OUTJAR_NAME = "/bin/test.jar"; 
-       public static final String DEFAULT_AOPXML_NAME = Constants.AOP_AJC_XML; 
-       public static final String CUSTOM_AOPXML_NAME = "custom/aop.xml"; 
+       public static final String OUTJAR_NAME = "/bin/test.jar";
+       public static final String DEFAULT_AOPXML_NAME = Constants.AOP_AJC_XML;
+       public static final String CUSTOM_AOPXML_NAME = "custom/aop.xml";
 
        private String[] files = new String[]{
                        "src" + File.separator + "TestAbstractAspect.aj",
@@ -39,7 +39,7 @@ public class OutxmlTest extends AjdeCoreTestCase {
                        "src" + File.separator + "TestConcreteAspect.aj",
                        "src" + File.separator + "TestInterface.java"
        };
-       
+
        private TestMessageHandler handler;
        private TestCompilerConfiguration compilerConfig;
 
@@ -56,7 +56,7 @@ public class OutxmlTest extends AjdeCoreTestCase {
                handler = null;
                compilerConfig = null;
        }
-       
+
        /**
         * Aim: Test "-outxml" option produces the correct xml file
         */
@@ -65,31 +65,31 @@ public class OutxmlTest extends AjdeCoreTestCase {
                compilerConfig.setNonStandardOptions("-outxml");
                doBuild(true);
                assertTrue("Expected no compiler errors or warnings but found "
-                               + handler.getMessages(), handler.getMessages().isEmpty());              
+                               + handler.getMessages(), handler.getMessages().isEmpty());
                File aopxml = openFile(BIN_DIR + "/" + DEFAULT_AOPXML_NAME);
                assertTrue(DEFAULT_AOPXML_NAME + " missing",aopxml.exists());
        }
-       
+
        /**
-        * Aim: Test "-outxmlfile filename" option produces the correct 
+        * Aim: Test "-outxmlfile filename" option produces the correct
         * xml file
-        * 
+        *
         */
        public void testOutxmlfileToFile () {
                compilerConfig.setProjectSourceFiles(getSourceFileList(files));
                compilerConfig.setNonStandardOptions("-outxmlfile custom/aop.xml");
                doBuild(true);
                assertTrue("Expected no compiler errors or warnings but found "
-                               + handler.getMessages(), handler.getMessages().isEmpty());              
-               
+                               + handler.getMessages(), handler.getMessages().isEmpty());
+
                File aopxml = openFile(BIN_DIR + "/" + CUSTOM_AOPXML_NAME);
                assertTrue(CUSTOM_AOPXML_NAME + " missing",aopxml.exists());
        }
 
        /**
-        * Aim: Test "-outxml" option produces the correct 
+        * Aim: Test "-outxml" option produces the correct
         * xml entry in outjar file
-        * 
+        *
         */
        public void testOutxmlToOutjar () {
                File outjar = openFile(OUTJAR_NAME);
@@ -98,44 +98,44 @@ public class OutxmlTest extends AjdeCoreTestCase {
                compilerConfig.setNonStandardOptions("-outxml");
                doBuild(true);
                assertTrue("Expected no compiler errors or warnings but found "
-                               + handler.getMessages(), handler.getMessages().isEmpty());              
-               
+                               + handler.getMessages(), handler.getMessages().isEmpty());
+
                File aopxml = openFile(BIN_DIR + "/" + DEFAULT_AOPXML_NAME);
                assertFalse(DEFAULT_AOPXML_NAME + " should not exisit",aopxml.exists());
                assertJarContainsEntry(outjar,DEFAULT_AOPXML_NAME);
        }
 
        /**
-        * Aim: Test "-outxml" option produces a warning if "META-INF/aop.xml 
+        * Aim: Test "-outxml" option produces a warning if "META-INF/aop.xml
         * already exists in source
-        * 
+        *
         */
        public void testOutxmlToOutjarWithAop_xml () {
                File f = new File( getAbsoluteProjectDir() + File.separator + "src-resources" + File.separator + "testjar.jar");
                Set<File> roots = new HashSet<>();
                roots.add(f);
                compilerConfig.setInpath(roots);
-               
+
                File outjar = openFile(OUTJAR_NAME);
                compilerConfig.setOutjar(outjar.getAbsolutePath());
                compilerConfig.setNonStandardOptions("-outxml");
                doBuild(true);
                assertFalse("Expected compiler errors or warnings but didn't find any "
                                + handler.getMessages(), handler.getMessages().isEmpty());
-               
+
                List<TestMessage> msgs = handler.getMessages();
-               String msg = ((TestMessageHandler.TestMessage)msgs.get(0)).getContainedMessage().getMessage();
+               String msg = msgs.get(0).getContainedMessage().getMessage();
                String exp = "-outxml/-outxmlfile option ignored because resource already exists:";
                assertTrue("Expected message to start with : " + exp + " but found message " + msg,msg.startsWith(exp));
-               
+
                File aopxml = openFile(BIN_DIR + "/" + DEFAULT_AOPXML_NAME);
                assertFalse(DEFAULT_AOPXML_NAME + " should not exisit",aopxml.exists());
                assertJarContainsEntry(outjar,DEFAULT_AOPXML_NAME);
        }
 
-       
+
        /**
-        * Aim: Test "-outxmlfile filename" option produces the correct 
+        * Aim: Test "-outxmlfile filename" option produces the correct
         * xml entry in outjar file
         */
        public void testOutxmlfileToOutjar () {
@@ -145,17 +145,15 @@ public class OutxmlTest extends AjdeCoreTestCase {
                compilerConfig.setNonStandardOptions("-outxmlfile custom/aop.xml");
                doBuild(true);
                assertTrue("Expected no compiler errors or warnings but found "
-                               + handler.getMessages(), handler.getMessages().isEmpty());              
-               
+                               + handler.getMessages(), handler.getMessages().isEmpty());
+
                File aopxml = openFile(BIN_DIR + "/" + CUSTOM_AOPXML_NAME);
                assertFalse(CUSTOM_AOPXML_NAME + " should not exisit",aopxml.exists());
                assertJarContainsEntry(outjar,CUSTOM_AOPXML_NAME);
        }
 
        private void assertJarContainsEntry (File file, String entryName) {
-       
-               try {
-                       JarFile jarFile = new JarFile(file);
+               try (JarFile jarFile = new JarFile(file)) {
                        JarEntry jarEntry = jarFile.getJarEntry(entryName);
                        assertNotNull(entryName + " missing",jarEntry);
                }
index 4e5a87882dff940d30cbb525276f42bc99259b57..111f74c4a49cb460fc907d2c1b4eafd128c5c362 100644 (file)
@@ -1,12 +1,12 @@
 /* *******************************************************************
  * Copyright (c) 2004 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: 
+ * 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 version
  *    Helen Hawkins    Converted to new interface (bug 148190)
  * ******************************************************************/
@@ -19,7 +19,6 @@ import java.io.FileWriter;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Hashtable;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -35,24 +34,24 @@ import org.aspectj.util.LangUtil;
  * Weaving messages are complicated things. There are multiple places where weaving takes place and the places vary depending on
  * whether we are doing a binary weave or going from source. All places that output weaving messages are tagged: // TAG:
  * WeavingMessage so you can easily find them!
- * 
+ *
  * Advice is the simplest to deal with as that is advice weaving is always done in the weaver.
- * 
+ *
  * Next is intertype declarations. These are also always done in the weaver but in the case of a binary weave we don't know the
  * originating source line for the ITD.
- * 
+ *
  * Finally, declares. Declare Parents: extends Can only be done when going from source, if attempted by a binary weave then an error
  * message (compiler limitation) is produced. Declare Parents: implements Is (currently!) done at both compile time and weave time.
  * If going from source then the message is produced by the code in the compiler. if going from binary then the message is produced
  * by the weaver. Declare Soft: Comes out with 'advice' as a special kind of advice: softener advice
- * 
- * 
+ *
+ *
  * Q: Where are the messages turned on/off? A: It is a bit messy. See BuildArgParser.genBuildConfig(). Basically that method is the
  * first time we parse the option set. Whether weaving messages are on or off is stored in the build config. As soon as we have
  * parser the options and determined that weave messages are on, we grab the top level message handler and tell it not to ignore
  * WeaveInfo messages.
- * 
- * 
+ *
+ *
  * TODO - Other forms of declare? Do they need messages? e.g. declare precedence *
  */
 public class ShowWeaveMessagesTest extends AjdeCoreTestCase {
index 7a2ec9fc5f0105c945b077691ea8e23cf39760c5..6112e67a3abe4b56ade29903f9ea94424ca134f0 100644 (file)
@@ -1,11 +1,11 @@
 /* *******************************************************************
  * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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 
- * 
+ * 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
+ *
  * ******************************************************************/
 package org.aspectj.ajde.core.tests.model;
 
@@ -19,7 +19,7 @@ import org.aspectj.asm.IProgramElement;
 
 public class AsmDeclarationsTest extends AjdeCoreTestCase {
 
-       private AsmManager manager = null;
+       //      private AsmManager manager = null;
        private IHierarchy model = null;
 
        private final String[] files = new String[] { "ModelCoverage.java", "pkg" + File.separator + "InPackage.java" };
@@ -33,7 +33,7 @@ public class AsmDeclarationsTest extends AjdeCoreTestCase {
                compilerConfig.setProjectSourceFiles(getSourceFileList(files));
                compilerConfig.setNonStandardOptions("-Xset:minimalModel=false");
                doBuild();
-               manager = AsmManager.lastActiveStructureModel;
+               //              manager = AsmManager.lastActiveStructureModel;
                model = AsmManager.lastActiveStructureModel.getHierarchy();
        }
 
@@ -72,10 +72,10 @@ public class AsmDeclarationsTest extends AjdeCoreTestCase {
        public void testFileInPackageAndDefaultPackage() {
                IProgramElement root = model.getRoot();
                assertEquals(root.toLabelString(), "coverage");
-               IProgramElement pkg = (IProgramElement) root.getChildren().get(1);
+               IProgramElement pkg = root.getChildren().get(1);
                assertEquals(pkg.toLabelString(), "pkg");
-               assertEquals(((IProgramElement) pkg.getChildren().get(0)).toLabelString(), "InPackage.java");
-               assertEquals(((IProgramElement) ((IProgramElement) root.getChildren().get(0)).getChildren().get(0)).toLabelString(),
+               assertEquals(pkg.getChildren().get(0).toLabelString(), "InPackage.java");
+               assertEquals(root.getChildren().get(0).getChildren().get(0).toLabelString(),
                                "ModelCoverage.java");
        }
 
@@ -105,9 +105,9 @@ public class AsmDeclarationsTest extends AjdeCoreTestCase {
                // check the next two relative to this one
                int declareIndex = decParentsNode.getParent().getChildren().indexOf(decParentsNode);
                String decParentsPtnMessage = "declare parents: extends Observable";
-               assertEquals(decParentsPtnMessage, ((IProgramElement) aspect.getChildren().get(declareIndex + 1)).toLabelString());
+               assertEquals(decParentsPtnMessage, aspect.getChildren().get(declareIndex + 1).toLabelString());
                String decParentsTPMessage = "declare parents: extends Observable";
-               assertEquals(decParentsTPMessage, ((IProgramElement) aspect.getChildren().get(declareIndex + 2)).toLabelString());
+               assertEquals(decParentsTPMessage, aspect.getChildren().get(declareIndex + 2).toLabelString());
 
                String decSoftMessage = "declare soft: SizeException";
                IProgramElement decSoftNode = model.findElementForSignature(aspect, IProgramElement.Kind.DECLARE_SOFT, "declare soft");
index 4feefedcb5b09739dcb95e28afbb12d151e06f8d..093de8cb775fb932ee7d58b2031300390485a6b0 100644 (file)
@@ -1,17 +1,16 @@
 /* *******************************************************************
  * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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 
- * 
+ * 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
+ *
  * ******************************************************************/
 
 package org.aspectj.ajde.core.tests.model;
 
 import java.io.File;
-import java.util.Iterator;
 import java.util.List;
 
 import org.aspectj.ajde.core.AjdeCoreTestCase;
index 739daee32b53aa909d2d45bc64a112fb70c6da9b..6f06a1aa0bd2b3613f65b00366b79cf550b55c4a 100644 (file)
@@ -1,13 +1,13 @@
 /* *******************************************************************
  * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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: 
- *     Xerox/PARC     initial implementation 
+ * 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:
+ *     Xerox/PARC     initial implementation
  *     AMC 21.01.2003 fixed for new source location in eclipse.org
  *     Helen Hawkins    Converted to new interface (bug 148190)
  * ******************************************************************/
@@ -15,7 +15,6 @@ package org.aspectj.ajde.core.tests.model;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.Iterator;
 
 import org.aspectj.ajde.core.AjdeCoreTestCase;
 import org.aspectj.ajde.core.TestCompilerConfiguration;
@@ -57,7 +56,7 @@ public class StructureModelTest extends AjdeCoreTestCase {
                File testFile = openFile("figures" + File.separator + "Figure.java");
                IProgramElement node = manager.getHierarchy().findElementForSourceFile(testFile.getAbsolutePath());
                assertTrue("find result", node != null);
-               String child = ((IProgramElement) node.getChildren().get(2)).getName();
+               String child = node.getChildren().get(2).getName();
                assertTrue("expected Figure got child " + child, child.equals("Figure"));
        }
 
@@ -65,9 +64,9 @@ public class StructureModelTest extends AjdeCoreTestCase {
                File testFile = openFile("figures" + File.separator + "Main.java");
                IProgramElement node = manager.getHierarchy().findElementForSourceFile(testFile.getAbsolutePath());
                assertTrue("find result", node != null);
-               IProgramElement pNode = (IProgramElement) (node).getChildren().get(3);
+               IProgramElement pNode = (node).getChildren().get(3);
                assertEquals(IProgramElement.Kind.ASPECT, pNode.getKind());
-               IProgramElement pointcut = (IProgramElement) pNode.getChildren().get(0);
+               IProgramElement pointcut = pNode.getChildren().get(0);
                assertTrue("kind", pointcut.getKind().equals(IProgramElement.Kind.POINTCUT));
                assertTrue("found node: " + pointcut.getName(), pointcut.toLabelString().equals("testptct()"));
        }
index ebef7661a51d0e0376cf1f3965b1723b5984014b..15fdf0d9fed328e3f4a513f8fbcac67a3e4be992 100644 (file)
@@ -117,7 +117,7 @@ public class Ajc {
        private int incrementalStage = 10;
        private boolean shouldEmptySandbox = true;
        private final AjcCommandController controller;
-       public static boolean verbose = System.getProperty("org.aspectj.tools.ajc.Ajc.verbose", "true").equals("true");
+       public static boolean verbose = System.getProperty("aspectj.tests.verbose", "true").equals("true");
 
        /**
         * Constructs a new Ajc instance, with a new AspectJ compiler inside.
index 6ef5ff14aaf873e95144b2fb6513e35f7da806a2..d5238b477f0ab3429548508002180e83fe29efc8 100644 (file)
@@ -116,7 +116,7 @@ public abstract class AjcTestCase extends TestCase {
        public final static PrintStream out = System.out;
        private final static DelegatingOutputStream delegatingErr;
        private final static DelegatingOutputStream delegatingOut;
-       public final static boolean DEFAULT_VERBOSE = getBoolean("org.aspectj.tools.ajc.AjcTestCase.verbose", true);
+       public final static boolean DEFAULT_VERBOSE = getBoolean("aspectj.tests.verbose", true);
        public final static boolean DEFAULT_ERR_VERBOSE = getBoolean("org.aspectj.tools.ajc.AjcTestCase.verbose.err", DEFAULT_VERBOSE);
        public final static boolean DEFAULT_OUT_VERBOSE = getBoolean("org.aspectj.tools.ajc.AjcTestCase.verbose.out", DEFAULT_VERBOSE);
 
index 361415a3e0f4b97a7cefbfc988dac6f4ead20b58..62efc30e18be8b082fa3b515179607cc19420985 100644 (file)
@@ -26,7 +26,7 @@ public class Hello5 {
                                
                                System.out.println("Annotation count is "+annos.length);
                                for (Annotation anno: la) {
-                                       System.out.println(anno);
+                                       print(anno);
                                }
                        }
                } catch (Exception e) {
@@ -34,6 +34,15 @@ public class Hello5 {
                }
         }
         
+        static void print(Annotation anno) {
+               if (anno instanceof AnnoDouble) {
+                       AnnoDouble ad = ((AnnoDouble)anno);
+                       System.out.println("@AnnoDouble(value="+ad.value()+",ddd="+ad.ddd()+")");
+               } else {
+                       System.out.println(anno);
+               }
+        }
+        
         static class AnnoComparator implements Comparator<Annotation> {
                public int compare(Annotation a, Annotation b) {
                        return a.toString().compareTo(b.toString());
index 58ab1959d96b38dace4eb5edd08474e3b0b0e52c..5cfb4b1a7c0db2794c62a63ace48f3856933a01d 100644 (file)
@@ -1,11 +1,11 @@
 /********************************************************************
- * Copyright (c) 2005 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://eclipse.org/legal/epl-v10.html 
- *  
- * Contributors: 
+ * Copyright (c) 2005 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://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
  *     Andy Clement      initial implementation
  *     Helen Hawkins     Converted to new interface (bug 148190)
  *******************************************************************/
@@ -15,7 +15,6 @@ import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -35,14 +34,14 @@ import junit.framework.TestCase;
 
 /**
  * This class uses Ajde in the same way that an IDE (e.g. AJDT) does.
- * 
+ *
  * The build is driven through 'doBuild(projectName)' but the build can be configured by the methods beginning 'configure***'.
  * Information about what happened during a build is accessible through the get*, was*, print* public methods...
- * 
+ *
  */
 public class AjdeInteractionTestbed extends TestCase {
 
-       public static boolean VERBOSE = false; // do you want the gory details?
+       public static boolean VERBOSE = System.getProperty("aspectj.tests.verbose","true").equalsIgnoreCase("true");
 
        public static String testdataSrcDir = "../tests/multiIncremental";
        protected static File sandboxDir;
@@ -552,5 +551,5 @@ public class AjdeInteractionTestbed extends TestCase {
                        decisions.append(s).append("\n");
                        log(s);
                }
-       };
+       }
 }
\ No newline at end of file
index dcd08917f4dcadee26244a96548f8f2667ddf152..fde9ff259e08ff0b5ffddd9721b9e8e0ca98173d 100644 (file)
            <line text="Annotation count is 4"/>
            <line text="@AnnoChar(value=z, ccc=a)" vm="1.2,1.3,1.4,1.5,1.6,1.7,1.8"/>
            <line text="@AnnoChar(value='z', ccc='a')" vm="9+"/>
-           <line text="@AnnoDouble(ddd=3.0, value=99.0)" vm="1.2,1.3,1.4,1.5,1.6,1.7,1.8"/>
-           <line text="@AnnoDouble(value=99.0, ddd=3.0)" vm="11,12,13,14+"/>
+           <line text="@AnnoDouble(value=99.0,ddd=3.0)"/>
            <line text="@AnnoFloat(value=6.0, fff=4.0)" vm="1.2,1.3,1.4,1.5,1.6,1.7,1.8"/>
            <line text="@AnnoFloat(value=6.0f, fff=4.0f)" vm="9+"/>
            <line text="@AnnoShort(value=8, sss=3)"/>
index 8bd4793321a303d418b3ff0941412589b7bdc47b..bbad8ed6a2feeeec760f01cb7cf1104972fef152 100644 (file)
@@ -94,7 +94,7 @@ class BcelClassWeaver implements IClassWeaver {
        private static Trace trace = TraceFactory.getTraceFactory().getTrace(BcelClassWeaver.class);
 
        // Name of helper method generated by JDT compiler. Javac uses a separate inner class.
-    private static final String SWITCH_TABLE_SYNTHETIC_METHOD_PREFIX = "$SWITCH_TABLE$";
+       private static final String SWITCH_TABLE_SYNTHETIC_METHOD_PREFIX = "$SWITCH_TABLE$";
 
        public static boolean weave(BcelWorld world, LazyClassGen clazz, List<ShadowMunger> shadowMungers,
                        List<ConcreteTypeMunger> typeMungers, List<ConcreteTypeMunger> lateTypeMungers, boolean inReweavableMode) {
@@ -783,7 +783,6 @@ class BcelClassWeaver implements IClassWeaver {
                        return false; // dont bother if we are an interface
                }
 
-               boolean didSomething = false; // set if we build any bridge methods
                // So what methods do we have right now in this class?
                List<LazyMethodGen> methods = clazz.getMethodGens();
 
@@ -796,6 +795,7 @@ class BcelClassWeaver implements IClassWeaver {
                        methodsSet.add(sb.toString()); // e.g. "foo(Ljava/lang/String;)V"
                }
 
+               List<BridgeMethodDescriptor> bridges = null;
                // Now go through all the methods in this type
                for (LazyMethodGen bridgeToCandidate : methods) {
                        // This is the local method that we *might* have to bridge to
@@ -835,9 +835,12 @@ class BcelClassWeaver implements IClassWeaver {
                                                if (world.forDEBUG_bridgingCode) {
                                                        System.err.println("Bridging:bridging to '" + overriddenMethod + "'");
                                                }
-                                               createBridgeMethod(world, bridgeToCandidate, clazz, overriddenMethod);
+                                               if (bridges== null) {
+                                                       bridges = new ArrayList<>();
+                                               }
+                                               bridges.add(new BridgeMethodDescriptor(bridgeToCandidate, overriddenMethod));
+                                               //createBridgeMethod(world, bridgeToCandidate, clazz, overriddenMethod);
                                                methodsSet.add(key);
-                                               didSomething = true;
                                        }
                                }
                        }
@@ -856,9 +859,12 @@ class BcelClassWeaver implements IClassWeaver {
                                        String key = new StringBuffer().append(overriddenMethod.getName()).append(overriddenMethod.getSignatureErased()).toString(); // pr237419
                                        boolean alreadyHaveABridgeMethod = methodsSet.contains(key);
                                        if (!alreadyHaveABridgeMethod) {
-                                               createBridgeMethod(world, bridgeToCandidate, clazz, overriddenMethod);
+                                               if (bridges== null) {
+                                                       bridges = new ArrayList<>();
+                                               }
+                                               bridges.add(new BridgeMethodDescriptor(bridgeToCandidate, overriddenMethod));
+                                               // createBridgeMethod(world, bridgeToCandidate, clazz, overriddenMethod);
                                                methodsSet.add(key);
-                                               didSomething = true;
                                                if (world.forDEBUG_bridgingCode) {
                                                        System.err.println("Bridging:bridging to " + overriddenMethod);
                                                }
@@ -867,7 +873,25 @@ class BcelClassWeaver implements IClassWeaver {
                        }
                }
 
-               return didSomething;
+               if (bridges != null) {
+                       for (BridgeMethodDescriptor bmDescriptor: bridges) {
+                               createBridgeMethod(world, bmDescriptor.bridgeToCandidate, clazz, bmDescriptor.overriddenMethod);
+                       }
+               }
+
+               return bridges!=null && !bridges.isEmpty();
+       }
+
+       static class BridgeMethodDescriptor {
+
+               final LazyMethodGen bridgeToCandidate;
+               final ResolvedMember overriddenMethod;
+
+               public BridgeMethodDescriptor(LazyMethodGen bridgeToCandidate, ResolvedMember overriddenMethod) {
+                       this.bridgeToCandidate = bridgeToCandidate;
+                       this.overriddenMethod = overriddenMethod;
+               }
+
        }
 
        // **************************** end of bridge method creation code *****************
@@ -909,9 +933,9 @@ class BcelClassWeaver implements IClassWeaver {
                        for (LazyMethodGen method: addedLazyMethodGens) {
                                // They have no resolvedmember of their own, conjure one up for matching purposes
                                ResolvedMember resolvedmember =
-                                       new ResolvedMemberImpl(ResolvedMember.METHOD,method.getEnclosingClass().getType(),method.getAccessFlags(),
-                                                       BcelWorld.fromBcel(method.getReturnType()),method.getName(),
-                                                       BcelWorld.fromBcel(method.getArgumentTypes()),UnresolvedType.forNames(method.getDeclaredExceptions()));
+                                               new ResolvedMemberImpl(ResolvedMember.METHOD,method.getEnclosingClass().getType(),method.getAccessFlags(),
+                                                               BcelWorld.fromBcel(method.getReturnType()),method.getName(),
+                                                               BcelWorld.fromBcel(method.getArgumentTypes()),UnresolvedType.forNames(method.getDeclaredExceptions()));
                                resolvedmember.setAnnotationTypes(method.getAnnotationTypes());
                                resolvedmember.setAnnotations(method.getAnnotations());
 
@@ -1119,7 +1143,7 @@ class BcelClassWeaver implements IClassWeaver {
                                                        WeaveMessage.WEAVEMESSAGE_ANNOTATES,
                                                        new String[] { sig.toString(), loc.toString(), decaM.getAnnotationString(),
                                                                        methodName.startsWith("<init>") ? "constructor" : "method", decaM.getAspect().toString(),
-                                                                       Utility.beautifyLocation(decaM.getSourceLocation()) }));
+                                                                                       Utility.beautifyLocation(decaM.getSourceLocation()) }));
                }
        }
 
@@ -1548,9 +1572,9 @@ class BcelClassWeaver implements IClassWeaver {
                        world.getMessageHandler().handleMessage(
                                        WeaveMessage.constructWeavingMessage(
                                                        isRemove ? WeaveMessage.WEAVEMESSAGE_REMOVES_ANNOTATION : WeaveMessage.WEAVEMESSAGE_ANNOTATES,
-                                                       new String[] { theField.getFieldAsIs().toString() + "' of type '" + clazz.getName(),
-                                                                       clazz.getFileName(), decaf.getAnnotationString(), "field", decaf.getAspect().toString(),
-                                                                       Utility.beautifyLocation(decaf.getSourceLocation()) }));
+                                                                       new String[] { theField.getFieldAsIs().toString() + "' of type '" + clazz.getName(),
+                                                                                       clazz.getFileName(), decaf.getAnnotationString(), "field", decaf.getAspect().toString(),
+                                                                                       Utility.beautifyLocation(decaf.getSourceLocation()) }));
                }
        }
 
@@ -2214,53 +2238,53 @@ class BcelClassWeaver implements IClassWeaver {
                                        cpi.setIndex(recipientCpg.addConstant(donorCpg.getConstant(cpi.getIndex()), donorCpg));
                                }
                                // May need to copy bootstrapmethods across too.
-//                             if (fresh instanceof InvokeDynamic) {
-//                                     InvokeDynamic id = (InvokeDynamic)fresh;
-//                                     ConstantInvokeDynamic cid = (ConstantInvokeDynamic)donorCpg.getConstant(src.getInstruction().getIndex());
-//                                     int bmaIndex = cid.getBootstrapMethodAttrIndex();
-//                                     if (bootstrapMethods == null) {
-//                                             Collection<Attribute> attributes = donor.getEnclosingClass().getAttributes();
-//                                             if (attributes != null) {
-//                                                     for (Attribute attribute: attributes) {
-//                                                             if (attribute instanceof BootstrapMethods) {
-//                                                                     bootstrapMethods = (BootstrapMethods)attribute;
-//                                                             }
-//                                                     }
-//                                             }
-//                                             BootstrapMethods.BootstrapMethod bootstrapMethod =
-//                                                             bootstrapMethods.getBootstrapMethods()[bmaIndex];
-//                                             ConstantMethodHandle methodhandle = (ConstantMethodHandle)donorCpg.getConstant(bootstrapMethod.getBootstrapMethodRef());
-//                                             int bootstrapMethodArguments[] = bootstrapMethod.getBootstrapArguments();
-//
-//                                             // Finally have all we need to build the new one...
-//
-//                                             int newMethodHandleIndex = recipientCpg.addConstant(methodhandle, donorCpg);
-//                                             int[] newMethodArguments = new int[bootstrapMethodArguments.length];
-//                                             for (int a=0; a<bootstrapMethodArguments.length; a++) {
-//                                                     newMethodArguments[a] = recipientCpg.addConstant(donorCpg.getConstant(bootstrapMethodArguments[a]),donorCpg);
-//                                             }
-//                                             BootstrapMethods.BootstrapMethod newBootstrapMethod =
-//                                                             new BootstrapMethods.BootstrapMethod(newMethodHandleIndex,newMethodArguments);
-//
-//                                             Collection<Attribute> newAttributes = recipient.getEnclosingClass().getAttributes();
-//                                             BootstrapMethods newBootstrapMethods = null;
-//                                             for (Attribute attr: newAttributes) {
-//                                                     if (attr instanceof BootstrapMethods) {
-//                                                             newBootstrapMethods = (BootstrapMethods)newBootstrapMethods;
-//                                                     }
-//                                             }
-//                                             if (newBootstrapMethods == null) {
-//                                                     newBootstrapMethods =
-//                                                                     new BootstrapMethods(recipientCpg.addUtf8("BootstrapMethods"),
-//                                                                                     2+newBootstrapMethod.getLength(),
-//                                                                                     new BootstrapMethods.BootstrapMethod[] {newBootstrapMethod},
-//                                                                                     recipientCpg);
-//                                                     recipient.getEnclosingClass().addAttribute(newBootstrapMethods);
-//                                             }
-// TODO need to copy over lambda$0 support methods too...
-//                                     }
-//
-//                             }
+                               //                              if (fresh instanceof InvokeDynamic) {
+                               //                                      InvokeDynamic id = (InvokeDynamic)fresh;
+                               //                                      ConstantInvokeDynamic cid = (ConstantInvokeDynamic)donorCpg.getConstant(src.getInstruction().getIndex());
+                               //                                      int bmaIndex = cid.getBootstrapMethodAttrIndex();
+                               //                                      if (bootstrapMethods == null) {
+                               //                                              Collection<Attribute> attributes = donor.getEnclosingClass().getAttributes();
+                               //                                              if (attributes != null) {
+                               //                                                      for (Attribute attribute: attributes) {
+                               //                                                              if (attribute instanceof BootstrapMethods) {
+                               //                                                                      bootstrapMethods = (BootstrapMethods)attribute;
+                               //                                                              }
+                               //                                                      }
+                               //                                              }
+                               //                                              BootstrapMethods.BootstrapMethod bootstrapMethod =
+                               //                                                              bootstrapMethods.getBootstrapMethods()[bmaIndex];
+                               //                                              ConstantMethodHandle methodhandle = (ConstantMethodHandle)donorCpg.getConstant(bootstrapMethod.getBootstrapMethodRef());
+                               //                                              int bootstrapMethodArguments[] = bootstrapMethod.getBootstrapArguments();
+                               //
+                               //                                              // Finally have all we need to build the new one...
+                               //
+                               //                                              int newMethodHandleIndex = recipientCpg.addConstant(methodhandle, donorCpg);
+                               //                                              int[] newMethodArguments = new int[bootstrapMethodArguments.length];
+                               //                                              for (int a=0; a<bootstrapMethodArguments.length; a++) {
+                               //                                                      newMethodArguments[a] = recipientCpg.addConstant(donorCpg.getConstant(bootstrapMethodArguments[a]),donorCpg);
+                               //                                              }
+                               //                                              BootstrapMethods.BootstrapMethod newBootstrapMethod =
+                               //                                                              new BootstrapMethods.BootstrapMethod(newMethodHandleIndex,newMethodArguments);
+                               //
+                               //                                              Collection<Attribute> newAttributes = recipient.getEnclosingClass().getAttributes();
+                               //                                              BootstrapMethods newBootstrapMethods = null;
+                               //                                              for (Attribute attr: newAttributes) {
+                               //                                                      if (attr instanceof BootstrapMethods) {
+                               //                                                              newBootstrapMethods = (BootstrapMethods)newBootstrapMethods;
+                               //                                                      }
+                               //                                              }
+                               //                                              if (newBootstrapMethods == null) {
+                               //                                                      newBootstrapMethods =
+                               //                                                                      new BootstrapMethods(recipientCpg.addUtf8("BootstrapMethods"),
+                               //                                                                                      2+newBootstrapMethod.getLength(),
+                               //                                                                                      new BootstrapMethods.BootstrapMethod[] {newBootstrapMethod},
+                               //                                                                                      recipientCpg);
+                               //                                                      recipient.getEnclosingClass().addAttribute(newBootstrapMethods);
+                               //                                              }
+                               // TODO need to copy over lambda$0 support methods too...
+                               //                                      }
+                               //
+                               //                              }
                        }
                        if (src.getInstruction() == Range.RANGEINSTRUCTION) {
                                dest = ret.append(Range.RANGEINSTRUCTION);
@@ -2653,7 +2677,7 @@ class BcelClassWeaver implements IClassWeaver {
                                                return false;
                                        }
                                        if (mg.getName().startsWith(SWITCH_TABLE_SYNTHETIC_METHOD_PREFIX)
-                        && Objects.equals(mg.getReturnType().getSignature(), "[I")) {
+                                                       && Objects.equals(mg.getReturnType().getSignature(), "[I")) {
                                                // this is a synthetic switch helper, should be skipped (since it's not 'declared')
                                                return false;
                                        }
@@ -3239,7 +3263,7 @@ class BcelClassWeaver implements IClassWeaver {
                                                        && s.charAt(4) == 'a'
                                                        && (s.equals("org.aspectj.runtime.internal.CFlowCounter")
                                                                        || s.equals("org.aspectj.runtime.internal.CFlowStack") || s
-                                                                               .equals("org.aspectj.runtime.reflect.Factory"))) {
+                                                                       .equals("org.aspectj.runtime.reflect.Factory"))) {
                                                proceed = false;
                                        } else {
                                                if (methodName.equals("aspectOf")) {