author | alanb |
Thu, 01 Dec 2016 15:54:39 +0000 | |
changeset 42309 | 21f9f3fbc302 |
parent 40631 | ed82623d7831 |
child 46403 | f2b91b928476 |
permissions | -rw-r--r-- |
25327
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
1 |
/* |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
2 |
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. |
25327
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
4 |
* |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
8 |
* |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
13 |
* accompanied this code). |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
14 |
* |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
18 |
* |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
21 |
* questions. |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
22 |
*/ |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
23 |
|
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
24 |
import java.io.File; |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
25 |
import java.io.FileOutputStream; |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
26 |
|
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
27 |
import jdk.internal.org.objectweb.asm.ClassWriter; |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
28 |
import jdk.internal.org.objectweb.asm.MethodVisitor; |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
29 |
import static jdk.internal.org.objectweb.asm.Opcodes.*; |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
30 |
|
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
31 |
import jdk.test.lib.process.ProcessTools; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
32 |
import jdk.test.lib.process.OutputAnalyzer; |
25327
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
33 |
|
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
34 |
/* |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
35 |
* @test |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
36 |
* @summary Test that anewarray bytecode is valid only if it specifies 255 or fewer dimensions. |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
37 |
* @library /test/lib |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
25327
diff
changeset
|
38 |
* @modules java.base/jdk.internal.org.objectweb.asm |
36851 | 39 |
* java.base/jdk.internal.misc |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
25327
diff
changeset
|
40 |
* java.management |
25327
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
41 |
* @compile -XDignore.symbol.file TestANewArray.java |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
42 |
* @run main/othervm TestANewArray 49 |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
43 |
* @run main/othervm TestANewArray 50 |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
44 |
* @run main/othervm TestANewArray 51 |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
45 |
* @run main/othervm TestANewArray 52 |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
46 |
*/ |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
47 |
|
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
48 |
/* |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
49 |
* Testing anewarray instruction with 254, 255 & 264 dimensions to verify JVMS 8, |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
50 |
* Section 4.9.1, Static Constraints that states the following: |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
51 |
* |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
52 |
* "No anewarray instruction may be used to create an array of more than 255 dimensions." |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
53 |
* |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
54 |
*/ |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
55 |
|
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
56 |
public class TestANewArray { |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
57 |
|
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
58 |
static String classCName = null; // the generated class name |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
59 |
|
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
60 |
static final int test_Dimension_254 = 254; // should always pass |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
61 |
static final int test_Dimension_255 = 255; // should always pass, except for cfv 49 |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
62 |
static final int test_Dimension_264 = 264; // should always fail |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
63 |
|
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
64 |
static final String array_Dimension_254 = genArrayDim(test_Dimension_254); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
65 |
static final String array_Dimension_255 = genArrayDim(test_Dimension_255); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
66 |
static final String array_Dimension_264 = genArrayDim(test_Dimension_264); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
67 |
|
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
68 |
public static void main(String... args) throws Exception { |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
69 |
int cfv = Integer.parseInt(args[0]); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
70 |
|
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
71 |
// 254 array dimensions |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
72 |
byte[] classFile_254 = dumpClassFile(cfv, test_Dimension_254, array_Dimension_254); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
73 |
writeClassFileFromByteArray(classFile_254); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
74 |
System.err.println("Running with cfv: " + cfv + ", test_Dimension_254"); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
75 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-verify", "-cp", ".", classCName); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
76 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
77 |
output.shouldNotContain("java.lang.VerifyError"); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
78 |
output.shouldHaveExitValue(0); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
79 |
|
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
80 |
// 255 array dimensions |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
81 |
byte[] classFile_255 = dumpClassFile(cfv, test_Dimension_255, array_Dimension_255); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
82 |
writeClassFileFromByteArray(classFile_255); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
83 |
System.err.println("Running with cfv: " + cfv + ", test_Dimension_255"); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
84 |
pb = ProcessTools.createJavaProcessBuilder(true, "-verify", "-cp", ".", classCName); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
85 |
output = new OutputAnalyzer(pb.start()); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
86 |
if (cfv == 49) { |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
87 |
// The type-inferencing verifier used for <=49.0 ClassFiles detects an anewarray instruction |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
88 |
// with exactly 255 dimensions and incorrectly issues the "Array with too many dimensions" VerifyError. |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
89 |
output.shouldContain("Array with too many dimensions"); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
90 |
output.shouldHaveExitValue(1); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
91 |
} else { |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
92 |
// 255 dimensions should always pass, except for cfv 49 |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
93 |
output.shouldNotContain("java.lang.VerifyError"); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
94 |
output.shouldNotContain("java.lang.ClassFormatError"); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
95 |
output.shouldHaveExitValue(0); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
96 |
} |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
97 |
|
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
98 |
// 264 array dimensions |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
99 |
byte[] classFile_264 = dumpClassFile(cfv, test_Dimension_264, array_Dimension_264); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
100 |
writeClassFileFromByteArray(classFile_264); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
101 |
System.err.println("Running with cfv: " + cfv + ", test_Dimension_264"); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
102 |
pb = ProcessTools.createJavaProcessBuilder(true, "-verify", "-cp", ".", classCName); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
103 |
output = new OutputAnalyzer(pb.start()); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
104 |
output.shouldContain("java.lang.ClassFormatError"); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
105 |
output.shouldHaveExitValue(1); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
106 |
} |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
107 |
|
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
108 |
public static byte[] dumpClassFile(int cfv, int testDimension264, String arrayDim) throws Exception { |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
109 |
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
110 |
MethodVisitor mv; |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
111 |
|
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
112 |
classCName = "classCName_" + cfv + "_" + testDimension264; |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
113 |
|
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
114 |
cw.visit(cfv, ACC_PUBLIC + ACC_SUPER, classCName, null, "java/lang/Object", null); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
115 |
{ |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
116 |
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
117 |
mv.visitCode(); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
118 |
mv.visitVarInsn(ALOAD, 0); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
119 |
mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
120 |
mv.visitInsn(RETURN); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
121 |
mv.visitMaxs(1, 1); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
122 |
mv.visitEnd(); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
123 |
} |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
124 |
{ // classCName main method |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
125 |
mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "main", "([Ljava/lang/String;)V", null, null); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
126 |
mv.visitCode(); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
127 |
mv.visitIntInsn(BIPUSH, 1); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
128 |
mv.visitTypeInsn(ANEWARRAY, arrayDim); // Test ANEWARRAY bytecode with various dimensions |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
129 |
mv.visitInsn(RETURN); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
130 |
mv.visitMaxs(2, 2); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
131 |
mv.visitEnd(); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
132 |
} |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
133 |
cw.visitEnd(); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
134 |
return cw.toByteArray(); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
135 |
} |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
136 |
|
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
137 |
public static FileOutputStream writeClassFileFromByteArray(byte[] classFileByteArray) throws Exception { |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
138 |
FileOutputStream fos = new FileOutputStream(new File(classCName + ".class")); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
139 |
fos.write(classFileByteArray); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
140 |
fos.close(); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
141 |
return fos; |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
142 |
} |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
143 |
|
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
144 |
private static String genArrayDim(int testDim) { |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
145 |
StringBuilder array_Dimension = new StringBuilder(); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
146 |
for (int i = 0; i < testDim; i++) |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
147 |
{ |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
148 |
array_Dimension.append("["); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
149 |
} |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
150 |
return array_Dimension.append("Ljava/lang/Object;").toString(); |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
151 |
} |
8b34977169da
8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions
gtriantafill
parents:
diff
changeset
|
152 |
} |