author | hseigel |
Wed, 02 Mar 2016 23:48:41 +0000 | |
changeset 36397 | c487ced7231c |
parent 32337 | c9d3ab9f601c |
permissions | -rw-r--r-- |
15710
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
1 |
/* |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
15710
diff
changeset
|
2 |
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
15710
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
4 |
* |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
32337 | 7 |
* published by the Free Software Foundation. |
15710
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
8 |
* |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
13 |
* accompanied this code). |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
14 |
* |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
18 |
* |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
21 |
* questions. |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
22 |
*/ |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
23 |
|
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
24 |
/* |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
25 |
* @test |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
26 |
* @bug 7166455 |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
27 |
* @summary javac doesn't set ACC_STRICT bit on <clinit> for strictfp class |
30846 | 28 |
* @modules jdk.jdeps/com.sun.tools.classfile |
15710
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
29 |
* @run main CheckACC_STRICTFlagOnclinitTest |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
30 |
*/ |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
31 |
|
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
32 |
import java.util.ArrayList; |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
33 |
import java.util.List; |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
34 |
import java.io.File; |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
35 |
import java.io.IOException; |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
36 |
import com.sun.tools.classfile.ClassFile; |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
37 |
import com.sun.tools.classfile.ConstantPoolException; |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
38 |
import com.sun.tools.classfile.Descriptor; |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
39 |
import com.sun.tools.classfile.Descriptor.InvalidDescriptor; |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
40 |
import com.sun.tools.classfile.Method; |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
41 |
|
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
42 |
import static com.sun.tools.classfile.AccessFlags.ACC_STRICT; |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
43 |
|
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
44 |
public strictfp class CheckACC_STRICTFlagOnclinitTest { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
45 |
private static final String AssertionErrorMessage = |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
46 |
"All methods should have the ACC_STRICT access flag " + |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
47 |
"please check output"; |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
48 |
private static final String offendingMethodErrorMessage = |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
49 |
"Method %s of class %s doesn't have the ACC_STRICT access flag"; |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
50 |
|
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
51 |
static { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
52 |
class Foo { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
53 |
class Bar { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
54 |
void m11() {} |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
55 |
} |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
56 |
void m1() {} |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
57 |
} |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
58 |
} |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
59 |
void m2() { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
60 |
class Any { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
61 |
void m21() {} |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
62 |
} |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
63 |
} |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
64 |
|
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
65 |
private List<String> errors = new ArrayList<>(); |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
66 |
|
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
67 |
public static void main(String[] args) |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
68 |
throws IOException, ConstantPoolException, InvalidDescriptor { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
69 |
new CheckACC_STRICTFlagOnclinitTest().run(); |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
70 |
} |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
71 |
|
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
72 |
private void run() |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
73 |
throws IOException, ConstantPoolException, InvalidDescriptor { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
74 |
String testClasses = System.getProperty("test.classes"); |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
75 |
check(testClasses, |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
76 |
"CheckACC_STRICTFlagOnclinitTest.class", |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
77 |
"CheckACC_STRICTFlagOnclinitTest$1Foo.class", |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
78 |
"CheckACC_STRICTFlagOnclinitTest$1Foo$Bar.class", |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
79 |
"CheckACC_STRICTFlagOnclinitTest$1Any.class"); |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
80 |
if (errors.size() > 0) { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
81 |
for (String error: errors) { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
82 |
System.err.println(error); |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
83 |
} |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
84 |
throw new AssertionError(AssertionErrorMessage); |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
85 |
} |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
86 |
} |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
87 |
|
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
88 |
void check(String dir, String... fileNames) |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
89 |
throws |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
90 |
IOException, |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
91 |
ConstantPoolException, |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
92 |
Descriptor.InvalidDescriptor { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
93 |
for (String fileName : fileNames) { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
94 |
ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName)); |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
95 |
|
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
96 |
for (Method method : classFileToCheck.methods) { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
97 |
if ((method.access_flags.flags & ACC_STRICT) == 0) { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
98 |
errors.add(String.format(offendingMethodErrorMessage, |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
99 |
method.getName(classFileToCheck.constant_pool), |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
100 |
classFileToCheck.getName())); |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
101 |
} |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
102 |
} |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
103 |
} |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
104 |
} |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
105 |
|
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
106 |
} |