* @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);
}
--- /dev/null
+public aspect Aspect {
+ before () : execution(public static void main(String[])) {
+ System.out.println(thisJoinPoint);
+ }
+}
\ No newline at end of file
--- /dev/null
+public class HelloWorld {
+
+ public static void main (String[] args) {
+ System.out.println("Hello World!");
+ }
+
+}
\ No newline at end of file
--- /dev/null
+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
</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
--- /dev/null
+<aspectj>
+ <weaver options="-XmessageHandlerClass:MessageHandler"/>
+</aspectj>
\ No newline at end of file
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);
<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">
#com.xyz.foo.level = SEVERE
org.aspectj.weaver.level = FINER
org.aspectj.weaver.loadtime.level = FINER
+org.aspectj.weaver.weaver.level = FINER