org.aspectj.ajdt.internal.compiler
Class AjPipeliningCompilerAdapter

java.lang.Object
  extended by org.aspectj.ajdt.internal.compiler.AbstractCompilerAdapter
      extended by org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter
All Implemented Interfaces:
ICompilerAdapter

public class AjPipeliningCompilerAdapter
extends AbstractCompilerAdapter

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\ClassTwo.java) AjCompilerAdapter.weave() >BcelWeaver.prepareForWeave AjLookupEnvironment.completeTypeBindings() Compiler.process(C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassOne.java) AjCompilerAdapter.weave() >BcelWeaver.prepareForWeave Compiler.process(C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java) AjCompilerAdapter.weave() woven class ClassTwo (from C:\temp\ajcSandbox\aspectjhead\ajcTest23160.tmp\ClassTwo.java)


Field Summary
static java.util.Hashtable<java.lang.String,java.lang.String> pipelineOutput
           
static boolean pipelineTesting
          SECRET: FOR TESTING - this can be used to collect information that tests can verify.
 
Constructor Summary
AjPipeliningCompilerAdapter(Compiler compiler, boolean isBatchCompile, BcelWorld world, BcelWeaver weaver, EclipseFactory eFactory, IIntermediateResultsRequestor intRequestor, IProgressListener progressListener, IOutputClassFileNameProvider outputFileNameProvider, IBinarySourceProvider binarySourceProvider, java.util.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
 void acceptResult(CompilationResult result)
           
 void afterAnalysing(CompilationUnitDeclaration unit)
           
 void afterCompiling(CompilationUnitDeclaration[] units)
           
 void afterDietParsing(CompilationUnitDeclaration[] units)
          In a pipelining compilation system, we need to ensure aspects are through the pipeline first.
 void afterGenerating(CompilationUnitDeclaration unit)
           
 void afterProcessing(CompilationUnitDeclaration unit, int unitIndex)
           
 void afterResolving(CompilationUnitDeclaration unit)
           
 void beforeAnalysing(CompilationUnitDeclaration unit)
           
 void beforeCompiling(ICompilationUnit[] sourceUnits)
           
 void beforeGenerating(CompilationUnitDeclaration unit)
           
 void beforeProcessing(CompilationUnitDeclaration unit)
           
 void beforeResolving(CompilationUnitDeclaration unit)
           
static java.lang.String getPipelineDebugOutput(java.lang.String key)
           
 java.util.List<InterimCompilationResult> getResultsPendingWeave()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pipelineTesting

public static boolean pipelineTesting
SECRET: FOR TESTING - this can be used to collect information that tests can verify.


pipelineOutput

public static java.util.Hashtable<java.lang.String,java.lang.String> pipelineOutput
Constructor Detail

AjPipeliningCompilerAdapter

public AjPipeliningCompilerAdapter(Compiler compiler,
                                   boolean isBatchCompile,
                                   BcelWorld world,
                                   BcelWeaver weaver,
                                   EclipseFactory eFactory,
                                   IIntermediateResultsRequestor intRequestor,
                                   IProgressListener progressListener,
                                   IOutputClassFileNameProvider outputFileNameProvider,
                                   IBinarySourceProvider binarySourceProvider,
                                   java.util.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 source
isBatchCompile - true if this is a full build (non-incremental)
world - the bcelWorld used for type resolution during weaving
weaver - the weaver
intRequestor - recipient of interim compilation results from compiler (pre-weave)
outputFileNameProvider - implementor of a strategy providing output file names for results
binarySourceEntries - binary source that we didn't compile, but that we need to weave
resultSetForFullWeave - 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 Detail

afterDietParsing

public void afterDietParsing(CompilationUnitDeclaration[] units)
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 interface ICompilerAdapter
Specified by:
afterDietParsing in class AbstractCompilerAdapter

beforeCompiling

public void beforeCompiling(ICompilationUnit[] sourceUnits)
Specified by:
beforeCompiling in interface ICompilerAdapter
Specified by:
beforeCompiling in class AbstractCompilerAdapter

beforeProcessing

public void beforeProcessing(CompilationUnitDeclaration unit)
Specified by:
beforeProcessing in interface ICompilerAdapter
Specified by:
beforeProcessing in class AbstractCompilerAdapter

beforeResolving

public void beforeResolving(CompilationUnitDeclaration unit)
Specified by:
beforeResolving in interface ICompilerAdapter
Specified by:
beforeResolving in class AbstractCompilerAdapter

afterResolving

public void afterResolving(CompilationUnitDeclaration unit)
Specified by:
afterResolving in interface ICompilerAdapter
Specified by:
afterResolving in class AbstractCompilerAdapter

beforeAnalysing

public void beforeAnalysing(CompilationUnitDeclaration unit)
Specified by:
beforeAnalysing in interface ICompilerAdapter
Specified by:
beforeAnalysing in class AbstractCompilerAdapter

afterAnalysing

public void afterAnalysing(CompilationUnitDeclaration unit)
Specified by:
afterAnalysing in interface ICompilerAdapter
Specified by:
afterAnalysing in class AbstractCompilerAdapter

beforeGenerating

public void beforeGenerating(CompilationUnitDeclaration unit)
Specified by:
beforeGenerating in interface ICompilerAdapter
Specified by:
beforeGenerating in class AbstractCompilerAdapter

afterGenerating

public void afterGenerating(CompilationUnitDeclaration unit)
Specified by:
afterGenerating in interface ICompilerAdapter
Specified by:
afterGenerating in class AbstractCompilerAdapter

afterCompiling

public void afterCompiling(CompilationUnitDeclaration[] units)
Specified by:
afterCompiling in interface ICompilerAdapter
Specified by:
afterCompiling in class AbstractCompilerAdapter

afterProcessing

public void afterProcessing(CompilationUnitDeclaration unit,
                            int unitIndex)
Specified by:
afterProcessing in interface ICompilerAdapter
Specified by:
afterProcessing in class AbstractCompilerAdapter

acceptResult

public void acceptResult(CompilationResult result)
Specified by:
acceptResult in class AbstractCompilerAdapter

getPipelineDebugOutput

public static java.lang.String getPipelineDebugOutput(java.lang.String key)

getResultsPendingWeave

public java.util.List<InterimCompilationResult> getResultsPendingWeave()
Specified by:
getResultsPendingWeave in class AbstractCompilerAdapter