jnr / jnr-posix

Java Posix layer
Other
237 stars 91 forks source link

Java 8 breakage #76

Open nsayer opened 7 years ago

nsayer commented 7 years ago

We use jnr-posix to relinquish root privileges after opening server sockets (that is, listening sockets < 1024). With java 8, we get

java.lang.IllegalStateException: getpwnam unimplemented is not implemented in jnr-posix at jnr.posix.util.DefaultPOSIXHandler.unimplementedError(DefaultPOSIXHandler.java:28) at jnr.posix.JavaPOSIX.getpwnam(JavaPOSIX.java:176) at jnr.posix.LazyPOSIX.getpwnam(LazyPOSIX.java:198)

This worked fine in previous JREs.

nsayer commented 7 years ago

Our code is fairly straightforward:

POSIX posix = POSIXFactory.getPOSIX(); Passwd pwd = posix.getpwnam(user);

That last line is the one that throws the exception.

headius commented 7 years ago

That's very strange. It is possible that changed Java method dispatch rules in Java 8 are causing to to call a wrong overload? We use getpwnam in JRuby on Java 8 and it works fine.

nsayer commented 7 years ago

Bueller?

headius commented 7 years ago

There isn't really a way to implement this in the pure Java code. Are you disabling the native version for some reason? Or perhaps on your platform it stop loading correctly?

I don't know why we would have broken this on purpose, so I suspect it was never implemented.

nsayer commented 7 years ago

We're not doing anything particular to prevent the native code running. The only difference is the JDK version.