The string returned by toString() shows the bridge methods as having the volatile modificator.
Run the following code:
import java.lang.reflect.Method;
public class BridgeMethodTest {
public static void main(String[] args) throws ClassNotFoundException {
Class cl = Class.forName("java.lang.String");
for(Method m : cl.getDeclaredMethods()) {
if (m.isBridge())
System.out.println(m);
}
}
}
The result is:
public volatile int java.lang.String.compareTo(java.lang.Object)
Run the following code:
import java.lang.reflect.Method;
public class BridgeMethodTest {
public static void main(String[] args) throws ClassNotFoundException {
Class cl = Class.forName("java.lang.String");
for(Method m : cl.getDeclaredMethods()) {
if (m.isBridge())
System.out.println(m);
}
}
}
The result is:
public volatile int java.lang.String.compareTo(java.lang.Object)
- duplicates
-
JDK-6354476 (reflect) {Method, Constructor}.toString prints out inappropriate modifiers
- Resolved