Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 508889 - [9] Support Module attribute in Disassembler
Summary: [9] Support Module attribute in Disassembler
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.7   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 4.8 M5   Edit
Assignee: Manoj N Palat CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 519558
Blocks: 457413
  Show dependency tree
 
Reported: 2016-12-08 05:25 EST by Sasikanth Bharadwaj CLA
Modified: 2018-02-20 01:38 EST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sasikanth Bharadwaj CLA 2016-12-08 05:25:42 EST
We need to support the module attribute in Disassembler as well.
I started work on this sometime ago, mainly to add testcases for code gen, but stopped midway. It might be a good idea to wait for JVM specification before we add this support anyway
Comment 1 Markus Keller CLA 2016-12-08 08:13:44 EST
(In reply to Sasikanth Bharadwaj from comment #0)
> It might be a good idea to wait for JVM specification
> before we add this support anyway

http://cr.openjdk.java.net/~mr/jigsaw/spec/lang-vm.html#jigsaw-2.2 looks pretty complete to me (version from 2016/10/28). Would you need anything else from the VM spec?
Comment 2 Jay Arthanareeswaran CLA 2016-12-08 09:07:39 EST
(In reply to Markus Keller from comment #1)
> (In reply to Sasikanth Bharadwaj from comment #0)
> > It might be a good idea to wait for JVM specification
> > before we add this support anyway
> 
> http://cr.openjdk.java.net/~mr/jigsaw/spec/lang-vm.html#jigsaw-2.2 looks
> pretty complete to me (version from 2016/10/28). Would you need anything
> else from the VM spec?

Nope, we do have the details we need. But considering that there have been changes in this area as recently as last month, unless someone really wants this, we will keep it in the back burner.
Comment 3 Olivier Thomann CLA 2016-12-08 10:22:43 EST
Jay, I can take a look at this if you want. Let me know what the ETA is.
Comment 4 Eclipse Genie CLA 2017-06-29 05:25:52 EDT
New Gerrit change created: https://git.eclipse.org/r/100333
Comment 5 Stephan Herrmann CLA 2017-07-01 11:02:37 EDT
JVMS 4.7.25 now contains what we need here.

IMHO, having these tests is now a high priority: I just noted what looks like a bug in javap (vs. all of JVMS, javac, ecj):
JVMS: 
 module_name_index
  The value of the module_name_index item must be a valid index into the
  constant_pool table. The constant_pool entry at that index must be a
  CONSTANT_Module_info structure denoting the current module.
ecj:
  int moduleNameIndex =
			this.constantPool.literalIndexForModule(binding.moduleName);

With this, javap barfs:
  Error: invalid index #6

If I change the above in ecj to
  int moduleNameIndex =
			this.constantPool.literalIndex(binding.moduleName);

then javap is happy.

In fact javap even rejects the output of javac regarding any module-info.


In order to test things like this on our side, disassembler support is key. Since javap cannot be relied upon, our own disassembler should stand in.
Comment 6 Stephan Herrmann CLA 2017-07-01 11:10:36 EDT
(In reply to Stephan Herrmann from comment #5)
> With this, javap barfs:
>   Error: invalid index #6
> 
> In fact javap even rejects the output of javac regarding any module-info.

http://mail.openjdk.java.net/pipermail/jigsaw-dev/2017-July/013034.html
Comment 7 Stephan Herrmann CLA 2017-07-01 13:13:36 EDT
(In reply to Stephan Herrmann from comment #6)
> (In reply to Stephan Herrmann from comment #5)
> > With this, javap barfs:
> >   Error: invalid index #6
> > 
> > In fact javap even rejects the output of javac regarding any module-info.
> 
> http://mail.openjdk.java.net/pipermail/jigsaw-dev/2017-July/013034.html

That was a red herring.
Comment 8 Markus Keller CLA 2017-07-05 13:44:07 EDT
The current Gerrit implements the first few entries in the Module attribute. It has only been tested manually, by opening a module-info.class file without source attachment.

I'm confident that the implemented structure and the new APIs are right. The remaining gaps are marked with TODO comments in ModuleAttribute, IModuleAttribute, ClassFileReader, and Disassembler.
Comment 9 Manoj N Palat CLA 2017-07-11 22:55:58 EDT
(In reply to Markus Keller from comment #8)
> The current Gerrit implements the first few entries in the Module attribute.
> It has only been tested manually, by opening a module-info.class file
> without source attachment.
> 
> I'm confident that the implemented structure and the new APIs are right. The
> remaining gaps are marked with TODO comments in ModuleAttribute,
> IModuleAttribute, ClassFileReader, and Disassembler.

@Markus: I will take a stab at this to take this work forward.
Comment 10 Markus Keller CLA 2017-07-13 10:36:55 EDT
Thanks Manoj. Feel free to make yourself the author of the Gerrit, or at least add an Also-by: in the footer.
Comment 11 Manoj N Palat CLA 2017-07-13 13:15:35 EDT
(In reply to Markus Keller from comment #10)
> Thanks Manoj. Feel free to make yourself the author of the Gerrit, or at
> least add an Also-by: in the footer.

Initial Idea was to submit it two parts - - wasn't aware of Also-by - would use this to make life simpler for combining both the parts and submit - thanks Markus!
Comment 12 Eclipse Genie CLA 2017-07-13 13:28:25 EDT
New Gerrit change created: https://git.eclipse.org/r/101206
Comment 13 Manoj N Palat CLA 2017-07-17 10:50:47 EDT
(In reply to Eclipse Genie from comment #12)
> New Gerrit change created: https://git.eclipse.org/r/101206

abandoned as this was duplicated. The patch updated via the link in comment 4
Comment 14 Manoj N Palat CLA 2017-07-18 05:04:31 EDT
(In reply to Eclipse Genie from comment #4)
> New Gerrit change created: https://git.eclipse.org/r/100333
(Eclipse genie didn't post the commit here probably due to some bugzilla server issue?)

Commit via http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA9&id=c1481bac406d75d14e6deeee7721d87f2f9b7275

unit tests pending [see bug 519558]
Comment 15 Stephan Herrmann CLA 2017-10-07 06:38:14 EDT
How about additional attributes from bug 516377?
Comment 16 Manoj N Palat CLA 2017-10-09 00:16:41 EDT
(In reply to Stephan Herrmann from comment #15)
> How about additional attributes from bug 516377?

Assuming you mean MODULE_MAIN_CLASS and MODULE_PACKAGES, these are already implemented ( Disassembler:1150 neighbourhood)
Comment 17 Stephan Herrmann CLA 2017-10-09 16:43:17 EDT
(In reply to Manoj Palat from comment #16)
> (In reply to Stephan Herrmann from comment #15)
> > How about additional attributes from bug 516377?
> 
> Assuming you mean MODULE_MAIN_CLASS and MODULE_PACKAGES, these are already
> implemented ( Disassembler:1150 neighbourhood)

Yep, that's what I meant. Cool it's already supported :)
Comment 18 Eclipse Genie CLA 2018-01-08 21:11:37 EST
New Gerrit change created: https://git.eclipse.org/r/115079
Comment 20 Eclipse Genie CLA 2018-01-16 22:37:43 EST
New Gerrit change created: https://git.eclipse.org/r/115497
Comment 21 Eclipse Genie CLA 2018-01-17 02:11:25 EST
Gerrit change https://git.eclipse.org/r/115497 was merged to [R4_7_maintenance].
Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=6c73d1a0910c9a1dc57b95c515fe65f08e4f8f42
Comment 22 Sasikanth Bharadwaj CLA 2018-01-24 04:14:32 EST
Verified for 4.8 M5 using I20180123-2000 build
Comment 23 Sasikanth Bharadwaj CLA 2018-02-20 01:38:14 EST
Verified for 4.7.3 using M20180215-0545