author | hseigel |
Tue, 21 Feb 2017 09:53:49 -0500 | |
changeset 43977 | bf59cd83ea95 |
permissions | -rw-r--r-- |
43977
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
1 |
/* |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
4 |
* |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
8 |
* |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
13 |
* accompanied this code). |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
14 |
* |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
18 |
* |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
21 |
* questions. |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
22 |
*/ |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
23 |
|
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
24 |
/* |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
25 |
* @test |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
26 |
* @bug 8174725 |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
27 |
* @summary Throw NoClassDefFoundError if class access_flags have ACC_MODULE set |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
28 |
* @compile BadAccModule.jcod BadAccModInrClss.jcod |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
29 |
* @run main AccModuleTest |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
30 |
*/ |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
31 |
|
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
32 |
// Test that classes with access_flags containing ACC_MODULE cause ClassDefNotFoundErrors. |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
33 |
public class AccModuleTest { |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
34 |
public static void main(String args[]) throws Throwable { |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
35 |
|
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
36 |
System.out.println("Regression test for bug 8174725"); |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
37 |
try { |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
38 |
Class newClass = Class.forName("BadAccModule"); |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
39 |
throw new RuntimeException("Expected NoClassDefFoundError exception not thrown"); |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
40 |
} catch (java.lang.NoClassDefFoundError e) { |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
41 |
if (!e.getMessage().contains("BadAccModule is not a class because access_flag ACC_MODULE is set")) { |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
42 |
throw new RuntimeException("Wrong NoClassDefFoundError exception for AccModuleTest: " + e.getMessage()); |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
43 |
} |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
44 |
} |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
45 |
try { |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
46 |
Class newClass = Class.forName("BadAccModInrClss"); |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
47 |
throw new RuntimeException("Expected NoClassDefFoundError exception not thrown"); |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
48 |
} catch (java.lang.NoClassDefFoundError e) { |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
49 |
if (!e.getMessage().contains("BadAccModInrClss is not a class because access_flag ACC_MODULE is set")) { |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
50 |
throw new RuntimeException("Wrong NoClassDefFoundError exception for BadAccModInrClss: " + e.getMessage()); |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
51 |
} |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
52 |
} |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
53 |
} |
bf59cd83ea95
8174725: JVM should throw NoClassDefFoundError if ACC_MODULE is set in access_flags
hseigel
parents:
diff
changeset
|
54 |
} |