-
Bug
-
Resolution: Not an Issue
-
P5
-
None
-
6u21
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.6.0_11"
Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing)
1.6.0_21-b07
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
If a class extends a non-public super class, the methods inherited will be volatile, and the getDeclaringClass() of such methods will be subclass, not superclass.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
compile the java files: javac *.java
then run Child: java Child
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
public static void Child.main(java.lang.String[]), declaring class is class Child
public int Father.getID(), declaring class is class Father
ACTUAL -
public static void Child.main(java.lang.String[]), declaring class is class Child
public int Child.getID(), declaring class is class Child
isVolatile
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
Father.java:
class Father {
protected int id;
public int getID() {
return id;
}
}
Child.java:
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
public class Child extends Father {
public static void main(String[] args) {
Method[] ms = Child.class.getMethods();
for (Method m : ms) {
if (!m.getDeclaringClass().equals(Object.class)) {
String oo = m.toString();
System.out.println(oo);
if (Modifier.isVolatile(m.getModifiers())) {
System.out.println("\tisVolatile, and its declaring class is "
+ m.getDeclaringClass());
}
}
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
make superclass public. Then run Child can get the expected result.
java version "1.6.0_11"
Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing)
1.6.0_21-b07
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
If a class extends a non-public super class, the methods inherited will be volatile, and the getDeclaringClass() of such methods will be subclass, not superclass.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
compile the java files: javac *.java
then run Child: java Child
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
public static void Child.main(java.lang.String[]), declaring class is class Child
public int Father.getID(), declaring class is class Father
ACTUAL -
public static void Child.main(java.lang.String[]), declaring class is class Child
public int Child.getID(), declaring class is class Child
isVolatile
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
Father.java:
class Father {
protected int id;
public int getID() {
return id;
}
}
Child.java:
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
public class Child extends Father {
public static void main(String[] args) {
Method[] ms = Child.class.getMethods();
for (Method m : ms) {
if (!m.getDeclaringClass().equals(Object.class)) {
String oo = m.toString();
System.out.println(oo);
if (Modifier.isVolatile(m.getModifiers())) {
System.out.println("\tisVolatile, and its declaring class is "
+ m.getDeclaringClass());
}
}
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
make superclass public. Then run Child can get the expected result.
- relates to
-
JDK-6342411 Add bridge method to allow reflective access to public method in non-public class
- Closed
-
JDK-6261502 (reflect) Add the functionality to screen out the "inappropriate" modifier bits
- Resolved
-
JDK-6354476 (reflect) {Method, Constructor}.toString prints out inappropriate modifiers
- Resolved
-
JDK-6316717 (reflect) Method.toGenericString prints out inappropriate modifiers
- Closed