When it reaches the if (dryRun) case, it already loads the VM and main class 
successfully with no exception.  Hence it sets ret = 0.

If there is any exception thrown during the course, CHECK_EXCEPTION_LEAVE or 
CHECK_EXCEPTION_NULL_LEAVE macros reports the exception and exit with ret=1.


$ java -addmods abc --dry-run -cp hi.jar Hi
Error occurred during initialization of VM
java.lang.module.ResolutionException: Module abc not found
        at java.lang.module.Resolver.fail(java.base/Resolver.java:790)
        at java.lang.module.Resolver.resolveRequires(java.base/Resolver.java:94)
        at 
java.lang.module.Configuration.resolveRequiresAndUses(java.base/Configuration.java:370)
        at 
java.lang.module.ModuleDescriptor$1.resolveRequiresAndUses(java.base/ModuleDescriptor.java:1986)
        at 
jdk.internal.module.ModuleBootstrap.boot(java.base/ModuleBootstrap.java:263)
        at java.lang.System.initPhase2(java.base/System.java:1928)

$ echo $?
1


> On Jun 28, 2016, at 8:18 AM, Paul Benedict <pbened...@apache.org> wrote:
> 
> Mandy, if I am reading the diff correctly, it looks like you moved the error 
> exit code (1 = unhandled exception) inside the "else" block for a real run 
> only? I think if the dry run also throws an exception, you should set the 
> exit code to 1. If I read the diff wrong, my apologies :-) 
> 
> Cheers,
> Paul
> 
> On Mon, Jun 27, 2016 at 12:36 PM, Mandy Chung <mandy.ch...@oracle.com> wrote:
> -XshowSettings would probably be a good place to include the VM arguments.
> $ java -XshowSettings:vm -—dry-run
> 
> I file a JBS issue:
>   https://bugs.openjdk.java.net/browse/JDK-8160389
> 
> Mandy
> 
> 
> > On Jun 27, 2016, at 9:20 AM, Paul Benedict <pbened...@apache.org> wrote:
> >
> > Mandy, if I may recommend another suggestion, another "sanity" check could 
> > be dumping the command line arguments. I know quite a few bash programmers 
> > who would really love to see they passed their arguments correctly without 
> > executing their program. :-)
> >
> > Cheers,
> > Paul
> >
> > On Mon, Jun 27, 2016 at 10:48 AM, Raymond Gallardo 
> > <raymond.galla...@oracle.com> wrote:
> > Hi Mandy,
> >
> > Does this enhancement need to be doc'd? If so, could you add a subtask 
> > (component = docs)?
> >
> > Thanks,
> > --Raymond
> >
> > On 24/06/2016 9:49 AM, Mandy Chung wrote:
> > Webrev:
> >    http://cr.openjdk.java.net/~mchung/jdk9/webrevs/8159596/webrev.00/
> >
> > `java --dry-run` will create the VM, load the main, locate the static void 
> > main method, and exit (with 0) instead of executing the method.  As all 
> > module options are processed and the boot layer is created, this would be 
> > useful to sanity check the options and detect possible issues.
> >
> > Mandy
> >
> >
> >
> 
> 

Reply via email to