Re: Needing more info from ModuleInfo

Remi Forax <[email protected]> Wed, 20 Jul 2016 19:06:33 +0200 (CEST)
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <[email protected]>
----- Mail original -----
> De: [email protected]
> À: [email protected]
> Envoyé: Mercredi 20 Juillet 2016 17:50:45
> Objet: [asm] Needing more info from ModuleInfo
> 

Hi Paul,
first, be aware that the format of the module is still in flux,
the last draft of the VM spec [2], is not the one implemented by the alpha of ASM 6,
mostly because the spec is still in flux and i hope will change soon, again.

Currently, ASM 6 follows the implementation of the JDK 9 repository.
The proposed changes are implemented in another repository (under the name jigsaw/jake) but these changes have not been validated by the expert group.
When the changes will be validated and integrated in the main jdk9 repository, the ASM team will surely publish a new alpha (or a beta, we will see).
 
> I understand ASM is still alpha, but I have some questions on ModuleVisitor.
> Pertaining to the callback methods:
> 
> 1) How to get module name?

The module name is encoded as part of the class name,
by example for
  module foo.bar { }
the class name is "foo/bar/module-info" so if you skip the last part (module-info) and replace the "/" by ".", you can get the module name.

This is obviously this is not the best way to encode the name of the module, i've already raised that issue [1]


> 2) How to get module version?

The version is encoded as an attribute of the class, see [2].
It was not specified until recently. I suppose i will provide a way to get the version directly from the ModuleVisitor we things will be settled. 

If you want to know how to read an attribute with ASM, the best is to read the guide [3].
The JDK also uses ASM to read the module version, so you can take a look to the implementation [4].


> 3) How to get main class?

same as for the module version


> 4) How to get annotations?

The annotation are stored on the class.
See the ASM guide [3] on how to read an annotation.


regards,
Rémi

[1] http://openjdk.java.net/projects/jigsaw/spec/issues/#ClassFileModuleName
[2] http://cr.openjdk.java.net/~mr/jigsaw/spec/lang-vm.html
[3] http://download.forge.objectweb.org/asm/asm4-guide.pdf
[4] http://hg.openjdk.java.net/jdk9/jdk9/jdk/file/9446c534f022/src/java.base/share/classes/jdk/internal/module/ClassFileAttributes.java


-- 
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws