phase has not been overridden instance = new Phase(context); return instance; } protected Phase(Context context) { context.put(phaseKey, this); // other intitialization follows... } } }
In the compiler, we simply use Phase.instance(context) to get the reference to the phase. But in extensions of the compiler, we must register extensions of the phases to replace the base phase, and this must be done before any reference to the phase is accessed using Phase.instance(). An extended phase might be declared thus:
{@code}public class NewPhase extends Phase protected NewPhase(Context context) { super(context); } public static void preRegister(final Context context) { context.put(phaseKey, new Context.Factory() { public Phase make() { return new NewPhase(context); } }); } } }
And is registered early in the extended compiler like this
NewPhase.preRegister(context);
This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.