From: aclement Date: Tue, 21 Oct 2008 18:08:14 +0000 (+0000) Subject: 246125: c14 X-Git-Tag: V1_6_3rc1~156 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7ba6c461a1d36e83093c8c474310786a3e1a5405;p=aspectj.git 246125: c14 --- diff --git a/weaver/src/org/aspectj/weaver/AjcMemberMaker.java b/weaver/src/org/aspectj/weaver/AjcMemberMaker.java index 643871bc1..e76141577 100644 --- a/weaver/src/org/aspectj/weaver/AjcMemberMaker.java +++ b/weaver/src/org/aspectj/weaver/AjcMemberMaker.java @@ -14,8 +14,6 @@ package org.aspectj.weaver; import java.lang.reflect.Modifier; -import org.aspectj.lang.JoinPoint; - //import org.aspectj.weaver.ResolvedType.Name; public class AjcMemberMaker { @@ -614,9 +612,10 @@ public class AjcMemberMaker { public final static UnresolvedType TYPEX_PROCEEDINGJOINPOINT = UnresolvedType .forSignature("Lorg/aspectj/lang/ProceedingJoinPoint;"); - public final static UnresolvedType TYPEX_STATICJOINPOINT = UnresolvedType.forName(JoinPoint.StaticPart.class.getName().replace( - '/', '.')); - public final static UnresolvedType TYPEX_ENCLOSINGSTATICJOINPOINT = UnresolvedType.forName(JoinPoint.EnclosingStaticPart.class - .getName().replace('/', '.')); + public final static UnresolvedType TYPEX_STATICJOINPOINT = UnresolvedType + .forSignature("Lorg/aspectj/lang/JoinPoint$StaticPart;"); + + public final static UnresolvedType TYPEX_ENCLOSINGSTATICJOINPOINT = UnresolvedType + .forSignature("Lorg/aspectj/lang/JoinPoint$EnclosingStaticPart;"); } diff --git a/weaver/src/org/aspectj/weaver/BindingScope.java b/weaver/src/org/aspectj/weaver/BindingScope.java new file mode 100644 index 000000000..b49122e00 --- /dev/null +++ b/weaver/src/org/aspectj/weaver/BindingScope.java @@ -0,0 +1,58 @@ +/* ******************************************************************* + * Copyright (c) 2006-2008 Contributors + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * ******************************************************************/ + package org.aspectj.weaver; + +import org.aspectj.bridge.ISourceLocation; +import org.aspectj.weaver.patterns.FormalBinding; +import org.aspectj.weaver.patterns.SimpleScope; + +/** + * BindingScope that knows the enclosingType, which is needed for pointcut reference resolution + * + * @author Alexandre Vasseur + */ +public class BindingScope extends SimpleScope { + private final ResolvedType m_enclosingType; + private final ISourceContext m_sourceContext; + + public BindingScope(ResolvedType type, ISourceContext sourceContext, FormalBinding[] bindings) { + super(type.getWorld(), bindings); + m_enclosingType = type; + m_sourceContext = sourceContext; + } + + public ResolvedType getEnclosingType() { + return m_enclosingType; + } + + public ISourceLocation makeSourceLocation(IHasPosition location) { + return m_sourceContext.makeSourceLocation(location); + } + + public UnresolvedType lookupType(String name, IHasPosition location) { + // bug 126560 + if (m_enclosingType != null) { + // add the package we're in to the list of imported + // prefixes so that we can find types in the same package + String pkgName = m_enclosingType.getPackageName(); + if (pkgName != null && !pkgName.equals("")) { + String[] currentImports = getImportedPrefixes(); + String[] newImports = new String[currentImports.length + 1]; + for (int i = 0; i < currentImports.length; i++) { + newImports[i] = currentImports[i]; + } + newImports[currentImports.length] = pkgName.concat("."); + setImportedPrefixes(newImports); + } + } + return super.lookupType(name, location); + } + +} \ No newline at end of file diff --git a/weaver/src/org/aspectj/weaver/ICrossReferenceHandler.java b/weaver/src/org/aspectj/weaver/ICrossReferenceHandler.java index 02ad84c85..e38338ae1 100644 --- a/weaver/src/org/aspectj/weaver/ICrossReferenceHandler.java +++ b/weaver/src/org/aspectj/weaver/ICrossReferenceHandler.java @@ -10,20 +10,14 @@ *******************************************************************************/ package org.aspectj.weaver; -import org.aspectj.asm.IRelationship; import org.aspectj.bridge.ISourceLocation; /** - * Clients can pass a single cross-reference handler to the weaver on construction - * of a BcelWorld. Any cross-references detected during munging will be notified - * to the handler. + * Clients can pass a single cross-reference handler to the weaver on construction of a BcelWorld. Any cross-references detected + * during munging will be notified to the handler. */ public interface ICrossReferenceHandler { - void addCrossReference( - ISourceLocation from, - ISourceLocation to, - IRelationship.Kind kind, - boolean runtimeTest); - + void addCrossReference(ISourceLocation from, ISourceLocation to, String kind, boolean runtimeTest); + } diff --git a/weaver/src/org/aspectj/weaver/IUnwovenClassFile.java b/weaver/src/org/aspectj/weaver/IUnwovenClassFile.java new file mode 100644 index 000000000..289c20c66 --- /dev/null +++ b/weaver/src/org/aspectj/weaver/IUnwovenClassFile.java @@ -0,0 +1,26 @@ +/* ******************************************************************* + * Copyright (c) 2008 Contributors + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * ******************************************************************/ +package org.aspectj.weaver; + +/** + * History: 246125 + * @author Andy Clement + */ +public interface IUnwovenClassFile { + + String getFilename(); + + String getClassName(); + + byte[] getBytes(); + + char[] getClassNameAsChars(); + +} diff --git a/weaver/src/org/aspectj/weaver/IWeaveRequestor.java b/weaver/src/org/aspectj/weaver/IWeaveRequestor.java index 04f1b4e1e..13d8b957a 100644 --- a/weaver/src/org/aspectj/weaver/IWeaveRequestor.java +++ b/weaver/src/org/aspectj/weaver/IWeaveRequestor.java @@ -10,29 +10,29 @@ *******************************************************************************/ package org.aspectj.weaver; -import org.aspectj.weaver.bcel.UnwovenClassFile; /** * @author colyer - * - * This interface is implemented by clients driving weaving through the - * IClassFileProvider interface. It is used by the weaver to return woven - * class file results back to the client. The client can correlate weave - * results with inputs since it knows the last UnwovenClassFile returned by - * its iterator. + * + * This interface is implemented by clients driving weaving through the IClassFileProvider interface. It is used by the + * weaver to return woven class file results back to the client. The client can correlate weave results with inputs since it + * knows the last UnwovenClassFile returned by its iterator. */ public interface IWeaveRequestor { - + /* - * A class file resulting from a weave (yes, even though the type name - * says "unwoven"...). + * A class file resulting from a weave (yes, even though the type name says "unwoven"...). */ - void acceptResult(UnwovenClassFile result); - + void acceptResult(IUnwovenClassFile result); + // various notifications to the requestor about our progress... void processingReweavableState(); + void addingTypeMungers(); + void weavingAspects(); + void weavingClasses(); + void weaveCompleted(); } diff --git a/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java b/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java index acdd19209..8ff67fbd0 100644 --- a/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java +++ b/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java @@ -46,7 +46,7 @@ import org.aspectj.weaver.Advice; import org.aspectj.weaver.AdviceKind; import org.aspectj.weaver.AjAttribute; import org.aspectj.weaver.AjcMemberMaker; -import org.aspectj.weaver.IHasPosition; +import org.aspectj.weaver.BindingScope; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.MethodDelegateTypeMunger; import org.aspectj.weaver.NameMangler; @@ -71,7 +71,6 @@ import org.aspectj.weaver.patterns.PerObject; import org.aspectj.weaver.patterns.PerSingleton; import org.aspectj.weaver.patterns.PerTypeWithin; import org.aspectj.weaver.patterns.Pointcut; -import org.aspectj.weaver.patterns.SimpleScope; import org.aspectj.weaver.patterns.TypePattern; /** @@ -1504,50 +1503,6 @@ public class AtAjAttributes { } } - /** - * BindingScope that knows the enclosingType, which is needed for pointcut reference resolution - * - * @author Alexandre Vasseur - */ - public static class BindingScope extends SimpleScope { - private final ResolvedType m_enclosingType; - private final ISourceContext m_sourceContext; - - public BindingScope(ResolvedType type, ISourceContext sourceContext, FormalBinding[] bindings) { - super(type.getWorld(), bindings); - m_enclosingType = type; - m_sourceContext = sourceContext; - } - - public ResolvedType getEnclosingType() { - return m_enclosingType; - } - - public ISourceLocation makeSourceLocation(IHasPosition location) { - return m_sourceContext.makeSourceLocation(location); - } - - public UnresolvedType lookupType(String name, IHasPosition location) { - // bug 126560 - if (m_enclosingType != null) { - // add the package we're in to the list of imported - // prefixes so that we can find types in the same package - String pkgName = m_enclosingType.getPackageName(); - if (pkgName != null && !pkgName.equals("")) { - String[] currentImports = getImportedPrefixes(); - String[] newImports = new String[currentImports.length + 1]; - for (int i = 0; i < currentImports.length; i++) { - newImports[i] = currentImports[i]; - } - newImports[currentImports.length] = pkgName.concat("."); - setImportedPrefixes(newImports); - } - } - return super.lookupType(name, location); - } - - } - /** * LazyResolvedPointcutDefinition lazyly resolve the pointcut so that we have time to register all pointcut referenced before * pointcut resolution happens diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java b/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java index d999336f0..b532b156e 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java @@ -41,6 +41,7 @@ import org.aspectj.weaver.AjcMemberMaker; import org.aspectj.weaver.AnnotationAJ; import org.aspectj.weaver.AnnotationTargetKind; import org.aspectj.weaver.BCException; +import org.aspectj.weaver.BindingScope; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ReferenceType; import org.aspectj.weaver.ResolvedMember; @@ -51,7 +52,6 @@ import org.aspectj.weaver.TypeVariable; import org.aspectj.weaver.UnresolvedType; import org.aspectj.weaver.WeaverStateInfo; import org.aspectj.weaver.World; -import org.aspectj.weaver.bcel.AtAjAttributes.BindingScope; import org.aspectj.weaver.bcel.BcelGenericSignatureToTypeXConverter.GenericSignatureFormatException; import org.aspectj.weaver.patterns.Declare; import org.aspectj.weaver.patterns.DeclareErrorOrWarning; diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java index e1c2555eb..3dd1c5012 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java @@ -61,6 +61,7 @@ import org.aspectj.weaver.ConcreteTypeMunger; import org.aspectj.weaver.CrosscuttingMembersSet; import org.aspectj.weaver.CustomMungerFactory; import org.aspectj.weaver.IClassFileProvider; +import org.aspectj.weaver.IUnwovenClassFile; import org.aspectj.weaver.IWeaveRequestor; import org.aspectj.weaver.NewParentTypeMunger; import org.aspectj.weaver.ReferenceType; @@ -999,9 +1000,9 @@ public class BcelWeaver { public IWeaveRequestor getRequestor() { return new IWeaveRequestor() { - public void acceptResult(UnwovenClassFile result) { + public void acceptResult(IUnwovenClassFile result) { try { - writeZipEntry(result.filename, result.bytes); + writeZipEntry(result.getFilename(), result.getBytes()); } catch (IOException ex) { } } diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java b/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java index f59e894bd..2453765bc 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java @@ -118,7 +118,7 @@ public class BcelWorld extends World implements Repository { if (getCrossReferenceHandler() != null) { getCrossReferenceHandler().addCrossReference(munger.getSourceLocation(), // What is being applied shadow.getSourceLocation(), // Where is it being applied - determineRelKind(munger), // What kind of advice? + determineRelKind(munger).getName(), // What kind of advice? ((Advice) munger).hasDynamicTests() // Is a runtime test being stuffed in the code? ); } @@ -770,8 +770,12 @@ public class BcelWorld extends World implements Repository { getMessageHandler().handleMessage(iMessage); if (getCrossReferenceHandler() != null) { - getCrossReferenceHandler().addCrossReference(checker.getSourceLocation(), shadow.getSourceLocation(), - (checker.isError() ? IRelationship.Kind.DECLARE_ERROR : IRelationship.Kind.DECLARE_WARNING), false); + getCrossReferenceHandler() + .addCrossReference( + checker.getSourceLocation(), + shadow.getSourceLocation(), + (checker.isError() ? IRelationship.Kind.DECLARE_ERROR.getName() : IRelationship.Kind.DECLARE_WARNING + .getName()), false); } diff --git a/weaver/src/org/aspectj/weaver/bcel/UnwovenClassFile.java b/weaver/src/org/aspectj/weaver/bcel/UnwovenClassFile.java index e45eac109..22dfeb9ba 100644 --- a/weaver/src/org/aspectj/weaver/bcel/UnwovenClassFile.java +++ b/weaver/src/org/aspectj/weaver/bcel/UnwovenClassFile.java @@ -21,8 +21,9 @@ import java.util.List; import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.util.FileUtil; +import org.aspectj.weaver.IUnwovenClassFile; -public class UnwovenClassFile { +public class UnwovenClassFile implements IUnwovenClassFile { protected String filename; protected char[] charfilename; protected byte[] bytes; diff --git a/weaver/src/org/aspectj/weaver/patterns/PerCflow.java b/weaver/src/org/aspectj/weaver/patterns/PerCflow.java index 92ff54b7f..eae943afc 100644 --- a/weaver/src/org/aspectj/weaver/patterns/PerCflow.java +++ b/weaver/src/org/aspectj/weaver/patterns/PerCflow.java @@ -96,10 +96,10 @@ public class PerCflow extends PerClause { Collection previousCflowEntries = xcut.getCflowEntries(); Pointcut concreteEntry = entry.concretize(inAspect, inAspect, 0, null); // IntMap - // . - // EMPTY - // ) - // ; + // . + // EMPTY + // ) + // ; List innerCflowEntries = new ArrayList(xcut.getCflowEntries()); innerCflowEntries.removeAll(previousCflowEntries); @@ -115,7 +115,8 @@ public class PerCflow extends PerClause { // ATAJ inline around advice support - don't use a late munger to allow // around inling for itself if (inAspect.isAnnotationStyleAspect() && !inAspect.getWorld().isXnoInline()) { - inAspect.crosscuttingMembers.addTypeMunger(new BcelAccessForInlineMunger(inAspect)); + inAspect.crosscuttingMembers.addTypeMunger(inAspect.getWorld().getWeavingSupport() + .createAccessForInlineMunger(inAspect)); } return ret; diff --git a/weaver/src/org/aspectj/weaver/tools/PointcutParser.java b/weaver/src/org/aspectj/weaver/tools/PointcutParser.java index f6ff5ba03..3e651f0ca 100644 --- a/weaver/src/org/aspectj/weaver/tools/PointcutParser.java +++ b/weaver/src/org/aspectj/weaver/tools/PointcutParser.java @@ -22,6 +22,7 @@ import java.util.Set; import org.aspectj.bridge.IMessageHandler; import org.aspectj.bridge.ISourceLocation; import org.aspectj.bridge.SourceLocation; +import org.aspectj.weaver.BindingScope; import org.aspectj.weaver.IHasPosition; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; @@ -30,7 +31,6 @@ import org.aspectj.weaver.Shadow; import org.aspectj.weaver.UnresolvedType; import org.aspectj.weaver.WeakClassLoaderReference; import org.aspectj.weaver.World; -import org.aspectj.weaver.bcel.AtAjAttributes; import org.aspectj.weaver.internal.tools.PointcutExpressionImpl; import org.aspectj.weaver.internal.tools.TypePatternMatcherImpl; import org.aspectj.weaver.patterns.AndPointcut; @@ -410,7 +410,7 @@ public class PointcutParser { } public void tidy() {} }; - return new AtAjAttributes.BindingScope(inType,sourceContext,formalBindings); + return new BindingScope(inType,sourceContext,formalBindings); } } diff --git a/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java b/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java index 7cb43e909..eed696682 100644 --- a/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java +++ b/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java @@ -45,6 +45,7 @@ import org.aspectj.bridge.IMessage.Kind; import org.aspectj.util.FileUtil; import org.aspectj.util.LangUtil; import org.aspectj.weaver.IClassFileProvider; +import org.aspectj.weaver.IUnwovenClassFile; import org.aspectj.weaver.IWeaveRequestor; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.World; @@ -56,26 +57,22 @@ import org.aspectj.weaver.bcel.Utility; // OPTIMIZE add guards for all the debug/info/etc /** - * This adaptor allows the AspectJ compiler to be embedded in an existing - * system to facilitate load-time weaving. It provides an interface for a - * weaving class loader to provide a classpath to be woven by a set of - * aspects. A callback is supplied to allow a class loader to define classes - * generated by the compiler during the weaving process. + * This adaptor allows the AspectJ compiler to be embedded in an existing system to facilitate load-time weaving. It provides an + * interface for a weaving class loader to provide a classpath to be woven by a set of aspects. A callback is supplied to allow a + * class loader to define classes generated by the compiler during the weaving process. *

- * A weaving class loader should create a WeavingAdaptor before - * any classes are defined, typically during construction. The set of aspects - * passed to the adaptor is fixed for the lifetime of the adaptor although the - * classpath can be augmented. A system property can be set to allow verbose - * weaving messages to be written to the console. - * + * A weaving class loader should create a WeavingAdaptor before any classes are defined, typically during construction. + * The set of aspects passed to the adaptor is fixed for the lifetime of the adaptor although the classpath can be augmented. A + * system property can be set to allow verbose weaving messages to be written to the console. + * */ public class WeavingAdaptor implements IMessageContext { /** - * System property used to turn on verbose weaving messages + * System property used to turn on verbose weaving messages */ - public static final String WEAVING_ADAPTOR_VERBOSE = "aj.weaving.verbose"; - public static final String SHOW_WEAVE_INFO_PROPERTY = "org.aspectj.weaver.showWeaveInfo"; + public static final String WEAVING_ADAPTOR_VERBOSE = "aj.weaving.verbose"; + public static final String SHOW_WEAVE_INFO_PROPERTY = "org.aspectj.weaver.showWeaveInfo"; public static final String TRACE_MESSAGES_PROPERTY = "org.aspectj.tracing.messages"; private boolean enabled = false; @@ -87,90 +84,87 @@ public class WeavingAdaptor implements IMessageContext { private boolean abortOnError = false; protected GeneratedClassHandler generatedClassHandler; protected Map generatedClasses = new HashMap(); /* String -> UnwovenClassFile */ - protected BcelObjectType delegateForCurrentClass; // lazily initialized, should be used to prevent parsing bytecode multiple times + protected BcelObjectType delegateForCurrentClass; // lazily initialized, should be used to prevent parsing bytecode multiple + // times private int weavingSpecialTypes = 0; - private static final int INITIALIZED = 0x1; + private static final int INITIALIZED = 0x1; private static final int WEAVE_JAVA_PACKAGE = 0x2; - private static final int WEAVE_JAVAX_PACKAGE= 0x4; - - + private static final int WEAVE_JAVAX_PACKAGE = 0x4; + private static Trace trace = TraceFactory.getTraceFactory().getTrace(WeavingAdaptor.class); - protected WeavingAdaptor () { + protected WeavingAdaptor() { } - - + /** - * Construct a WeavingAdaptor with a reference to a weaving class loader. The - * adaptor will automatically search the class loader hierarchy to resolve - * classes. The adaptor will also search the hierarchy for WeavingClassLoader - * instances to determine the set of aspects to be used ofr weaving. - * @param loader instance of ClassLoader + * Construct a WeavingAdaptor with a reference to a weaving class loader. The adaptor will automatically search the class loader + * hierarchy to resolve classes. The adaptor will also search the hierarchy for WeavingClassLoader instances to determine the + * set of aspects to be used ofr weaving. + * + * @param loader instance of ClassLoader */ - public WeavingAdaptor (WeavingClassLoader loader) { -// System.err.println("? WeavingAdaptor.(" + loader +"," + aspectURLs.length + ")"); + public WeavingAdaptor(WeavingClassLoader loader) { + // System.err.println("? WeavingAdaptor.(" + loader +"," + aspectURLs.length + ")"); generatedClassHandler = loader; - init(getFullClassPath((ClassLoader)loader),getFullAspectPath((ClassLoader)loader/*,aspectURLs*/)); + init(getFullClassPath((ClassLoader) loader), getFullAspectPath((ClassLoader) loader/* ,aspectURLs */)); } /** - * Construct a WeavingAdator with a reference to a - * GeneratedClassHandler, a full search path for resolving - * classes and a complete set of aspects. The search path must include - * classes loaded by the class loader constructing the WeavingAdaptor and - * all its parents in the hierarchy. + * Construct a WeavingAdator with a reference to a GeneratedClassHandler, a full search path for resolving classes + * and a complete set of aspects. The search path must include classes loaded by the class loader constructing the + * WeavingAdaptor and all its parents in the hierarchy. + * * @param handler GeneratedClassHandler - * @param classURLs the URLs from which to resolve classes - * @param aspectURLs the aspects used to weave classes defined by this class loader + * @param classURLs the URLs from which to resolve classes + * @param aspectURLs the aspects used to weave classes defined by this class loader */ - public WeavingAdaptor (GeneratedClassHandler handler, URL[] classURLs, URL[] aspectURLs) { -// System.err.println("? WeavingAdaptor.()"); + public WeavingAdaptor(GeneratedClassHandler handler, URL[] classURLs, URL[] aspectURLs) { + // System.err.println("? WeavingAdaptor.()"); generatedClassHandler = handler; - init(FileUtil.makeClasspath(classURLs),FileUtil.makeClasspath(aspectURLs)); + init(FileUtil.makeClasspath(classURLs), FileUtil.makeClasspath(aspectURLs)); } - - private List getFullClassPath (ClassLoader loader) { + + private List getFullClassPath(ClassLoader loader) { List list = new LinkedList(); for (; loader != null; loader = loader.getParent()) { if (loader instanceof URLClassLoader) { - URL[] urls = ((URLClassLoader)loader).getURLs(); - list.addAll(0,FileUtil.makeClasspath(urls)); - } - else { - warn("cannot determine classpath"); + URL[] urls = ((URLClassLoader) loader).getURLs(); + list.addAll(0, FileUtil.makeClasspath(urls)); + } else { + warn("cannot determine classpath"); } } - list.addAll(0,makeClasspath(System.getProperty("sun.boot.class.path"))); + list.addAll(0, makeClasspath(System.getProperty("sun.boot.class.path"))); return list; } - - private List getFullAspectPath (ClassLoader loader) { + + private List getFullAspectPath(ClassLoader loader) { List list = new LinkedList(); for (; loader != null; loader = loader.getParent()) { if (loader instanceof WeavingClassLoader) { - URL[] urls = ((WeavingClassLoader)loader).getAspectURLs(); - list.addAll(0,FileUtil.makeClasspath(urls)); + URL[] urls = ((WeavingClassLoader) loader).getAspectURLs(); + list.addAll(0, FileUtil.makeClasspath(urls)); } } return list; } - - private static boolean getVerbose () { + + private static boolean getVerbose() { return Boolean.getBoolean(WEAVING_ADAPTOR_VERBOSE); } - + private void init(List classPath, List aspectPath) { abortOnError = true; createMessageHandler(); - - info("using classpath: " + classPath); - info("using aspectpath: " + aspectPath); - - bcelWorld = new BcelWorld(classPath,messageHandler,null); + + info("using classpath: " + classPath); + info("using aspectpath: " + aspectPath); + + bcelWorld = new BcelWorld(classPath, messageHandler, null); bcelWorld.setXnoInline(false); bcelWorld.getLint().loadDefaultProperties(); if (LangUtil.is15VMOrGreater()) { @@ -179,260 +173,269 @@ public class WeavingAdaptor implements IMessageContext { weaver = new BcelWeaver(bcelWorld); registerAspectLibraries(aspectPath); - + enabled = true; } protected void createMessageHandler() { messageHolder = new WeavingAdaptorMessageHolder(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$ + 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 () { + + protected IMessageHandler getMessageHandler() { return messageHandler; } - - public IMessageHolder getMessageHolder () { + + public IMessageHolder getMessageHolder() { return messageHolder; } - - protected void setMessageHandler (IMessageHandler mh) { + + protected void setMessageHandler(IMessageHandler mh) { if (mh instanceof ISupportsMessageContext) { - ISupportsMessageContext smc = (ISupportsMessageContext)mh; + ISupportsMessageContext smc = (ISupportsMessageContext) mh; smc.setMessageContext(this); } - if (mh != messageHolder) messageHolder.setDelegate(mh); + if (mh != messageHolder) + messageHolder.setDelegate(mh); messageHolder.flushMessages(); } - - protected void disable () { - if (trace.isTraceEnabled()) trace.enter("disable",this); + + protected void disable() { + if (trace.isTraceEnabled()) + trace.enter("disable", this); enabled = false; messageHolder.flushMessages(); - - if (trace.isTraceEnabled()) trace.exit("disable"); + + if (trace.isTraceEnabled()) + trace.exit("disable"); } - - protected void enable () { + + protected void enable() { enabled = true; messageHolder.flushMessages(); } - - protected boolean isEnabled () { + + protected boolean isEnabled() { return enabled; } - + /** * Appends URL to path used by the WeavingAdptor to resolve classes + * * @param url to be appended to search path */ public void addURL(URL url) { File libFile = new File(url.getPath()); try { weaver.addLibraryJarFile(libFile); - } - catch (IOException ex) { + } catch (IOException ex) { warn("bad library: '" + libFile + "'"); } } - + /** * Weave a class using aspects previously supplied to the adaptor. + * * @param name the name of the class * @param bytes the class bytes * @return the woven bytes - * @exception IOException weave failed + * @exception IOException weave failed */ public byte[] weaveClass(String name, byte[] bytes) throws IOException { - return weaveClass(name,bytes,false); + return weaveClass(name, bytes, false); } /** * Weave a class using aspects previously supplied to the adaptor. + * * @param name the name of the class * @param bytes the class bytes * @param mustWeave if true then this class *must* get woven (used for concrete aspects generated from XML) * @return the woven bytes - * @exception IOException weave failed + * @exception IOException weave failed */ - public byte[] weaveClass (String name, byte[] bytes,boolean mustWeave) throws IOException { - if (trace.isTraceEnabled()) trace.enter("weaveClass",this,new Object[] {name, bytes}); + public byte[] weaveClass(String name, byte[] bytes, boolean mustWeave) throws IOException { + if (trace.isTraceEnabled()) + trace.enter("weaveClass", this, new Object[] { name, bytes }); if (!enabled) { - if (trace.isTraceEnabled()) trace.exit("weaveClass",false); - return bytes; + if (trace.isTraceEnabled()) + trace.exit("weaveClass", false); + return bytes; } - + try { - delegateForCurrentClass=null; - name = name.replace('/','.'); + delegateForCurrentClass = null; + name = name.replace('/', '.'); if (couldWeave(name, bytes)) { - if (accept(name, bytes)) { - // TODO @AspectJ problem - // Annotation style aspects need to be included regardless in order to get - // a valid aspectOf()/hasAspect() generated in them. However - if they are excluded - // (via include/exclude in aop.xml) they really should only get aspectOf()/hasAspect() - // and not be included in the full set of aspects being applied by 'this' weaver + if (accept(name, bytes)) { + // TODO @AspectJ problem + // Annotation style aspects need to be included regardless in order to get + // a valid aspectOf()/hasAspect() generated in them. However - if they are excluded + // (via include/exclude in aop.xml) they really should only get aspectOf()/hasAspect() + // and not be included in the full set of aspects being applied by 'this' weaver debug("weaving '" + name + "'"); bytes = getWovenBytes(name, bytes); } else if (shouldWeaveAnnotationStyleAspect(name, bytes)) { if (mustWeave) { if (bcelWorld.getLint().mustWeaveXmlDefinedAspects.isEnabled()) { - bcelWorld.getLint().mustWeaveXmlDefinedAspects.signal(name,null); + bcelWorld.getLint().mustWeaveXmlDefinedAspects.signal(name, null); } } - // an @AspectJ aspect needs to be at least munged by the aspectOf munger - debug("weaving '" + name + "'"); - bytes = getAtAspectJAspectBytes(name, bytes); + // an @AspectJ aspect needs to be at least munged by the aspectOf munger + debug("weaving '" + name + "'"); + bytes = getAtAspectJAspectBytes(name, bytes); } else { debug("not weaving '" + name + "'"); } - } else { + } else { debug("cannot weave '" + name + "'"); } } finally { - delegateForCurrentClass=null; + delegateForCurrentClass = null; } - if (trace.isTraceEnabled()) trace.exit("weaveClass",bytes); - return bytes; + if (trace.isTraceEnabled()) + trace.exit("weaveClass", bytes); + return bytes; } - /** - * @param name - * @return true if even valid to weave: either with an accept check or to munge it for @AspectJ aspectof support - */ - private boolean couldWeave (String name, byte[] bytes) { + /** + * @param name + * @return true if even valid to weave: either with an accept check or to munge it for @AspectJ aspectof support + */ + private boolean couldWeave(String name, byte[] bytes) { return !generatedClasses.containsKey(name) && shouldWeaveName(name); } - //ATAJ - protected boolean accept(String name, byte[] bytes) { - return true; - } + // ATAJ + protected boolean accept(String name, byte[] bytes) { + return true; + } - protected boolean shouldDump(String name, boolean before) { - return false; - } + protected boolean shouldDump(String name, boolean before) { + return false; + } - private boolean shouldWeaveName (String name) { - if ((weavingSpecialTypes&INITIALIZED)==0) { - weavingSpecialTypes|=INITIALIZED; + private boolean shouldWeaveName(String name) { + if ((weavingSpecialTypes & INITIALIZED) == 0) { + weavingSpecialTypes |= INITIALIZED; // initialize it Properties p = weaver.getWorld().getExtraConfiguration(); - if (p!=null) { - boolean b = p.getProperty(World.xsetWEAVE_JAVA_PACKAGES,"false").equalsIgnoreCase("true"); + if (p != null) { + boolean b = p.getProperty(World.xsetWEAVE_JAVA_PACKAGES, "false").equalsIgnoreCase("true"); if (b) { - weavingSpecialTypes|=WEAVE_JAVA_PACKAGE; + weavingSpecialTypes |= WEAVE_JAVA_PACKAGE; } - b = p.getProperty(World.xsetWEAVE_JAVAX_PACKAGES,"false").equalsIgnoreCase("true"); + b = p.getProperty(World.xsetWEAVE_JAVAX_PACKAGES, "false").equalsIgnoreCase("true"); if (b) { - weavingSpecialTypes|=WEAVE_JAVAX_PACKAGE; + weavingSpecialTypes |= WEAVE_JAVAX_PACKAGE; } } } - boolean should = - !(name.startsWith("org.aspectj.") - || (name.startsWith("java.") && (weavingSpecialTypes&WEAVE_JAVA_PACKAGE)==0) - || (name.startsWith("javax.") && (weavingSpecialTypes&WEAVE_JAVAX_PACKAGE)==0) - //|| name.startsWith("$Proxy")//JDK proxies//FIXME AV is that 1.3 proxy ? fe. ataspect.$Proxy0 is a java5 proxy... - || name.startsWith("sun.reflect."));//JDK reflect + boolean should = !(name.startsWith("org.aspectj.") + || (name.startsWith("java.") && (weavingSpecialTypes & WEAVE_JAVA_PACKAGE) == 0) + || (name.startsWith("javax.") && (weavingSpecialTypes & WEAVE_JAVAX_PACKAGE) == 0) + // || name.startsWith("$Proxy")//JDK proxies//FIXME AV is that 1.3 proxy ? fe. ataspect.$Proxy0 is a java5 proxy... + || name.startsWith("sun.reflect."));// JDK reflect return should; } - /** - * We allow @AJ aspect weaving so that we can add aspectOf() as part of the weaving - * (and not part of the source compilation) - * - * @param name - * @param bytes bytecode (from classloader), allow to NOT lookup stuff on disk again during resolve - * @return true if @Aspect - */ + /** + * We allow @AJ aspect weaving so that we can add aspectOf() as part of the weaving (and not part of the source compilation) + * + * @param name + * @param bytes bytecode (from classloader), allow to NOT lookup stuff on disk again during resolve + * @return true if @Aspect + */ private boolean shouldWeaveAnnotationStyleAspect(String name, byte[] bytes) { - if (delegateForCurrentClass==null) { -// if (weaver.getWorld().isASMAround()) return asmCheckAnnotationStyleAspect(bytes); -// else - ensureDelegateInitialized(name, bytes); - } + if (delegateForCurrentClass == null) { + // if (weaver.getWorld().isASMAround()) return asmCheckAnnotationStyleAspect(bytes); + // else + ensureDelegateInitialized(name, bytes); + } return (delegateForCurrentClass.isAnnotationStyleAspect()); } -// private boolean asmCheckAnnotationStyleAspect(byte[] bytes) { -// IsAtAspectAnnotationVisitor detector = new IsAtAspectAnnotationVisitor(); -// -// ClassReader cr = new ClassReader(bytes); -// try { -// cr.accept(detector, true);//, ClassReader.SKIP_DEBUG | ClassReader.SKIP_CODE | ClassReader.SKIP_FRAMES); -// } catch (Exception spe) { -// // if anything goes wrong, e.g., an NPE, then assume it's NOT an @AspectJ aspect... -// System.err.println("Unexpected problem parsing bytes to discover @Aspect annotation"); -// spe.printStackTrace(); -// return false; -// } -// -// return detector.isAspect(); -// } - - protected void ensureDelegateInitialized(String name,byte[] bytes) { - if (delegateForCurrentClass==null) - delegateForCurrentClass = ((BcelWorld)weaver.getWorld()).addSourceObjectType(Utility.makeJavaClass(name, bytes)); + // private boolean asmCheckAnnotationStyleAspect(byte[] bytes) { + // IsAtAspectAnnotationVisitor detector = new IsAtAspectAnnotationVisitor(); + // + // ClassReader cr = new ClassReader(bytes); + // try { + // cr.accept(detector, true);//, ClassReader.SKIP_DEBUG | ClassReader.SKIP_CODE | ClassReader.SKIP_FRAMES); + // } catch (Exception spe) { + // // if anything goes wrong, e.g., an NPE, then assume it's NOT an @AspectJ aspect... + // System.err.println("Unexpected problem parsing bytes to discover @Aspect annotation"); + // spe.printStackTrace(); + // return false; + // } + // + // return detector.isAspect(); + // } + + protected void ensureDelegateInitialized(String name, byte[] bytes) { + if (delegateForCurrentClass == null) + delegateForCurrentClass = ((BcelWorld) weaver.getWorld()).addSourceObjectType(Utility.makeJavaClass(name, bytes)); } /** - * Weave a set of bytes defining a class. + * Weave a set of bytes defining a class. + * * @param name the name of the class being woven * @param bytes the bytes that define the class * @return byte[] the woven bytes for the class * @throws IOException */ private byte[] getWovenBytes(String name, byte[] bytes) throws IOException { - WeavingClassFileProvider wcp = new WeavingClassFileProvider(name,bytes); + WeavingClassFileProvider wcp = new WeavingClassFileProvider(name, bytes); + weaver.weave(wcp); + return wcp.getBytes(); + } + + /** + * Weave a set of bytes defining a class for only what is needed to turn @AspectJ aspect in a usefull form ie with aspectOf + * method - see #113587 + * + * @param name the name of the class being woven + * @param bytes the bytes that define the class + * @return byte[] the woven bytes for the class + * @throws IOException + */ + private byte[] getAtAspectJAspectBytes(String name, byte[] bytes) throws IOException { + WeavingClassFileProvider wcp = new WeavingClassFileProvider(name, bytes); + wcp.setApplyAtAspectJMungersOnly(); weaver.weave(wcp); - return wcp.getBytes(); - } - - /** - * Weave a set of bytes defining a class for only what is needed to turn @AspectJ aspect - * in a usefull form ie with aspectOf method - see #113587 - * @param name the name of the class being woven - * @param bytes the bytes that define the class - * @return byte[] the woven bytes for the class - * @throws IOException - */ - private byte[] getAtAspectJAspectBytes(String name, byte[] bytes) throws IOException { - WeavingClassFileProvider wcp = new WeavingClassFileProvider(name,bytes); - wcp.setApplyAtAspectJMungersOnly(); - weaver.weave(wcp); - return wcp.getBytes(); - } - - private void registerAspectLibraries(List aspectPath) { -// System.err.println("? WeavingAdaptor.registerAspectLibraries(" + aspectPath + ")"); + return wcp.getBytes(); + } + + private void registerAspectLibraries(List aspectPath) { + // System.err.println("? WeavingAdaptor.registerAspectLibraries(" + aspectPath + ")"); for (Iterator i = aspectPath.iterator(); i.hasNext();) { - String libName = (String)i.next(); + String libName = (String) i.next(); addAspectLibrary(libName); } - + weaver.prepareForWeave(); } /* - * Register an aspect library with this classloader for use during - * weaving. This class loader will also return (unmodified) any of the - * classes in the library in response to a findClass() request. - * The library is not required to be on the weavingClasspath given when this - * classloader was constructed. + * Register an aspect library with this classloader for use during weaving. This class loader will also return (unmodified) any + * of the classes in the library in response to a findClass() request. The library is not required to be on the + * weavingClasspath given when this classloader was constructed. + * * @param aspectLibraryJarFile a jar file representing an aspect library + * * @throws IOException */ private void addAspectLibrary(String aspectLibraryName) { File aspectLibrary = new File(aspectLibraryName); - if (aspectLibrary.isDirectory() - || (FileUtil.isZipFile(aspectLibrary))) { + if (aspectLibrary.isDirectory() || (FileUtil.isZipFile(aspectLibrary))) { try { info("adding aspect library: '" + aspectLibrary + "'"); weaver.addLibraryJarFile(aspectLibrary); @@ -443,49 +446,49 @@ public class WeavingAdaptor implements IMessageContext { error("bad aspect library: '" + aspectLibrary + "'"); } } - + private static List makeClasspath(String cp) { List ret = new ArrayList(); if (cp != null) { - StringTokenizer tok = new StringTokenizer(cp,File.pathSeparator); + StringTokenizer tok = new StringTokenizer(cp, File.pathSeparator); while (tok.hasMoreTokens()) { ret.add(tok.nextToken()); } } return ret; } - - protected boolean debug (String message) { - return MessageUtil.debug(messageHandler,message); + + protected boolean debug(String message) { + return MessageUtil.debug(messageHandler, message); } - - protected boolean info (String message) { - return MessageUtil.info(messageHandler,message); + + protected boolean info(String message) { + return MessageUtil.info(messageHandler, message); } - - protected boolean warn (String message) { - return MessageUtil.warn(messageHandler,message); + + protected boolean warn(String message) { + return MessageUtil.warn(messageHandler, message); } - - protected boolean warn (String message, Throwable th) { - return messageHandler.handleMessage(new Message(message, IMessage.WARNING, th, null)); + + protected boolean warn(String message, Throwable th) { + return messageHandler.handleMessage(new Message(message, IMessage.WARNING, th, null)); } - - protected boolean error (String message) { - return MessageUtil.error(messageHandler,message); + + protected boolean error(String message) { + return MessageUtil.error(messageHandler, message); } - - protected boolean error (String message, Throwable th) { - return messageHandler.handleMessage(new Message(message, IMessage.ERROR, th, null)); + + protected boolean error(String message, Throwable th) { + return messageHandler.handleMessage(new Message(message, IMessage.ERROR, th, null)); } - - public String getContextId () { + + public String getContextId() { return "WeavingAdaptor"; } /** * Dump the given bytcode in _dump/... (dev mode) - * + * * @param name * @param b * @param before whether we are dumping before weaving @@ -493,134 +496,126 @@ public class WeavingAdaptor implements IMessageContext { */ protected void dump(String name, byte[] b, boolean before) { String dirName = getDumpDir(); - - if (before) dirName = dirName + File.separator + "_before"; - - String className = name.replace('.', '/'); - final File dir; - if (className.indexOf('/') > 0) { - dir = new File(dirName + File.separator + className.substring(0, className.lastIndexOf('/'))); - } else { - dir = new File(dirName); - } - dir.mkdirs(); - String fileName = dirName + File.separator + className + ".class"; - try { -// System.out.println("WeavingAdaptor.dump() fileName=" + new File(fileName).getAbsolutePath()); - FileOutputStream os = new FileOutputStream(fileName); - os.write(b); - os.close(); - } - catch (IOException ex) { - warn("unable to dump class " + name + " in directory " + dirName,ex); - } - } - + + if (before) + dirName = dirName + File.separator + "_before"; + + String className = name.replace('.', '/'); + final File dir; + if (className.indexOf('/') > 0) { + dir = new File(dirName + File.separator + className.substring(0, className.lastIndexOf('/'))); + } else { + dir = new File(dirName); + } + dir.mkdirs(); + String fileName = dirName + File.separator + className + ".class"; + try { + // System.out.println("WeavingAdaptor.dump() fileName=" + new File(fileName).getAbsolutePath()); + FileOutputStream os = new FileOutputStream(fileName); + os.write(b); + os.close(); + } catch (IOException ex) { + warn("unable to dump class " + name + " in directory " + dirName, ex); + } + } + /** - * @return the directory in which to dump - default is _ajdump but it + * @return the directory in which to dump - default is _ajdump but it */ protected String getDumpDir() { return "_ajdump"; } /** - * Processes messages arising from weaver operations. - * Tell weaver to abort on any message more severe than warning. + * Processes messages arising from weaver operations. Tell weaver to abort on any message more severe than warning. */ protected class WeavingAdaptorMessageHolder extends MessageHandler { - private IMessageHandler delegate; - private List savedMessages; + private List savedMessages; protected boolean traceMessages = Boolean.getBoolean(TRACE_MESSAGES_PROPERTY); - - public WeavingAdaptorMessageHolder (PrintWriter writer) { - + + public WeavingAdaptorMessageHolder(PrintWriter writer) { + this.delegate = new WeavingAdaptorMessageWriter(writer); super.dontIgnore(IMessage.WEAVEINFO); } - - private void traceMessage (IMessage message) { + + private void traceMessage(IMessage message) { if (message instanceof WeaveMessage) { trace.debug(render(message)); - } - else if (message.isDebug()) { + } else if (message.isDebug()) { trace.debug(render(message)); - } - else if (message.isInfo()) { + } else if (message.isInfo()) { trace.info(render(message)); - } - else if (message.isWarning()) { - trace.warn(render(message),message.getThrown()); - } - else if (message.isError()) { - trace.error(render(message),message.getThrown()); - } - else if (message.isFailed()) { - trace.fatal(render(message),message.getThrown()); - } - else if (message.isAbort()) { - trace.fatal(render(message),message.getThrown()); - } - else { - trace.error(render(message),message.getThrown()); + } else if (message.isWarning()) { + trace.warn(render(message), message.getThrown()); + } else if (message.isError()) { + trace.error(render(message), message.getThrown()); + } else if (message.isFailed()) { + trace.fatal(render(message), message.getThrown()); + } else if (message.isAbort()) { + trace.fatal(render(message), message.getThrown()); + } else { + trace.error(render(message), message.getThrown()); } } - protected String render(IMessage message) { - return "[" + getContextId() + "] " + message.toString(); - } - - public void flushMessages () { + protected String render(IMessage message) { + return "[" + getContextId() + "] " + message.toString(); + } + + public void flushMessages() { if (savedMessages == null) { savedMessages = new ArrayList(); savedMessages.addAll(super.getUnmodifiableListView()); clearMessages(); - for (Iterator iter = savedMessages.iterator(); iter.hasNext();) { - IMessage message = (IMessage)iter.next(); - delegate.handleMessage(message); - } + for (Iterator iter = savedMessages.iterator(); iter.hasNext();) { + IMessage message = (IMessage) iter.next(); + delegate.handleMessage(message); + } } -// accumulating = false; -// messages.clear(); + // accumulating = false; + // messages.clear(); } - - public void setDelegate (IMessageHandler messageHandler) { + + public void setDelegate(IMessageHandler messageHandler) { delegate = messageHandler; } - /* * IMessageHandler */ public boolean handleMessage(IMessage message) throws AbortException { - if (traceMessages) traceMessage(message); + if (traceMessages) + traceMessage(message); super.handleMessage(message); - + if (abortOnError && 0 <= message.getKind().compareTo(IMessage.ERROR)) { throw new AbortException(message); } -// if (accumulating) { -// boolean result = addMessage(message); -// if (abortOnError && 0 <= message.getKind().compareTo(IMessage.ERROR)) { -// throw new AbortException(message); -// } -// return result; -// } -// else return delegate.handleMessage(message); - - if (savedMessages != null) delegate.handleMessage(message); + // if (accumulating) { + // boolean result = addMessage(message); + // if (abortOnError && 0 <= message.getKind().compareTo(IMessage.ERROR)) { + // throw new AbortException(message); + // } + // return result; + // } + // else return delegate.handleMessage(message); + + if (savedMessages != null) + delegate.handleMessage(message); return true; } - public boolean isIgnoring (Kind kind) { + public boolean isIgnoring(Kind kind) { return delegate.isIgnoring(kind); } - public void dontIgnore (IMessage.Kind kind) { + public void dontIgnore(IMessage.Kind kind) { if (null != kind && delegate != null) { delegate.dontIgnore(kind); } @@ -632,13 +627,12 @@ public class WeavingAdaptor implements IMessageContext { } } - /* * IMessageHolder */ public List getUnmodifiableListView() { -// System.err.println("? WeavingAdaptorMessageHolder.getUnmodifiableListView() savedMessages=" + savedMessages); + // System.err.println("? WeavingAdaptorMessageHolder.getUnmodifiableListView() savedMessages=" + savedMessages); List allMessages = new ArrayList(); allMessages.addAll(savedMessages); allMessages.addAll(super.getUnmodifiableListView()); @@ -648,35 +642,35 @@ public class WeavingAdaptor implements IMessageContext { protected class WeavingAdaptorMessageWriter extends MessageWriter { - private Set ignoring = new HashSet(); - private IMessage.Kind failKind; + private final Set ignoring = new HashSet(); + private final IMessage.Kind failKind; + + public WeavingAdaptorMessageWriter(PrintWriter writer) { + super(writer, true); - public WeavingAdaptorMessageWriter (PrintWriter writer) { - super(writer,true); - ignore(IMessage.WEAVEINFO); - ignore(IMessage.DEBUG); - ignore(IMessage.INFO); + ignore(IMessage.DEBUG); + ignore(IMessage.INFO); this.failKind = IMessage.ERROR; } public boolean handleMessage(IMessage message) throws AbortException { -// boolean result = - super.handleMessage(message); + // boolean result = + super.handleMessage(message); if (abortOnError && 0 <= message.getKind().compareTo(failKind)) { throw new AbortException(message); } - return true; + return true; } - public boolean isIgnoring (Kind kind) { + public boolean isIgnoring(Kind kind) { return ((null != kind) && (ignoring.contains(kind))); } /** * Set a message kind to be ignored from now on */ - public void ignore (IMessage.Kind kind) { + public void ignore(IMessage.Kind kind) { if ((null != kind) && (!ignoring.contains(kind))) { ignoring.add(kind); } @@ -685,46 +679,48 @@ public class WeavingAdaptor implements IMessageContext { /** * Remove a message kind from the list of those ignored from now on. */ - public void dontIgnore (IMessage.Kind kind) { + public void dontIgnore(IMessage.Kind kind) { if (null != kind) { ignoring.remove(kind); } } - protected String render(IMessage message) { - return "[" + getContextId() + "] " + super.render(message); - } + protected String render(IMessage message) { + return "[" + getContextId() + "] " + super.render(message); + } } private class WeavingClassFileProvider implements IClassFileProvider { - private UnwovenClassFile unwovenClass; - private List unwovenClasses = new ArrayList(); /* List */ - private UnwovenClassFile wovenClass; - private boolean isApplyAtAspectJMungersOnly = false; + private final UnwovenClassFile unwovenClass; + private final List unwovenClasses = new ArrayList(); /* List */ + private IUnwovenClassFile wovenClass; + private boolean isApplyAtAspectJMungersOnly = false; - public WeavingClassFileProvider (String name, byte[] bytes) { - ensureDelegateInitialized(name, bytes); - this.unwovenClass = new UnwovenClassFile(name,delegateForCurrentClass.getResolvedTypeX().getName(),bytes); + public WeavingClassFileProvider(String name, byte[] bytes) { + ensureDelegateInitialized(name, bytes); + this.unwovenClass = new UnwovenClassFile(name, delegateForCurrentClass.getResolvedTypeX().getName(), bytes); this.unwovenClasses.add(unwovenClass); - - if (shouldDump(name.replace('/', '.'),true)) { + + if (shouldDump(name.replace('/', '.'), true)) { dump(name, bytes, true); } - + } - public void setApplyAtAspectJMungersOnly() { - isApplyAtAspectJMungersOnly = true; - } + public void setApplyAtAspectJMungersOnly() { + isApplyAtAspectJMungersOnly = true; + } - public boolean isApplyAtAspectJMungersOnly() { - return isApplyAtAspectJMungersOnly; - } + public boolean isApplyAtAspectJMungersOnly() { + return isApplyAtAspectJMungersOnly; + } - public byte[] getBytes () { - if (wovenClass != null) return wovenClass.getBytes(); - else return unwovenClass.getBytes(); + public byte[] getBytes() { + if (wovenClass != null) + return wovenClass.getBytes(); + else + return unwovenClass.getBytes(); } public Iterator getClassFileIterator() { @@ -734,40 +730,45 @@ public class WeavingAdaptor implements IMessageContext { public IWeaveRequestor getRequestor() { return new IWeaveRequestor() { - public void acceptResult(UnwovenClassFile result) { + public void acceptResult(IUnwovenClassFile result) { if (wovenClass == null) { wovenClass = result; - + String name = result.getClassName(); if (shouldDump(name.replace('/', '.'), false)) { dump(name, result.getBytes(), false); } } - + /* Classes generated by weaver e.g. around closure advice */ else { String className = result.getClassName(); - generatedClasses.put(className,result); - generatedClasses.put(wovenClass.getClassName(),result); - generatedClassHandler.acceptClass(className,result.getBytes()); + generatedClasses.put(className, result); + generatedClasses.put(wovenClass.getClassName(), result); + generatedClassHandler.acceptClass(className, result.getBytes()); } } - public void processingReweavableState() { } + public void processingReweavableState() { + } - public void addingTypeMungers() {} + public void addingTypeMungers() { + } - public void weavingAspects() {} + public void weavingAspects() { + } - public void weavingClasses() {} + public void weavingClasses() { + } public void weaveCompleted() { ResolvedType.resetPrimitives(); - if (delegateForCurrentClass!=null) delegateForCurrentClass.weavingCompleted(); + if (delegateForCurrentClass != null) + delegateForCurrentClass.weavingCompleted(); ResolvedType.resetPrimitives(); - //bcelWorld.discardType(typeBeingProcessed.getResolvedTypeX()); // work in progress + // bcelWorld.discardType(typeBeingProcessed.getResolvedTypeX()); // work in progress } - }; + }; } } } \ No newline at end of file