From c7dfaa577bd7940283563befa0aacd048f5de4d7 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Thu, 17 Mar 2005 09:59:36 +0000 Subject: [PATCH] Modernize Jikes (unconditionally) - PR 25868 and 26404 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278007 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 8 +-- docs/manual/CoreTasks/javac.html | 6 ++- .../tools/ant/taskdefs/compilers/Jikes.java | 50 +++++++++++-------- 3 files changed, 39 insertions(+), 25 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 3af7e7797..834a825d8 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -156,6 +156,11 @@ Changes that could break older environments: you must set filtertrace to false. Bugzilla Report 22758 +* The jikes compiler adapter now supports -bootclasspath, -extdirs and + -sourcepath and also uses the same logic for debug flags as javac. + This means, the jikes compiler adapter now requires Jikes 1.15 or later. + Bugzilla Reports 25868, 26404 and 32609. + Other changes: -------------- @@ -194,9 +199,6 @@ Other changes: * added a new mapper -* The jikes compiler adapter now supports -bootclasspath. Bugzilla - Report 32609. - * When a BuildListener tried to access System.err or System.out, Ant would have thrown an exception - this has been changed. Ant now silently ignores the message. BuildListeners still should avoid diff --git a/docs/manual/CoreTasks/javac.html b/docs/manual/CoreTasks/javac.html index fe809ec6c..859170e5b 100644 --- a/docs/manual/CoreTasks/javac.html +++ b/docs/manual/CoreTasks/javac.html @@ -58,7 +58,7 @@ attribute are:

javac1.4 and javac1.5 can be used as aliases.
  • jikes (the Jikes + href="http://jikes.sourceforge.net/" target="_top">Jikes compiler).
  • jvc (the Command-Line Compiler from Microsoft's SDK for Java / Visual J++) – microsoft can be used @@ -209,7 +209,7 @@ invoking the compiler.

    debuglevel Keyword list to be appended to the -g command-line switch. This will be ignored by all implementations except - modern and classic(ver >= 1.2). + modern, classic(ver >= 1.2) and jikes. Legal values are none or a comma-separated list of the following keywords: lines, vars, and source. @@ -536,6 +536,8 @@ using. This problem may occur with all JDKs < 1.2.

    Jikes Notes

    +

    You need Jikes 1.15 or later.

    +

    Jikes supports some extra options, which can be set be defining the properties shown below prior to invoking the task. The setting for each property will be in affect for all <javac> diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java b/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java index 2c8b29dad..2a04fadbc 100644 --- a/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java +++ b/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java @@ -44,11 +44,24 @@ public class Jikes extends DefaultCompilerAdapter { public boolean execute() throws BuildException { attributes.log("Using jikes compiler", Project.MSG_VERBOSE); - Path classpath = new Path(project); + Commandline cmd = new Commandline(); - // Jikes doesn't support an extension dir (-extdir) - // so we'll emulate it for compatibility and convenience. - classpath.addExtdirs(extdirs); + // For -sourcepath, use the "sourcepath" value if present. + // Otherwise default to the "srcdir" value. + Path sourcepath = null; + if (compileSourcepath != null) { + sourcepath = compileSourcepath; + } else { + sourcepath = src; + } + // If the buildfile specifies sourcepath="", then don't + // output any sourcepath. + if (sourcepath.size() > 0) { + cmd.createArgument().setValue("-sourcepath"); + cmd.createArgument().setPath(sourcepath); + } + + Path classpath = new Path(project); if (bootclasspath == null || bootclasspath.size() == 0) { // no bootclasspath, therefore, get one from the java runtime @@ -61,21 +74,17 @@ public class Jikes extends DefaultCompilerAdapter { } classpath.append(getCompileClasspath()); - // Jikes has no option for source-path so we - // will add it to classpath. - if (compileSourcepath != null) { - classpath.append(compileSourcepath); - } else { - classpath.append(src); - } - // if the user has set JIKESPATH we should add the contents as well String jikesPath = System.getProperty("jikes.class.path"); if (jikesPath != null) { classpath.append(new Path(project, jikesPath)); } - Commandline cmd = new Commandline(); + if (extdirs != null && extdirs.size() > 0) { + cmd.createArgument().setValue("-extdirs"); + cmd.createArgument().setPath(extdirs); + } + String exec = getJavac().getExecutable(); cmd.setExecutable(exec == null ? "jikes" : exec); @@ -96,7 +105,14 @@ public class Jikes extends DefaultCompilerAdapter { cmd.createArgument().setValue(encoding); } if (debug) { - cmd.createArgument().setValue("-g"); + String debugLevel = attributes.getDebugLevel(); + if (debugLevel != null) { + cmd.createArgument().setValue("-g:" + debugLevel); + } else { + cmd.createArgument().setValue("-g"); + } + } else { + cmd.createArgument().setValue("-g:none"); } if (optimize) { cmd.createArgument().setValue("-O"); @@ -148,12 +164,6 @@ public class Jikes extends DefaultCompilerAdapter { cmd.createArgument().setValue("-nowarn"); } } if (attributes.getNowarn()) { - /* - * FIXME later - * - * let the magic property win over the attribute for backwards - * compatibility - */ cmd.createArgument().setValue("-nowarn"); }