Class AjPipeliningCompilerAdapter
java.lang.Object
org.aspectj.ajdt.internal.compiler.AbstractCompilerAdapter
org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter
- All Implemented Interfaces:
ICompilerAdapter
Adapts standard JDT Compiler to add in AspectJ specific behaviours. This version implements pipelining - where files are compiled
and then woven immediately, unlike AjCompilerAdapter which compiles everything then weaves everything. (One small note: because
all aspects have to be known before weaving can take place, the weaving pipeline is 'stalled' until all aspects have been
compiled).
The basic strategy is this:
1. diet parse all input source files - this is enough for us to implement ITD matching - this enables us to determine which are
aspects 2. sort the input files, aspects first - keep a note of how many files contain aspects 3. if there are aspects, mark the
pipeline as 'stalled' 3. repeat 3a. compile a file 3b. have we now compiled all aspects? NO - put file in a weave pending queue
YES- unstall the 'pipeline' 3c. is the pipeline stalled? NO - weave all pending files and this one YES- do nothing
Complexities arise because of: - what does -XterminateAfterCompilation mean? since there is no stage where everything is compiled
and nothing is woven
Here is the compiler loop difference when pipelining.
the old way: Finished diet parsing [C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java] Finished diet parsing
[C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java] > AjLookupEnvironment.completeTypeBindings() <
AjLookupEnvironment.completeTypeBindings() compiling C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java
>Compiler.process(C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java)
<Compiler.process(C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java) compiling
C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java
>Compiler.process(C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java)
<Compiler.process(C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java) >AjCompilerAdapter.weave()
>BcelWeaver.prepareForWeave <BcelWeaver.prepareForWeave woven class ClassOne (from
C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java) woven class ClassTwo (from
C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java) <AjCompilerAdapter.weave()
the new way (see the compiling/weaving mixed up): Finished diet parsing
[C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java] Finished diet parsing
[C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java] >AjLookupEnvironment.completeTypeBindings()
<AjLookupEnvironment.completeTypeBindings() compiling C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java
>Compiler.process(C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java)
<Compiler.process(C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java) >AjCompilerAdapter.weave()
>BcelWeaver.prepareForWeave <BcelWeaver.prepareForWeave woven class ClassOne (from
C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java) <AjCompilerAdapter.weave() compiling
C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java
>Compiler.process(C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java)
<Compiler.process(C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java) >AjCompilerAdapter.weave() woven class ClassTwo
(from C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java) invalid input: '<'AjCompilerAdapter.weave()
-
Field Summary
Modifier and TypeFieldDescriptionstatic boolean
SECRET: FOR TESTING - this can be used to collect information that tests can verify. -
Constructor Summary
ConstructorDescriptionAjPipeliningCompilerAdapter
(Compiler compiler, boolean isBatchCompile, BcelWorld world, BcelWeaver weaver, EclipseFactory eFactory, IIntermediateResultsRequestor intRequestor, IProgressListener progressListener, IOutputClassFileNameProvider outputFileNameProvider, IBinarySourceProvider binarySourceProvider, Map fullBinarySourceEntries, boolean isXterminateAfterCompilation, boolean proceedOnError, boolean noAtAspectJProcessing, boolean makeReflectable, AjState incrementalCompilationState) Create an adapter, and tell it everything it needs to now to drive the AspectJ parts of a compile cycle. -
Method Summary
Modifier and TypeMethodDescriptionvoid
acceptResult
(CompilationResult result) void
void
afterCompiling
(CompilationUnitDeclaration[] units) void
In a pipelining compilation system, we need to ensure aspects are through the pipeline first.void
void
afterProcessing
(CompilationUnitDeclaration unit, int unitIndex) void
void
void
beforeCompiling
(ICompilationUnit[] sourceUnits) void
void
void
static String
-
Field Details
-
pipelineTesting
public static boolean pipelineTestingSECRET: FOR TESTING - this can be used to collect information that tests can verify. -
pipelineOutput
-
-
Constructor Details
-
AjPipeliningCompilerAdapter
public AjPipeliningCompilerAdapter(Compiler compiler, boolean isBatchCompile, BcelWorld world, BcelWeaver weaver, EclipseFactory eFactory, IIntermediateResultsRequestor intRequestor, IProgressListener progressListener, IOutputClassFileNameProvider outputFileNameProvider, IBinarySourceProvider binarySourceProvider, Map fullBinarySourceEntries, boolean isXterminateAfterCompilation, boolean proceedOnError, boolean noAtAspectJProcessing, boolean makeReflectable, AjState incrementalCompilationState) Create an adapter, and tell it everything it needs to now to drive the AspectJ parts of a compile cycle.- Parameters:
compiler
- the JDT compiler that produces class files from sourceisBatchCompile
- true if this is a full build (non-incremental)world
- the bcelWorld used for type resolution during weavingweaver
- the weaverintRequestor
- recipient of interim compilation results from compiler (pre-weave)outputFileNameProvider
- implementor of a strategy providing output file names for resultsbinarySourceProvider
- binary source that we didn't compile, but that we need to weaveincrementalCompilationState
- if we are doing an incremental build, and the weaver determines that we need to weave the world, this is the set of intermediate results that will be passed to the weaver.
-
-
Method Details
-
afterDietParsing
In a pipelining compilation system, we need to ensure aspects are through the pipeline first. Only when they are all through (and therefore we know about all static/dynamic crosscutting) can be proceed to weave anything. Effectively the weaving part of the pipeline stalls until all the aspects have been fully compiled. This method sorts the compilation units such that any containing aspects are fully compiled first and it keeps a note on how long it should stall the pipeline before commencing weaving.- Specified by:
afterDietParsing
in interfaceICompilerAdapter
- Specified by:
afterDietParsing
in classAbstractCompilerAdapter
-
beforeCompiling
- Specified by:
beforeCompiling
in interfaceICompilerAdapter
- Specified by:
beforeCompiling
in classAbstractCompilerAdapter
-
beforeProcessing
- Specified by:
beforeProcessing
in interfaceICompilerAdapter
- Specified by:
beforeProcessing
in classAbstractCompilerAdapter
-
beforeResolving
- Specified by:
beforeResolving
in interfaceICompilerAdapter
- Specified by:
beforeResolving
in classAbstractCompilerAdapter
-
afterResolving
- Specified by:
afterResolving
in interfaceICompilerAdapter
- Specified by:
afterResolving
in classAbstractCompilerAdapter
-
beforeAnalysing
- Specified by:
beforeAnalysing
in interfaceICompilerAdapter
- Specified by:
beforeAnalysing
in classAbstractCompilerAdapter
-
afterAnalysing
- Specified by:
afterAnalysing
in interfaceICompilerAdapter
- Specified by:
afterAnalysing
in classAbstractCompilerAdapter
-
beforeGenerating
- Specified by:
beforeGenerating
in interfaceICompilerAdapter
- Specified by:
beforeGenerating
in classAbstractCompilerAdapter
-
afterGenerating
- Specified by:
afterGenerating
in interfaceICompilerAdapter
- Specified by:
afterGenerating
in classAbstractCompilerAdapter
-
afterCompiling
- Specified by:
afterCompiling
in interfaceICompilerAdapter
- Specified by:
afterCompiling
in classAbstractCompilerAdapter
-
afterProcessing
- Specified by:
afterProcessing
in interfaceICompilerAdapter
- Specified by:
afterProcessing
in classAbstractCompilerAdapter
-
acceptResult
- Specified by:
acceptResult
in classAbstractCompilerAdapter
-
getPipelineDebugOutput
-
getResultsPendingWeave
- Specified by:
getResultsPendingWeave
in classAbstractCompilerAdapter
-