Skip to content

Commit 8a06b55

Browse files
committed
[GR-68157] Do not use CompilerDirectives.shouldNotReachHere before Truffle runtime is created.
PullRequest: graal/21769
2 parents fca0ddb + 2ed1d93 commit 8a06b55

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/InternalResource.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ private void copyResource(Path source, Path target, Set<PosixFilePermission> att
400400
String resourceName = getResourceName(source);
401401
Path parent = target.getParent();
402402
if (parent == null) {
403-
throw CompilerDirectives.shouldNotReachHere("RelativeResourcePath must be non-empty.");
403+
throw new AssertionError("RelativeResourcePath must be non-empty.");
404404
}
405405
Files.createDirectories(parent);
406406
try (BufferedInputStream in = new BufferedInputStream(getResourceStream(resourceName))) {
@@ -546,7 +546,7 @@ public String toString() {
546546
public static OS getCurrent() {
547547
String os = System.getProperty("os.name");
548548
if (os == null) {
549-
throw CompilerDirectives.shouldNotReachHere("The 'os.name' system property is not set.");
549+
throw new AssertionError("The 'os.name' system property is not set.");
550550
} else if (os.equalsIgnoreCase("linux")) {
551551
return LINUX;
552552
} else if (os.equalsIgnoreCase("mac os x") || os.equalsIgnoreCase("darwin")) {
@@ -620,7 +620,7 @@ public String toString() {
620620
public static CPUArchitecture getCurrent() {
621621
String arch = System.getProperty("os.arch");
622622
if (arch == null) {
623-
throw CompilerDirectives.shouldNotReachHere("The 'os.arch' system property is not set.");
623+
throw new AssertionError("The 'os.arch' system property is not set.");
624624
}
625625
return switch (arch) {
626626
case "amd64", "x86_64" -> AMD64;

truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/InternalResourceCache.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
import org.graalvm.nativeimage.c.function.CEntryPointLiteral;
8282
import org.graalvm.nativeimage.c.function.CFunctionPointer;
8383

84-
import com.oracle.truffle.api.CompilerDirectives;
8584
import com.oracle.truffle.api.InternalResource;
8685
import com.oracle.truffle.api.TruffleOptions;
8786
import com.oracle.truffle.api.provider.InternalResourceProvider;
@@ -176,7 +175,7 @@ void initializeOwningRoot(InternalResourceRoots.Root root) {
176175
case RESOURCE -> InternalResourceRoots.overriddenResourceRootProperty(id, resourceId) + " system property";
177176
case COMPONENT -> InternalResourceRoots.overriddenComponentRootProperty(id) + " system property";
178177
case UNVERSIONED -> "internal resource cache root directory";
179-
default -> throw CompilerDirectives.shouldNotReachHere(root.kind().name());
178+
default -> throw new AssertionError(root.kind().name());
180179
};
181180
InternalResourceRoots.logInternalResourceEvent("Resolved a pre-created directory for the internal resource %s::%s to: %s, determined by the %s with the value %s.",
182181
id, resourceId, path, hint, root.path());
@@ -231,7 +230,7 @@ private static InternalResource.Env createInternalResourceEnvReflectively(Intern
231230
newEnv.setAccessible(true);
232231
return newEnv.newInstance(resource, (BooleanSupplier) () -> TruffleOptions.AOT);
233232
} catch (ReflectiveOperationException e) {
234-
throw CompilerDirectives.shouldNotReachHere(e);
233+
throw new AssertionError("Failed to instantiate InternalResource.Env", e);
235234
}
236235
}
237236

@@ -252,7 +251,7 @@ private Path installResource(Function<InternalResource, InternalResource.Env> re
252251
InternalResourceRoots.logInternalResourceEvent("Resolved a directory for the internal resource %s::%s to: %s, unpacking resource files.", id, resourceId, target);
253252
Path parent = target.getParent();
254253
if (parent == null) {
255-
throw CompilerDirectives.shouldNotReachHere("Target must have a parent directory but was " + target);
254+
throw new AssertionError("Target must have a parent directory but was " + target);
256255
}
257256
Path owner = Files.createDirectories(Objects.requireNonNull(parent));
258257
Path tmpDir = Files.createTempDirectory(owner, null);

truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/InternalResourceRoots.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
import org.graalvm.nativeimage.ImageInfo;
5959
import org.graalvm.nativeimage.ProcessProperties;
6060

61-
import com.oracle.truffle.api.CompilerDirectives;
6261
import com.oracle.truffle.api.InternalResource;
6362
import com.oracle.truffle.api.TruffleOptions;
6463

@@ -298,7 +297,7 @@ private static Path getExecutablePath() {
298297
} else if (ImageInfo.isSharedLibrary()) {
299298
path = ProcessProperties.getObjectFile(InternalResourceCacheSymbol.SYMBOL);
300299
} else {
301-
throw CompilerDirectives.shouldNotReachHere("Should only be invoked within native image runtime code.");
300+
throw new AssertionError("Should only be invoked within native image runtime code.");
302301
}
303302
return path == null ? null : Path.of(path);
304303
}
@@ -311,7 +310,7 @@ private static ResolvedCacheFolder findCacheRootDefault() {
311310
}
312311
String userHomeValue = System.getProperty("user.home");
313312
if (userHomeValue == null) {
314-
throw CompilerDirectives.shouldNotReachHere("The 'user.home' system property is not set.");
313+
throw new AssertionError("The 'user.home' system property is not set.");
315314
}
316315
Path userHome = Paths.get(userHomeValue);
317316
ResolvedCacheFolder container = switch (InternalResource.OS.getCurrent()) {

0 commit comments

Comments
 (0)