Skip to content

Commit 07e742f

Browse files
committed
remove deprecated instantiation of wrapper classes for primitives (#3073)
1 parent 3f9b69f commit 07e742f

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

compiler/src/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/GraalHotSpotVMConfigAccess.java

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -376,34 +376,23 @@ public <T> T getFlag(String name, Class<T> type) {
376376
/**
377377
* @see HotSpotVMConfigAccess#getFlag(String, Class, Object)
378378
*/
379-
@SuppressWarnings("deprecation")
380379
public <T> T getFlag(String name, Class<T> type, T notPresent, boolean expectPresent) {
381380
if (expectPresent) {
382381
return getFlag(name, type);
383382
}
383+
// Expecting flag not to be present
384384
if (Assertions.assertionsEnabled()) {
385385
// There's more overhead for checking unexpectedly
386-
// present flag values due to the fact that a VM call
387-
// not exposed by JVMCI is needed to determine whether
388-
// a flag value is available. As such, only pay the
389-
// overhead when running with assertions enabled.
390-
T sentinel;
391-
if (type == Boolean.class) {
392-
sentinel = type.cast(new Boolean(false));
393-
} else if (type == Byte.class) {
394-
sentinel = type.cast(new Byte((byte) 123));
395-
} else if (type == Integer.class) {
396-
sentinel = type.cast(new Integer(1234567890));
397-
} else if (type == Long.class) {
398-
sentinel = type.cast(new Long(1234567890987654321L));
399-
} else if (type == String.class) {
400-
sentinel = type.cast(new String("1234567890987654321"));
401-
} else {
402-
throw new JVMCIError("Unsupported flag type: " + type.getName());
403-
}
404-
T value = access.getFlag(name, type, sentinel);
405-
if (value != sentinel) {
386+
// present flag values due to the fact that private
387+
// JVMCI method (i.e., jdk.vm.ci.hotspot.CompilerToVM.getFlagValue)
388+
// is needed to determine whether a flag value is available.
389+
// As such, only incur the overhead when running with assertions enabled.
390+
try {
391+
T value = access.getFlag(name, type, null);
392+
// Flag value present -> fail
406393
recordError(name, unexpected, String.valueOf(value));
394+
} catch (JVMCIError e) {
395+
// Flag value not present -> pass
407396
}
408397
}
409398
return access.getFlag(name, type, notPresent);

0 commit comments

Comments
 (0)