author | juh |
Tue, 25 Jun 2013 14:31:29 -0700 | |
changeset 18551 | 882a3948c6e6 |
parent 15710 | 5792a085da41 |
child 30730 | d3ce7619db2c |
permissions | -rw-r--r-- |
15710
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
1 |
/* |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
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 |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
10 |
* |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
11 |
* 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
|
12 |
* 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
|
13 |
* 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
|
14 |
* 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
|
15 |
* accompanied this code). |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
16 |
* |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
17 |
* 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
|
18 |
* 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
|
19 |
* 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
|
20 |
* |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
21 |
* 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
|
22 |
* 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
|
23 |
* questions. |
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 |
|
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
26 |
/* |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
27 |
* @test |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
28 |
* @bug 7166455 |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
29 |
* @summary javac doesn't set ACC_STRICT bit on <clinit> for strictfp class |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
30 |
* @run main CheckACC_STRICTFlagOnclinitTest |
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 |
|
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
33 |
import java.util.ArrayList; |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
34 |
import java.util.List; |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
35 |
import java.io.File; |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
36 |
import java.io.IOException; |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
37 |
import com.sun.tools.classfile.ClassFile; |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
38 |
import com.sun.tools.classfile.ConstantPoolException; |
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; |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
40 |
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
|
41 |
import com.sun.tools.classfile.Method; |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
42 |
|
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
43 |
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
|
44 |
|
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
45 |
public strictfp class CheckACC_STRICTFlagOnclinitTest { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
46 |
private static final String AssertionErrorMessage = |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
47 |
"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
|
48 |
"please check output"; |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
49 |
private static final String offendingMethodErrorMessage = |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
50 |
"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
|
51 |
|
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
52 |
static { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
53 |
class Foo { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
54 |
class Bar { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
55 |
void m11() {} |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
56 |
} |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
57 |
void m1() {} |
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 |
} |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
60 |
void m2() { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
61 |
class Any { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
62 |
void m21() {} |
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 |
|
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
66 |
private List<String> errors = new ArrayList<>(); |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
67 |
|
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
68 |
public static void main(String[] args) |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
69 |
throws IOException, ConstantPoolException, InvalidDescriptor { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
70 |
new CheckACC_STRICTFlagOnclinitTest().run(); |
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 |
|
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
73 |
private void run() |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
74 |
throws IOException, ConstantPoolException, InvalidDescriptor { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
75 |
String testClasses = System.getProperty("test.classes"); |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
76 |
check(testClasses, |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
77 |
"CheckACC_STRICTFlagOnclinitTest.class", |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
78 |
"CheckACC_STRICTFlagOnclinitTest$1Foo.class", |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
79 |
"CheckACC_STRICTFlagOnclinitTest$1Foo$Bar.class", |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
80 |
"CheckACC_STRICTFlagOnclinitTest$1Any.class"); |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
81 |
if (errors.size() > 0) { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
82 |
for (String error: errors) { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
83 |
System.err.println(error); |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
84 |
} |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
85 |
throw new AssertionError(AssertionErrorMessage); |
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 |
|
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
89 |
void check(String dir, String... fileNames) |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
90 |
throws |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
91 |
IOException, |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
92 |
ConstantPoolException, |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
93 |
Descriptor.InvalidDescriptor { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
94 |
for (String fileName : fileNames) { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
95 |
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
|
96 |
|
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
97 |
for (Method method : classFileToCheck.methods) { |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
98 |
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
|
99 |
errors.add(String.format(offendingMethodErrorMessage, |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
100 |
method.getName(classFileToCheck.constant_pool), |
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
101 |
classFileToCheck.getName())); |
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 |
|
5792a085da41
7166455: javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
vromero
parents:
diff
changeset
|
107 |
} |