jmx-dev JDK-7120365 DiffHBTest.java fails due to ConcurrentModificationException
Stuart Marks
stuart.marks at oracle.com
Thu Dec 27 10:19:10 PST 2012
I hate to contradict Alan on this....
It's true that one can omit the @run tag and single-file tests like this one
will get built and run by default. My advice, however, is to use the @run tag
even when one isn't strictly required. The reason has to do with jtreg's rules
of when it decides to behave as if an @run tag were present, and perhaps more
pertinently, when it does NOT.
Here's an example. Suppose we have a test that has these tags in a file named
MyTest.java:
@test
@bug 1234567
@summary My simple test.
@author Fred
Since there are no @run tags, jtreg will implicitly act as if "@run main
MyTest" were present. OK so far.
Now suppose we modify the test to use a helper class of some sort. We'd need to
add an @build tag to ensure this class is built:
@test
@bug 1234567
@summary My simple test.
@author Fred
@build Helper
The problem here is that "@build Helper" is an abbreviation for "@run build
Helper". Since there is now an @run tag present, the implicit "@run main
MyTest" behavior no longer occurs, so the test doesn't actually get run! Worse,
if you ask jtreg to run the test, it will happily build the Helper and MyTest
classes and declare that the test has passed, without actually having run
anything!! You have to inspect the test output fairly carefully in order to
discover this.
This kind of problem is hard to spot. In the JDK regression suite, we've had
tests in this state for long periods of time where they would "pass" regularly
but nobody noticed that the test wasn't actually running.
So, I'd suggest that you add a @run tag anyway if you get a chance before you
push the changeset.
s'marks
On 12/27/12 3:33 AM, shanliang wrote:
> Thanks for all comments, here is the new webrev:
> http://cr.openjdk.java.net/~sjiang/JDK-7120365/webrev.03/
>
> Indeed, no need to have @run for the test.
>
> Shanliang
>
> Alan Bateman wrote:
>> You can probably remove the
>> @run as the defaults (compile + run) is right for this test.
>>
>> -Alan
>
More information about the serviceability-dev
mailing list