-
Bug
-
Resolution: Duplicate
-
P4
-
7
-
generic
-
generic
Please see the minimized test below to reproduce the failure:
Minimized test:
===============
$ cat Test.java
import java.dyn.*;
public class Test {
public static void meth() {
System.out.println("Invoked: public static void target()");
}
public static void catcher(Throwable e) {
System.out.println("Invoked: public static void catcher(Throwable e)");
}
public static void catcher(MyExc e) {
System.out.println("Invoked: public static void catcher(MyExc e)");
}
public static void main(String[] args) throws Throwable {
MethodHandle target = MethodHandles.lookup().findStatic(
Test.class, "meth", MethodType.methodType(void.class));
MethodHandle handler = MethodHandles.lookup().findStatic(
Test.class, "catcher", MethodType.methodType(
void.class, Throwable.class));
MethodHandle handler2 = MethodHandles.lookup().findStatic(
Test.class, "catcher", MethodType.methodType(
void.class, MyExc.class));
try {
MethodHandles.catchException(target, Throwable.class, handler);
System.out.println("OKAY");
} catch (Throwable e) {
System.out.println("FAILED. Unexpected exception thrown: " + e);
}
try {
MethodHandles.catchException(target, MyExc.class, handler2);
System.out.println("OKAY");
} catch (Throwable e) {
System.out.println("FAILED. Unexpected exception thrown: " + e);
}
}
}
$ cat MyExc.java
public class MyExc extends Throwable {}
Minimized test output:
======================
$ javac -fullversion Test.java MyExc.java
javac full version "1.7.0-ea-b82"
java -showversion -XX:+UnlockExperimentalVMOptions -XX:+EnableInvokeDynamic Test
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b82)
Java HotSpot(TM) Server VM (build 17.0-b08, mixed mode)
OKAY
FAILED. Unexpected exception thrown: java.dyn.NoAccessException: cannot access: *.java.dyn.MethodHandle.invoke(MyExc)void
Minimized test:
===============
$ cat Test.java
import java.dyn.*;
public class Test {
public static void meth() {
System.out.println("Invoked: public static void target()");
}
public static void catcher(Throwable e) {
System.out.println("Invoked: public static void catcher(Throwable e)");
}
public static void catcher(MyExc e) {
System.out.println("Invoked: public static void catcher(MyExc e)");
}
public static void main(String[] args) throws Throwable {
MethodHandle target = MethodHandles.lookup().findStatic(
Test.class, "meth", MethodType.methodType(void.class));
MethodHandle handler = MethodHandles.lookup().findStatic(
Test.class, "catcher", MethodType.methodType(
void.class, Throwable.class));
MethodHandle handler2 = MethodHandles.lookup().findStatic(
Test.class, "catcher", MethodType.methodType(
void.class, MyExc.class));
try {
MethodHandles.catchException(target, Throwable.class, handler);
System.out.println("OKAY");
} catch (Throwable e) {
System.out.println("FAILED. Unexpected exception thrown: " + e);
}
try {
MethodHandles.catchException(target, MyExc.class, handler2);
System.out.println("OKAY");
} catch (Throwable e) {
System.out.println("FAILED. Unexpected exception thrown: " + e);
}
}
}
$ cat MyExc.java
public class MyExc extends Throwable {}
Minimized test output:
======================
$ javac -fullversion Test.java MyExc.java
javac full version "1.7.0-ea-b82"
java -showversion -XX:+UnlockExperimentalVMOptions -XX:+EnableInvokeDynamic Test
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b82)
Java HotSpot(TM) Server VM (build 17.0-b08, mixed mode)
OKAY
FAILED. Unexpected exception thrown: java.dyn.NoAccessException: cannot access: *.java.dyn.MethodHandle.invoke(MyExc)void
- duplicates
-
JDK-6939196 method handle signatures off the boot class path get linkage errors
- Resolved