diff options
author | avasseur <avasseur> | 2005-07-18 11:23:32 +0000 |
---|---|---|
committer | avasseur <avasseur> | 2005-07-18 11:23:32 +0000 |
commit | de064586adce1a43081832aefa88d27e883cb81e (patch) | |
tree | d7ca71ffa5b93c81f962fcde6eea9c480b3b18ee | |
parent | 2ef8599677b00f02ddbe130ec65db7e7cdef9efb (diff) | |
download | aspectj-de064586adce1a43081832aefa88d27e883cb81e.tar.gz aspectj-de064586adce1a43081832aefa88d27e883cb81e.zip |
fix LTW for JMX stuff, rename messageHolder, some doc on that + dump
9 files changed, 47 insertions, 38 deletions
diff --git a/docs/adk15ProgGuideDB/ltw.xml b/docs/adk15ProgGuideDB/ltw.xml index 05aef43f6..cbbdef913 100644 --- a/docs/adk15ProgGuideDB/ltw.xml +++ b/docs/adk15ProgGuideDB/ltw.xml @@ -134,7 +134,7 @@ methods). The following example shows a simple aop.xml file: </para> <programlisting><![CDATA[ <aspectj> - + <aspects> <!-- declare two existing aspects to the weaver --> <aspect name="com.MyAspect"/> @@ -144,14 +144,14 @@ <concrete-aspect name="com.xyz.tracing.MyTracing" extends="tracing.AbstractTracing"> <pointcut name="tracingScope" expression="within(org.maw.*)"/> </concrete-aspect> - + <!-- Of the set of aspects known to the weaver, use aspects matching the type pattern "com..*" for weaving. --> <include within="com..*"/> - + <!-- Do not use any aspects with the @CoolAspect annotation for weaving --> - <exclude within="@CoolAspect *"/> - + <exclude within="@CoolAspect *"/> + </aspects> <weaver options="-verbose -XlazyTjp"> @@ -161,10 +161,11 @@ <include within="javax.*"/> <include within="org.aspectj.*"/> <include within="(!@NoWeave foo.*) AND foo.*"/> + <dump within="somepack.*"/><!-- will dump weaved classes to the "./_ajdump" folder on disk (for diagnostic purpose) --> </weaver> - + </aspectj> - + ]]></programlisting> <para> @@ -248,7 +249,9 @@ It will simply contain a (possibly empty) set of aspect elements, one for each concrete aspect included in the JAR. </para> </sect2> - + + <!-- TODO someone implement that --> + <!-- <sect2> <title>Configuring Load-time Weaving with Properties Files</title> <para> For memory constrained environments or those without support for XML a simple @@ -265,7 +268,8 @@ weaver.include=javax.* OR org.aspectj.* ]]></programlisting> </sect2> - + --> + <sect2> <title>Weaver Options</title> <para> The table below lists the AspectJ options supported by LTW. All other options @@ -281,6 +285,16 @@ <tbody> <row> <entry> + <literal>-verbose</literal> + </entry> + <entry>Issue informational messages about the weaving process. If ever you need to have information + when the load time weaving engine is bootstrapped (hence its logger as per <literal>-XmessageHandlerClass:...</literal> not ready yet), + you can use the option <literal>-Daj.weaving.verbose=true</literal> on the JVM startup command line. Messages will then be printed + on stderr as long as the message handler class is not ready. + </entry> + </row> + <row> + <entry> <literal>-1.5</literal> </entry> <entry>Run the weaver in 1.5 mode (supports autoboxing in @@ -314,12 +328,6 @@ </row> <row> <entry> - <literal>-verbose</literal> - </entry> - <entry>Issue informational messages about the weaving process</entry> - </row> - <row> - <entry> <literal>-Xreweavable</literal> </entry> <entry>Produce class files that can subsequently be rewoven</entry> @@ -338,11 +346,11 @@ </row> <row> <entry> - <literal>-XmessageHolderClass:...</literal> + <literal>-XmessageHandlerClass:...</literal> </entry> <entry>Provide alternative output destination to stdout/stderr for all weaver messages. The given value must be the full qualified class name of a class that implements - <literal>org.aspectj.weaver.loadtime</literal> + <literal>org.aspectj.bridge.IMessageHandler</literal> and that is visible from where the <literal>aop.xml</literal> is packed. If more than one such options are used, the first occurence only is taken into account.</entry> diff --git a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java index 9414819b4..ee0783088 100644 --- a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java +++ b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java @@ -15,6 +15,7 @@ import org.aspectj.asm.IRelationship; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.ISourceLocation; import org.aspectj.bridge.Message; +import org.aspectj.bridge.MessageUtil; import org.aspectj.weaver.ICrossReferenceHandler; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.UnresolvedType; @@ -87,6 +88,7 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor { // register the definitions registerDefinitions(weaver, loader); + messageHandler = bcelWorld.getMessageHandler(); // after adding aspects weaver.prepareForWeave(); @@ -100,20 +102,23 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor { */ private void registerDefinitions(final BcelWeaver weaver, final ClassLoader loader) { try { + MessageUtil.info(messageHandler, "register classloader " + ((loader!=null)?loader.getClass().getName()+"@"+loader.hashCode():"null")); //TODO av underoptimized: we will parse each XML once per CL that see it Enumeration xmls = loader.getResources(AOP_XML); List definitions = new ArrayList(); //TODO av dev mode needed ? TBD -Daj5.def=... - if (loader != null && loader != ClassLoader.getSystemClassLoader().getParent()) { + if (ClassLoader.getSystemClassLoader().equals(loader)) { String file = System.getProperty("aj5.def", null); if (file != null) { + MessageUtil.info(messageHandler, "using (-Daj5.def) " + file); definitions.add(DocumentParser.parse((new File(file)).toURL())); } } while (xmls.hasMoreElements()) { URL xml = (URL) xmls.nextElement(); + MessageUtil.info(messageHandler, "using " + xml.getFile()); definitions.add(DocumentParser.parse(xml)); } diff --git a/loadtime/src/org/aspectj/weaver/loadtime/Options.java b/loadtime/src/org/aspectj/weaver/loadtime/Options.java index 429adc209..e6c502d10 100644 --- a/loadtime/src/org/aspectj/weaver/loadtime/Options.java +++ b/loadtime/src/org/aspectj/weaver/loadtime/Options.java @@ -38,9 +38,7 @@ public class Options { private final static String OPTION_reweavable = "-Xreweavable"; private final static String OPTION_noinline = "-Xnoinline"; private final static String OPTION_showWeaveInfo = "-showWeaveInfo"; - private final static String OPTIONVALUED_messageHolder = "-XmessageHolderClass:";//TODO rename to Handler - - //FIXME dump option - dump what - dump before/after ? + private final static String OPTIONVALUED_messageHandler = "-XmessageHandlerClass:"; public static WeaverOption parse(String options, ClassLoader laoder) { if (LangUtil.isEmpty(options)) { @@ -55,9 +53,9 @@ public class Options { // do a first round on the message handler since it will report the options themselves for (Iterator iterator = flags.iterator(); iterator.hasNext();) { String arg = (String) iterator.next(); - if (arg.startsWith(OPTIONVALUED_messageHolder)) { - if (arg.length() > OPTIONVALUED_messageHolder.length()) { - String handlerClass = arg.substring(OPTIONVALUED_messageHolder.length()).trim(); + if (arg.startsWith(OPTIONVALUED_messageHandler)) { + if (arg.length() > OPTIONVALUED_messageHandler.length()) { + String handlerClass = arg.substring(OPTIONVALUED_messageHandler.length()).trim(); try { Class handler = Class.forName(handlerClass, false, laoder); weaverOption.messageHandler = ((IMessageHandler) handler.newInstance()); @@ -94,7 +92,7 @@ public class Options { weaverOption.showWeaveInfo = true; } else if (arg.equalsIgnoreCase(OPTION_verbose)) { weaverOption.verbose = true; - } else if (arg.startsWith(OPTIONVALUED_messageHolder)) { + } else if (arg.startsWith(OPTIONVALUED_messageHandler)) { ;// handled in first round } else { weaverOption.messageHandler.handleMessage( diff --git a/tests/java5/ataspectj/ataspectj/aop-aroundinlinemungertest.xml b/tests/java5/ataspectj/ataspectj/aop-aroundinlinemungertest.xml index ce025ce29..b45c24430 100644 --- a/tests/java5/ataspectj/ataspectj/aop-aroundinlinemungertest.xml +++ b/tests/java5/ataspectj/ataspectj/aop-aroundinlinemungertest.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> <aspectj> - <weaver options="-XmessageHolderClass:ataspectj.TestHelper"/> + <weaver options="-XmessageHandlerClass:ataspectj.TestHelper"/> <aspects> <aspect name="ataspectj.AroundInlineMungerTestAspects.Open"/> </aspects> diff --git a/tests/java5/ataspectj/ataspectj/aop-aroundinlinemungertest2.xml b/tests/java5/ataspectj/ataspectj/aop-aroundinlinemungertest2.xml index 3f7de3cd3..bbf4b1674 100644 --- a/tests/java5/ataspectj/ataspectj/aop-aroundinlinemungertest2.xml +++ b/tests/java5/ataspectj/ataspectj/aop-aroundinlinemungertest2.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> <aspectj> - <weaver options="-XmessageHolderClass:ataspectj.TestHelper"/> + <weaver options="-XmessageHandlerClass:ataspectj.TestHelper"/> <aspects> <aspect name="ataspectj.AroundInlineMungerTestAspects2.Open"/> </aspects> diff --git a/tests/java5/ataspectj/ataspectj/aop-dump.xml b/tests/java5/ataspectj/ataspectj/aop-dump.xml index 76bfda829..8290814ab 100644 --- a/tests/java5/ataspectj/ataspectj/aop-dump.xml +++ b/tests/java5/ataspectj/ataspectj/aop-dump.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> <aspectj> - <weaver options="-XmessageHolderClass:ataspectj.TestHelper"> + <weaver options="-XmessageHandlerClass:ataspectj.TestHelper"> <dump within="ataspectj.DumpTestThe*"/> </weaver> </aspectj> diff --git a/tests/java5/ataspectj/ataspectj/aop-perclausetest.xml b/tests/java5/ataspectj/ataspectj/aop-perclausetest.xml index 655e2b55e..236a6a856 100644 --- a/tests/java5/ataspectj/ataspectj/aop-perclausetest.xml +++ b/tests/java5/ataspectj/ataspectj/aop-perclausetest.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> <aspectj> - <weaver options="-XmessageHolderClass:ataspectj.TestHelper"/> + <weaver options="-XmessageHandlerClass:ataspectj.TestHelper"/> <aspects> <aspect name="ataspectj.PerClauseTestAspects.TestAspectPerSingleton"/> <aspect name="ataspectj.PerClauseTestAspects.TestAspectPerTarget"/> diff --git a/weaver/src/org/aspectj/weaver/World.java b/weaver/src/org/aspectj/weaver/World.java index a49aebb1f..d6905da18 100644 --- a/weaver/src/org/aspectj/weaver/World.java +++ b/weaver/src/org/aspectj/weaver/World.java @@ -193,7 +193,7 @@ public abstract class World implements Dump.INode { } //System.out.println("ret: " + ret); // Pulling in the type may have already put the right entry in the map - if (typeMap.get(signature)==null) { + if (typeMap.get(signature)==null && !ResolvedType.MISSING.equals(ret)) { typeMap.put(signature, ret); } return ret; diff --git a/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java b/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java index 91b5a07cc..4430667c2 100644 --- a/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java +++ b/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java @@ -28,15 +28,13 @@ import java.util.Map; import java.util.Set; import java.util.StringTokenizer; -import org.aspectj.bridge.AbortException; -import org.aspectj.bridge.IMessage; -import org.aspectj.bridge.MessageUtil; -import org.aspectj.bridge.MessageWriter; +import org.aspectj.bridge.*; import org.aspectj.bridge.IMessage.Kind; import org.aspectj.util.FileUtil; import org.aspectj.weaver.IClassFileProvider; import org.aspectj.weaver.IWeaveRequestor; import org.aspectj.weaver.ResolvedType; +import org.aspectj.weaver.UnresolvedType; import org.aspectj.weaver.bcel.BcelWeaver; import org.aspectj.weaver.bcel.BcelWorld; import org.aspectj.weaver.bcel.UnwovenClassFile; @@ -67,7 +65,7 @@ public class WeavingAdaptor { protected boolean verbose = getVerbose(); protected BcelWorld bcelWorld = null; protected BcelWeaver weaver = null; - protected WeavingAdaptorMessageHandler messageHandler = null; + protected IMessageHandler/*WeavingAdaptorMessageHandler*/ messageHandler = null; protected GeneratedClassHandler generatedClassHandler; protected Map generatedClasses = new HashMap(); /* String -> UnwovenClassFile */ @@ -136,7 +134,6 @@ public class WeavingAdaptor { private void init(List classPath, List aspectPath) { messageHandler = new WeavingAdaptorMessageHandler(new PrintWriter(System.err)); if (verbose) messageHandler.dontIgnore(IMessage.INFO); - else messageHandler.ignore(IMessage.INFO); if (Boolean.getBoolean(SHOW_WEAVE_INFO_PROPERTY)) messageHandler.dontIgnore(IMessage.WEAVEINFO); info("using classpath: " + classPath); @@ -211,8 +208,8 @@ public class WeavingAdaptor { * @param name * @return */ - private boolean shouldWeaveAspect (String name) { - ResolvedType type = bcelWorld.resolve(name); + private boolean shouldWeaveAspect(String name) { + ResolvedType type = bcelWorld.resolve(UnresolvedType.forName(name), true); return (type == null || !type.isAspect() || type.isAnnotationStyleAspect()); } @@ -307,6 +304,7 @@ public class WeavingAdaptor { super(writer,true); ignore(IMessage.WEAVEINFO); + ignore(IMessage.INFO); this.failKind = IMessage.ERROR; } |