ModuleClass

Alex Buckley Alex.Buckley at Sun.COM
Tue Mar 3 11:47:03 PST 2009


Being able to put flags in the main class attribute would probably be 
worthwhile if multiple main class attributes were allowed: "Main class M 
is flagged as an FX 1.1 app", "Main class N is flagged as a bundle 
activator and can be assumed to implement interface...".

However, I think for now one ModuleClass attribute is enough, pointing 
to a CONSTANT_Class_info, and without flags.

The ModuleClass attribute is defined as follows:

ModuleClass_attribute {
   u2 attribute_name_index;
   u4 attribute_length;
   u2 main_class;
}

attribute_name_index
     The value of the attribute_name_index item must be a valid index 
into the constant_pool table. The constant_pool entry at that index must 
be a CONSTANT_Utf8_info structure representing the string "ModuleClass".

attribute_length
     The value of the attribute_length item is the length of the 
attribute excluding the initial six bytes.

main_class
     The value of the main_class item must be a valid index into the 
constant_pool table. The constant_pool entry at that index must be a 
CONSTANT_Class_info structure representing the name of the class which 
the host system should treat as the entrypoint to the module.

Attached is an updated (+ tiny corrections) classfile spec.

Alex

Jonathan Gibbons wrote:
> Alex suggested adding it when I asked him for a spec of the ModuleClass
> attribute.  At the time, the thought was to be able to mark the type of 
> class,
> main class, applet etc.  A more topical example, from a separate email
> thread going on now, would be to be able to mark a JavaFX class.
> [Kumar is working on changes to the launcher to make it capable of
> starting FX programs, given an FX main class.] So the ability to give
> simple attributes regarding the class appears somewhat reasonable.
> 
> I guess the updated classfile spec got pre-empted by FOSDEM ;-)
> 
> -- Jon
> 
> 
> On Mar 3, 2009, at 9:21 AM, Mark Reinhold wrote:
> 
>>> Date: Tue, 03 Mar 2009 07:54:39 -0800
>>> From: jonathan.gibbons at sun.com
>>
>>> Point noted about the incorrect use of CONSTANT_Utf8 instead of
>>> CONSTANT_Class.  I'll check that out.
>>
>> Okay, thanks.
>>
>>>                                       Also, if I recall correctly,
>>> that item is followed by an array of Utf8 strings representing an open
>>> ended set of flags/modifiers, similar to that used for the requires
>>> entry. If nothing else, you might need to skip over them if there is
>>> any info to follow.
>>
>> Hmm, didn't know that, and neither does the ModuleInfoReader code.
>>
>> I don't recall having discussed the need for modifiers in the main-class
>> declaration.  Do we have use cases?
>>
>> - Mark
> 


More information about the jigsaw-dev mailing list