Package: ant / 1.8.2-4

0001-detect-classpath-based-JVM.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
From: Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>
Date: Thu, 11 Mar 2010 21:50:00 +0100
Subject: [PATCH] detect classpath based JVM

---
 .../optional/native2ascii/KaffeNative2Ascii.java   |    1 +
 .../native2ascii/Native2AsciiAdapterFactory.java   |    4 ++--
 .../org/apache/tools/ant/util/JavaEnvUtils.java    |   14 ++++++++++++++
 3 files changed, 17 insertions(+), 2 deletions(-)

Index: apache-ant-1.8.2/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/KaffeNative2Ascii.java
===================================================================
--- apache-ant-1.8.2.orig/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/KaffeNative2Ascii.java	2010-12-20 18:48:16.000000000 +0000
+++ apache-ant-1.8.2/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/KaffeNative2Ascii.java	2011-05-04 15:19:49.235567112 +0100
@@ -32,6 +32,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",
Index: apache-ant-1.8.2/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/Native2AsciiAdapterFactory.java
===================================================================
--- apache-ant-1.8.2.orig/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/Native2AsciiAdapterFactory.java	2010-12-20 18:48:16.000000000 +0000
+++ apache-ant-1.8.2/src/main/org/apache/tools/ant/taskdefs/optional/native2ascii/Native2AsciiAdapterFactory.java	2011-05-04 15:19:49.235567112 +0100
@@ -40,7 +40,7 @@
      * 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 @@
                                                  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)) {
Index: apache-ant-1.8.2/src/main/org/apache/tools/ant/util/JavaEnvUtils.java
===================================================================
--- apache-ant-1.8.2.orig/src/main/org/apache/tools/ant/util/JavaEnvUtils.java	2010-12-20 18:48:17.000000000 +0000
+++ apache-ant-1.8.2/src/main/org/apache/tools/ant/util/JavaEnvUtils.java	2011-05-04 15:20:36.905590251 +0100
@@ -96,6 +96,10 @@
 
     /** 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;
 
@@ -165,6 +169,13 @@
         } catch (Throwable t) {
             // swallow as this simply doesn't seem to be Apache Harmony
         }
+		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.
+		}
     }
 
     /**
@@ -224,6 +235,10 @@
     public static boolean isKaffe() {
         return kaffeDetected;
     }
+
+    public static boolean isClasspathBased() {
+        return classpathDetected;
+    }
 
     /**
      * Checks whether the current Java VM is the GNU interpreter gij