author | hseigel |
Wed, 19 Jun 2019 08:42:15 -0400 | |
changeset 55437 | 360f8769d3dc |
parent 54607 | b6db97903b69 |
permissions | -rw-r--r-- |
54124
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
1 |
/* |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
4 |
* |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
8 |
* |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
13 |
* accompanied this code). |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
14 |
* |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
18 |
* |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
21 |
* questions. |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
22 |
*/ |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
23 |
|
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
24 |
/* |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
25 |
* @test |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
26 |
* @bug 8129579 |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
27 |
* @summary Test that signatures are properly parsed when verification of local |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
28 |
* classes is requested but verification of remote classes is not. |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
29 |
* @compile BadSignatures.jcod |
54607
b6db97903b69
8221685: -XX:BytecodeVerificationRemote and -XX:BytecodeVerificationLocal should be diagnostic options
hseigel
parents:
54124
diff
changeset
|
30 |
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+BytecodeVerificationLocal -XX:-BytecodeVerificationRemote TestSigParse |
54124
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
31 |
*/ |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
32 |
|
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
33 |
public class TestSigParse { |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
34 |
|
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
35 |
public static void main(String args[]) throws Throwable { |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
36 |
System.out.println("Regression test for bug 819579"); |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
37 |
|
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
38 |
// Test a FieldRef with a bad signature. |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
39 |
try { |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
40 |
Class newClass = Class.forName("BadFieldRef"); |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
41 |
throw new RuntimeException("Expected ClasFormatError exception not thrown"); |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
42 |
} catch (java.lang.ClassFormatError e) { |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
43 |
String eMsg = e.getMessage(); |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
44 |
if (!eMsg.contains("Field") || !eMsg.contains("has illegal signature")) { |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
45 |
throw new RuntimeException("Unexpected exception: " + eMsg); |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
46 |
} |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
47 |
} |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
48 |
|
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
49 |
// Test a MethodRef with a bad signature. |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
50 |
try { |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
51 |
Class newClass = Class.forName("BadMethodRef"); |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
52 |
throw new RuntimeException("Expected ClasFormatError exception not thrown"); |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
53 |
} catch (java.lang.ClassFormatError e) { |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
54 |
String eMsg = e.getMessage(); |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
55 |
if (!eMsg.contains("Method") || !eMsg.contains("has illegal signature")) { |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
56 |
throw new RuntimeException("Unexpected exception: " + eMsg); |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
57 |
} |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
58 |
} |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
59 |
|
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
60 |
// Test a method in a class with a bad signature. |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
61 |
try { |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
62 |
Class newClass = Class.forName("BadMethodSig"); |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
63 |
throw new RuntimeException("Expected ClasFormatError exception not thrown"); |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
64 |
} catch (java.lang.ClassFormatError e) { |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
65 |
String eMsg = e.getMessage(); |
55437
360f8769d3dc
8225789: Empty method parameter type should generate ClassFormatError
hseigel
parents:
54607
diff
changeset
|
66 |
if (!eMsg.contains("Class name is empty or contains illegal character")) { |
54124
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
67 |
throw new RuntimeException("Unexpected exception: " + eMsg); |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
68 |
} |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
69 |
} |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
70 |
} |
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
71 |
|
5d48ae032588
8219579: Remove redundant signature parsing from the verifier
hseigel
parents:
diff
changeset
|
72 |
} |