RFR(S): 8195731: [Graal] runtime/SharedArchiveFile/serviceability/transformRelatedClasses/TransformSuperSubTwoPckgs.java intermittently fails with Graal JIT
David Holmes
david.holmes at oracle.com
Fri Feb 2 09:15:03 UTC 2018
On 2/02/2018 6:41 PM, Tobias Hartmann wrote:
> Hi Vladimir and Serguei,
>
> thanks for looking at this!
>
>> On 2/1/18 11:55, Vladimir Kozlov wrote:
>>> I thought we should not use System.exit() and throw some Error or RuntimeException instead. I remember Igor I. did
>>> some changes but I forgot which tests.
>
> I think Igor just removed System.exit in the case where the test *passes*. I think it should be fine to bail out with
> System.exit(1) in the *failing* case.
>
> @Igor: What's the reason to avoid System.exit?
http://openjdk.java.net/jtreg/faq.html#question2.6
2.6. Should a test call the System.exit method?
No. Depending on how you run the tests, you may get a security exception
from the harness.
---
Plus if you call System.exit you have to run in othervm mode.
So generally we avoid System.exit and just fail by throwing an exception
from "main" (or whatever the test entry point is, depending on which
framework it uses - like testng). There are exceptions of course (pardon
the pun) and a lot of legacy tests use System.exit(97) or
System.exit(95) to indicate success or failure.
> The problem is that throwing an exception in ClassFileTransformer::transform() is silently ignored:
> "If the transformer throws an exception (which it doesn't catch), subsequent transformers will still be called and the
> load, redefine or retransform will still be attempted. Thus, throwing an exception has the same effect as returning
> null." [1]
>
> As a result, the test fails without any information. I've basically copied this code from
> runtime/RedefineTests/RedefineAnnotations.java [2] were we use System.exit as well. If there's a reason to avoid
> System.exit here, we can also just print an error and fail later with the generic exception:
> "java.lang.RuntimeException: 'parent-transform-check: this-has-been--transformed' missing from stdout/stderr"
This does sounds like a case where you need System.exit to force
immediate termination.
David
-----
> http://cr.openjdk.java.net/~thartmann/8195731/webrev.01/
>
> Thanks,
> Tobias
>
> [1] https://docs.oracle.com/javase/8/docs/api/java/lang/instrument/ClassFileTransformer.html
> [2]
> http://hg.openjdk.java.net/jdk/hs/file/e50e326a2bfc/test/hotspot/jtreg/runtime/RedefineTests/RedefineAnnotations.java#l145
>
More information about the hotspot-dev
mailing list