The problem has been discovered by Maurizio Cimadamore.
Problem description:
The problem is that some tests fail with an 'impossible' assertion error; that is, an assertion of the kind:
Assert.check(ht.het(key) == o); //this method throws an AssertionError if the condition passed as argument is false
*) failure only occurs on certain test runs (i.e. 1 out of 10 runs)
*) failing test always occurs after an 'heavy' test has been ran
*) after some digging, some information has been printed out about the objects being tested - here's the debug statements added:
o2 = com.sun.tools.javac.file.JavacFileManager@60c22955
hash(o1) = com.sun.tools.javac.file.JavacFileManager@60c22955
hash(o2) = com.sun.tools.javac.file.JavacFileManager@60c22955
(o1 == o2) = true
the two objects are indeed identical, note that this output is printed on an handler of the assertion error issued on the above statement.
Adding the debug statements was not an easy task, as soon the code was modified (i.e. by printing the objects involved in the tests) the problem disappeared. Running langtools tests with -Xint also makes the problem disappear, while it seems that the problem occur with both -client and -server options.
Given that there's no concurrency going on (that could explain differences in the value of ht.get(key) before/after the assertion), our understanding is that this is a VM bug. What do you think?
-----------------------------------------------------------------------------------------------------------------------------------------------
How to reproduce it:
The error is hard to reproduce:
There is a testing environment at: /net/t4.ie.oracle.com/export/home/langtools/repos/langtoolsMaurizio.
the following script should be executed from the given folder:
../../hgsanitycheck_multi.sh test/tools/javac/defaultMethods
The bug is very rare now that is why the script execute the tests in the given folder 20 times.
The stacktrace of the error is:
java.lang.AssertionError
at com.sun.tools.javac.util.Assert.error(Assert.java:126)
at com.sun.tools.javac.util.Assert.check(Assert.java:45)
at com.sun.tools.javac.util.Context.get(Context.java:153)
at com.sun.tools.javac.util.Context.get(Context.java:193)
at com.sun.tools.javac.main.JavaCompiler.<init>(JavaCompiler.java:336)
at com.sun.tools.javac.main.JavaCompiler.instance(JavaCompiler.java:91)
at com.sun.tools.javac.main.Main.compile(Main.java:470)
at com.sun.tools.javac.main.Main.compile(Main.java:365)
at com.sun.tools.javac.main.Main.compile(Main.java:354)
at com.sun.tools.javac.main.Main.compile(Main.java:345)
at com.sun.tools.javac.Main.compile(Main.java:94)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:477)
at com.sun.javatest.regtest.RegressionCompileCommand.run(RegressionCompileCommand.java:247)
at com.sun.javatest.regtest.CompileAction.runCompile(CompileAction.java:556)
at com.sun.javatest.regtest.CompileAction.runSameJVM(CompileAction.java:395)
at com.sun.javatest.regtest.CompileAction.run(CompileAction.java:250)
at com.sun.javatest.regtest.RegressionScript.run(RegressionScript.java:146)
at com.sun.javatest.Script.run(Script.java:228)
at com.sun.javatest.DefaultTestRunner.runTest(DefaultTestRunner.java:174)
at com.sun.javatest.DefaultTestRunner.access$100(DefaultTestRunner.java:43)
at com.sun.javatest.DefaultTestRunner$1.run(DefaultTestRunner.java:66)
result: Error. compiler crashed (exit code 4)