javac issues with proposed API
Jonathan Gibbons
Jonathan.Gibbons at Sun.COM
Thu Feb 12 16:28:55 PST 2009
Mark,
I am uncovering issues with the proposed new API as it pertains to javac.
Some of this we sensed before, but we can start to be more specific.
1. ModuleInfo
ModuleInfo extends java.lang.reflect.AnnotatedElement. While this is
acceptable for runtime access, it is not acceptable for javac. Rightly
or wrongly, annotations potentially involve Class<?> items, and javac
does not want to load any classes into any class loader in order to access
a ModuleInfo which might have such an annotation. This is why the
JSR 269 API mirrors rather than reuses the java.lang.reflect hierarchy.
2. ModuleLibrary.findModule
This is commented as "for javac", but javac is going to need something
more. The method seems to assume that the module library has complete
knowledge of the available modules, which may not be true if some
module-info files are being provided on the command line. This is where
we need the beginning of the "module info graph" we have talked about
on and off.
Either we need to be able to query the module library to get candidate
module-info files for any given module name, so that we can build the
module info graph externally to the library, or we will need to pass in to
the module library information about modules being compiled so that the
library can take it into account as part of the findModule call. In effect,
this latter case corresponds to reifying the module info graph inside the
module library implementation.
In either case, javac will have to communicate with the module library
using some sort of module info, which ties this issue to the earlier issue
about ModuleInfo.
As a general observation, you could draw an analogy with the need for
the JigsawModuleClassLoader.defineClass(Module , ...) method. That is
the means by which the runtime becomes aware of new modules in the
system, such that ModuleLibrary.findModule can give the correct response.
There is currently no such equivalent call for the compiler to use.
I'll see what it takes to come up with a module info graph API that
addresses
these concerns.
-- Jon
More information about the jigsaw-dev
mailing list