JavaCompiler.desuar attempts to organize the order in which classes are
desugared, so that supertypes are desugared before subclasses. This is
needed because TransTypes destroys type information, and there is a
clear cut distinction in the compiler between classes that have already
gone through TransTypes and those which did not. The two sets cannot
easily be mixed, because all the type info (super types etc.) has been
erased. For instance the bridge generation logic expects that the
bridges have already been inserted in supertypes, etc.
While this is a pragmatic solution, the reality is that there are some
cases in which no valid ordering exists. This leads to either bridges
not being generated or bridges to be generated redundantly, depending on
the order you end up with. While mocking with compiler policies might
offer some relief (Liam went down this path), I believe it is time we
remove such dependencies from the compiler pipeline.
To do this, we first need to turn TransTypes in a more harmless visitor
that doesn't erase info stored in the AST. Srikanth already did some
work in this direction and I believe he has something working in Valhalla:
http://hg.openjdk.java.net/valhalla/valhalla9/langtools/rev/9204dd938160
So we need to port his patch to JDK 10, and see what other steps need to
be carried out to completely get rid of the linearization step. I would
expect that as a bonus point, we should be able to get rid or simplify
the CompileStates class.
desugared, so that supertypes are desugared before subclasses. This is
needed because TransTypes destroys type information, and there is a
clear cut distinction in the compiler between classes that have already
gone through TransTypes and those which did not. The two sets cannot
easily be mixed, because all the type info (super types etc.) has been
erased. For instance the bridge generation logic expects that the
bridges have already been inserted in supertypes, etc.
While this is a pragmatic solution, the reality is that there are some
cases in which no valid ordering exists. This leads to either bridges
not being generated or bridges to be generated redundantly, depending on
the order you end up with. While mocking with compiler policies might
offer some relief (Liam went down this path), I believe it is time we
remove such dependencies from the compiler pipeline.
To do this, we first need to turn TransTypes in a more harmless visitor
that doesn't erase info stored in the AST. Srikanth already did some
work in this direction and I believe he has something working in Valhalla:
http://hg.openjdk.java.net/valhalla/valhalla9/langtools/rev/9204dd938160
So we need to port his patch to JDK 10, and see what other steps need to
be carried out to completely get rid of the linearization step. I would
expect that as a bonus point, we should be able to get rid or simplify
the CompileStates class.