Top Inners Fields Constructors Methods
org.aspectj.weaver.loadtime

public Class ClassLoaderWeavingAdaptor

extends WeavingAdaptor
Class Inheritance
Imports
java.io.File, .IOException, .InputStream, java.lang.reflect.Field, .Method, java.net.MalformedURLException, .URL, java.security.ProtectionDomain, java.util.ArrayList, .Enumeration, .HashMap, .HashSet, .Iterator, .LinkedList, .List, .Map, .Map.Entry, .Properties, .Set, .StringTokenizer, org.aspectj.bridge.AbortException, .Constants, .MessageUtil, org.aspectj.util.LangUtil, org.aspectj.weaver.IUnwovenClassFile, .Lint, .Lint.Kind, .ResolvedType, .UnresolvedType, .World, org.aspectj.weaver.bcel.BcelWeakClassLoaderReference, .BcelWeaver, .BcelWorld, .Utility, org.aspectj.weaver.loadtime.definition.Definition, .DocumentParser, org.aspectj.weaver.ltw.LTWWorld, org.aspectj.weaver.patterns.PatternParser, .TypePattern, org.aspectj.weaver.tools.GeneratedClassHandler, .Trace, .TraceFactory, .WeavingAdaptor, org.aspectj.weaver.tools.cache.WeavedClassCache, sun.misc.Unsafe

Authors
Alexandre Vasseur, Andy Clement, Abraham Nevado, David Knibb, John Kew

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class

Field Summary

Modifier and TypeField and Description
private static final String
private List<String>
private List<TypePattern>
private List<String>
private List<TypePattern>
private static Method
private List<ConcreteAspectCodeGen>
pack-priv static Method
private static Object
private boolean
private boolean
private List<TypePattern>
private List<String>
private List<String>
private List<String[]>
private List<String>
private List<String>
private List<TypePattern>
private boolean
private boolean
private List<String>
private boolean
private List<String>
private List<TypePattern>
private boolean
private static Boolean
private static Method
private static final Object
private StringBuffer
private static Trace
private Unsafe
private IWeavingContext
Inherited from org.aspectj.weaver.tools.WeavingAdaptor:
activeProtectionDomainbcelWorldcachedelegateForCurrentClassgeneratedClassesgeneratedClassHandlerSHOW_WEAVE_INFO_PROPERTYTRACE_MESSAGES_PROPERTYverboseweaverWEAVING_ADAPTOR_VERBOSE

Constructor Summary

AccessConstructor and Description
public
public
ClassLoaderWeavingAdaptor(final ClassLoader deprecatedLoader, final IWeavingContext deprecatedContext)

Deprecated
We don't need a reference to the class loader and using it during construction can cause problems with recursion.

Method Summary

Modifier and TypeMethod and Description
protected boolean

Returns:

true if it should be accepted for weaving
accept
(String
the name of the type to possibly accept
className
,
byte[]
the bytecode for the type (in case we need to look inside, eg. annotations)
bytes
)

Overrides org.aspectj.weaver.tools.WeavingAdaptor.accept.

Determine whether a type should be accepted for weaving, by checking it against any includes/excludes.
private boolean
acceptAspect(String aspectClassName)

private void
defineClass(ClassLoader loader, String name, byte[] bytes, ProtectionDomain protectionDomain)

private void
defineClass(ClassLoader loader, String name, byte[] bytes)

public void
flushGeneratedClasses()

Flush the generated classes cache

public void
flushGeneratedClassesFor(String
a slashed classname (e.g. com/foo/Bar)
className
)

Remove generated classes based on the supplied className.

public boolean

Returns:

true if a class has been generated and is stored in the cache
generatedClassesExistFor
(String
TODO
className
)

Check to see if any classes are stored in the generated classes cache.

pack-priv List<String>
getAspectClassNames(List<Definition> definitions)

Get the list of all aspects from the defintion list

private String
public String
protected String
public String

Returns:

Returns the key.
getNamespace
()

private Unsafe
private boolean
hasSpaceAnnotationPlus(String string, int pos)

Determine if something in the string is going to affect our ability to optimize.

private boolean
hasStarDot(String string, int pos)

Determine if something in the string is going to affect our ability to optimize.

public void
initialize(final ClassLoader classLoader, IWeavingContext context)

private static synchronized void
protected void
lint(String name, String[] infos)

private String
looksLikeEndsWith(String typePattern)

Checks if the pattern looks like "*Exception"

private String
looksLikeExactName(String typePattern)

Checks if the pattern looks like "com.foo.Bar" - an exact name

private String
looksLikeStarDotDotStarExclude(String typePattern)

Checks if the pattern looks like "*..*XXXX*" and if so returns XXXX.

private String
looksLikeStartsWith(String typePattern)

Checks if the type pattern looks like "com.foo..*"

pack-priv List<Definition>
parseDefinitions(final ClassLoader loader)

Load and cache the aop.xml/properties according to the classloader visibility rules

private void
registerAspectExclude(final BcelWeaver weaver, final ClassLoader loader, final List<Definition> definitions)

private void
registerAspectInclude(final BcelWeaver weaver, final ClassLoader loader, final List<Definition> definitions)

private boolean
registerAspects(final BcelWeaver weaver, final ClassLoader loader, final List<Definition> definitions)

Register the aspect, following include / exclude rules

private boolean
registerDefinitions(final BcelWeaver weaver, final ClassLoader loader, List<Definition> definitions)

private void
registerDump(final BcelWeaver weaver, final ClassLoader loader, final List<Definition> definitions)

Register the dump filter

private void
registerIncludeExclude(final BcelWeaver weaver, final ClassLoader loader, final List<Definition> definitions)

Register the include / exclude filters.

private void
registerOptions(final BcelWeaver weaver, final ClassLoader loader, final List<Definition> definitions)

Configure the weaver according to the option directives TODO av - don't know if it is that good to reuse, since we only allow a small subset of options in LTW

protected boolean
private boolean
Inherited from org.aspectj.weaver.tools.WeavingAdaptor:
addURLcreateMessageHandlerdebugdisabledumpenableensureDelegateInitializederrorerrorgetFullClassPathgetMessageHandlergetMessageHolderinfoinitializeCacheisEnabledsetActiveProtectionDomainsetMessageHandlerwarnwarnweaveClassweaveClass

Field Detail

AOP_XMLback to summary
private static final String AOP_XML
aspectExcludeStartsWithback to summary
private List<String> aspectExcludeStartsWith
aspectExcludeTypePatternback to summary
private List<TypePattern> aspectExcludeTypePattern
aspectIncludeStartsWithback to summary
private List<String> aspectIncludeStartsWith
aspectIncludeTypePatternback to summary
private List<TypePattern> aspectIncludeTypePattern
bindTo_Methodback to summary
private static Method bindTo_Method
concreteAspectsback to summary
private List<ConcreteAspectCodeGen> concreteAspects
defineClassMethodback to summary
pack-priv static Method defineClassMethod
defineClassMethodHandleback to summary
private static Object defineClassMethodHandle
dumpBeforeback to summary
private boolean dumpBefore
dumpDirPerClassloaderback to summary
private boolean dumpDirPerClassloader
dumpTypePatternback to summary
private List<TypePattern> dumpTypePattern
excludeEndsWithback to summary
private List<String> excludeEndsWith
excludeExactNameback to summary
private List<String> excludeExactName
excludeSpecialback to summary
private List<String[]> excludeSpecial
excludeStarDotDotStarback to summary
private List<String> excludeStarDotDotStar
excludeStartsWithback to summary
private List<String> excludeStartsWith
excludeTypePatternback to summary
private List<TypePattern> excludeTypePattern
hasExcludesback to summary
private boolean hasExcludes
hasIncludesback to summary
private boolean hasIncludes
includeExactNameback to summary
private List<String> includeExactName
includeStarback to summary
private boolean includeStar
includeStartsWithback to summary
private List<String> includeStartsWith
includeTypePatternback to summary
private List<TypePattern> includeTypePattern
initializedback to summary
private boolean initialized
initializedForJava11back to summary
private static Boolean initializedForJava11
invokeWithArguments_Methodback to summary
private static Method invokeWithArguments_Method
lockback to summary
private static final Object lock
namespaceback to summary
private StringBuffer namespace
traceback to summary
private static Trace trace

Hides org.aspectj.weaver.tools.WeavingAdaptor.trace.

unsafeback to summary
private Unsafe unsafe
weavingContextback to summary
private IWeavingContext weavingContext

Constructor Detail

ClassLoaderWeavingAdaptorback to summary
public ClassLoaderWeavingAdaptor()
ClassLoaderWeavingAdaptorback to summary
public ClassLoaderWeavingAdaptor(final ClassLoader deprecatedLoader, final IWeavingContext deprecatedContext)

Deprecated

We don't need a reference to the class loader and using it during construction can cause problems with recursion. It also makes sense to supply the weaving context during initialization to.

Annotations
@Deprecated

Method Detail

acceptback to summary
protected boolean accept(String className, byte[] bytes)

Overrides org.aspectj.weaver.tools.WeavingAdaptor.accept.

Determine whether a type should be accepted for weaving, by checking it against any includes/excludes.

Parameters
className:String

the name of the type to possibly accept

bytes:byte[]

the bytecode for the type (in case we need to look inside, eg. annotations)

Returns:boolean

true if it should be accepted for weaving

Annotations
@Override
acceptAspectback to summary
private boolean acceptAspect(String aspectClassName)
defineClassback to summary
private void defineClass(ClassLoader loader, String name, byte[] bytes, ProtectionDomain protectionDomain)
defineClassback to summary
private void defineClass(ClassLoader loader, String name, byte[] bytes)
flushGeneratedClassesback to summary
public void flushGeneratedClasses()

Flush the generated classes cache

flushGeneratedClassesForback to summary
public void flushGeneratedClassesFor(String className)

Remove generated classes based on the supplied className. This will remove any entries related to this name - so the class itself plus and inner classes.

Parameters
className:String

a slashed classname (e.g. com/foo/Bar)

generatedClassesExistForback to summary
public boolean generatedClassesExistFor(String className)

Check to see if any classes are stored in the generated classes cache. Then flush the cache if it is not empty

Parameters
className:String

TODO

Returns:boolean

true if a class has been generated and is stored in the cache

getAspectClassNamesback to summary
pack-priv List<String> getAspectClassNames(List<Definition> definitions)

Get the list of all aspects from the defintion list

getClassLoaderNameback to summary
private String getClassLoaderName(ClassLoader loader)
getContextIdback to summary
public String getContextId()

Overrides org.aspectj.weaver.tools.WeavingAdaptor.getContextId.

Implements org.aspectj.bridge.IMessageContext.getContextId.

Annotations
@Override
getDumpDirback to summary
protected String getDumpDir()

Overrides org.aspectj.weaver.tools.WeavingAdaptor.getDumpDir.

Returns:String

Doc from org.aspectj.weaver.tools.WeavingAdaptor.getDumpDir.

the directory in which to dump - default is _ajdump but it

Annotations
@Override
getNamespaceback to summary
public String getNamespace()
Returns:String

Returns the key.

getUnsafeback to summary
private Unsafe getUnsafe() throws NoSuchFieldException, IllegalAccessException
hasSpaceAnnotationPlusback to summary
private boolean hasSpaceAnnotationPlus(String string, int pos)

Determine if something in the string is going to affect our ability to optimize. Checks for: ' ' '@' '+'

hasStarDotback to summary
private boolean hasStarDot(String string, int pos)

Determine if something in the string is going to affect our ability to optimize. Checks for: '*' '.'

initializeback to summary
public void initialize(final ClassLoader classLoader, IWeavingContext context)
initializeForJava11back to summary
private static synchronized void initializeForJava11()
lintback to summary
protected void lint(String name, String[] infos)
looksLikeEndsWithback to summary
private String looksLikeEndsWith(String typePattern)

Checks if the pattern looks like "*Exception"

looksLikeExactNameback to summary
private String looksLikeExactName(String typePattern)

Checks if the pattern looks like "com.foo.Bar" - an exact name

looksLikeStarDotDotStarExcludeback to summary
private String looksLikeStarDotDotStarExclude(String typePattern)

Checks if the pattern looks like "*..*XXXX*" and if so returns XXXX. This will enable fast name matching of CGLIB exclusion

looksLikeStartsWithback to summary
private String looksLikeStartsWith(String typePattern)

Checks if the type pattern looks like "com.foo..*"

parseDefinitionsback to summary
pack-priv List<Definition> parseDefinitions(final ClassLoader loader)

Load and cache the aop.xml/properties according to the classloader visibility rules

registerAspectExcludeback to summary
private void registerAspectExclude(final BcelWeaver weaver, final ClassLoader loader, final List<Definition> definitions)
registerAspectIncludeback to summary
private void registerAspectInclude(final BcelWeaver weaver, final ClassLoader loader, final List<Definition> definitions)
registerAspectsback to summary
private boolean registerAspects(final BcelWeaver weaver, final ClassLoader loader, final List<Definition> definitions)

Register the aspect, following include / exclude rules

registerDefinitionsback to summary
private boolean registerDefinitions(final BcelWeaver weaver, final ClassLoader loader, List<Definition> definitions)
registerDumpback to summary
private void registerDump(final BcelWeaver weaver, final ClassLoader loader, final List<Definition> definitions)

Register the dump filter

registerIncludeExcludeback to summary
private void registerIncludeExclude(final BcelWeaver weaver, final ClassLoader loader, final List<Definition> definitions)

Register the include / exclude filters. We duplicate simple patterns in startWith filters that will allow faster matching without ResolvedType

registerOptionsback to summary
private void registerOptions(final BcelWeaver weaver, final ClassLoader loader, final List<Definition> definitions)

Configure the weaver according to the option directives TODO av - don't know if it is that good to reuse, since we only allow a small subset of options in LTW

shouldDumpback to summary
protected boolean shouldDump(String className, boolean before)

Overrides org.aspectj.weaver.tools.WeavingAdaptor.shouldDump.

Annotations
@Override
weaveAndDefineConceteAspectsback to summary
private boolean weaveAndDefineConceteAspects()
org.aspectj.weaver.loadtime back to summary

pack-priv Class ClassLoaderWeavingAdaptor.SimpleGeneratedClassHandler

extends Object
implements GeneratedClassHandler
Class Inheritance
  • java.lang.Object
  • org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.SimpleGeneratedClassHandler
All Implemented Interfaces
org.aspectj.weaver.tools.GeneratedClassHandler

Field Summary

Modifier and TypeField and Description
private BcelWeakClassLoaderReference

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
acceptClass(String
class name
name
,
byte[]
original class bytes
originalBytes
,
byte[]
woven class bytes
wovenBytes
)

Implements org.aspectj.weaver.tools.GeneratedClassHandler.acceptClass.

Callback when we need to define a Closure in the JVM
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

loaderRefback to summary
private BcelWeakClassLoaderReference loaderRef

Constructor Detail

SimpleGeneratedClassHandlerback to summary
pack-priv SimpleGeneratedClassHandler(ClassLoader loader)

Method Detail

acceptClassback to summary
public void acceptClass(String name, byte[] originalBytes, byte[] wovenBytes)

Implements org.aspectj.weaver.tools.GeneratedClassHandler.acceptClass.

Callback when we need to define a Closure in the JVM

Parameters
name:String

Doc from org.aspectj.weaver.tools.GeneratedClassHandler.acceptClass.

class name

originalBytes:byte[]

Doc from org.aspectj.weaver.tools.GeneratedClassHandler.acceptClass.

original class bytes

wovenBytes:byte[]

Doc from org.aspectj.weaver.tools.GeneratedClassHandler.acceptClass.

woven class bytes

Annotations
@Override