aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormwebster <mwebster>2006-08-01 20:41:52 +0000
committermwebster <mwebster>2006-08-01 20:41:52 +0000
commitbebb3640698bf2c465b64d9565123ec699dac45d (patch)
tree01f62d8a964a8125b31a85c6c84b43a3cdc130ee
parenta89eac7f94cbea34f2ca76e49a1c42a594194080 (diff)
downloadaspectj-bebb3640698bf2c465b64d9565123ec699dac45d.tar.gz
aspectj-bebb3640698bf2c465b64d9565123ec699dac45d.zip
Bug 151938 "Handle Duplicate -javaagent entries more gracefully" (ignore duplicate agents)
-rw-r--r--lib/test/loadtime5.jarbin2720 -> 2834 bytes
-rw-r--r--loadtime5/java5-src/org/aspectj/weaver/loadtime/Agent.java4
-rw-r--r--tests/java5/ataspectj/Aspect.aj5
-rw-r--r--tests/java5/ataspectj/HelloWorld.java7
-rw-r--r--tests/java5/ataspectj/MessageHandler.java27
-rw-r--r--tests/java5/ataspectj/ajc-ant.xml19
-rw-r--r--tests/java5/ataspectj/aop-messagehandler.xml3
-rw-r--r--tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java4
-rw-r--r--tests/src/org/aspectj/systemtest/ajc153/ajc153.xml8
-rw-r--r--weaver5/testdata/logging.properties1
10 files changed, 77 insertions, 1 deletions
diff --git a/lib/test/loadtime5.jar b/lib/test/loadtime5.jar
index 18892227d..ed95dc5c4 100644
--- a/lib/test/loadtime5.jar
+++ b/lib/test/loadtime5.jar
Binary files differ
diff --git a/loadtime5/java5-src/org/aspectj/weaver/loadtime/Agent.java b/loadtime5/java5-src/org/aspectj/weaver/loadtime/Agent.java
index bb3489841..4989c0275 100644
--- a/loadtime5/java5-src/org/aspectj/weaver/loadtime/Agent.java
+++ b/loadtime5/java5-src/org/aspectj/weaver/loadtime/Agent.java
@@ -39,6 +39,10 @@ public class Agent {
* @param instrumentation
*/
public static void premain(String options, Instrumentation instrumentation) {
+ /* Handle duplicate agents */
+ if (s_instrumentation != null) {
+ return;
+ }
s_instrumentation = instrumentation;
s_instrumentation.addTransformer(s_transformer);
}
diff --git a/tests/java5/ataspectj/Aspect.aj b/tests/java5/ataspectj/Aspect.aj
new file mode 100644
index 000000000..03a4403a3
--- /dev/null
+++ b/tests/java5/ataspectj/Aspect.aj
@@ -0,0 +1,5 @@
+public aspect Aspect {
+ before () : execution(public static void main(String[])) {
+ System.out.println(thisJoinPoint);
+ }
+} \ No newline at end of file
diff --git a/tests/java5/ataspectj/HelloWorld.java b/tests/java5/ataspectj/HelloWorld.java
new file mode 100644
index 000000000..58cd14253
--- /dev/null
+++ b/tests/java5/ataspectj/HelloWorld.java
@@ -0,0 +1,7 @@
+public class HelloWorld {
+
+ public static void main (String[] args) {
+ System.out.println("Hello World!");
+ }
+
+} \ No newline at end of file
diff --git a/tests/java5/ataspectj/MessageHandler.java b/tests/java5/ataspectj/MessageHandler.java
new file mode 100644
index 000000000..111b32fc0
--- /dev/null
+++ b/tests/java5/ataspectj/MessageHandler.java
@@ -0,0 +1,27 @@
+import org.aspectj.bridge.AbortException;
+import org.aspectj.bridge.IMessage;
+import org.aspectj.bridge.IMessageHandler;
+import org.aspectj.bridge.IMessage.Kind;
+
+public class MessageHandler implements IMessageHandler {
+
+ public boolean handleMessage(IMessage message) throws AbortException {
+ System.out.println(message);
+ if (message.getKind() == IMessage.ERROR) {
+ System.exit(-1);
+ }
+ else if (message.getKind() == IMessage.ABORT) {
+ throw new AbortException(message.toString());
+ }
+ return true;
+ }
+
+ public boolean isIgnoring(IMessage.Kind kind) {
+ return false;
+ }
+
+ public void dontIgnore(IMessage.Kind kind) {
+
+ }
+
+} \ No newline at end of file
diff --git a/tests/java5/ataspectj/ajc-ant.xml b/tests/java5/ataspectj/ajc-ant.xml
index 695e8ac07..8dccebac7 100644
--- a/tests/java5/ataspectj/ajc-ant.xml
+++ b/tests/java5/ataspectj/ajc-ant.xml
@@ -221,4 +221,23 @@
</java>
</target>
+ <target name="Duplicate JVMTI agents">
+ <copy file="${aj.root}/tests/java5/ataspectj/aop-messagehandler.xml"
+ tofile="${aj.sandbox}/META-INF/aop.xml"/>
+ <java fork="yes" classname="HelloWorld" failonerror="yes">
+ <classpath refid="aj.path"/>
+ <!-- use META-INF/aop.xml style -->
+ <classpath>
+ <pathelement path="${aj.sandbox}/aspects.jar"/>
+ </classpath>
+ <jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
+<!--
+-->
+ <jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
+ <jvmarg value="-Daj.weaving.verbose=true"/>
+ <jvmarg value="-Djava.util.logging.config.file=${aj.root}/weaver5/testdata/logging.properties"/>
+<!-- <jvmarg line="${jdwp}"/>-->
+ </java>
+ </target>
+
</project> \ No newline at end of file
diff --git a/tests/java5/ataspectj/aop-messagehandler.xml b/tests/java5/ataspectj/aop-messagehandler.xml
new file mode 100644
index 000000000..9d7c34be0
--- /dev/null
+++ b/tests/java5/ataspectj/aop-messagehandler.xml
@@ -0,0 +1,3 @@
+<aspectj>
+ <weaver options="-XmessageHandlerClass:MessageHandler"/>
+</aspectj> \ No newline at end of file
diff --git a/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java b/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java
index 100426762..954e223f7 100644
--- a/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java
@@ -48,7 +48,9 @@ public class Ajc153Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
public void testCantFindType_pr149322_03() {runTest("can't find type on interface call 3");}
public void testMatchVolatileField_pr150671() {runTest("match volatile field");};
-
+
+ public void testDuplicateJVMTIAgents_pr151938() {runTest("Duplicate JVMTI agents");};
+
/////////////////////////////////////////
public static Test suite() {
return XMLBasedAjcTestCase.loadSuite(Ajc153Tests.class);
diff --git a/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml b/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml
index 46b3db42a..7a8c50131 100644
--- a/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml
+++ b/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml
@@ -240,6 +240,14 @@
<message kind="error" line="8" text="test"/>
</compile>
</ajc-test>
+
+ <ajc-test dir="java5/ataspectj" title="Duplicate JVMTI agents">
+ <compile files="HelloWorld.java"/>
+ <compile files="MessageHandler.java"/>
+<!-- <compile files="Aspect.aj" options="-outxml"/> -->
+ <compile files="Aspect.aj" options="-outxml -outjar aspects.jar"/>
+ <ant file="ajc-ant.xml" target="Duplicate JVMTI agents" verbose="true"/>
+ </ajc-test>
<ajc-test dir="bugs153/pr151978" title="generics problem">
<compile files="IMessage.java" options="-1.5">
diff --git a/weaver5/testdata/logging.properties b/weaver5/testdata/logging.properties
index fb96358eb..b65bfeaa5 100644
--- a/weaver5/testdata/logging.properties
+++ b/weaver5/testdata/logging.properties
@@ -57,3 +57,4 @@ java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
#com.xyz.foo.level = SEVERE
org.aspectj.weaver.level = FINER
org.aspectj.weaver.loadtime.level = FINER
+org.aspectj.weaver.weaver.level = FINER