{"action":"created","issue":{"url":"https://api.github.com/repos/ceylon/ceylon-compiler/issues/2419","labels_url":"https://api.github.com/repos/ceylon/ceylon-compiler/issues/2419/labels{/name}","comments_url":"https://api.github.com/repos/ceylon/ceylon-compiler/issues/2419/comments","events_url":"https://api.github.com/repos/ceylon/ceylon-compiler/issues/2419/events","html_url":"https://github.com/ceylon/ceylon-compiler/issues/2419","id":115628172,"number":2419,"title":"Investigate replacing `File.getCanonicalPath` with `Path.getRealPath()`","user":{"login":"quintesse","id":778793,"avatar_url":"https://avatars.githubusercontent.com/u/778793?v=3","gravatar_id":"","url":"https://api.github.com/users/quintesse","html_url":"https://github.com/quintesse","followers_url":"https://api.github.com/users/quintesse/followers","following_url":"https://api.github.com/users/quintesse/following{/other_user}","gists_url":"https://api.github.com/users/quintesse/gists{/gist_id}","starred_url":"https://api.github.com/users/quintesse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quintesse/subscriptions","organizations_url":"https://api.github.com/users/quintesse/orgs","repos_url":"https://api.github.com/users/quintesse/repos","events_url":"https://api.github.com/users/quintesse/events{/privacy}","received_events_url":"https://api.github.com/users/quintesse/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ceylon/ceylon-compiler/labels/refactoring","name":"refactoring","color":"CAFEBA"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/ceylon/ceylon-compiler/milestones/10","html_url":"https://github.com/ceylon/ceylon-compiler/milestones/1.3","labels_url":"https://api.github.com/repos/ceylon/ceylon-compiler/milestones/10/labels","id":429513,"number":10,"title":"1.3","description":"","creator":{"login":"tombentley","id":879487,"avatar_url":"https://avatars.githubusercontent.com/u/879487?v=3","gravatar_id":"","url":"https://api.github.com/users/tombentley","html_url":"https://github.com/tombentley","followers_url":"https://api.github.com/users/tombentley/followers","following_url":"https://api.github.com/users/tombentley/following{/other_user}","gists_url":"https://api.github.com/users/tombentley/gists{/gist_id}","starred_url":"https://api.github.com/users/tombentley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tombentley/subscriptions","organizations_url":"https://api.github.com/users/tombentley/orgs","repos_url":"https://api.github.com/users/tombentley/repos","events_url":"https://api.github.com/users/tombentley/events{/privacy}","received_events_url":"https://api.github.com/users/tombentley/received_events","type":"User","site_admin":false},"open_issues":206,"closed_issues":13,"state":"open","created_at":"2013-09-17T08:27:05Z","updated_at":"2015-11-07T03:00:04Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2015-11-07T02:57:42Z","updated_at":"2015-11-07T03:48:50Z","closed_at":null,"body":"See #2416 but in short @lukehutch mentioned:\r\n\r\n\"As an example of what could go wrong, imagine a project root at MyProject/source that has a symlink from MyProject/source/com/xyz/package to MyOtherProject/source/com/xyz/package. Calling getCanonicalPath() will cause the source links to be based in MyOtherProject, while the source root is still in MyProject (because the source root occurs above the symlink).\r\n\r\nI think the right thing to do is to never follow symlinks when absolutizing paths. You still need to handle \"..\" etc.\r\n\r\nThe \"One Right Way\" to handle paths in JDK >= 1.7 is using Path, not File. I recently switched a bunch of my own code from File to Path, and it's significantly nicer, more robust, more portable and safer to do things the Path way.\r\n\r\nIn this case, I think what you want is Path.toRealPath(LinkOption.NOFOLLOW_LINKS).\"\r\n"},"comment":{"url":"https://api.github.com/repos/ceylon/ceylon-compiler/issues/comments/154614239","html_url":"https://github.com/ceylon/ceylon-compiler/issues/2419#issuecomment-154614239","issue_url":"https://api.github.com/repos/ceylon/ceylon-compiler/issues/2419","id":154614239,"user":{"login":"lukehutch","id":811305,"avatar_url":"https://avatars.githubusercontent.com/u/811305?v=3","gravatar_id":"","url":"https://api.github.com/users/lukehutch","html_url":"https://github.com/lukehutch","followers_url":"https://api.github.com/users/lukehutch/followers","following_url":"https://api.github.com/users/lukehutch/following{/other_user}","gists_url":"https://api.github.com/users/lukehutch/gists{/gist_id}","starred_url":"https://api.github.com/users/lukehutch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukehutch/subscriptions","organizations_url":"https://api.github.com/users/lukehutch/orgs","repos_url":"https://api.github.com/users/lukehutch/repos","events_url":"https://api.github.com/users/lukehutch/events{/privacy}","received_events_url":"https://api.github.com/users/lukehutch/received_events","type":"User","site_admin":false},"created_at":"2015-11-07T03:48:50Z","updated_at":"2015-11-07T03:48:50Z","body":"I just realized my own project [FastClasspathScanner](https://github.com/lukehutch/fast-classpath-scanner) has this same bug, where it resolved symlinks, and then tried to resolve paths relative to each other while expecting that the paths had not jumped to somewhere else in the file hierarchy. (Had to add NOFOLLOW_LINKS there.)"}}