[modules-dev] Initial repository management tool

Rémi Forax forax at univ-mlv.fr
Sat Jul 14 02:01:37 PDT 2007


Andreas Sterbenz a écrit :
> Dave Bristor wrote:
>   
>>>  . the Boolean.getBoolean() code in the comments can fail if there is 
>>> a security manager
>>>       
>> Hmm, I had the security manager at one point, anyway it's back now: thanks.
>>     
>
> Right. It would only fail if there is unprivileged code on the stack, i.e. 
> not when started from the command line but potentially in the future 
> when/if we support invocation via something like the JSR 199 Tools API.
>
>   
>>>  . commands and JRepo constructor: it would seem clearer to me if the 
>>> code to initialize the static 'commands' Map was in a static 
>>> initializer rather than under a check in the constructor
>>>       
>> Since Command is not static, a "this" is required for their 
>> construction, so they can't be done statically.  Command is not static 
>> because it makes use of ToolBase.usageError, etc.  Perhaps it would be 
>> better to have "ToolHelper" (name?), and have JRepo create an instance 
>> of it.  It's not much of a class and is only valuable *if* we convert 
>> Jam.java to also use it.  What do you think?  I'm starting to tend that 
>> way...
>>     
>
> I see. I don't have any clever suggestions right now. We can figure that 
> out later.
>   
if commands are static, you could declare Command as an interface
and all the commands in an enum that implements this interface
and "inject" the ToolHelper (or JRepo) as a parameter of the usage method.

interface Command {
  void usage(ToolHelper helper);
}

enum JRepoCommand implements Command {
  public usage(ToolHelper helper) {
    ...
 }
}
...
> Andreas.
>
> _______________________________________________
> modules-dev mailing list
> modules-dev at openjdk.java.net
> http://mail.openjdk.java.net/mailman/listinfo/modules-dev
>   
Rémi



More information about the modules-dev mailing list