aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2020-08-14 10:56:10 -0700
committerAndy Clement <aclement@pivotal.io>2020-08-14 10:56:10 -0700
commitb0b2f50a27499227580852496964e037e9204f22 (patch)
treea3e327b7903c5edc7b0735399b20d6fe881d69e1
parente5c41da8638f924a6ba5ed4acd2da45784412fa2 (diff)
downloadaspectj-b0b2f50a27499227580852496964e037e9204f22.tar.gz
aspectj-b0b2f50a27499227580852496964e037e9204f22.zip
Fix up tests and reduce verbosity on J11
-rw-r--r--ajde.core/src/main/java/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java31
-rw-r--r--ajde.core/src/test/java/org/aspectj/ajde/core/TestBuildProgressMonitor.java47
-rw-r--r--ajde.core/src/test/java/org/aspectj/ajde/core/tests/OutxmlTest.java68
-rw-r--r--ajde.core/src/test/java/org/aspectj/ajde/core/tests/ShowWeaveMessagesTest.java29
-rw-r--r--ajde.core/src/test/java/org/aspectj/ajde/core/tests/model/AsmDeclarationsTest.java26
-rw-r--r--ajde.core/src/test/java/org/aspectj/ajde/core/tests/model/AsmRelationshipsTest.java13
-rw-r--r--ajde.core/src/test/java/org/aspectj/ajde/core/tests/model/StructureModelTest.java23
-rw-r--r--org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java2
-rw-r--r--org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java2
-rw-r--r--tests/bugs170/xmldefs/Hello5.java11
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java23
-rw-r--r--tests/src/test/resources/org/aspectj/systemtest/ajc170/ajc170.xml3
-rw-r--r--weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java150
13 files changed, 230 insertions, 198 deletions
diff --git a/ajde.core/src/main/java/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java b/ajde.core/src/main/java/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java
index 6547d101c..49948db46 100644
--- a/ajde.core/src/main/java/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java
+++ b/ajde.core/src/main/java/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java
@@ -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() {
diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/TestBuildProgressMonitor.java b/ajde.core/src/test/java/org/aspectj/ajde/core/TestBuildProgressMonitor.java
index f732d2acb..5269a586a 100644
--- a/ajde.core/src/test/java/org/aspectj/ajde/core/TestBuildProgressMonitor.java
+++ b/ajde.core/src/test/java/org/aspectj/ajde/core/TestBuildProgressMonitor.java
@@ -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);
}
}
-
+
}
diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/OutxmlTest.java b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/OutxmlTest.java
index 6434629bf..64417e84c 100644
--- a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/OutxmlTest.java
+++ b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/OutxmlTest.java
@@ -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);
}
diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ShowWeaveMessagesTest.java b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ShowWeaveMessagesTest.java
index 4e5a87882..111f74c4a 100644
--- a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ShowWeaveMessagesTest.java
+++ b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ShowWeaveMessagesTest.java
@@ -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 {
diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/model/AsmDeclarationsTest.java b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/model/AsmDeclarationsTest.java
index 7a2ec9fc5..6112e67a3 100644
--- a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/model/AsmDeclarationsTest.java
+++ b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/model/AsmDeclarationsTest.java
@@ -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");
diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/model/AsmRelationshipsTest.java b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/model/AsmRelationshipsTest.java
index 4feefedcb..093de8cb7 100644
--- a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/model/AsmRelationshipsTest.java
+++ b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/model/AsmRelationshipsTest.java
@@ -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;
diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/model/StructureModelTest.java b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/model/StructureModelTest.java
index 739daee32..6f06a1aa0 100644
--- a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/model/StructureModelTest.java
+++ b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/model/StructureModelTest.java
@@ -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()"));
}
diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java
index ebef7661a..15fdf0d9f 100644
--- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java
+++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/Ajc.java
@@ -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.
diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java
index 6ef5ff14a..d5238b477 100644
--- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java
+++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java
@@ -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);
diff --git a/tests/bugs170/xmldefs/Hello5.java b/tests/bugs170/xmldefs/Hello5.java
index 361415a3e..62efc30e1 100644
--- a/tests/bugs170/xmldefs/Hello5.java
+++ b/tests/bugs170/xmldefs/Hello5.java
@@ -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());
diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java
index 58ab1959d..5cfb4b1a7 100644
--- a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java
+++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java
@@ -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
diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc170/ajc170.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc170/ajc170.xml
index dcd08917f..fde9ff259 100644
--- a/tests/src/test/resources/org/aspectj/systemtest/ajc170/ajc170.xml
+++ b/tests/src/test/resources/org/aspectj/systemtest/ajc170/ajc170.xml
@@ -204,8 +204,7 @@
<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)"/>
diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java
index 8bd479332..bbad8ed6a 100644
--- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java
+++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java
@@ -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")) {