hotspot/test/runtime/verifier/TestMultiANewArray.java
author twisti
Mon, 27 Apr 2015 09:02:41 -0700
changeset 30288 476c276de939
parent 29678 dd2f3932c21e
child 30604 b8d532cb6420
permissions -rw-r--r--
8022853: add ability to load uncompressed object and Klass references in a compressed environment to Unsafe Reviewed-by: coleenp, jrose, kvn
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
/*
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 23998
diff changeset
     2
 * Copyright (c) 2014, 2015, 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.*;
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    29
import com.oracle.java.testlibrary.*;
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    30
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
 * @test TestMultiANewArray
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    33
 * @bug 8038076
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    34
 * @library /testlibrary
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 23998
diff changeset
    35
 * @modules java.base/jdk.internal.org.objectweb.asm
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 23998
diff changeset
    36
 *          java.base/sun.misc
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 23998
diff changeset
    37
 *          java.management
23998
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    38
 * @compile -XDignore.symbol.file TestMultiANewArray.java
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    39
 * @run main/othervm TestMultiANewArray 49
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    40
 * @run main/othervm TestMultiANewArray 50
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    41
 * @run main/othervm TestMultiANewArray 51
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    42
 * @run main/othervm TestMultiANewArray 52
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    43
 */
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
public class TestMultiANewArray {
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    46
    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
    47
        int cfv = Integer.parseInt(args[0]);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    48
        writeClassFile(cfv);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    49
        System.err.println("Running with cfv: " + cfv);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    50
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-cp", ".",  "ClassFile");
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    51
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    52
        output.shouldContain("VerifyError");
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    53
        output.shouldHaveExitValue(1);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    54
    }
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
    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
    57
        ClassWriter cw = new ClassWriter(0);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    58
        MethodVisitor mv;
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    59
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    60
        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
    61
        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
    62
        mv.visitCode();
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    63
        mv.visitVarInsn(ALOAD, 0);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    64
        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
    65
        mv.visitInsn(RETURN);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    66
        mv.visitMaxs(1, 1);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    67
        mv.visitEnd();
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    68
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    69
        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
    70
        mv.visitCode();
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    71
        mv.visitInsn(ICONST_1);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    72
        mv.visitInsn(ICONST_2);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    73
        mv.visitMultiANewArrayInsn("[I", 2);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    74
        mv.visitVarInsn(ASTORE, 1);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    75
        mv.visitInsn(RETURN);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    76
        mv.visitMaxs(2, 2);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    77
        mv.visitEnd();
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    78
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    79
        cw.visitEnd();
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    80
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    81
        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
    82
             fos.write(cw.toByteArray());
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    83
        }
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
}