diff --git a/aQute.libg/src/aQute/lib/io/IO.java b/aQute.libg/src/aQute/lib/io/IO.java index e5b25e243e..98f22d40a3 100644 --- a/aQute.libg/src/aQute/lib/io/IO.java +++ b/aQute.libg/src/aQute/lib/io/IO.java @@ -22,13 +22,12 @@ import java.io.StringWriter; import java.io.UnsupportedEncodingException; import java.io.Writer; -import java.lang.reflect.Array; -import java.lang.reflect.Method; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.nio.ByteBuffer; +import java.nio.file.Files; import java.security.MessageDigest; import java.util.Collection; import java.util.LinkedHashSet; @@ -628,15 +627,8 @@ public static PrintWriter writer(OutputStream out) throws IOException { */ public static boolean createSymbolicLink(File link, File target) throws Exception { try { - Method toPath = link.getClass().getMethod("toPath"); - Class< ? > Files = Class.forName("java.nio.file.Files"); - for (Method m : Files.getMethods()) { - if (m.getName().equals("createSymbolicLink") && m.getParameterTypes().length == 3) { - Object attrs = Array.newInstance(m.getParameterTypes()[2].getComponentType(), 0); - m.invoke(null, toPath.invoke(link), toPath.invoke(target), attrs); - return true; - } - } + Files.createSymbolicLink(link.toPath(), target.toPath()); + return true; } catch (Exception e) { // ignore } @@ -644,15 +636,7 @@ public static boolean createSymbolicLink(File link, File target) throws Exceptio } public static boolean isSymbolicLink(File link) { - try { - Method toPath = link.getClass().getMethod("toPath"); - Class< ? > Files = Class.forName("java.nio.file.Files"); - Method method = Files.getMethod("isSymbolicLink", toPath.getReturnType()); - return (Boolean) method.invoke(null, toPath.invoke(link)); - } catch (Exception e) { - // ignore - } - return false; + return Files.isSymbolicLink(link.toPath()); } static public OutputStream nullStream = new OutputStream() { diff --git a/biz.aQute.bndlib/src/aQute/bnd/util/repository/DownloadListenerPromise.java b/biz.aQute.bndlib/src/aQute/bnd/util/repository/DownloadListenerPromise.java index d401ffd783..66cc23aa37 100644 --- a/biz.aQute.bndlib/src/aQute/bnd/util/repository/DownloadListenerPromise.java +++ b/biz.aQute.bndlib/src/aQute/bnd/util/repository/DownloadListenerPromise.java @@ -28,7 +28,7 @@ public class DownloadListenerPromise implements Success, Failure { /** * Use the promise to signal the Download Listeners - * + * * @param reporter a reporter or null (will use a SLF4 in that case) * @param task * @param promise @@ -50,7 +50,7 @@ public Promise call(Promise resolved) throws Exception { File file = resolved.getValue(); if (linked != null) { - Files.createLink(linked.toPath(), file.toPath()); + Files.createSymbolicLink(linked.toPath(), file.toPath()); } for (DownloadListener dl : dls) { diff --git a/biz.aQute.repository/src/aQute/bnd/repository/p2/provider/P2Indexer.java b/biz.aQute.repository/src/aQute/bnd/repository/p2/provider/P2Indexer.java index b509d86266..47ed62ebf8 100644 --- a/biz.aQute.repository/src/aQute/bnd/repository/p2/provider/P2Indexer.java +++ b/biz.aQute.repository/src/aQute/bnd/repository/p2/provider/P2Indexer.java @@ -96,7 +96,8 @@ File get(String bsn, Version version, Map properties, DownloadLis final File link = new File(location, bsn + "-" + version + ".jar"); if (link.isFile()) Files.delete(link.toPath()); - Files.createLink(link.toPath(), source.toPath()); + + Files.createSymbolicLink(link.toPath(), source.toPath()); Promise go = client.build().useCache(MAX_STALE).async(url.toURL()).map(new Function() { @Override