db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1092333 - /db/derby/code/trunk/java/build/org/apache/derbyPreBuild/PropertySetter.java
Date Thu, 14 Apr 2011 15:21:17 GMT
Author: kahatlen
Date: Thu Apr 14 15:21:17 2011
New Revision: 1092333

URL: http://svn.apache.org/viewvc?rev=1092333&view=rev
Log:
DERBY-5189: PropertySetter should ignore GCJ installations

Modified:
    db/derby/code/trunk/java/build/org/apache/derbyPreBuild/PropertySetter.java

Modified: db/derby/code/trunk/java/build/org/apache/derbyPreBuild/PropertySetter.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/build/org/apache/derbyPreBuild/PropertySetter.java?rev=1092333&r1=1092332&r2=1092333&view=diff
==============================================================================
--- db/derby/code/trunk/java/build/org/apache/derbyPreBuild/PropertySetter.java (original)
+++ db/derby/code/trunk/java/build/org/apache/derbyPreBuild/PropertySetter.java Thu Apr 14
15:21:17 2011
@@ -584,19 +584,49 @@ public class PropertySetter extends Task
 
         Arrays.sort( versions );
 
-        File        javadir = versions[ count - 1 ];
-        String      libStub = "";
+        // Search the versions backwards (highest first) until a usable one
+        // is found.
+        for (int i = count - 1; i >= 0; i--) {
+            File javadir = versions[i];
+
+            if (isExcludedJDK(javadir)) {
+                // This directory contains a JDK that we don't expect to
+                // work. Skip it.
+                continue;
+            }
 
-        //
-        // If the selected java dir is a JDK rather than a JRE, then it
-        // will have a jre subdirectory
-        //
-        File        jreSubdirectory = new File( javadir, "jre" );
-        if ( jreSubdirectory.exists() ) { libStub = libStub + File.separator + "jre"; }
+            String libStub = javadir.getAbsolutePath();
+
+            //
+            // If the selected java dir is a JDK rather than a JRE, then it
+            // will have a jre subdirectory
+            //
+            File jreSubdirectory = new File(javadir, "jre");
+            if (jreSubdirectory.exists()) {
+                libStub = libStub + File.separator + "jre";
+            }
+
+            libStub = libStub + File.separator + "lib";
 
-        libStub = libStub + File.separator + "lib";
+            return libStub;
+        }
+
+        return null;
+    }
 
-        return javadir.getAbsolutePath() + libStub;
+    /**
+     * Check if the specified directory should be excluded when searching for
+     * a usable set of Java libraries.
+     *
+     * @param dir the directory to check
+     * @return {@code true} if the libraries in the directory should not be
+     * used for constructing a compile classpath
+     */
+    private static boolean isExcludedJDK(File dir) {
+        // DERBY-5189: The libraries that come with GCJ lack some classes in
+        // the javax.management.remote package and cannot be used for building
+        // Derby.
+        return dir.getName().toLowerCase().contains("gcj");
     }
 
     // JDK heuristics based on inspecting JARs.



Mime
View raw message