From 58a2039b5add57f3f44226441eb50a125803d103 Mon Sep 17 00:00:00 2001 From: Antoine Levy-Lambert Date: Mon, 6 May 2013 02:21:56 +0000 Subject: [PATCH] Debian patch for GNU Classpath, contributed by Emmanuel Bourg. Bugzilla PR 54760 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1479454 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 3 +++ .../native2ascii/KaffeNative2Ascii.java | 2 +- .../Native2AsciiAdapterFactory.java | 4 ++-- .../apache/tools/ant/util/JavaEnvUtils.java | 20 +++++++++++++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index dee636274..138baa622 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -175,6 +175,9 @@ Other changes: This will be useful to use the contains selector if the encoding of the VM is different from the encoding of the files being selected. + * support for GNU Classpath. + Bugzilla report 54760. + Changes from Ant 1.8.3 TO Ant 1.8.4 =================================== diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/KaffeNative2Ascii.java b/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/KaffeNative2Ascii.java index cd4d36a8b..da4836fde 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/KaffeNative2Ascii.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/KaffeNative2Ascii.java @@ -32,7 +32,7 @@ public final class KaffeNative2Ascii extends DefaultNative2Ascii { // sorted by newest Kaffe version first private static final String[] N2A_CLASSNAMES = new String[] { - "gnu.classpath.tools.native2ascii.Native2Ascii", + "gnu.classpath.tools.native2ascii.Native2ASCII", // pre Kaffe 1.1.5 "kaffe.tools.native2ascii.Native2Ascii", }; diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/Native2AsciiAdapterFactory.java b/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/Native2AsciiAdapterFactory.java index e60a4b0c8..ae4190395 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/Native2AsciiAdapterFactory.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/Native2AsciiAdapterFactory.java @@ -40,7 +40,7 @@ public class Native2AsciiAdapterFactory { * vendor */ public static String getDefault() { - if (JavaEnvUtils.isKaffe()) { + if (JavaEnvUtils.isKaffe() || JavaEnvUtils.isClasspathBased()) { return KaffeNative2Ascii.IMPLEMENTATION_NAME; } return SunNative2Ascii.IMPLEMENTATION_NAME; @@ -79,7 +79,7 @@ public class Native2AsciiAdapterFactory { ProjectComponent log, Path classpath) throws BuildException { - if ((JavaEnvUtils.isKaffe() && choice == null) + if (((JavaEnvUtils.isKaffe() || JavaEnvUtils.isClasspathBased()) && choice == null) || KaffeNative2Ascii.IMPLEMENTATION_NAME.equals(choice)) { return new KaffeNative2Ascii(); } else if (SunNative2Ascii.IMPLEMENTATION_NAME.equals(choice)) { diff --git a/src/main/org/apache/tools/ant/util/JavaEnvUtils.java b/src/main/org/apache/tools/ant/util/JavaEnvUtils.java index eb416688d..90d4cc886 100644 --- a/src/main/org/apache/tools/ant/util/JavaEnvUtils.java +++ b/src/main/org/apache/tools/ant/util/JavaEnvUtils.java @@ -101,6 +101,10 @@ public final class JavaEnvUtils { /** Whether this is the Kaffe VM */ private static boolean kaffeDetected; + + /** Wheter this is a GNU Classpath based VM */ + private static boolean classpathDetected; + /** Whether this is the GNU VM (gcj/gij) */ private static boolean gijDetected; @@ -159,6 +163,13 @@ public final class JavaEnvUtils { } catch (Throwable t) { // swallow as this simply doesn't seem to be Kaffe } + classpathDetected = false; + try { + Class.forName("gnu.classpath.Configuration"); + classpathDetected = true; + } catch (Throwable t) { + // swallow as this simply doesn't seem to be GNU classpath based. + } gijDetected = false; try { Class.forName("gnu.gcj.Core"); @@ -233,6 +244,15 @@ public final class JavaEnvUtils { return kaffeDetected; } + /** + * Checks whether the current Java VM is GNU Classpath + * @since Ant 1.9.1 + * @return true if the version of Java is GNU Classpath + */ + public static boolean isClasspathBased() { + return classpathDetected; + } + /** * Checks whether the current Java VM is the GNU interpreter gij * or we are running in a gcj precompiled binary.