JDK-8141331 : Test hotspot/compiler/oracle/MethodMatcher.java fails with NPE
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2015-11-03
  • Updated: 2020-09-01
  • Resolved: 2015-11-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b94Fixed
Related Reports
Relates :  
Description
#section:main
----------messages:(3/246)----------
command: main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
reason: User specified action: run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission 
elapsed time (seconds): 16.261
----------System.out:(0/0)----------
----------System.err:(15/781)----------
java.lang.NullPointerException
	at java.util.Objects.requireNonNull(Objects.java:219)
	at java.nio.file.Files.copy(Files.java:3002)
	at ClassFileInstaller.main(ClassFileInstaller.java:52)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:520)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:92)
	at java.lang.Thread.run(Thread.java:747)

JavaTest Message: Test threw exception: java.lang.NullPointerException
JavaTest Message: shutting down test

STATUS:Failed.`main' threw exception: java.lang.NullPointerException
Comments
I looked at some nightly logs both for failing cases and passing. Sometimes GetMethodOptionTest.java is run before and sometimes after, although I don't know how accurate the logs are w.r.t. the order tests are run in, since jtreg is run with -conc:32. It is odd that this test was consistently passing, so was consistently being saved by another test running before it and triggering the compilation of WhiteBox.java, and suddenly with the latest nightly it is consistently failing. My changes JDK-8140189 possibly are the cause, although I still don't see how. It did result in WhiteBox.class no longer being placed incorrectly in test/lib of the current directory, but is now in the JTwork directory. It is still shared between tests, so if it was compiled by a previous test, then this failing test should see it.
03-11-2015

According to the log ClassFileInstaller fails to found these classes: WhiteBox and/or Asserts. These classes should be built explicitly before the ClassFileInstaller is executed. I think adding @build is a good solution for this
03-11-2015

I seems that other test prepare things for MethodMatcherTest.java and MethodMatcherTest.java was executed successfully. For example, I ran MethodMatcherTest.java in empty folder and got NPE exception. Then I ran compiler/oracle/GetMethodOptionTest.java. It successfully executed. I leave JTwork and JTreport from GetMethodOptionTest.java run. And just after that I ran MethodMatcherTest.java and it also was successfully executed! It seems that previously MethodMatcherTest.java was executed after other tests which can prepare classes for it. But now it ran before and this shows that test have missed build step.
03-11-2015

Ok, I just tried it myself. The @library change does not seem to make a difference. It fails both with and without this change. So why is this suddenly showing up in the nightly?
03-11-2015

Any idea why adding the @build fixes the problem? My changes for JDK-8140189 impact how WhiteBox.java is found. I changed this test with the following: * @library /testlibrary /../../test/lib became * @library /testlibrary /test/lib Does reverting this change also fix the problem?
03-11-2015

RULE "compiler/oracle/MethodMatcherTest.java" Exception java.lang.NullPointerException
03-11-2015

Adding the following rule to the MethodMatcher.java file seems to fix the issue: @build sun.hotspot.WhiteBox jdk.test.lib.Asserts MethodMatcherTest
03-11-2015