Name: boT120536 Date: 11/06/2000
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
If you compile and run the following program it indicates that the value of the
modifiers on method m is 2 and om is zero indicating that the method m is
private and method pm has default access, however the JLS (2nd Ed) on page 172
section 8.4.3.3 states that a Private method and all methods declared in a
final class are implicitly final ......
This would appear to indicate that the modifier values for m should be 0x12 and
0x10 for pm.
import java.lang.reflect.*;
final class fc
{
private int m(){ return 1;}
private class Inner {
int pm(){ return 20;}
}
public static void main(String argv[])
{
try {
Class cx = fc.class;
java.lang.reflect.Method mt = cx.getDeclaredMethod("m",
null);
System.out.println("Modifiers for m are "+
mt.getModifiers());
cx = Inner.class;
mt = cx.getDeclaredMethod("pm", null);
System.out.println("Modifiers for pm are "+
mt.getModifiers());
}catch(Exception e) {
e.printStackTrace();
}
}
}
(Review ID: 111557)
======================================================================
- duplicates
-
JDK-4249112 Compiler does not mark methods of final classes as final
-
- Closed
-