// register the definitions
registerDefinitions(weaver, loader, definitions);
+ if (enabled) {
- //bcelWorld.setResolutionLoader(loader.getParent());//(ClassLoader)null);//
-
- // after adding aspects
- weaver.prepareForWeave();
+ //bcelWorld.setResolutionLoader(loader.getParent());//(ClassLoader)null);//
+
+ // after adding aspects
+ weaver.prepareForWeave();
+ }
+ else {
+ bcelWorld = null;
+ weaver = null;
+ }
}
/**
}
}
}
+
+ /* We didn't register any aspects so disable the adaptor */
+ if (namespace == null) {
+ enabled = false;
+ info("no aspects registered. Disabling weaver for class loader " + getClassLoaderName(loader));
+ }
}
/**
--- /dev/null
+package ataspectj;
+
+public aspect EmptyAspect {
+
+}
\ No newline at end of file
<?xml version="1.0"?>
<aspectj>
+ <aspects>
+ <aspect name="ataspectj.EmptyAspect"/>
+ </aspects>
<weaver options="-XmessageHandlerClass:ataspectj.TestHelper">
<dump within="ataspectj.DumpTestThe*"/>
</weaver>
<?xml version="1.0"?>
<aspectj>
+ <aspects>
+ <aspect name="ataspectj.EmptyAspect"/>
+ </aspects>
<weaver options="-XlazyTjp -verbose">
<dump within="com.foo.bar..*" beforeandafter="true"/>
<include within="com.foo..*"/>
<?xml version="1.0"?>
<aspectj>
+ <aspects>
+ <aspect name="ataspectj.EmptyAspect"/>
+ </aspects>
<weaver>
<!--
<dump within="*..*Proxy*" beforeandafter="true"/>
--- /dev/null
+package ataspectj.ltwreweavable;
+
+import org.aspectj.lang.annotation.Aspect;
+
+@Aspect
+public class EmptyAtAspect {
+
+}
+
\ No newline at end of file
<weaver options="-XmessageHandlerClass:ataspectj.ltwlog.MessageHolder"/>
<aspects>
<aspect name="ataspectj.ltwreweavable.AspectReweavableLogging"/>
+ <aspect name="ataspectj.ltwreweavable.EmptyAtAspect"/>
</aspects>
</aspectj>
\ No newline at end of file
<aspectj>
<weaver options="-XmessageHandlerClass:ataspectj.ltwlog.MessageHolder"/>
<!--aspect is not declared here so as to produce an error -->
- <aspects/>
+ <aspects>
+ <aspect name="ataspectj.ltwreweavable.EmptyAtAspect"/>
+ </aspects>
</aspectj>
\ No newline at end of file
--- /dev/null
+<aspectj>
+ <weaver options="-verbose"/>
+</aspectj>
</ajc-test>
<ajc-test dir="java5/ataspectj" title="LTW DumpTest">
+ <compile
+ files="ataspectj/EmptyAspect.aj"
+ options="-1.5 -Xlint:ignore"/>
<compile
files="ataspectj/DumpTest.java,ataspectj/DumpTestTheDump.java,ataspectj/TestHelper.java"
options="-1.5"/>
</ajc-test>
<ajc-test dir="java5/ataspectj" title="LTW DumpTest before and after">
+ <compile
+ files="ataspectj/EmptyAspect.aj"
+ options="-1.5 -Xlint:ignore"/>
<compile
files="com/foo/bar/Test.java, com/foo/bar/Test$$EnhancerByCGLIB$$12345.java"
options="-1.5"/>
<line text="info AspectJ Weaver Version"/>
<line text="info register classloader"/>
<line text="info using"/>
+ <line text="info register aspect ataspectj.EmptyAspect"/>
<line text="info weaving 'com.foo.bar.Test'"/>
</stderr>
</run>
</ajc-test>
<ajc-test dir="java5/ataspectj" title="LTW DumpTest proxy">
+ <compile
+ files="ataspectj/EmptyAspect.aj"
+ options="-1.5 -Xlint:ignore"/>
<compile
files="ataspectj/TestProxyGenerator.java,ataspectj/TestInterface.java"
options="-1.5"/>
<ajc-test dir="java5/ataspectj" title="Compile time aspects declared to ltw weaver">
<compile
- files="ataspectj/ltwlog/MessageHolder.java,ataspectj/ltwreweavable/MainReweavableLogging.java,ataspectj/ltwreweavable/AspectReweavableLogging.java,ataspectj/ltwreweavable/Advisable.java"
+ files="ataspectj/ltwlog/MessageHolder.java,ataspectj/ltwreweavable/MainReweavableLogging.java,ataspectj/ltwreweavable/AspectReweavableLogging.java,ataspectj/ltwreweavable/Advisable.java,ataspectj/ltwreweavable/EmptyAtAspect.java"
options="-1.5"
outjar="main1.jar"/>
<ant file="ajc-ant.xml" target="ltw.oldAspectsDeclared" verbose="true"/>
import junit.framework.Test;
-//import org.aspectj.systemtest.ajc150.GenericsTests;
import org.aspectj.asm.AsmManager;
import org.aspectj.asm.IHierarchy;
import org.aspectj.asm.IProgramElement;
// // public class Pair<F,S> affected by pertarget aspect
// GenericsTests.verifyClassSignature(ajc,"Pair","<F:Ljava/lang/Object;S:Ljava/lang/Object;>Ljava/lang/Object;LIdempotentCache$ajcMightHaveAspect;;");
// }
+
+ public void testNoAspects(){
+// setSystemProperty(WeavingAdaptor.WEAVING_ADAPTOR_VERBOSE,"true");
+ runTest("Ensure no weaving without included aspects");
+ }
// tests that can't be included for some reason
<!-- should check for expected stderr output here -->
</run>
</ajc-test>
+
+ <ajc-test dir="ltw"
+ title="Ensure no weaving without included aspects"
+ keywords="reweavable">
+ <compile
+ files="TestMain.java, Main.java"
+ >
+ </compile>
+ <run class="TestMain" ltw="aop-optionsonly.xml">
+ <stdout>
+ <line text="Main.main"/>
+ <line text="Main.test1"/>
+ <line text="Main.test2"/>
+ </stdout>
+ <stderr>
+ <line text="info AspectJ Weaver Version"/>
+ <line text="info register classloader org.aspectj.weaver.loadtime.WeavingURLClassLoader"/>
+ <line text="info using"/>
+ <line text="info no aspects registered. Disabling weaver for class loader org.aspectj.weaver.loadtime.WeavingURLClassLoader"/>
+ </stderr>
+ </run>
+ </ajc-test>
</suite>
\ No newline at end of file