}
bcelWorld = new BcelWorld(
- loader, messageHandler, new ICrossReferenceHandler() {
+ loader, getMessageHandler(), new ICrossReferenceHandler() {
public void addCrossReference(ISourceLocation from, ISourceLocation to, IRelationship.Kind kind, boolean runtimeTest) {
;// for tools only
}
// register the definitions
registerDefinitions(weaver, loader, definitions);
- messageHandler = bcelWorld.getMessageHandler();
//bcelWorld.setResolutionLoader(loader.getParent());//(ClassLoader)null);//
allOptions.append(definition.getWeaverOptions()).append(' ');
}
- Options.WeaverOption weaverOption = Options.parse(allOptions.toString(), loader, messageHandler);
+ Options.WeaverOption weaverOption = Options.parse(allOptions.toString(), loader, getMessageHandler());
// configure the weaver and world
// AV - code duplicates AspectJBuilder.initWorldAndWeaver()
World world = weaver.getWorld();
- world.setMessageHandler(weaverOption.messageHandler);
+ setMessageHandler(weaverOption.messageHandler);
world.setXlazyTjp(weaverOption.lazyTjp);
world.setXHasMemberSupportEnabled(weaverOption.hasMember);
world.setPinpointMode(weaverOption.pinpoint);
<line text="Test.main()"/>
</stdout>
<stderr>
+ <line text="info AspectJ Weaver Version"/>
+ <line text="info register classloader"/>
+ <line text="info using"/>
<line text="info weaving 'com.foo.bar.Test'"/>
</stderr>
</run>
<line text="execution(Main.target())"/>
</stdout>
<stderr>
+ <line text="info AspectJ Weaver Version"/>
+ <line text="info register classloader"/>
+ <line text="info using"/>
<line text="info register aspect ataspectj.ltwlog.Aspect1"/>
<line text="info weaving 'ataspectj.ltwlog.Main'"/>
<line text="info weaving 'ataspectj.ltwlog.Aspect1'"/>
<line text="execution(Main.target())"/>
</stdout>
<stderr>
+ <line text="info AspectJ Weaver Version"/>
+ <line text="info register classloader"/>
+ <line text="info using"/>
<line text="info register aspect ataspectj.ltwlog.Aspect1"/>
<line text="info weaving 'ataspectj.ltwlog.Main'"/>
<line text="weaveinfo Join point 'method-execution(void ataspectj.ltwlog.Main.target())' in Type 'ataspectj.ltwlog.Main' (Main.java:22) advised by before advice from 'ataspectj.ltwlog.Aspect1' (Aspect1.java)"/>
<line text="Main.test2"/>
</stdout>
<stderr>
+ <line text="info AspectJ Weaver Version"/>
+ <line text="info register classloader"/>
+ <line text="info using"/>
<line text="info generating class 'ConcreteAspect'"/>
<line text="info weaving 'Main'"/>
<line text="AbstractSuperAspect.before_test1"/>
</compile>
<run class="Main" ltw="aop-nomatch.xml">
<stderr>
+ <line text="info AspectJ Weaver Version"/>
+ <line text="info register classloader"/>
+ <line text="info using"/>
<line text="info register aspect Aspect3"/>
<line text="info weaving 'Main'"/>
</stderr>
</compile>
<run class="Main" ltw="aop-nomatchxlintfile.xml" xlintfile="Xlint-nomatch.properties">
<stderr>
+ <line text="info AspectJ Weaver Version"/>
+ <line text="info register classloader"/>
+ <line text="info using"/>
<line text="info register aspect Aspect3"/>
<line text="info weaving 'Main'"/>
<line text="advice defined in Aspect3 has not been applied [Xlint:adviceDidNotMatch]"/>
</compile>
<run class="Main" ltw="aop-nomatchxlint.xml">
<stderr>
+ <line text="info AspectJ Weaver Version"/>
+ <line text="info register classloader"/>
+ <line text="info using"/>
<line text="info register aspect Aspect3"/>
<line text="info weaving 'Main'"/>
<line text="advice defined in Aspect3 has not been applied [Xlint:adviceDidNotMatch]"/>
</compile>
<run class="Main" ltw="aop-nomatchxlint.xml">
<stderr>
+ <line text="info AspectJ Weaver Version"/>
+ <line text="info register classloader"/>
+ <line text="info using"/>
<line text="info register aspect Aspect3"/>
<line text="info weaving 'Main'"/>
<line text="advice defined in Aspect3 has not been applied [Xlint:adviceDidNotMatch]"/>
protected boolean enabled = true;
protected boolean verbose = getVerbose();
- protected BcelWorld bcelWorld = null;
- protected BcelWeaver weaver = null;
- protected IMessageHandler/*WeavingAdaptorMessageHandler*/ messageHandler = null;
+ protected BcelWorld bcelWorld;
+ protected BcelWeaver weaver;
+ private IMessageHandler messageHandler;
+ private WeavingAdaptorMessageHandler messageHolder;
protected GeneratedClassHandler generatedClassHandler;
protected Map generatedClasses = new HashMap(); /* String -> UnwovenClassFile */
registerAspectLibraries(aspectPath);
}
-
private void createMessageHandler() {
- messageHandler = new WeavingAdaptorMessageHandler(new PrintWriter(System.err));
+ messageHolder = new WeavingAdaptorMessageHandler(new PrintWriter(System.err));
+ messageHandler = messageHolder;
if (verbose) messageHandler.dontIgnore(IMessage.INFO);
if (Boolean.getBoolean(SHOW_WEAVE_INFO_PROPERTY)) messageHandler.dontIgnore(IMessage.WEAVEINFO);
info("AspectJ Weaver Version " + Version.text + " built on " + Version.time_text); //$NON-NLS-1$
}
+ protected IMessageHandler getMessageHandler () {
+ return messageHandler;
+ }
+
+ protected void setMessageHandler (IMessageHandler mh) {
+ if (messageHolder != null) {
+ messageHolder.flushMessages();
+ messageHolder = null;
+ }
+ messageHandler = mh;
+ bcelWorld.setMessageHandler(mh);
+ }
+
/**
* Appends URL to path used by the WeavingAdptor to resolve classes
* @param url to be appended to search path
private Set ignoring = new HashSet();
private IMessage.Kind failKind;
+ private boolean accumulating = true;
+ private List messages = new ArrayList();
public WeavingAdaptorMessageHandler (PrintWriter writer) {
super(writer,true);
ignore(IMessage.WEAVEINFO);
ignore(IMessage.INFO);
this.failKind = IMessage.ERROR;
-
}
public boolean handleMessage(IMessage message) throws AbortException {
+ addMessage(message);
boolean result = super.handleMessage(message);
if (0 <= message.getKind().compareTo(failKind)) {
throw new AbortException(message);
public void dontIgnore (IMessage.Kind kind) {
if (null != kind) {
ignoring.remove(kind);
+ if (kind.equals(IMessage.INFO)) accumulating = false;
+ }
+ }
+
+ private void addMessage (IMessage message) {
+ if (accumulating && isIgnoring(message.getKind())) {
+ messages.add(message);
}
}
+
+ public void flushMessages () {
+ for (Iterator iter = messages.iterator(); iter.hasNext();) {
+ IMessage message = (IMessage)iter.next();
+ super.handleMessage(message);
+ }
+ accumulating = false;
+ messages.clear();
+ }
}
private class WeavingClassFileProvider implements IClassFileProvider {