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