Mercurial > hg > graal-jvmci-8
annotate test/compiler/jsr292/methodHandleExceptions/TestAMEnotNPE.java @ 12332:dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
Summary: Copied null-checks from templateInterpreter_CPU into methodHandles_CPU
Reviewed-by: jrose, twisti
author | drchase |
---|---|
date | Fri, 27 Sep 2013 13:36:25 -0400 |
parents | |
children | 9d15b81d5d1b |
rev | line source |
---|---|
12332
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
1 /* |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
4 * |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
8 * |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
13 * accompanied this code). |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
14 * |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
18 * |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
21 * questions. |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
22 * |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
23 */ |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
24 |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
25 import java.lang.reflect.InvocationTargetException; |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
26 import jdk.internal.org.objectweb.asm.ClassWriter; |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
27 import jdk.internal.org.objectweb.asm.Handle; |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
28 import jdk.internal.org.objectweb.asm.MethodVisitor; |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
29 import jdk.internal.org.objectweb.asm.Opcodes; |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
30 |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
31 /** |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
32 * @test |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
33 * @bug 8025260 |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
34 * @summary Ensure that AbstractMethodError is thrown, not NullPointerException, through MethodHandles::jump_from_method_handle code path |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
35 * |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
36 * @compile -XDignore.symbol.file ByteClassLoader.java I.java C.java TestAMEnotNPE.java |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
37 * @run main/othervm TestAMEnotNPE |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
38 */ |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
39 |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
40 public class TestAMEnotNPE implements Opcodes { |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
41 |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
42 /** |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
43 * The bytes for D, a NOT abstract class extending abstract class C |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
44 * without supplying an implementation for abstract method m. |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
45 * There is a default method in the interface I, but it should lose to |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
46 * the abstract class. |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
47 |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
48 class D extends C { |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
49 D() { super(); } |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
50 // does not define m |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
51 } |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
52 |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
53 * @return |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
54 * @throws Exception |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
55 */ |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
56 public static byte[] bytesForD() throws Exception { |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
57 |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
58 ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES|ClassWriter.COMPUTE_MAXS); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
59 MethodVisitor mv; |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
60 |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
61 cw.visit(V1_8, ACC_PUBLIC + ACC_SUPER, "D", null, "C", null); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
62 |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
63 { |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
64 mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
65 mv.visitCode(); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
66 mv.visitVarInsn(ALOAD, 0); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
67 mv.visitMethodInsn(INVOKESPECIAL, "C", "<init>", "()V"); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
68 mv.visitInsn(RETURN); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
69 mv.visitMaxs(0, 0); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
70 mv.visitEnd(); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
71 } |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
72 cw.visitEnd(); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
73 |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
74 return cw.toByteArray(); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
75 } |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
76 |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
77 |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
78 /** |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
79 * The bytecodes for an invokeExact of a particular methodHandle, I.m, invoked on a D |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
80 |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
81 class T { |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
82 T() { super(); } // boring constructor |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
83 int test() { |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
84 MethodHandle mh = `I.m():int`; |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
85 D d = new D(); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
86 return mh.invokeExact(d); // Should explode here, AbstractMethodError |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
87 } |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
88 } |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
89 |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
90 * @return |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
91 * @throws Exception |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
92 */ |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
93 public static byte[] bytesForT() throws Exception { |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
94 |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
95 ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES|ClassWriter.COMPUTE_MAXS); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
96 MethodVisitor mv; |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
97 |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
98 cw.visit(V1_8, ACC_PUBLIC + ACC_SUPER, "T", null, "java/lang/Object", null); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
99 { |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
100 mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
101 mv.visitCode(); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
102 mv.visitVarInsn(ALOAD, 0); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
103 mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V"); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
104 mv.visitInsn(RETURN); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
105 mv.visitMaxs(0,0); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
106 mv.visitEnd(); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
107 } |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
108 { |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
109 mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "test", "()I", null, null); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
110 mv.visitCode(); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
111 mv.visitLdcInsn(new Handle(Opcodes.H_INVOKEINTERFACE, "I", "m", "()I")); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
112 mv.visitTypeInsn(NEW, "D"); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
113 mv.visitInsn(DUP); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
114 mv.visitMethodInsn(INVOKESPECIAL, "D", "<init>", "()V"); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
115 mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/invoke/MethodHandle", "invokeExact", "(LI;)I"); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
116 mv.visitInsn(IRETURN); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
117 mv.visitMaxs(0,0); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
118 mv.visitEnd(); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
119 } |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
120 cw.visitEnd(); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
121 return cw.toByteArray(); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
122 } |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
123 |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
124 public static void main(String args[] ) throws Throwable { |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
125 ByteClassLoader bcl = new ByteClassLoader(); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
126 Class<?> d = bcl.loadBytes("D", bytesForD()); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
127 Class<?> t = bcl.loadBytes("T", bytesForT()); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
128 try { |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
129 Object result = t.getMethod("test").invoke(null); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
130 System.out.println("Expected AbstractMethodError wrapped in InvocationTargetException, saw no exception"); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
131 throw new Error("Missing expected exception"); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
132 } catch (InvocationTargetException e) { |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
133 Throwable th = e.getCause(); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
134 if (th instanceof AbstractMethodError) { |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
135 th.printStackTrace(System.out); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
136 System.out.println("PASS, saw expected exception (AbstractMethodError, wrapped in InvocationTargetException)."); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
137 } else { |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
138 System.out.println("Expected AbstractMethodError wrapped in InvocationTargetException, saw " + th); |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
139 throw th; |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
140 } |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
141 } |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
142 } |
dc261f466b6d
8025260: Methodhandles/JSR292: NullPointerException (NPE) thrown instead of AbstractMethodError (AME)
drchase
parents:
diff
changeset
|
143 } |