8297784: Optimize @Stable field for Method.isCallerSensitive

Reviewed-by: redestad, jvernee, alanb
This commit is contained in:
Aleksey Shipilev 2022-12-02 07:29:27 +00:00
parent 11ba7591df
commit 9bbcb546c8

View file

@ -605,13 +605,17 @@ public final class Method extends Executable {
return callerSensitive ? ma.invoke(obj, args, caller) : ma.invoke(obj, args);
}
@Stable private Boolean callerSensitive; // lazily initialize
// 0 = not initialized (@Stable contract)
// 1 = initialized, CS
// -1 = initialized, not CS
@Stable private byte callerSensitive;
private boolean isCallerSensitive() {
Boolean cs = callerSensitive;
if (cs == null) {
callerSensitive = cs = Reflection.isCallerSensitive(this);
byte cs = callerSensitive;
if (cs == 0) {
callerSensitive = cs = (byte)(Reflection.isCallerSensitive(this) ? 1 : -1);
}
return cs;
return (cs > 0);
}
/**