Skip to content

Commit 0b78865

Browse files
committed
AjLookupEnvironment: move phase CONNECT_TYPE_HIERARCHY2 to later
Actually, this is just a guess. I do not understand enough about the whole lookup process to decide confidently, where the call to CompilationUnitScope.connectTypeHierarchy2() really should be made. Splitting the phases in CompilationAndWeavingContext, mimicking what JDT Core does in LookupEnvironment, is one thing. But deciding when to initiate the second phase for connecting the type hierarchy, is another one. Moving it to after BUILD_FIELDS_AND_METHODS is inconsistent with JDT Core, but at least it fixes the previously failing tests. Signed-off-by: Alexander Kriegisch <[email protected]>
1 parent e39b13f commit 0b78865

File tree

2 files changed

+29
-23
lines changed

2 files changed

+29
-23
lines changed

bridge/src/main/java/org/aspectj/bridge/context/CompilationAndWeavingContext.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class CompilationAndWeavingContext {
4141
public static final int COMPLETING_TYPE_BINDINGS = 6;
4242
public static final int PROCESSING_DECLARE_PARENTS = 7;
4343
public static final int CHECK_AND_SET_IMPORTS = 8;
44-
public static final int CONNECTING_TYPE_HIERARCHY = 9;
44+
public static final int CONNECTING_TYPE_HIERARCHY1 = 9;
4545
public static final int BUILDING_FIELDS_AND_METHODS = 10;
4646
public static final int COLLECTING_ITDS_AND_DECLARES = 11;
4747
public static final int PROCESSING_DECLARE_ANNOTATIONS = 12;
@@ -54,31 +54,32 @@ public class CompilationAndWeavingContext {
5454
public static final int FIXING_SUPER_CALLS_IN_ITDS = 19;
5555
public static final int FIXING_SUPER_CALLS = 20;
5656
public static final int OPTIMIZING_THIS_JOIN_POINT_CALLS = 21;
57+
public static final int CONNECTING_TYPE_HIERARCHY2 = 22;
5758

5859
// "BACK END"
5960

60-
public static final int WEAVING = 22;
61-
public static final int PROCESSING_REWEAVABLE_STATE = 23;
62-
public static final int PROCESSING_TYPE_MUNGERS = 24;
63-
public static final int WEAVING_ASPECTS = 25;
64-
public static final int WEAVING_CLASSES = 26;
65-
public static final int WEAVING_TYPE = 27;
66-
public static final int MATCHING_SHADOW = 28;
67-
public static final int IMPLEMENTING_ON_SHADOW = 29;
68-
public static final int MATCHING_POINTCUT = 30;
69-
public static final int MUNGING_WITH = 31;
70-
public static final int PROCESSING_ATASPECTJTYPE_MUNGERS_ONLY = 32;
61+
public static final int WEAVING = 23;
62+
public static final int PROCESSING_REWEAVABLE_STATE = 24;
63+
public static final int PROCESSING_TYPE_MUNGERS = 25;
64+
public static final int WEAVING_ASPECTS = 26;
65+
public static final int WEAVING_CLASSES = 27;
66+
public static final int WEAVING_TYPE = 28;
67+
public static final int MATCHING_SHADOW = 29;
68+
public static final int IMPLEMENTING_ON_SHADOW = 30;
69+
public static final int MATCHING_POINTCUT = 31;
70+
public static final int MUNGING_WITH = 32;
71+
public static final int PROCESSING_ATASPECTJTYPE_MUNGERS_ONLY = 33;
7172

7273
// phase names
7374
public static final String[] PHASE_NAMES = new String[] { "batch building", "incrementally building",
7475
"processing compilation unit", "resolving types defined in compilation unit",
7576
"analysing types defined in compilation unit", "generating unwoven code for type defined in compilation unit",
76-
"completing type bindings", "processing declare parents", "checking and setting imports", "connecting type hierarchy",
77+
"completing type bindings", "processing declare parents", "checking and setting imports", "connecting type hierarchy 1",
7778
"building fields and methods", "collecting itds and declares", "processing declare annotations",
7879
"weaving intertype declarations", "resolving pointcut declarations", "adding declare warning and errors",
7980
"validating @AspectJ annotations", "creating accessors for inlining", "adding @AspectJ annotations",
8081
"fixing super calls in ITDs in interface context", "fixing super calls in ITDs",
81-
"optimizing thisJoinPoint calls",
82+
"optimizing thisJoinPoint calls", "connecting type hierarchy 2",
8283

8384
// BACK END
8485

org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,19 +146,12 @@ public void completeTypeBindings() {
146146
stepCompleted = CHECK_AND_SET_IMPORTS;
147147

148148
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
149-
ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.CONNECTING_TYPE_HIERARCHY,
149+
ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.CONNECTING_TYPE_HIERARCHY1,
150150
units[i].compilationResult.fileName);
151151
units[i].scope.connectTypeHierarchy1();
152152
CompilationAndWeavingContext.leavingPhase(tok);
153153
}
154154
stepCompleted = CONNECT_TYPE_HIERARCHY1;
155-
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
156-
ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.CONNECTING_TYPE_HIERARCHY,
157-
units[i].compilationResult.fileName);
158-
units[i].scope.connectTypeHierarchy2();
159-
CompilationAndWeavingContext.leavingPhase(tok);
160-
}
161-
stepCompleted = CONNECT_TYPE_HIERARCHY2;
162155
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
163156
ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.BUILDING_FIELDS_AND_METHODS,
164157
units[i].compilationResult.fileName);
@@ -225,6 +218,17 @@ public void completeTypeBindings() {
225218

226219
doPendingWeaves();
227220

221+
// TODO:
222+
// Is it correct to put the call to CompilationUnitScope.connectTypeHierarchy2() here,
223+
// or should it occur earlier?
224+
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
225+
ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.CONNECTING_TYPE_HIERARCHY2,
226+
units[i].compilationResult.fileName);
227+
units[i].scope.connectTypeHierarchy2();
228+
CompilationAndWeavingContext.leavingPhase(tok);
229+
}
230+
stepCompleted = CONNECT_TYPE_HIERARCHY2;
231+
228232
// We now have some list of types to process, and we are about to apply
229233
// the type mungers.
230234
// There can be situations where the order of types passed to the
@@ -300,11 +304,12 @@ public void completeTypeBindings() {
300304
}
301305
}
302306

307+
stepCompleted = BUILD_FIELDS_AND_METHODS;
308+
303309
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
304310
units[i] = null; // release unnecessary reference to the parsed unit
305311
}
306312

307-
stepCompleted = BUILD_FIELDS_AND_METHODS;
308313
lastCompletedUnitIndex = lastUnitIndex;
309314
AsmManager.setCompletingTypeBindings(false);
310315
factory.getWorld().getCrosscuttingMembersSet().verify();

0 commit comments

Comments
 (0)