author | michaelm |
Fri, 16 Feb 2018 10:34:17 +0000 | |
branch | http-client-branch |
changeset 56137 | dd867826d55b |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
40633
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
1 |
/* |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
4 |
* |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
8 |
* |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
13 |
* accompanied this code). |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
14 |
* |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
18 |
* |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
21 |
* questions. |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
22 |
*/ |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
23 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
24 |
/* |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
25 |
* @test 8163808 |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
26 |
* @modules java.base/jdk.internal.org.objectweb.asm |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
27 |
* @run main TransitiveOverrideCFV50 |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
28 |
*/ |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
29 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
30 |
import java.util.*; |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
31 |
import java.io.File; |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
32 |
import java.io.FileOutputStream; |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
33 |
import jdk.internal.org.objectweb.asm.ClassWriter; |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
34 |
import jdk.internal.org.objectweb.asm.MethodVisitor; |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
35 |
import jdk.internal.org.objectweb.asm.AnnotationVisitor; |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
36 |
import jdk.internal.org.objectweb.asm.Opcodes; |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
37 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
38 |
/* |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
39 |
* Test mixed classfile version overriding handling. |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
40 |
* Key is to generate P2/C with an older classfile version <=50 |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
41 |
* Correct response is B.m:2 for older classfiles |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
42 |
* This test was added to ensure no assertions in debug |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
43 |
* note: for P2/C classfile version >=51, correct answer becomes C.m:3 |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
44 |
* public class P1.A { public int m() { return 1; } |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
45 |
* |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
46 |
* public class P1.B extends A { int m() { return 2; } |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
47 |
* |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
48 |
* public class P2.c extends P1.B { public int m() { return 3; } |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
49 |
*/ |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
50 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
51 |
public class TransitiveOverrideCFV50 implements Opcodes{ |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
52 |
static final String classP1A = "P1.A"; |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
53 |
static final String classP1B = "P1.B"; |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
54 |
static final String classP2C = "P2.C"; |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
55 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
56 |
static final String callerName = classP2C; |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
57 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
58 |
public static void main(String[] args) throws Exception { |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
59 |
ClassLoader cl = new ClassLoader() { |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
60 |
public Class<?> loadClass(String name) throws ClassNotFoundException { |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
61 |
if (findLoadedClass(name) != null) { |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
62 |
return findLoadedClass(name); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
63 |
} |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
64 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
65 |
if (classP1A.equals(name)) { |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
66 |
byte[] classFile = dumpP1A(); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
67 |
return defineClass(classP1A, classFile, 0, classFile.length); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
68 |
} |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
69 |
if (classP1B.equals(name)) { |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
70 |
byte[] classFile = dumpP1B(); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
71 |
return defineClass(classP1B, classFile, 0, classFile.length); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
72 |
} |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
73 |
if (classP2C.equals(name)) { |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
74 |
byte[] classFile = dumpP2C(); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
75 |
return defineClass(classP2C, classFile, 0, classFile.length); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
76 |
} |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
77 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
78 |
return super.loadClass(name); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
79 |
} |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
80 |
}; |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
81 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
82 |
cl.loadClass(classP1A); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
83 |
cl.loadClass(classP1B); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
84 |
cl.loadClass(classP2C); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
85 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
86 |
//cl.loadClass(callerName).getDeclaredMethod("test"); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
87 |
cl.loadClass(callerName).newInstance(); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
88 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
89 |
int result = (Integer)cl.loadClass(callerName).getDeclaredMethod("test").invoke(null); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
90 |
if (result != 2) { |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
91 |
throw new RuntimeException("expected B.m:2, got " + result); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
92 |
} |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
93 |
} |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
94 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
95 |
public static byte[] dumpP1A() { |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
96 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
97 |
ClassWriter cw = new ClassWriter(0); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
98 |
MethodVisitor mv; |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
99 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
100 |
cw.visit(V1_7, ACC_PUBLIC + ACC_SUPER, "P1/A", null, "java/lang/Object", null); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
101 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
102 |
{ |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
103 |
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
104 |
mv.visitCode(); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
105 |
mv.visitVarInsn(ALOAD, 0); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
106 |
mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
107 |
mv.visitInsn(RETURN); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
108 |
mv.visitMaxs(1, 1); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
109 |
mv.visitEnd(); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
110 |
} |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
111 |
{ |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
112 |
mv = cw.visitMethod(ACC_PUBLIC, "m", "()I", null, null); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
113 |
mv.visitCode(); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
114 |
mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;"); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
115 |
mv.visitLdcInsn("A.m"); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
116 |
mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
117 |
mv.visitIntInsn(BIPUSH, 1); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
118 |
mv.visitInsn(IRETURN); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
119 |
mv.visitMaxs(2, 1); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
120 |
mv.visitEnd(); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
121 |
} |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
122 |
cw.visitEnd(); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
123 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
124 |
return cw.toByteArray(); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
125 |
} |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
126 |
public static byte[] dumpP1B() { |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
127 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
128 |
ClassWriter cw = new ClassWriter(0); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
129 |
MethodVisitor mv; |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
130 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
131 |
cw.visit(V1_8, ACC_PUBLIC + ACC_SUPER, "P1/B", null, "P1/A", null); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
132 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
133 |
{ |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
134 |
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
135 |
mv.visitCode(); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
136 |
mv.visitVarInsn(ALOAD, 0); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
137 |
mv.visitMethodInsn(INVOKESPECIAL, "P1/A", "<init>", "()V", false); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
138 |
mv.visitInsn(RETURN); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
139 |
mv.visitMaxs(1, 1); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
140 |
mv.visitEnd(); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
141 |
} |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
142 |
{ |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
143 |
mv = cw.visitMethod(0, "m", "()I", null, null); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
144 |
mv.visitCode(); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
145 |
mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;"); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
146 |
mv.visitLdcInsn("B.m"); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
147 |
mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
148 |
mv.visitIntInsn(BIPUSH, 2); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
149 |
mv.visitInsn(IRETURN); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
150 |
mv.visitMaxs(2, 1); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
151 |
mv.visitEnd(); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
152 |
} |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
153 |
cw.visitEnd(); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
154 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
155 |
return cw.toByteArray(); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
156 |
} |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
157 |
public static byte[] dumpP2C() { |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
158 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
159 |
ClassWriter cw = new ClassWriter(0); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
160 |
MethodVisitor mv; |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
161 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
162 |
cw.visit(V1_6, ACC_PUBLIC + ACC_SUPER, "P2/C", null, "P1/B", null); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
163 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
164 |
{ |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
165 |
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
166 |
mv.visitCode(); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
167 |
mv.visitVarInsn(ALOAD, 0); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
168 |
mv.visitMethodInsn(INVOKESPECIAL, "P1/B", "<init>", "()V", false); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
169 |
mv.visitInsn(RETURN); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
170 |
mv.visitMaxs(1, 1); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
171 |
mv.visitEnd(); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
172 |
} |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
173 |
{ |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
174 |
mv = cw.visitMethod(ACC_PUBLIC, "m", "()I", null, null); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
175 |
mv.visitCode(); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
176 |
mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;"); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
177 |
mv.visitLdcInsn("P2/C.m"); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
178 |
mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
179 |
mv.visitIntInsn(BIPUSH, 3); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
180 |
mv.visitInsn(IRETURN); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
181 |
mv.visitMaxs(2, 1); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
182 |
mv.visitEnd(); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
183 |
} |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
184 |
{ |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
185 |
mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "test", "()I", null, null); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
186 |
mv.visitCode(); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
187 |
mv.visitTypeInsn(NEW, "P2/C"); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
188 |
mv.visitInsn(DUP); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
189 |
mv.visitMethodInsn(INVOKESPECIAL, "P2/C", "<init>", "()V", false); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
190 |
mv.visitMethodInsn(INVOKEVIRTUAL, "P1/A", "m", "()I", false); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
191 |
mv.visitInsn(IRETURN); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
192 |
mv.visitMaxs(3, 2); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
193 |
mv.visitEnd(); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
194 |
} |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
195 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
196 |
cw.visitEnd(); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
197 |
|
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
198 |
return cw.toByteArray(); |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
199 |
} |
c33ad2ff51de
8163808: Fix asserts and logging for old classfile vtable construction
acorn
parents:
diff
changeset
|
200 |
} |