From bebb3640698bf2c465b64d9565123ec699dac45d Mon Sep 17 00:00:00 2001 From: mwebster Date: Tue, 1 Aug 2006 20:41:52 +0000 Subject: [PATCH] Bug 151938 "Handle Duplicate -javaagent entries more gracefully" (ignore duplicate agents) --- lib/test/loadtime5.jar | Bin 2720 -> 2834 bytes .../org/aspectj/weaver/loadtime/Agent.java | 4 +++ tests/java5/ataspectj/Aspect.aj | 5 ++++ tests/java5/ataspectj/HelloWorld.java | 7 +++++ tests/java5/ataspectj/MessageHandler.java | 27 ++++++++++++++++++ tests/java5/ataspectj/ajc-ant.xml | 19 ++++++++++++ tests/java5/ataspectj/aop-messagehandler.xml | 3 ++ .../systemtest/ajc153/Ajc153Tests.java | 4 ++- .../org/aspectj/systemtest/ajc153/ajc153.xml | 8 ++++++ weaver5/testdata/logging.properties | 1 + 10 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 tests/java5/ataspectj/Aspect.aj create mode 100644 tests/java5/ataspectj/HelloWorld.java create mode 100644 tests/java5/ataspectj/MessageHandler.java create mode 100644 tests/java5/ataspectj/aop-messagehandler.xml diff --git a/lib/test/loadtime5.jar b/lib/test/loadtime5.jar index 18892227d292a0c79e96278ab731579b1e9c0ec9..ed95dc5c4ca6bd784a61b058d67b3c0be6243882 100644 GIT binary patch delta 2204 zcmZ9NdpHw(8^^b`m_tT}MUImY*_e48mRNEYW2BT*Az3Tw5n|0@IYewq(uT*Wc*x^S zIm8^2FlR#K5HaOYdC+=zd%W+}d;jzMUf=uv-Pe6z*YEm$GQ?=&LbjHB!2E!nNR0z( zCke^({Hr!)z&j3I8mRPBm;%**ikm=;&`zo&D@d<&`=U26$xxC^>^6di%fT9!^`+iX zGyntrX7v{Pp%X(IrAoY%qC&}+ak_`=p#F4P}cg8L8@Kk(`$%kKy#8J2WSfZ!TY&STPpM&DKd13-h zhA6aJ88Kh9CHJso5$jIv;Muk>??Hu%mT{8VlfCu>XN>oC2S2q_427GR^HbCRYPOM_ zUWKwc-s>yZKp1OOD%p97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cQDh^c_m43y={%ZP=w|>m?&jJczxc@x@*R;zQ8u?I` z{6>X~QDZw-DW|yEQw$rL;_`4|No~4*oi!qT4YFdY{rj#^ZhjcT@BLzKyiH%=y)Pw2 zqB0h$N}7wD-YebOO4AT8M{!}Vt*A^>c}yej0}?TrJ_ZT_l!bP4TSE2mo<)9>MWOY* zwU(sg!BIUW>;ORhHUL25H%WSum7Zu1EZT!$hxPO%czn%TxV^2r7uI7fd8sCD7^n$2 zNKVQX(aDCx0qKQhWk^uJ1Y4X~5<33{BHG4LHQ+__w3|P%w5s${CwWEeff1FI*YZx+ zamg@h9B-`|WBR&jWT48i?P9Cv!1T)8JmCR*!o#CD$^~1#_?f0-eU0g)bW)abj2U7W zQzM@`4 zp(1x}itBR4!%1SF)oqB}V-OaOvZ&`r9WdYV2q6RuA0Fc7;rR3*LP^SZ{?D|A&$#;d zRqB`JH0m;QyUGg2HL27vLS)$@g&<}*PWdHc#BR=}hM>hI=b6>SH(fDP<@d?ao$VO( z9(*)pPMy*ET%T zq)`j`uT0&DwO+bt0o z>Us4k1;%?psn;UToipqukYdAMdf@Tx_~du8Z470Si(>Lc%O_IA?i^?ZQiXBrWNnyn zo$Q6<-L^&aY~Iiv%+kdILx)oiAP$FDKM&bR9t)->=vYD@5QrwkjQ zCBb^bd_6u0p;bTrWC!WNYo-EE>=>^Oe0qfpiXG55g5ihkBzg`0#)9y1QmVzCidkQR z0cgD~Y+&}ED+}hCz%)L<6r9!mpflEKn=1_#m}QwHR_Xgr`$2d7YG78CUo+OgQ_SvK z&0imL^QynW;N7yu*w6q!XR=hl2J_gznBO(Q&mFK-!G;6p%^m!p5!O9zt`gRLWs)*~ xya4e2ee<^!|@C9<2xDU^(PuUP?@TW5&sP`v)aPC%6Cr 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 @@ + + + + + + + + + + + + + + + + + \ 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 @@ + + + \ 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 @@ + + + + + + + + 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 -- 2.39.5