JDK-8144509 : java/lang/invoke/AccessControlTest.java starts failing on all platforms
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang.invoke
  • Affected Version: 9,9-repo-jigsaw
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2015-12-02
  • Updated: 2017-10-24
  • Resolved: 2017-10-24
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.
Other
tbd_majorResolved
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description
java/lang/invoke/AccessControlTest.java

This test starts failing on all platform in 2015-12-01 jigsaw nightly testing.

#section:testng
----------messages:(3/177)----------
command: testng test.java.lang.invoke.AccessControlTest
reason: User specified action: run testng/othervm test.java.lang.invoke.AccessControlTest 
elapsed time (seconds): 0.591
----------System.out:(51/3175)----------
[TestNG] Running:
  java/lang/invoke/AccessControlTest.java

loaders = [jdk.internal.misc.ClassLoaders$AppClassLoader@357246de, java.lang.invoke.MethodHandles$LookupHelper$1@27a497d5]
filled in 32 cases from 9 original cases in 3 rounds
Unnamed/public/loader#2 => AccessControlTest
fail findClass ex=java.lang.ClassNotFoundException: test.java.lang.invoke.AccessControlTest
test test.java.lang.invoke.AccessControlTest.test(): failure
java.lang.AssertionError: expected [false] but found [true]
	at org.testng.Assert.fail(Assert.java:94)
	at org.testng.Assert.failNotEquals(Assert.java:494)
	at org.testng.Assert.assertEquals(Assert.java:123)
	at org.testng.Assert.assertEquals(Assert.java:286)
	at org.testng.Assert.assertEquals(Assert.java:296)
	at test.java.lang.invoke.AccessControlTest.testOneAccess(AccessControlTest.java:447)
	at test.java.lang.invoke.AccessControlTest.test(AccessControlTest.java:399)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(java.base@9.0/Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(java.base@9.0/NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(java.base@9.0/DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(java.base@9.0/Method.java:531)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
	at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
	at org.testng.TestRunner.privateRun(TestRunner.java:767)
	at org.testng.TestRunner.run(TestRunner.java:617)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
	at org.testng.SuiteRunner.run(SuiteRunner.java:240)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
	at org.testng.TestNG.run(TestNG.java:1057)
	at com.sun.javatest.regtest.TestNGAction$TestNGRunner.main(TestNGAction.java:220)
	at com.sun.javatest.regtest.TestNGAction$TestNGRunner.main(TestNGAction.java:184)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(java.base@9.0/Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(java.base@9.0/NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(java.base@9.0/DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(java.base@9.0/Method.java:531)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:110)
	at java.lang.Thread.run(java.base@9.0/Thread.java:747)

===============================================
java/lang/invoke/AccessControlTest.java
Total tests run: 1, Failures: 1, Skips: 0
===============================================

----------System.err:(14/867)----------
java.lang.Exception: failures: 1
	at com.sun.javatest.regtest.TestNGAction$TestNGRunner.main(TestNGAction.java:223)
	at com.sun.javatest.regtest.TestNGAction$TestNGRunner.main(TestNGAction.java:184)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(java.base@9.0/Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(java.base@9.0/NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(java.base@9.0/DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(java.base@9.0/Method.java:531)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:110)
	at java.lang.Thread.run(java.base@9.0/Thread.java:747)

JavaTest Message: Test threw exception: java.lang.Exception: failures: 1
JavaTest Message: shutting down test

STATUS:Failed.`main' threw exception: java.lang.Exception: failures: 1
Comments
This test passes on JDK 9 and JDK 10. It's fixed in JDK-8173393 and later updated in the module system refresh ( JDK-8173393).
24-10-2017

Thanks Michael, I was wondering instead whether willAccess and willAccessClass could be changed to predict access without teleporting via the Lookup.in method. The reason is that teleporting from lookup class in a named module to any other module will drop all access and so makes it less useful in willXXX to predict whether access will succeed or not.
07-12-2015

I think the changes make sense. Suggestion: refactor the "loose module w/ public access" case like in the attached patch.
07-12-2015

I've updated AccessControlTest so that willAccessClass does the right visibility check when the lookup is the publicLookup as its defining loader is not the null loader in jake. I've also updated this method to predict access is allowed when the lookup has PUBLIC access and the target class is a public type in an unnamed module. So it's passing now in jake but I think we'll need to take a pass over the changes to make sure that we are okay with them. This will happen anyway once we do code review for the initial push to jake.
05-12-2015

It's likely due to this change: changeset: 14612:957e4e29ff28 user: mhaupt date: Fri Nov 20 15:34:12 2015 +0100 summary: 8139885: implement JEP 274: enhanced method handles It introduces new lookup API, and contains some changes to AccessControlTest that cover said API.
02-12-2015

The test changes for JEP 274 need updates to work in jake.
02-12-2015