Skip to content

Commit

Permalink
Fix Thread::Backtrace::Location#absolute_path to return a canonical path
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Jul 9, 2018
1 parent 266203e commit aef7089
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;

import java.io.File;
import java.io.IOException;

import org.jcodings.specific.UTF8Encoding;
import org.truffleruby.Layouts;
import org.truffleruby.RubyContext;
Expand All @@ -25,6 +28,7 @@
import org.truffleruby.core.string.StringNodes;
import org.truffleruby.language.backtrace.Activation;
import org.truffleruby.language.backtrace.Backtrace;
import org.truffleruby.language.control.JavaException;

@CoreClass("Thread::Backtrace::Location")
public class ThreadBacktraceLocationNodes {
Expand All @@ -50,7 +54,13 @@ public DynamicObject absolutePath(DynamicObject threadBacktraceLocation,
if (path == null) {
return coreStrings().UNKNOWN.createInstance();
} else {
return makeStringNode.fromRope(getContext().getPathToRopeCache().getCachedPath(path));
final String canonicalPath;
try {
canonicalPath = new File(path).getCanonicalPath();
} catch (IOException e) {
throw new JavaException(e);
}
return makeStringNode.fromRope(getContext().getPathToRopeCache().getCachedPath(canonicalPath));
}
}

Expand Down

0 comments on commit aef7089

Please sign in to comment.