Initial RFR for JDK-8134413: Devise alternate scheme for initializing javac context classes
Andreas Lundblad
andreas.lundblad at oracle.com
Thu Sep 29 18:18:50 UTC 2016
This is a request for an initial informal review of the work on JDK-8134413. A formal RFR with a proper webrev will be sent out at a later stage.
A brief background for those of you who haven't followed my work so far...
A summary of todays situation:
- The Context is a simple Map.
- Initialization is done lazily through static instance(Context c) or preRegister(Context c) methods.
- This approach relies on leaking uninitialized 'this' references at the top of every component constructor.
- It's practically impossible to figure out in which order components are initialized by looking at the code.
- Introducing new dependencies or tweaking the initialization order requires use of aspirin.
Maurizio outlines a solution to this in the bug report [1]. I encourage you read it. A summary follows:
- The proposal suggests we initialize all components up front in the Context constructor.
- There are "hard dependencies" and "soft dependencies" among components.
- If, for instance, the *initialization* of Enter requires TreeMaker to be initialized, we call it a hard dependency. (It imposes an initialization order constraint.)
- If the *use* of Enter requires TreeMaker to be initialized, we call it a soft dependency.
- The graph of hard dependencies has no cycles so the suggested approach works well.
- The override-specific-components-mechanism (currently solved with preRegister) is instead solved by subclassing Context, and overriding the behavior for creating a specific component.
The current status of the work:
- The proposed solution has been implemented.
- A postInit hook mechanism has been introduced to pick up soft dependencies after initialization is complete (i.e. to resolve cycles).
- There are currently about 20 javac test failures and 4 javadoc failures. Some of them are due to the same issue though. Help here is most welcome.
- There's some work left to do for jshell.
There are a few inline comments on the format "// [context-init] ..." with some question marks. Feel free to grep for those and help me out.
The work lives in the sandbox repo on the branch JDK-8134413-branch
Comments and feedback most welcome. I'm leaving Oracle October 9 so the sooner the better. After this date I will happily continue in discussions but it may be hard to find time to do much development.
best regards,
Andreas
[1] https://bugs.openjdk.java.net/browse/JDK-8134413
More information about the compiler-dev
mailing list