< prev index next >

test/hotspot/jtreg/compiler/lib/ir_framework/test/ApplicableIRRulesPrinter.java

Print this page

457         if (value.isEmpty()) {
458             TestFormat.failNoThrow("Provided empty value for flag " + flag + failAt());
459             return false;
460         }
461         Object actualFlagValue = WHITE_BOX.getBooleanVMFlag(flag);
462         if (actualFlagValue != null) {
463             return checkBooleanFlag(flag, value, (Boolean) actualFlagValue);
464         }
465         actualFlagValue = LONG_GETTERS.stream().map(f -> f.apply(flag)).filter(Objects::nonNull).findAny().orElse(null);
466         if (actualFlagValue != null) {
467             return checkFlag(Long::parseLong, "integer", flag, value, (Long) actualFlagValue);
468         }
469         actualFlagValue = WHITE_BOX.getDoubleVMFlag(flag);
470         if (actualFlagValue != null) {
471             return checkFlag(Double::parseDouble, "floating point", flag, value, (Double) actualFlagValue);
472         }
473         actualFlagValue = WHITE_BOX.getStringVMFlag(flag);
474         if (actualFlagValue != null) {
475             return value.equals(actualFlagValue);
476         }



477 
478         // This could be improved if the Whitebox offers a "isVMFlag" function. For now, just check if we can actually set
479         // a value for a string flag. If we find this value, it's a string flag. If null is returned, the flag is unknown.
480         WHITE_BOX.setStringVMFlag(flag, "test");
481         String stringFlagValue = WHITE_BOX.getStringVMFlag(flag);
482         if (stringFlagValue == null) {
483             TestFormat.failNoThrow("Could not find VM flag \"" + flag + "\"" + failAt());
484             return false;
485         }
486         TestFramework.check(stringFlagValue.equals("test"),
487                          "Must find newly set flag value \"test\" but found " + failAt());
488         WHITE_BOX.setStringVMFlag(flag, null); // reset flag to NULL
489         return false;
490     }
491 
492     private boolean checkBooleanFlag(String flag, String value, boolean actualFlagValue) {
493         boolean booleanValue = false;
494         if ("true".equalsIgnoreCase(value)) {
495             booleanValue = true;
496         } else if (!"false".equalsIgnoreCase(value)) {

457         if (value.isEmpty()) {
458             TestFormat.failNoThrow("Provided empty value for flag " + flag + failAt());
459             return false;
460         }
461         Object actualFlagValue = WHITE_BOX.getBooleanVMFlag(flag);
462         if (actualFlagValue != null) {
463             return checkBooleanFlag(flag, value, (Boolean) actualFlagValue);
464         }
465         actualFlagValue = LONG_GETTERS.stream().map(f -> f.apply(flag)).filter(Objects::nonNull).findAny().orElse(null);
466         if (actualFlagValue != null) {
467             return checkFlag(Long::parseLong, "integer", flag, value, (Long) actualFlagValue);
468         }
469         actualFlagValue = WHITE_BOX.getDoubleVMFlag(flag);
470         if (actualFlagValue != null) {
471             return checkFlag(Double::parseDouble, "floating point", flag, value, (Double) actualFlagValue);
472         }
473         actualFlagValue = WHITE_BOX.getStringVMFlag(flag);
474         if (actualFlagValue != null) {
475             return value.equals(actualFlagValue);
476         }
477         if (flag.equals("enable-valhalla")) {
478             return checkBooleanFlag(flag, value, Integer.class.isValue());
479         }
480 
481         // This could be improved if the Whitebox offers a "isVMFlag" function. For now, just check if we can actually set
482         // a value for a string flag. If we find this value, it's a string flag. If null is returned, the flag is unknown.
483         WHITE_BOX.setStringVMFlag(flag, "test");
484         String stringFlagValue = WHITE_BOX.getStringVMFlag(flag);
485         if (stringFlagValue == null) {
486             TestFormat.failNoThrow("Could not find VM flag \"" + flag + "\"" + failAt());
487             return false;
488         }
489         TestFramework.check(stringFlagValue.equals("test"),
490                          "Must find newly set flag value \"test\" but found " + failAt());
491         WHITE_BOX.setStringVMFlag(flag, null); // reset flag to NULL
492         return false;
493     }
494 
495     private boolean checkBooleanFlag(String flag, String value, boolean actualFlagValue) {
496         boolean booleanValue = false;
497         if ("true".equalsIgnoreCase(value)) {
498             booleanValue = true;
499         } else if (!"false".equalsIgnoreCase(value)) {
< prev index next >