List of usage examples for java.lang LinkageError printStackTrace
public void printStackTrace(PrintStream s)
From source file:hudson.Util.java
/** * Creates a symlink to baseDir+targetPath at baseDir+symlinkPath. * <p>// w w w . ja va2s. c o m * If there's a prior symlink at baseDir+symlinkPath, it will be overwritten. * * @param baseDir * Base directory to resolve the 'symlinkPath' parameter. * @param targetPath * The file that the symlink should point to. * @param symlinkPath * Where to create a symlink in. */ public static void createSymlink(File baseDir, String targetPath, String symlinkPath, TaskListener listener) throws InterruptedException { if (Functions.isWindows() || NO_SYMLINK) return; try { String errmsg = ""; // if a file or a directory exists here, delete it first. // try simple delete first (whether exists() or not, as it may be symlink pointing // to non-existent target), but fallback to "rm -rf" to delete non-empty dir. File symlinkFile = new File(baseDir, symlinkPath); if (!symlinkFile.delete() && symlinkFile.exists()) // ignore a failure. new LocalProc(new String[] { "rm", "-rf", symlinkPath }, new String[0], listener.getLogger(), baseDir).join(); int r; if (!SYMLINK_ESCAPEHATCH) { try { r = LIBC.symlink(targetPath, symlinkFile.getAbsolutePath()); if (r != 0) { r = Native.getLastError(); errmsg = LIBC.strerror(r); } } catch (LinkageError e) { // if JNA is unavailable, fall back. // we still prefer to try JNA first as PosixAPI supports even smaller platforms. r = PosixAPI.get().symlink(targetPath, symlinkFile.getAbsolutePath()); } } else // escape hatch, until we know that the above works well. r = new LocalProc(new String[] { "ln", "-s", targetPath, symlinkPath }, new String[0], listener.getLogger(), baseDir).join(); if (r != 0) listener.getLogger() .println(String.format("ln -s %s %s failed: %d %s", targetPath, symlinkFile, r, errmsg)); } catch (IOException e) { PrintStream log = listener.getLogger(); log.printf("ln %s %s failed\n", targetPath, new File(baseDir, symlinkPath)); Util.displayIOException(e, listener); e.printStackTrace(log); } }
From source file:hudson.Util.java
/** * Creates a symlink to baseDir+targetPath at baseDir+symlinkPath. * <p>/*from ww w . ja v a 2 s .com*/ * If there's a prior symlink at baseDir+symlinkPath, it will be overwritten. * * @param baseDir * Base directory to resolve the 'symlinkPath' parameter. * @param targetPath * The file that the symlink should point to. * @param symlinkPath * Where to create a symlink in. */ public static void createSymlink(File baseDir, String targetPath, String symlinkPath, TaskListener listener) throws InterruptedException { if (Functions.isWindows() || NO_SYMLINK) return; try { String errmsg = ""; // if a file or a directory exists here, delete it first. // try simple delete first (whether exists() or not, as it may be symlink pointing // to non-existent target), but fallback to "rm -rf" to delete non-empty dir. File symlinkFile = new File(baseDir, symlinkPath); if (!symlinkFile.delete() && symlinkFile.exists()) // ignore a failure. new LocalProc(new String[] { "rm", "-rf", symlinkPath }, new String[0], listener.getLogger(), baseDir).join(); int r; if (!SYMLINK_ESCAPEHATCH) { try { r = LIBC.symlink(targetPath, symlinkFile.getAbsolutePath()); if (r != 0) { r = Native.getLastError(); errmsg = LIBC.strerror(r); } } catch (LinkageError e) { // if JNA is unavailable, fall back. // we still prefer to try JNA first as PosixAPI supports even smaller platforms. r = PosixAPI.get().symlink(targetPath, symlinkFile.getAbsolutePath()); } } else // escape hatch, until we know that the above works well. r = new LocalProc(new String[] { "ln", "-s", targetPath, symlinkPath }, new String[0], listener.getLogger(), baseDir).join(); if (r != 0) listener.getLogger() .println(String.format("ln -s %s %s failed: %d %s", targetPath, symlinkFile, r, errmsg)); } catch (IOException e) { PrintStream log = listener.getLogger(); log.printf("ln %s %s failed%n", targetPath, new File(baseDir, symlinkPath)); Util.displayIOException(e, listener); e.printStackTrace(log); } }
From source file:hudson.Util.java
/** * Creates a symlink to baseDir+targetPath at baseDir+symlinkPath. * <p>// w ww.j a va2 s.c o m * If there's a prior symlink at baseDir+symlinkPath, it will be overwritten. * * @param baseDir * Base directory to resolve the 'symlinkPath' parameter. * @param targetPath * The file that the symlink should point to. * @param symlinkPath * Where to create a symlink in. */ public static void createSymlink(File baseDir, String targetPath, String symlinkPath, TaskListener listener) throws InterruptedException { if (Functions.isWindows() || NO_SYMLINK) return; try { String errmsg = ""; // if a file or a directory exists here, delete it first. // try simple delete first (whether exists() or not, as it may be symlink pointing // to non-existent target), but fallback to "rm -rf" to delete non-empty dir. File symlinkFile = new File(baseDir, symlinkPath); if (!symlinkFile.delete() && symlinkFile.exists()) // ignore a failure. new LocalProc(new String[] { "rm", "-rf", symlinkPath }, new String[0], listener.getLogger(), baseDir).join(); Integer r = null; if (!SYMLINK_ESCAPEHATCH) { try { r = LIBC.symlink(targetPath, symlinkFile.getAbsolutePath()); if (r != 0) { r = Native.getLastError(); errmsg = LIBC.strerror(r); } } catch (LinkageError e) { // if JNA is unavailable, fall back. // we still prefer to try JNA first as PosixAPI supports even smaller platforms. if (PosixAPI.supportsNative()) { r = PosixAPI.get().symlink(targetPath, symlinkFile.getAbsolutePath()); } } } if (r == null) { // if all else fail, fall back to the most expensive approach of forking a process r = new LocalProc(new String[] { "ln", "-s", targetPath, symlinkPath }, new String[0], listener.getLogger(), baseDir).join(); } if (r != 0) listener.getLogger() .println(String.format("ln -s %s %s failed: %d %s", targetPath, symlinkFile, r, errmsg)); } catch (IOException e) { PrintStream log = listener.getLogger(); log.printf("ln %s %s failed%n", targetPath, new File(baseDir, symlinkPath)); Util.displayIOException(e, listener); e.printStackTrace(log); } }