United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 6939196 method handle signatures off the boot class path get linkage errors
6939196 : method handle signatures off the boot class path get linkage errors

Details
Type:
Bug
Submit Date:
2010-03-30
Status:
Resolved
Updated Date:
2012-03-22
Project Name:
JDK
Resolved Date:
2010-05-18
Component:
hotspot
OS:
generic
Sub-Component:
compiler
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:
hs19

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

Sub Tasks

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
                                     
2010-05-02
SUGGESTED FIX

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



Hardware and Software, Engineered to Work Together