Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 19844 invoked from network); 14 Apr 2011 15:21:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 14 Apr 2011 15:21:41 -0000 Received: (qmail 51649 invoked by uid 500); 14 Apr 2011 15:21:41 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 51605 invoked by uid 500); 14 Apr 2011 15:21:40 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 51598 invoked by uid 99); 14 Apr 2011 15:21:40 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Apr 2011 15:21:40 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Apr 2011 15:21:38 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 647422388962; Thu, 14 Apr 2011 15:21:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1092333 - /db/derby/code/trunk/java/build/org/apache/derbyPreBuild/PropertySetter.java Date: Thu, 14 Apr 2011 15:21:17 -0000 To: derby-commits@db.apache.org From: kahatlen@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110414152117.647422388962@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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.