modulepath and classpath mixture

Alan Bateman Alan.Bateman at oracle.com
Fri Mar 18 08:29:40 UTC 2016



On 18/03/2016 07:56, Robert Scholte wrote:
>
> I can do the former with QDox, for the latter I had JDK APIs in mind, 
> but if ASM is an option too, that's an interesting option. Need to 
> figure out how to do that.
It should only be a few lines with ASM. If you have an input stream to 
the module-info.class then ASM's ClassReader will give you the class 
name in internal form and so easy to get the module name, this should do it:

ClassReader reader = new ClassReader(in);
String className = reader.getClassName();
int index = className.indexOf("/module-info");
if (index >= 1) {
     String moduleName = className.substring(0, index).replace('/', '.');
}

Using the APIs will work too but if Maven is running on JDK 8 or older 
then it won't be able to make use of the new Java SE 9 APIs.

-Alan.



More information about the jigsaw-dev mailing list