Skip to content

Commit b09f511

Browse files
committed
Rename isRunningInCI(), improve isCISetToTrue().
1 parent 9f1dd7e commit b09f511

File tree

4 files changed

+17
-18
lines changed

4 files changed

+17
-18
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateUtil.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,17 @@ public class SubstrateUtil {
8282

8383
public static String getArchitectureName() {
8484
String arch = System.getProperty("os.arch");
85-
switch (arch) {
86-
case "x86_64":
87-
arch = "amd64";
88-
break;
89-
case "arm64":
90-
arch = "aarch64";
91-
break;
92-
}
93-
return arch;
85+
return switch (arch) {
86+
case "x86_64" -> "amd64";
87+
case "arm64" -> "aarch64";
88+
default -> arch;
89+
};
9490
}
9591

92+
/*
93+
* [GR-55515]: Accessing isTerminal() reflectively only for 21 JDK compatibility. After dropping
94+
* JDK 21, use it directly.
95+
*/
9696
private static final Method IS_TERMINAL_METHOD = ReflectionUtil.lookupMethod(true, Console.class, "isTerminal");
9797

9898
private static boolean isTTY() {
@@ -111,12 +111,12 @@ private static boolean isTTY() {
111111
}
112112
}
113113

114-
public static boolean isRunningInCI() {
115-
return !isTTY() || isCISet();
114+
public static boolean isNonInteractiveTerminal() {
115+
return isCISetToTrue() || !isTTY();
116116
}
117117

118-
public static boolean isCISet() {
119-
return "true".equals(System.getenv("CI"));
118+
public static boolean isCISetToTrue() {
119+
return Boolean.parseBoolean(System.getenv("CI"));
120120
}
121121

122122
/**

substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/MemoryUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ private static List<String> determineMemoryUsageFlags(Function<Double, String> t
128128

129129
String memoryUsageReason = "unknown";
130130
final boolean isDedicatedMemoryUsage;
131-
if (SubstrateUtil.isCISet()) {
131+
if (SubstrateUtil.isCISetToTrue()) {
132132
isDedicatedMemoryUsage = true;
133133
memoryUsageReason = "$CI set to 'true'";
134134
} else if (isContainerized()) {

substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2504,12 +2504,12 @@ private static boolean isDumbTerm() {
25042504
}
25052505

25062506
private static boolean hasColorSupport() {
2507-
return !isDumbTerm() && !SubstrateUtil.isRunningInCI() && OS.getCurrent() != OS.WINDOWS &&
2507+
return !isDumbTerm() && !SubstrateUtil.isNonInteractiveTerminal() && OS.getCurrent() != OS.WINDOWS &&
25082508
System.getenv("NO_COLOR") == null /* https://no-color.org/ */;
25092509
}
25102510

25112511
private static boolean hasProgressSupport(List<String> imageBuilderArgs) {
2512-
if (isDumbTerm() || SubstrateUtil.isRunningInCI()) {
2512+
if (isDumbTerm() || SubstrateUtil.isNonInteractiveTerminal()) {
25132513
return false;
25142514
}
25152515

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@
107107
import jdk.graal.compiler.util.json.JsonWriter;
108108

109109
public class ProgressReporter implements FeatureSingleton, UnsavedSingleton {
110-
private static final boolean IS_CI = SubstrateUtil.isRunningInCI();
111110
private static final int CHARACTERS_PER_LINE;
112111
private static final String HEADLINE_SEPARATOR;
113112
private static final String LINE_SEPARATOR;
@@ -169,7 +168,7 @@ private enum BuildStage {
169168
}
170169

171170
static {
172-
CHARACTERS_PER_LINE = IS_CI ? ProgressReporterCHelper.MAX_CHARACTERS_PER_LINE : ProgressReporterCHelper.getTerminalWindowColumnsClamped();
171+
CHARACTERS_PER_LINE = SubstrateUtil.isNonInteractiveTerminal() ? ProgressReporterCHelper.MAX_CHARACTERS_PER_LINE : ProgressReporterCHelper.getTerminalWindowColumnsClamped();
173172
HEADLINE_SEPARATOR = Utils.stringFilledWith(CHARACTERS_PER_LINE, "=");
174173
LINE_SEPARATOR = Utils.stringFilledWith(CHARACTERS_PER_LINE, "-");
175174
}

0 commit comments

Comments
 (0)