JDK-8170120 jimage IOException solution?
Michal Vala
mvala at redhat.com
Fri Feb 16 13:35:22 UTC 2018
On 02/16/2018 02:17 PM, Alan Bateman wrote:
> On 16/02/2018 13:03, Michal Vala wrote:
>> Hi,
>>
>> I'm working on JDK-8170120[1]. I have 2 working solutions, but I'm not happy
>> with neither one.
>>
>> That IOException is thrown from jdk.internal.jimage.BasicImageReader, which is
>> in java.base module. Jimage is implemented in jdk.jlink module
>> (jdk.tools.jimage.JImageTask).
>>
>> One solution is new exception NotValidJimageException which can be thrown from
>> BasicImageReader and catch and handled at JImageTask. Then it's easy to return
>> proper error message to the output.
>> Issue is that this new exception has to be public in java.base so de-facto
>> defining new jdk core api, which of course I don't want to.
>>
>> Next option is leave there IOException, but give it some known message and
>> then handle this message in JImageTask.
>> This work also well, but "parsing" some message from exception is a bit clumsy.
> Why can't you just catch the IOException and adds the exception message to the
> error message that jimage prints?
Sure I can do that. However, all output messages are defined at
jimage.properties (jdk.jlink module) file and this won't be possible for this
case. I can't tell whether IOExcaption is caused by wrong jimage file or
something else so all I can do is really just print an exception message. It
also affects behavior of other cases that throws IOException (not sure if bad or
not) that are now catch with Exception and return EXIT_ABNORMAL error code.
So it sounds like another 'wrong' solution to me. Question is what solution is
least wrong and what is desired behavior. I wanted to fix that one specific case
with minimal side-effects.
--
Michal Vala
OpenJDK QE
Red Hat Czech
More information about the jigsaw-dev
mailing list