creating module ids

Jonathan Gibbons Jonathan.Gibbons at Sun.COM
Tue Nov 10 11:09:29 PST 2009


Mark Reinhold wrote:
>> Date: Tue, 10 Nov 2009 10:46:20 -0800
>> From: jonathan.gibbons at sun.com
>>     
>
>   
>> Is there any reason not to make the constructors accessible --
>> e.g. ModuleId(String name, Version version) ?
>> Having to go through parse methods all the time to create objects is, well,
>> tedious.
>>     
>
> Versions are module-system-specific, so you have to consult a
> ModuleSystem object to parse a version anyway.  Given that,
>
>     ModuleSystem.base().parseModuleId(n, v)
>
> seems to me to be less tedious than
>
>     new ModuleId(name, ModuleSystem.base().parseVersion(v))
>
> (or s/ModuleSystem.base()/JigsawModuleSystem.instance()/ if
> you like).
>
>   
>> Date: Tue, 10 Nov 2009 10:55:33 -0800
>> From: jonathan.gibbons at sun.com
>>     
>
>   
>> Brian Pontarelli wrote:
>>     
>>> Constructors bad. Factories better.
>>>       
>> Factories ok; parsing from strings every time: bad.
>>     
>
> Ah, I didn't realize that was your use case -- you already
> have a Version object.  So how about
>
>     ModuleId.create(String name, Version version) ?
>
> - Mark
>   


That last suggestion would seem to be most excellent, with a 
corresponding one for ModuleIdQuery.  

That being said, I can cope with the available APIs so far, and I am 
still rattling around somewhat trying to find the best way to create the 
necessary data structures inside javac, with a view to handling all the 
potential errors.

-- Jon



More information about the jigsaw-dev mailing list