I'm wondering if we could improve the information provided in the exception message. I don't think end users should have to turn on debug flags in all scenarios if the information could easily be inserted into the exception message.

e.g. src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java


                           if (JlinkTask.DEBUG) {
+ System.err.println("IOException while reading resource: " + res.path());
                               ex.printStackTrace();
                           }
                           throw new PluginException(ex);

Why not move this new message to the non-debug code ?

+ throw new PluginException("IOException while reading resource: " + res.path(), ex);

On the other hand, some messages might be deemed too verbose for exception message inclusion. Do end users mind how large an exception message is ?

e.g src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PluginRepository.java + System.err.println("Plugin " + plugin.getName() + " threw exception with config: " + config);

Including the config Map in an exception message might be deemed overkill for above.

Regards,
Sean.

On 09/11/16 03:43, Sundararajan Athijegannathan wrote:
Mandy,

The exceptions caught are propagated to caller - JlinkTask - which does
print getMessage from exception and exits.  So, if a plugin throws
illegal argument exception from "configure", jlink will print message
and exit - as expected.

Catching PluginException (and IllegalArgumentException in the case of
configure) at precise location is a debugging aid. Plugin name, actual
arguments map passed are dumped in addition to stack trace - only if
system property is defined.

-Sundar


On 11/9/2016 2:12 AM, Mandy Chung wrote:
Sundar,

Have you considered for plugins to throw different type of exceptions to 
differentiate if jlink should gracefully exit with no stack trace.  For example 
if it’s an user-error e.g. invalid option or duplicated entries then jlink can 
simply print the error message.

For unexpected error such as IOException, the stack trace would be useful for 
troubleshooting.

Mandy

On Nov 8, 2016, at 7:51 AM, Claes Redestad <claes.redes...@oracle.com> wrote:
Hi,

I think this looks good as-is, but:

Many times I've had the need to enable this kind of logging when
building the JDK (as jlink plugins are now essential to creating the
standard images), and having to hack the makefiles to add
-J-Djlink.debug=true(?) to the right place seems a bit awkward.

Should we simply make this added verbosity the default in the build?

Thanks!

/Claes

On 2016-11-08 16:08, Sundararajan Athijegannathan wrote:
Please review for http://cr.openjdk.java.net/~sundar/8160359/webrev.00/
for https://bugs.openjdk.java.net/browse/JDK-8160359

Thanks,

-Sundar


Reply via email to