mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8268124: Update java.lang to use switch expressions
Reviewed-by: naoto, darcy, mchung, iris, lancea, dfuchs
This commit is contained in:
parent
a187fcc3ec
commit
d43c8a74b3
22 changed files with 421 additions and 551 deletions
|
@ -313,20 +313,22 @@ final class MemberName implements Member, Cloneable {
|
|||
/*non-public*/
|
||||
boolean referenceKindIsConsistentWith(int originalRefKind) {
|
||||
int refKind = getReferenceKind();
|
||||
if (refKind == originalRefKind) return true;
|
||||
switch (originalRefKind) {
|
||||
case REF_invokeInterface:
|
||||
// Looking up an interface method, can get (e.g.) Object.hashCode
|
||||
assert(refKind == REF_invokeVirtual ||
|
||||
refKind == REF_invokeSpecial) : this;
|
||||
return true;
|
||||
case REF_invokeVirtual:
|
||||
case REF_newInvokeSpecial:
|
||||
// Looked up a virtual, can get (e.g.) final String.hashCode.
|
||||
assert(refKind == REF_invokeSpecial) : this;
|
||||
return true;
|
||||
if (refKind == originalRefKind) return true;
|
||||
if (getClass().desiredAssertionStatus()) {
|
||||
switch (originalRefKind) {
|
||||
case REF_invokeInterface -> {
|
||||
// Looking up an interface method, can get (e.g.) Object.hashCode
|
||||
assert (refKind == REF_invokeVirtual || refKind == REF_invokeSpecial) : this;
|
||||
}
|
||||
case REF_invokeVirtual, REF_newInvokeSpecial -> {
|
||||
// Looked up a virtual, can get (e.g.) final String.hashCode.
|
||||
assert (refKind == REF_invokeSpecial) : this;
|
||||
}
|
||||
default -> {
|
||||
assert (false) : this + " != " + MethodHandleNatives.refKindName((byte) originalRefKind);
|
||||
}
|
||||
}
|
||||
}
|
||||
assert(false) : this+" != "+MethodHandleNatives.refKindName((byte)originalRefKind);
|
||||
return true;
|
||||
}
|
||||
private boolean staticIsConsistent() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue