Skip to content

Commit e97caec

Browse files
committed
[GR-62927] Fix optimized runtime stack trace printing does not handle non-file URLs correctly.
PullRequest: graal/20264
2 parents 2630a23 + be4615f commit e97caec

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/OptimizedTruffleRuntime.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import java.lang.annotation.Annotation;
4848
import java.lang.invoke.MethodHandle;
4949
import java.lang.reflect.Method;
50+
import java.net.URL;
5051
import java.nio.Buffer;
5152
import java.nio.file.FileSystems;
5253
import java.nio.file.Path;
@@ -69,6 +70,7 @@
6970
import java.util.logging.Level;
7071
import java.util.stream.Collectors;
7172

73+
import com.oracle.truffle.api.source.Source;
7274
import org.graalvm.collections.EconomicMap;
7375
import org.graalvm.collections.UnmodifiableEconomicMap;
7476
import org.graalvm.home.Version;
@@ -1297,9 +1299,13 @@ private static String formatStackFrame(FrameInstance frameInstance, CallTarget t
12971299
}
12981300

12991301
private static String formatPath(SourceSection sourceSection) {
1300-
if (sourceSection.getSource().getPath() != null) {
1302+
Source source = sourceSection.getSource();
1303+
URL url = source.getURL();
1304+
if (url != null && !"file".equals(url.getProtocol())) {
1305+
return url.toExternalForm();
1306+
} else if (source.getPath() != null) {
13011307
Path path = FileSystems.getDefault().getPath(".").toAbsolutePath();
1302-
Path filePath = FileSystems.getDefault().getPath(sourceSection.getSource().getPath()).toAbsolutePath();
1308+
Path filePath = FileSystems.getDefault().getPath(source.getPath()).toAbsolutePath();
13031309

13041310
try {
13051311
return path.relativize(filePath).toString();

0 commit comments

Comments
 (0)