test/hotspot/jtreg/runtime/verifier/TestMultiANewArray.java
author egahlin
Tue, 26 Nov 2019 17:00:57 +0100
changeset 59274 eb3e2a5c2bcd
parent 47216 71c04702a3d5
permissions -rw-r--r--
8233870: JFR TestSetEndTime.java times out - onClose() is never called Reviewed-by: mgronlun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23998
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
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.
23998
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
     4
 *
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
     7
 * published by the Free Software Foundation.
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
     8
 *
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    13
 * accompanied this code).
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    14
 *
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    18
 *
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    21
 * questions.
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    22
 */
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    23
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    24
import java.io.File;
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    25
import java.io.FileOutputStream;
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    26
import jdk.internal.org.objectweb.asm.ClassWriter;
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    27
import jdk.internal.org.objectweb.asm.MethodVisitor;
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    28
import static jdk.internal.org.objectweb.asm.Opcodes.*;
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    29
import jdk.test.lib.process.ProcessTools;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    30
import jdk.test.lib.process.OutputAnalyzer;
23998
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    31
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    32
/*
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    33
 * @test TestMultiANewArray
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    34
 * @bug 8038076
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    35
 * @library /test/lib
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 23998
diff changeset
    36
 * @modules java.base/jdk.internal.org.objectweb.asm
36851
03e2f4d0a421 8153737: Unsupported Module
chegar
parents: 30604
diff changeset
    37
 *          java.base/jdk.internal.misc
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 23998
diff changeset
    38
 *          java.management
23998
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    39
 * @compile -XDignore.symbol.file TestMultiANewArray.java
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    40
 * @run main/othervm TestMultiANewArray 49
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    41
 * @run main/othervm TestMultiANewArray 50
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    42
 * @run main/othervm TestMultiANewArray 51
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    43
 * @run main/othervm TestMultiANewArray 52
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    44
 */
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    45
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    46
public class TestMultiANewArray {
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    47
    public static void main(String... args) throws Exception {
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    48
        int cfv = Integer.parseInt(args[0]);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    49
        writeClassFile(cfv);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    50
        System.err.println("Running with cfv: " + cfv);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    51
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-cp", ".",  "ClassFile");
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    52
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    53
        output.shouldContain("VerifyError");
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    54
        output.shouldHaveExitValue(1);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    55
    }
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    56
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    57
    public static void writeClassFile(int cfv) throws Exception {
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    58
        ClassWriter cw = new ClassWriter(0);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    59
        MethodVisitor mv;
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    60
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    61
        cw.visit(cfv, ACC_PUBLIC + ACC_SUPER, "ClassFile", null, "java/lang/Object", null);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    62
        mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    63
        mv.visitCode();
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    64
        mv.visitVarInsn(ALOAD, 0);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    65
        mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    66
        mv.visitInsn(RETURN);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    67
        mv.visitMaxs(1, 1);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    68
        mv.visitEnd();
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    69
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    70
        mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "main", "([Ljava/lang/String;)V", null, null);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    71
        mv.visitCode();
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    72
        mv.visitInsn(ICONST_1);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    73
        mv.visitInsn(ICONST_2);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    74
        mv.visitMultiANewArrayInsn("[I", 2);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    75
        mv.visitVarInsn(ASTORE, 1);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    76
        mv.visitInsn(RETURN);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    77
        mv.visitMaxs(2, 2);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    78
        mv.visitEnd();
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    79
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    80
        cw.visitEnd();
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    81
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    82
        try (FileOutputStream fos = new FileOutputStream(new File("ClassFile.class"))) {
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    83
             fos.write(cw.toByteArray());
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    84
        }
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    85
    }
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    86
}