|
1 /* |
|
2 * Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
13 * accompanied this code). |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License version |
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 * |
|
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
20 * CA 95054 USA or visit www.sun.com if you need additional information or |
|
21 * have any questions. |
|
22 */ |
|
23 |
|
24 /* |
|
25 * @test |
|
26 * @bug 4150966 4151040 4107254 4180437 |
|
27 * @summary General tests of strictfp changes and reflection |
|
28 * @author David Stoutamire (dps) |
|
29 * |
|
30 * @compile Test.java |
|
31 * @run main Test |
|
32 */ |
|
33 |
|
34 import java.lang.reflect.*; |
|
35 |
|
36 public class Test { |
|
37 strictfp void strict() {} |
|
38 strictfp class Inner2 { void strict() {} } |
|
39 |
|
40 public static void main(String[] args) throws NoSuchMethodException { |
|
41 assertStrict(Test.class.getDeclaredMethod("strict", new Class[0])); |
|
42 assertStrict(Test.Inner2.class.getDeclaredMethod("strict", new Class[0])); |
|
43 |
|
44 assertStrict(Test2.class.getDeclaredMethod("strict", new Class[0])); |
|
45 assertStrict(Test2.class.getDeclaredMethod("strict2", new Class[0])); |
|
46 assertStrict(Test2.Inner.class.getDeclaredMethod("strict", new Class[0])); |
|
47 assertStrict(Test2.Inner2.class.getDeclaredMethod("strict", new Class[0])); |
|
48 } |
|
49 |
|
50 private static void assertStrict(Method m) { |
|
51 int mod = m.getModifiers(); |
|
52 if (!Modifier.isStrict(mod)) |
|
53 barf(m, "strict"); |
|
54 } |
|
55 |
|
56 private static void barf(Method m, String msg) { |
|
57 System.err.println("Method "+m+" was not "+msg+": " |
|
58 +Modifier.toString(m.getModifiers())); |
|
59 |
|
60 } |
|
61 } |
|
62 |
|
63 |
|
64 strictfp class Test2 { |
|
65 void strict() {} |
|
66 strictfp void strict2() {} |
|
67 class Inner { void strict() {} } |
|
68 strictfp class Inner2 { void strict() {} } |
|
69 } |
|
70 |
|
71 // check local inner classes are accepted |
|
72 class OtherTest |
|
73 { |
|
74 static double m() { |
|
75 strictfp class Inn { |
|
76 float i; |
|
77 } |
|
78 return 2.0; |
|
79 } |
|
80 } |