Browse Source

detect Apache Harmony

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1033587 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 14 years ago
parent
commit
9f59925bbd
2 changed files with 21 additions and 0 deletions
  1. +2
    -0
      src/main/org/apache/tools/ant/Diagnostics.java
  2. +19
    -0
      src/main/org/apache/tools/ant/util/JavaEnvUtils.java

+ 2
- 0
src/main/org/apache/tools/ant/Diagnostics.java View File

@@ -399,6 +399,8 @@ public final class Diagnostics {
out.println(MagicNames.ANT_VERSION + ": " + p.getProperty(MagicNames.ANT_VERSION));
out.println(MagicNames.ANT_JAVA_VERSION + ": "
+ p.getProperty(MagicNames.ANT_JAVA_VERSION));
out.println("Is this the Apache Harmony VM? "
+ (JavaEnvUtils.isApacheHarmony() ? "yes" : "no"));
out.println("Is this the Kaffe VM? "
+ (JavaEnvUtils.isKaffe() ? "yes" : "no"));
out.println("Is this gij/gcj? "


+ 19
- 0
src/main/org/apache/tools/ant/util/JavaEnvUtils.java View File

@@ -94,6 +94,9 @@ public final class JavaEnvUtils {
/** Whether this is the GNU VM (gcj/gij) */
private static boolean gijDetected;

/** Whether this is Apache Harmony */
private static boolean harmonyDetected;

/** array of packages in the runtime */
private static Vector jrePackages;

@@ -147,6 +150,13 @@ public final class JavaEnvUtils {
} catch (Throwable t) {
// swallow as this simply doesn't seem to be gcj/gij
}
harmonyDetected = false;
try {
Class.forName("org.apache.harmony.luni.util.Base64");
harmonyDetected = true;
} catch (Throwable t) {
// swallow as this simply doesn't seem to be Apache Harmony
}
}

/**
@@ -217,6 +227,15 @@ public final class JavaEnvUtils {
return gijDetected;
}

/**
* Checks whether the current VM is Apache Harmony.
* @since Ant 1.8.2
* @return true if the current VM is Apache Harmony.
*/
public static boolean isApacheHarmony() {
return harmonyDetected;
}

/**
* Finds an executable that is part of a JRE installation based on
* the java.home system property.


Loading…
Cancel
Save