-
Bug
-
Resolution: Not an Issue
-
P4
-
8u66, 9
-
x86
-
other
FULL PRODUCT VERSION :
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
MAC OS X 10.8.5
A DESCRIPTION OF THE PROBLEM :
The "getDeclaredMethods" function should return only the methods that are declared in the input class A. However, when the modifier of the superclass of A is "abstract class" (without public), the function also returns the methods of the superclass.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public interface Posicion {
public void obtenerCoordenadaX();
public void obtenerCoordenadaY();
}
abstract class Vehiculo implements Posicion {
public void obtenerCoordenadaX(){};
public void obtenerCoordenadaY(){};
}
public class Coche extends Vehiculo {
}
import java.lang.reflect.Method;
public class TestCase {
public static void main(String[] args) {
Class<?> clazz = Coche.class;
Method[] methods = clazz.getDeclaredMethods();
}
}
---------- END SOURCE ----------
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
MAC OS X 10.8.5
A DESCRIPTION OF THE PROBLEM :
The "getDeclaredMethods" function should return only the methods that are declared in the input class A. However, when the modifier of the superclass of A is "abstract class" (without public), the function also returns the methods of the superclass.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public interface Posicion {
public void obtenerCoordenadaX();
public void obtenerCoordenadaY();
}
abstract class Vehiculo implements Posicion {
public void obtenerCoordenadaX(){};
public void obtenerCoordenadaY(){};
}
public class Coche extends Vehiculo {
}
import java.lang.reflect.Method;
public class TestCase {
public static void main(String[] args) {
Class<?> clazz = Coche.class;
Method[] methods = clazz.getDeclaredMethods();
}
}
---------- END SOURCE ----------
- relates to
-
JDK-8265174 Update Class.getDeclaredMethods to discuss synthetic and bridge methods
- Resolved
-
JDK-6815786 (reflect) Class.getDeclaredMethods() is returning inherited methods
- Closed
-
JDK-6342411 Add bridge method to allow reflective access to public method in non-public class
- Closed
-
JDK-8265174 Update Class.getDeclaredMethods to discuss synthetic and bridge methods
- Resolved