Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 53484 invoked from network); 3 Jan 2007 10:47:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Jan 2007 10:47:13 -0000 Received: (qmail 44209 invoked by uid 500); 3 Jan 2007 10:47:20 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 44109 invoked by uid 500); 3 Jan 2007 10:47:20 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 44100 invoked by uid 99); 3 Jan 2007 10:47:20 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Jan 2007 02:47:20 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Jan 2007 02:47:13 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id B39061A981A; Wed, 3 Jan 2007 02:46:16 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r492098 - /harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/javac/Compiler.java Date: Wed, 03 Jan 2007 10:46:16 -0000 To: commits@harmony.apache.org From: tellison@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070103104616.B39061A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tellison Date: Wed Jan 3 02:46:15 2007 New Revision: 492098 URL: http://svn.apache.org/viewvc?view=rev&rev=492098 Log: Search for the ECJ jar alongside the tools.jar if it is not in the local dir. Modified: harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/javac/Compiler.java Modified: harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/javac/Compiler.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/javac/Compiler.java?view=diff&rev=492098&r1=492097&r2=492098 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/javac/Compiler.java (original) +++ harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/javac/Compiler.java Wed Jan 3 02:46:15 2007 @@ -88,10 +88,6 @@ * Initialize our local variables. Called during type construction. */ protected void initialize() { - if (!new File(ECJ_JAR_FILE).exists()) { - System.err.println("javac requires the compiler jar \"" - + ECJ_JAR_FILE + "\" to run"); - } try { initializeMainClass(); initializeInstance(); @@ -139,9 +135,35 @@ IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { + URLClassLoader loader; + + // Find the ECJ JAR file + if (new File(ECJ_JAR_FILE).exists()) { + // It is in the working directory + URL ecjURL = new URL("file:" + ECJ_JAR_FILE); + loader = new URLClassLoader(new URL[] { ecjURL }); + } else { + // Assume it is next to the tools.jar + URLClassLoader bogusLoader = new URLClassLoader(new URL[] {}); + URLClassLoader parentLoader = (URLClassLoader) bogusLoader + .getParent(); + URL[] uls = parentLoader.getURLs(); + URL ecjURL = null; + for (int i = 0; i < uls.length; i++) { + URL l = uls[i]; + String filename = new File(l.getFile()).getName(); + if (filename.equals("tools.jar")) { + ecjURL = new URL(l, ECJ_JAR_FILE); + break; + } + } + if (ecjURL == null) { + throw new RuntimeException("Cannot find file " + ECJ_JAR_FILE); + } + loader = new URLClassLoader(new URL[] { ecjURL }); + } + // Load the ECJ main class - URL ecjURL = new URL("file:" + ECJ_JAR_FILE); - URLClassLoader loader = new URLClassLoader(new URL[] { ecjURL }); ecjCompilerClass = loader.loadClass(MAIN_CLASS_NAME); } @@ -153,7 +175,8 @@ NoSuchMethodException { staticMainMth = ecjCompilerClass.getMethod("main", new Class[] { String[].class }); - printUsageMth = ecjCompilerClass.getMethod("printUsage", (Class[])null); + printUsageMth = ecjCompilerClass + .getMethod("printUsage", (Class[]) null); } /**