8338979: Avoid bootstrapped switches in the classfile API
Reviewed-by: liach, asotona
This commit is contained in:
parent
20d8f58c92
commit
e63418ee01
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -83,17 +83,28 @@ public record ClassFileImpl(StackMapsOption stackMapsOption,
|
||||
var chro = classHierarchyResolverOption;
|
||||
var amo = attributeMapperOption;
|
||||
for (var o : options) {
|
||||
switch (o) {
|
||||
case StackMapsOption oo -> smo = oo;
|
||||
case DebugElementsOption oo -> deo = oo;
|
||||
case LineNumbersOption oo -> lno = oo;
|
||||
case AttributesProcessingOption oo -> apo = oo;
|
||||
case ConstantPoolSharingOption oo -> cpso = oo;
|
||||
case ShortJumpsOption oo -> sjo = oo;
|
||||
case DeadCodeOption oo -> dco = oo;
|
||||
case DeadLabelsOption oo -> dlo = oo;
|
||||
case ClassHierarchyResolverOption oo -> chro = oo;
|
||||
case AttributeMapperOption oo -> amo = oo;
|
||||
if (o instanceof StackMapsOption oo) {
|
||||
smo = oo;
|
||||
} else if (o instanceof DebugElementsOption oo) {
|
||||
deo = oo;
|
||||
} else if (o instanceof LineNumbersOption oo) {
|
||||
lno = oo;
|
||||
} else if (o instanceof AttributesProcessingOption oo) {
|
||||
apo = oo;
|
||||
} else if (o instanceof ConstantPoolSharingOption oo) {
|
||||
cpso = oo;
|
||||
} else if (o instanceof ShortJumpsOption oo) {
|
||||
sjo = oo;
|
||||
} else if (o instanceof DeadCodeOption oo) {
|
||||
dco = oo;
|
||||
} else if (o instanceof DeadLabelsOption oo) {
|
||||
dlo = oo;
|
||||
} else if (o instanceof ClassHierarchyResolverOption oo) {
|
||||
chro = oo;
|
||||
} else if (o instanceof AttributeMapperOption oo) {
|
||||
amo = oo;
|
||||
} else { // null or unknown Option type
|
||||
throw new IllegalArgumentException("Invalid option: " + o);
|
||||
}
|
||||
}
|
||||
return new ClassFileImpl(smo, deo, lno, apo, cpso, sjo, dco, dlo, chro, amo);
|
||||
|
@ -161,13 +161,14 @@ public class StackMapDecoder {
|
||||
|
||||
private static void writeTypeInfo(BufWriterImpl bw, VerificationTypeInfo vti) {
|
||||
bw.writeU1(vti.tag());
|
||||
switch (vti) {
|
||||
case SimpleVerificationTypeInfo svti ->
|
||||
switch (vti.tag()) {
|
||||
case VT_TOP, VT_INTEGER, VT_FLOAT, VT_DOUBLE, VT_LONG, VT_NULL, VT_UNINITIALIZED_THIS ->
|
||||
{}
|
||||
case ObjectVerificationTypeInfo ovti ->
|
||||
bw.writeIndex(ovti.className());
|
||||
case UninitializedVerificationTypeInfo uvti ->
|
||||
bw.writeU2(bw.labelContext().labelToBci(uvti.newTarget()));
|
||||
case VT_OBJECT ->
|
||||
bw.writeIndex(((ObjectVerificationTypeInfo)vti).className());
|
||||
case VT_UNINITIALIZED ->
|
||||
bw.writeU2(bw.labelContext().labelToBci(((UninitializedVerificationTypeInfo)vti).newTarget()));
|
||||
default -> throw new IllegalArgumentException("Invalid verification type tag: " + vti.tag());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user