Hi,

I've attached a lightly tested patch for this.

It seems that the Native2AsciiAdapterFactory was returning the Sun
implementation by default.

-- 
Anuradha Weeraman
http://www.linux.lk/~anu/
http://anuradha.wordpress.com
diff -Naur ant-1.7/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/KaffeNative2Ascii.java ant-1.7.0.native2ascii.fix/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/KaffeNative2Ascii.java
--- ant-1.7/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/KaffeNative2Ascii.java	2006-12-13 07:16:23.000000000 -0500
+++ ant-1.7.0.native2ascii.fix/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/KaffeNative2Ascii.java	2008-03-12 00:02:57.000000000 -0400
@@ -33,6 +33,7 @@
     // 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 -Naur ant-1.7/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/Native2AsciiAdapterFactory.java ant-1.7.0.native2ascii.fix/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/Native2AsciiAdapterFactory.java
--- ant-1.7/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/Native2AsciiAdapterFactory.java	2006-12-13 07:16:20.000000000 -0500
+++ ant-1.7.0.native2ascii.fix/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/Native2AsciiAdapterFactory.java	2008-03-11 23:28:28.000000000 -0400
@@ -38,7 +38,7 @@
      * vendor
      */
     public static String getDefault() {
-        if (JavaEnvUtils.isKaffe()) {
+        if (JavaEnvUtils.isKaffe() || JavaEnvUtils.isGcj()) {
             return KaffeNative2Ascii.IMPLEMENTATION_NAME;
         }
         return SunNative2Ascii.IMPLEMENTATION_NAME;
@@ -57,7 +57,7 @@
     public static Native2AsciiAdapter getAdapter(String choice,
                                                  ProjectComponent log)
         throws BuildException {
-        if ((JavaEnvUtils.isKaffe() && choice == null)
+        if (((JavaEnvUtils.isKaffe() || JavaEnvUtils.isGcj()) && choice == null)
             || KaffeNative2Ascii.IMPLEMENTATION_NAME.equals(choice)) {
             return new KaffeNative2Ascii();
         } else if (SunNative2Ascii.IMPLEMENTATION_NAME.equals(choice)) {
diff -Naur ant-1.7/src/main/org/apache/tools/ant/util/JavaEnvUtils.java ant-1.7.0.native2ascii.fix/src/main/org/apache/tools/ant/util/JavaEnvUtils.java
--- ant-1.7/src/main/org/apache/tools/ant/util/JavaEnvUtils.java	2006-12-13 07:16:19.000000000 -0500
+++ ant-1.7.0.native2ascii.fix/src/main/org/apache/tools/ant/util/JavaEnvUtils.java	2008-03-11 23:29:47.000000000 -0400
@@ -73,6 +73,9 @@
     /** Whether this is the Kaffe VM */
     private static boolean kaffeDetected;
 
+    /** Whether this is the GCJ VM */
+    private static boolean gcjDetected;
+
     /** array of packages in the runtime */
     private static Vector jrePackages;
 
@@ -119,6 +122,14 @@
         } catch (Throwable t) {
             // swallow as this simply doesn't seem to be Kaffe
         }
+
+		gcjDetected = false;
+        try {
+            Class.forName("gnu.gcj.Core");
+            gcjDetected = true;
+        } catch (Throwable t) {
+            // swallow as this simply doesn't seem to be GCJ
+        }
     }
 
     /**
@@ -180,6 +191,16 @@
     }
 
     /**
+     * Checks whether the current Java VM is GCJ.
+     * @return true if the current Java VM is GCJ.
+     * @since Ant 1.7.0
+     * @see <a href="http://gcc.gnu.org/java/";>http://gcc.gnu.org/java/</a>
+     */
+    public static boolean isGcj() {
+        return gcjDetected;
+    }
+
+    /**
      * Finds an executable that is part of a JRE installation based on
      * the java.home system property.
      *
_______________________________________________
pkg-java-maintainers mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/pkg-java-maintainers

Reply via email to