JDK-6939196 : method handle signatures off the boot class path get linkage errors
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 7
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2010-03-30
  • Updated: 2012-03-22
  • Resolved: 2010-05-18
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 6 JDK 7 Other
6u21pFixed 7Fixed hs19Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
The following test program throws an error on the marked line.  The problem is a weakness in the current JSR 292 Reference Implementation logic for resolving MethodTypes that mention types not on the boot class path.

The workaround, therefore, is to load your entire JSR 292 application using -Xbootclasspath/a:myapp.jar.

import java.dyn.*;
import static java.dyn.MethodHandles.*;
import static java.dyn.MethodType.*;

public class BCPBug {
    // Local class which appears in method signature;
    static class Example { }
    static void bcpTypesOnly(Object x) { System.out.println("bcpTypesOnly"); }
    static void hasUserType(Example x) { System.out.println("hasUserType"); }

    public static void main(String... av) throws Throwable {
        Lookup lookup = lookup();
        MethodHandle bcpTypesOnly = lookup.findStatic(lookup.lookupClass(), "bcpTypesOnly", methodType(void.class, Object.class));
        MethodHandle hasUserType  = lookup.findStatic(lookup.lookupClass(), "hasUserType",  methodType(void.class, Example.class));

        bcpTypesOnly.<void>invokeExact((Object)null);
        hasUserType.<void>invokeExact((Example)null); // throws NoClassDefFoundError on BCPBug$Example
    }
}

/* Run:
$ $JAVA7X_HOME/bin/javac -d . BCPBug.java
$ $JAVA7X_HOME/bin/java -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles -cp . BCPBug
bcpTypesOnly
Exception in thread "main" java.lang.NoClassDefFoundError: BCPBug$Example
	at BCPBug.main(BCPBug.java:17)
*/

Comments
EVALUATION http://hg.openjdk.java.net/jdk7/hotspot-comp/hotspot/rev/2ffde6cfe049
02-05-2010

SUGGESTED FIX http://hg.openjdk.java.net/mlvm/mlvm/hotspot/file/8c734933d83c/meth-bcp.patch
30-03-2010