-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Java 11 breaks chdir() for JavaPOSIX #131
Comments
After reading through JDK 4045688 (again) I'm quite sure that switching the current working directory of a running JVM is considered inherently insecure (and okay, it really is under certain circumstances) and will never be officially supported again in any way. The previously working solution (switch working directory and set "user.dir" accordingly) will no longer work with Java 11 and above, so maybe the "solution" is to let JavaPOSIX return an error code or throw an exception if called (if Java version is > 10). |
Is there any reason JNR can't access the corresponding system call, instead? It is Java Native Runtime. |
@Melab This is in the pure-Java emulation part of jnr-posix. The native logic does actually do a process-level @ickzon Setting It probably would be worth raising a better error for JavaPOSIX.chdir but since it's an error either way on Java 11 it's just moving the error around a bit. Perhaps we can raise something more like an We deal with this in JRuby by always maintaining a per-instance representation of the current directory, and adding logic to all filesystem-related calls to appropriately use that current directory. JDK-4045688 discusses a similar possible change for OpenJDK as being too big of a job (and it is certainly not easy) but it can be done externally by other users of jnr-posix (such as yourself) if you need to simulate a "virtual" CWD. Integrating virtual CWD support into jnr-posix's pure-Java support is probably out of scope since it would require us to provide JDK-equivalent |
@headius Considering I can't even get native POSIX support loaded without Java whining about an unsatisfied link or a missing class definition, I think this project's lack of |
@Melab Without loading the native library, there's no way to force the JVM to do a real chdir. When native support loads, chdir works fine. I'll try to help you in the other issue. |
In Java 11 setting system property "user.dir" doesn't have any effect JDK-8066709.
Now file handling is messed up after changing the working directory:
I'm not sure if there even is a way to get this working again. Maybe I should report that as a bug in the Java specs itself? Oracle will of course close this as "don't change the working directory of a running JVM"...
I'm so pissed how they are currently destroying the Java ecosystem...
The text was updated successfully, but these errors were encountered: