The attached test highlights a problem with the optimising compiler and the JNI test-suite
The optimising compiler incorrectly assumes that Strings can not change across a native method call when a reference to the string is passed as an argument. This causes the following code from the JNI StringRegion test to fail:
static native int testStringCritical(String s);
String inputStr = "Live Free or Die";
ret = testStringCritical(inputStr); // testStringCritical changes the string pointed to by inputStr to "Free Java or Die"
checkTest(ret, inputStr.equals("Free Java or Die"), "StringCritical");
To recreate this error:
i) Apply the attached patch which defines a new test-run
ii) Run the new test run by ant -f test.xml -Dhost.name=<your_host_type_here> -Dtest-run.name=jniOptimisationError
The test-run will build a production version of the RVM and then run the JNI test suite twice. The first time it specifies -X:aos:initial_compiler=base and all tests complete correctly, the second time the production RVM is run with -X:aos:initial_compiler=opt and the StringRegion test will fail.
I guess some sort of guard or dependency needs to be added to the opt compiler but I'm not sure where exactly
It's worth pointing out that this error could have been caught by the nightly stress regression run but the specified extra.args (-X:aos:enable_recompilation=false -X:aos:initial_compiler=opt -X:irc:O1) in stress.properties are not being propagated through to the RVM at runtime. It's not clear to me if this is intentional or just an oversight (edit: the non-propagation of properties was not intentional and has been fixed (see RVM-1035))