United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7194612 api/java_lang/invoke/MethodHandles/Lookup/index.html#ExceptionsTests[findVirtualNSME] fails w/ -esa
JDK-7194612 : api/java_lang/invoke/MethodHandles/Lookup/index.html#ExceptionsTests[findVirtualNSME] fails w/ -esa

Details
Type:
Bug
Submit Date:
2012-08-28
Status:
Closed
Updated Date:
2014-02-10
Project Name:
JDK
Resolved Date:
2012-08-28
Component:
core-libs
OS:
generic
Sub-Component:
java.lang.invoke
CPU:
generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
8
Fixed Versions:

Related Reports
Backport:
Backport:
Backport:
Duplicate:
Duplicate:
Relates:

Sub Tasks

Description
The following JCK8-b12 testcase:
  api/java_lang/invoke/MethodHandles/Lookup/index.html#ExceptionsTests[findVirtualNSME]
fails under JDK8-b52 when '-esa' option is specified:
--- cut ---
Expected exception java.lang.NoSuchMethodException was not thrown by testcase "findVirtualNSME"
"java.lang.AssertionError" was thrown instead
java.lang.AssertionError
	at java.lang.invoke.MemberName.referenceKindIsConsistent(MemberName.java:233)
	at java.lang.invoke.MemberName.setFlags(MemberName.java:312)
	at java.lang.invoke.MemberName.init(MemberName.java:455)
	at java.lang.invoke.MemberName.<init>(MemberName.java:635)
	at java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:1031)
	at java.lang.invoke.MethodHandles$Lookup.findVirtual(MethodHandles.java:652)
	at javasoft.sqe.tests.api.java.lang.invoke.MethodHandles.Lookup.ExceptionsTests.findVirtualNSME(ExceptionsTests.java:564)
	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:474)
	at com.sun.tck.lib.tgf.Util.invokeMethod(Util.java:352)
	at com.sun.tck.lib.tgf.Runner.invokeTestCase(Runner.java:276)
	at com.sun.tck.lib.tgf.Runner.performRunWithData(Runner.java:246)
	at com.sun.tck.lib.tgf.Runner.getDataAndRun(Runner.java:185)
	at com.sun.tck.lib.tgf.Runner.executeTestMethods(Runner.java:130)
	at com.sun.tck.lib.tgf.Runner.run(Runner.java:116)
	at com.sun.tck.lib.tgf.Runner.execute(Runner.java:108)
	at com.sun.tck.lib.tgf.TGFTest.run(TGFTest.java:58)
	at com.sun.tck.lib.tgf.TGFTest.run(TGFTest.java:64)
	at javasoft.sqe.tests.api.java.lang.invoke.MethodHandles.Lookup.ExceptionsTests.main(ExceptionsTests.java:59)
Testcase "findVirtualNSME" failed with arguments [class javasoft.sqe.tests.api.java.lang.invoke.MethodHandles.Lookup.TestCls, <init>, ()int]
--- cut ---

The failure is not reproducible without '-esa' option.

                                    

Comments
EVALUATION

The assert checks for a valid reference kind before method resolution throws the expected NoSuchMethodException.
                                     
2012-08-28
SUGGESTED FIX

diff --git a/src/share/classes/java/lang/invoke/MemberName.java b/src/share/classes/java/lang/invoke/MemberName.java
--- a/src/share/classes/java/lang/invoke/MemberName.java
+++ b/src/share/classes/java/lang/invoke/MemberName.java
@@ -306,12 +306,6 @@
         return this;
     }
 
-    private void setFlags(int flags) {
-        this.flags = flags;
-        assert(testAnyFlags(ALL_KINDS));
-        assert(referenceKindIsConsistent());
-    }
-
     private boolean testFlags(int mask, int value) {
         return (flags & mask) == value;
     }
@@ -452,8 +446,10 @@
         this.clazz = defClass;
         this.name = name;
         this.type = type;
-        setFlags(flags);
+        this.flags = flags;
+        assert(testAnyFlags(ALL_KINDS));
         assert(this.resolution == null);  // nobody should have touched this yet
+        //assert(referenceKindIsConsistent());  // do this after resolution
     }
 
     private void expandFromVM() {
                                     
2012-08-28
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-comp/jdk/rev/a43f1cd05776
                                     
2012-08-28
This fix already in promotion build. Verified with jdk8/b125 promotion build by jck tests api/java_lang/invoke/MethodHandles/Lookup/index_ExceptionsTests in description.

                                     
2014-01-23



Hardware and Software, Engineered to Work Together