author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 44243 | hotspot/test/runtime/duplAttributes/TestDupSignatureAttr.java@bd6ac32eb679 |
permissions | -rw-r--r-- |
44243
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
1 |
/* |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
4 |
* |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
8 |
* |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
13 |
* accompanied this code). |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
14 |
* |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
18 |
* |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
21 |
* questions. |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
22 |
*/ |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
23 |
|
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
24 |
/* |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
25 |
* @test |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
26 |
* @bug 8176147 |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
27 |
* @summary Throw ClassFormatError exception for multiple Signature attributes |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
28 |
* @compile DupSignatureAttrs.jcod |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
29 |
* @run main TestDupSignatureAttr |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
30 |
*/ |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
31 |
|
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
32 |
public class TestDupSignatureAttr { |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
33 |
public static void main(String args[]) throws Throwable { |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
34 |
|
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
35 |
System.out.println("Regression test for bug 8176147"); |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
36 |
|
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
37 |
String[] badClasses = new String[] { |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
38 |
"DupClassSigAttrs", |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
39 |
"DupMthSigAttrs", |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
40 |
"DupFldSigAttrs", |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
41 |
}; |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
42 |
String[] messages = new String[] { |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
43 |
"Multiple Signature attributes in class file", |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
44 |
"Multiple Signature attributes for method", |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
45 |
"Multiple Signature attributes for field", |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
46 |
}; |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
47 |
|
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
48 |
for (int x = 0; x < badClasses.length; x++) { |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
49 |
try { |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
50 |
Class newClass = Class.forName(badClasses[x]); |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
51 |
throw new RuntimeException("Expected ClassFormatError exception not thrown"); |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
52 |
} catch (java.lang.ClassFormatError e) { |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
53 |
if (!e.getMessage().contains(messages[x])) { |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
54 |
throw new RuntimeException("Wrong ClassFormatError exception thrown: " + |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
55 |
e.getMessage()); |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
56 |
} |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
57 |
} |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
58 |
} |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
59 |
|
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
60 |
// Multiple Signature attributes but no duplicates. |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
61 |
Class newClass = Class.forName("OkaySigAttrs"); |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
62 |
} |
bd6ac32eb679
8176147: JVM should throw CFE for duplicate Signature attributes
hseigel
parents:
diff
changeset
|
63 |
} |