As stated in this Java Tutorial a bridge method implies that it is also a synthetic method. The question is, is it possible that invocation of isSynthetic
method returns true but isBridge
method returns false for a Method
object, i.e., if a method is synthetic does it imply that it is also a bridge method?
It's not exactly the same but the source code for isSynthetic
and isBridge
methods looks like below:
static final int SYNTHETIC = 0x00001000;
public boolean isSynthetic() {
return (getModifiers() & SYNTHETIC) != 0;
}
static final int BRIDGE = 0x00000040;
public boolean isBridge() {
return (getModifiers() & BRIDGE) != 0;
}
Why isBridge
method body is not like return isSynthetic();
?
Copyright Notice:Content Author:「Görkem Mülayim」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/47630572/java-synthetic-method-and-bridge-method-confusion