Remove jna-posix (#5560)

This commit is contained in:
Basil Crow authored and GitHub committed 2021-06-19 12:02:39 +08:00
1 parent ec4c70069b
commit 36528c1a7c
5 files changed
+6 -132

No files matched your search

-5
View File
@@ -103,11 +103,6 @@ THE SOFTWARE.
<groupId>org.connectbot.jbcrypt</groupId>
<artifactId>jbcrypt</artifactId>
</dependency>
<dependency> <!-- for compatibility only; all new code should use JNR. Not included into BOM due to the same reason -->
<groupId>org.jruby.ext.posix</groupId>
<artifactId>jna-posix</artifactId>
<version>1.0.3-jenkins-1</version>
</dependency>
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-posix</artifactId>
+2 -101
View File
@@ -1,10 +1,5 @@
package hudson.os;
import java.io.File;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Map;
import java.util.logging.Logger;
import jnr.constants.platform.Errno;
import jnr.posix.POSIX;
import jnr.posix.POSIXFactory;
@@ -12,7 +7,6 @@ import jnr.posix.util.DefaultPOSIXHandler;
/**
* POSIX API wrapper.
* Formerly used the jna-posix library, but this has been superseded by jnr-posix.
* @author Kohsuke Kawaguchi
*/
public class PosixAPI {
@@ -30,106 +24,13 @@ public class PosixAPI {
if (posix == null) {
posix = POSIXFactory.getPOSIX(new DefaultPOSIXHandler() {
@Override public void error(Errno error, String extraData) {
throw new PosixException("native error " + error.description() + " " + extraData, convert(error));
throw new PosixException("native error " + error.description() + " " + extraData);
}
@Override public void error(Errno error, String methodName, String extraData) {
throw new PosixException("native error calling " + methodName + ": " + error.description() + " " + extraData, convert(error));
}
private org.jruby.ext.posix.POSIX.ERRORS convert(Errno error) {
try {
return org.jruby.ext.posix.POSIX.ERRORS.valueOf(error.name());
} catch (IllegalArgumentException x) {
return org.jruby.ext.posix.POSIX.ERRORS.EIO; // PosixException.message has real error anyway
}
throw new PosixException("native error calling " + methodName + ": " + error.description() + " " + extraData);
}
}, true);
}
return posix;
}
/**
* @deprecated use {@link #jnr} and {@link POSIX#isNative}
*/
@Deprecated
public boolean isNative() {
return supportsNative();
}
/**
* @deprecated use {@link #jnr} and {@link POSIX#isNative}
*/
@Deprecated
public static boolean supportsNative() {
return !(jnaPosix instanceof org.jruby.ext.posix.JavaPOSIX);
}
private static org.jruby.ext.posix.POSIX jnaPosix;
/** @deprecated Use {@link #jnr} instead. */
@Deprecated
public static synchronized org.jruby.ext.posix.POSIX get() {
if (jnaPosix == null) {
jnaPosix = org.jruby.ext.posix.POSIXFactory.getPOSIX(new org.jruby.ext.posix.POSIXHandler() {
@Override
public void error(org.jruby.ext.posix.POSIX.ERRORS errors, String s) {
throw new PosixException(s,errors);
}
@Override
public void unimplementedError(String s) {
throw new UnsupportedOperationException(s);
}
@Override
public void warn(WARNING_ID warning_id, String s, Object... objects) {
LOGGER.fine(s);
}
@Override
public boolean isVerbose() {
return true;
}
@Override
public File getCurrentWorkingDirectory() {
return new File(".").getAbsoluteFile();
}
@Override
public String[] getEnv() {
Map<String,String> envs = System.getenv();
String[] envp = new String[envs.size()];
int i = 0;
for (Map.Entry<String,String> e : envs.entrySet()) {
envp[i++] = e.getKey()+'+'+e.getValue();
}
return envp;
}
@Override
public InputStream getInputStream() {
return System.in;
}
@Override
public PrintStream getOutputStream() {
return System.out;
}
@Override
public int getPID() {
// TODO
return 0;
}
@Override
public PrintStream getErrorStream() {
return System.err;
}
}, true);
}
return jnaPosix;
}
private static final Logger LOGGER = Logger.getLogger(PosixAPI.class.getName());
}
@@ -1,28 +1,17 @@
package hudson.os;
import org.jruby.ext.posix.POSIX.ERRORS;
/**
* Indicates an error during POSIX API call.
* @see PosixAPI
* @author Kohsuke Kawaguchi
*/
public class PosixException extends RuntimeException {
private final ERRORS errors;
public PosixException(String message, ERRORS errors) {
public PosixException(String message) {
super(message);
this.errors = errors;
}
/** @deprecated Leaks reference to deprecated jna-posix API. */
@Deprecated
public ERRORS getErrorCode() {
return errors;
}
@Override
public String toString() {
return super.toString()+" "+errors;
public PosixException(String message, Throwable cause) {
super(message, cause);
}
}
+1 -3
View File
@@ -141,9 +141,7 @@ public class IOUtils {
return Util.permissionsToMode(Files.getPosixFilePermissions(fileToPath(f)));
}
} catch (IOException cause) {
PosixException e = new PosixException("Unable to get file permissions", null);
e.initCause(cause);
throw e;
throw new PosixException("Unable to get file permissions", cause);
}
}
-9
View File
@@ -81,13 +81,4 @@ complete {
match("net.jcip:jcip-annotations") {
rewriteLicense([],ccby)
}
//
// Choose from multi-licensed modules
//==========================================================================
match("*:jna-posix") {
accept("GNU Lesser General Public License Version 2.1")
}
}