hotspot/test/runtime/verifier/TestMultiANewArray.java
author mgerdin
Mon, 11 Aug 2014 17:12:41 +0400
changeset 25958 8dc85547d6d6
parent 23998 418ac4fe9834
child 29678 dd2f3932c21e
permissions -rw-r--r--
8011397: JTREG needs to copy additional WhiteBox class file to JTwork/scratch/sun/hotspot Reviewed-by: kvn, iignatyev, mgerdin Contributed-by: andrey.x.zakharov@oracle.com
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
/*
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
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
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    35
 * @compile -XDignore.symbol.file TestMultiANewArray.java
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    36
 * @run main/othervm TestMultiANewArray 49
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    37
 * @run main/othervm TestMultiANewArray 50
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    38
 * @run main/othervm TestMultiANewArray 51
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    39
 * @run main/othervm TestMultiANewArray 52
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    40
 */
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    41
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    42
public class TestMultiANewArray {
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    43
    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
    44
        int cfv = Integer.parseInt(args[0]);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    45
        writeClassFile(cfv);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    46
        System.err.println("Running with cfv: " + cfv);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    47
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-cp", ".",  "ClassFile");
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    48
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    49
        output.shouldContain("VerifyError");
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    50
        output.shouldHaveExitValue(1);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    51
    }
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    52
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    53
    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
    54
        ClassWriter cw = new ClassWriter(0);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    55
        MethodVisitor mv;
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
        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
    58
        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
    59
        mv.visitCode();
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    60
        mv.visitVarInsn(ALOAD, 0);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    61
        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
    62
        mv.visitInsn(RETURN);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    63
        mv.visitMaxs(1, 1);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    64
        mv.visitEnd();
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    65
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    66
        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
    67
        mv.visitCode();
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    68
        mv.visitInsn(ICONST_1);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    69
        mv.visitInsn(ICONST_2);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    70
        mv.visitMultiANewArrayInsn("[I", 2);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    71
        mv.visitVarInsn(ASTORE, 1);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    72
        mv.visitInsn(RETURN);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    73
        mv.visitMaxs(2, 2);
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    74
        mv.visitEnd();
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    75
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    76
        cw.visitEnd();
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    77
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    78
        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
    79
             fos.write(cw.toByteArray());
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
    }
418ac4fe9834 8038076: constraint on multianewarray instruction is not checked since class version 50.
lfoltan
parents:
diff changeset
    82
}