hotspot/test/runtime/7160757/Test7160757.java
author sundar
Tue, 25 Jun 2013 17:31:19 +0530
changeset 18615 3f6e6adcbc1a
parent 12986 14b117407405
permissions -rw-r--r--
8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223 Reviewed-by: hannesw, jlaskey
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12986
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
     1
/*
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
     4
 *
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
     8
 *
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    13
 * accompanied this code).
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    14
 *
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    18
 *
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    21
 * questions.
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    22
 */
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    23
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    24
/*
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    25
 * @test Test7160757.java
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    26
 * @bug 7160757
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    27
 * @summary Tests that superclass initialization is not skipped
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    28
 */
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    29
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    30
public class Test7160757 {
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    31
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    32
    public static void main(String args[]) throws Exception {
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    33
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    34
        ClassLoader loader = new SLoader();
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    35
        try {
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    36
            Class.forName("S", true, loader);
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    37
            System.out.println("FAILED");
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    38
            throw new Exception("Should have thrown a VerifyError.");
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    39
        } catch (VerifyError e) {
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    40
            System.out.println(e);
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    41
            System.out.println("PASSED");
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    42
        }
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    43
    }
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    44
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    45
    static class SLoader extends ClassLoader {
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    46
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    47
        /**
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    48
         * public class S extends Throwable {
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    49
         *     public S() {
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    50
         *         aload_0
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    51
         *         invokespecial Object.<init>()
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    52
         *         return
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    53
         *     }
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    54
         * }
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    55
         */
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    56
        static byte b(int i) { return (byte)i; }
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    57
        static byte S_class[] = {
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    58
            b(0xca), b(0xfe), b(0xba), b(0xbe), 0x00, 0x00, 0x00, 0x32,
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    59
            0x00, 0x0c, 0x0a, 0x00, 0x0b, 0x00, 0x07, 0x07,
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    60
            0x00, 0x08, 0x07, 0x00, 0x09, 0x01, 0x00, 0x06,
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    61
            0x3c, 0x69, 0x6e, 0x69, 0x74, 0x3e, 0x01, 0x00,
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    62
            0x03, 0x28, 0x29, 0x56, 0x01, 0x00, 0x04, 0x43,
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    63
            0x6f, 0x64, 0x65, 0x0c, 0x00, 0x04, 0x00, 0x05,
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    64
            0x01, 0x00, 0x01, 0x53, 0x01, 0x00, 0x13, 0x6a,
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    65
            0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67,
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    66
            0x2f, 0x54, 0x68, 0x72, 0x6f, 0x77, 0x61, 0x62,
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    67
            0x6c, 0x65, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76,
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    68
            0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x4f,
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    69
            0x62, 0x6a, 0x65, 0x63, 0x74, 0x07, 0x00, 0x0a,
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    70
            0x00, 0x21, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00,
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    71
            0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x04,
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    72
            0x00, 0x05, 0x00, 0x01, 0x00, 0x06, 0x00, 0x00,
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    73
            0x00, 0x11, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00,
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    74
            0x00, 0x05, 0x2a, b(0xb7), 0x00, 0x01, b(0xb1), 0x00,
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    75
            0x00, 0x00, 0x00, 0x00, 0x00
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    76
        };
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    77
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    78
        public Class findClass(String name) throws ClassNotFoundException {
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    79
            return defineClass(name, S_class, 0, S_class.length);
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    80
        }
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    81
    }
14b117407405 7160757: Problem with hotspot/runtime_classfile
kamg
parents:
diff changeset
    82
}