Clover coverage report - Ant Coverage
Coverage timestamp: Tue Apr 8 2003 20:43:55 EST
file stats: LOC: 238   Methods: 1
NCLOC: 93   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
Jikes.java 0% 0% 0% 0%
 1   
 /*
 2   
  * The Apache Software License, Version 1.1
 3   
  *
 4   
  * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
 5   
  * reserved.
 6   
  *
 7   
  * Redistribution and use in source and binary forms, with or without
 8   
  * modification, are permitted provided that the following conditions
 9   
  * are met:
 10   
  *
 11   
  * 1. Redistributions of source code must retain the above copyright
 12   
  *    notice, this list of conditions and the following disclaimer.
 13   
  *
 14   
  * 2. Redistributions in binary form must reproduce the above copyright
 15   
  *    notice, this list of conditions and the following disclaimer in
 16   
  *    the documentation and/or other materials provided with the
 17   
  *    distribution.
 18   
  *
 19   
  * 3. The end-user documentation included with the redistribution, if
 20   
  *    any, must include the following acknowlegement:
 21   
  *       "This product includes software developed by the
 22   
  *        Apache Software Foundation (http://www.apache.org/)."
 23   
  *    Alternately, this acknowlegement may appear in the software itself,
 24   
  *    if and wherever such third-party acknowlegements normally appear.
 25   
  *
 26   
  * 4. The names "Ant" and "Apache Software
 27   
  *    Foundation" must not be used to endorse or promote products derived
 28   
  *    from this software without prior written permission. For written
 29   
  *    permission, please contact apache@apache.org.
 30   
  *
 31   
  * 5. Products derived from this software may not be called "Apache"
 32   
  *    nor may "Apache" appear in their names without prior written
 33   
  *    permission of the Apache Group.
 34   
  *
 35   
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 36   
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 37   
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 38   
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 39   
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 40   
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 41   
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 42   
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 43   
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 44   
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 45   
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 46   
  * SUCH DAMAGE.
 47   
  * ====================================================================
 48   
  *
 49   
  * This software consists of voluntary contributions made by many
 50   
  * individuals on behalf of the Apache Software Foundation.  For more
 51   
  * information on the Apache Software Foundation, please see
 52   
  * <http://www.apache.org/>.
 53   
  */
 54   
 
 55   
 package org.apache.tools.ant.taskdefs.compilers;
 56   
 
 57   
 import org.apache.tools.ant.BuildException;
 58   
 import org.apache.tools.ant.Project;
 59   
 import org.apache.tools.ant.types.Commandline;
 60   
 import org.apache.tools.ant.types.Path;
 61   
 
 62   
 /**
 63   
  * The implementation of the jikes compiler.
 64   
  * This is primarily a cut-and-paste from the original javac task before it
 65   
  * was refactored.
 66   
  *
 67   
  * @author James Davidson <a href="mailto:duncan@x180.com">duncan@x180.com</a>
 68   
  * @author Robin Green 
 69   
  *         <a href="mailto:greenrd@hotmail.com">greenrd@hotmail.com</a>
 70   
  * @author Stefan Bodewig 
 71   
  * @author <a href="mailto:jayglanville@home.com">J D Glanville</a>
 72   
  * @since Ant 1.3
 73   
  */
 74   
 public class Jikes extends DefaultCompilerAdapter {
 75   
 
 76   
     /**
 77   
      * Performs a compile using the Jikes compiler from IBM..
 78   
      * Mostly of this code is identical to doClassicCompile()
 79   
      * However, it does not support all options like
 80   
      * bootclasspath, extdirs, deprecation and so on, because
 81   
      * there is no option in jikes and I don't understand
 82   
      * what they should do.
 83   
      *
 84   
      * It has been successfully tested with jikes >1.10
 85   
      */
 86  0
     public boolean execute() throws BuildException {
 87  0
         attributes.log("Using jikes compiler", Project.MSG_VERBOSE);
 88   
 
 89  0
         Path classpath = new Path(project);
 90   
 
 91   
         // Jikes doesn't support bootclasspath dir (-bootclasspath)
 92   
         // so we'll emulate it for compatibility and convenience.
 93  0
         if (bootclasspath != null) {
 94  0
             classpath.append(bootclasspath);
 95   
         }
 96   
 
 97   
         // Jikes doesn't support an extension dir (-extdir)
 98   
         // so we'll emulate it for compatibility and convenience.
 99  0
         classpath.addExtdirs(extdirs);
 100   
 
 101  0
         if (bootclasspath == null || bootclasspath.size() == 0) {
 102   
             // no bootclasspath, therefore, get one from the java runtime
 103  0
             includeJavaRuntime = true;
 104   
         } else {
 105   
             // there is a bootclasspath stated.  By default, the
 106   
             // includeJavaRuntime is false.  If the user has stated a
 107   
             // bootclasspath and said to include the java runtime, it's on
 108   
             // their head!
 109   
         }
 110  0
         classpath.append(getCompileClasspath());
 111   
 
 112   
         // Jikes has no option for source-path so we
 113   
         // will add it to classpath.
 114  0
         if (compileSourcepath != null) {
 115  0
             classpath.append(compileSourcepath);
 116   
         } else {
 117  0
             classpath.append(src);
 118   
         }
 119   
 
 120   
         // if the user has set JIKESPATH we should add the contents as well
 121  0
         String jikesPath = System.getProperty("jikes.class.path");
 122  0
         if (jikesPath != null) {
 123  0
             classpath.append(new Path(project, jikesPath));
 124   
         }
 125   
         
 126  0
         Commandline cmd = new Commandline();
 127  0
         cmd.setExecutable("jikes");
 128   
 
 129  0
         if (deprecation == true) {
 130  0
             cmd.createArgument().setValue("-deprecation");
 131   
         }
 132   
 
 133  0
         if (destDir != null) {
 134  0
             cmd.createArgument().setValue("-d");
 135  0
             cmd.createArgument().setFile(destDir);
 136   
         }
 137   
         
 138  0
         cmd.createArgument().setValue("-classpath");
 139  0
         cmd.createArgument().setPath(classpath);
 140   
 
 141  0
         if (encoding != null) {
 142  0
             cmd.createArgument().setValue("-encoding");
 143  0
             cmd.createArgument().setValue(encoding);
 144   
         }
 145  0
         if (debug) {
 146  0
             cmd.createArgument().setValue("-g");
 147   
         }
 148  0
         if (optimize) {
 149  0
             cmd.createArgument().setValue("-O");
 150   
         }
 151  0
         if (verbose) {
 152  0
             cmd.createArgument().setValue("-verbose");
 153   
         }
 154  0
         if (depend) {
 155  0
             cmd.createArgument().setValue("-depend");
 156   
         } 
 157   
         /**
 158   
          * XXX
 159   
          * Perhaps we shouldn't use properties for these
 160   
          * three options (emacs mode, warnings and pedantic),
 161   
          * but include it in the javac directive?
 162   
          */
 163   
 
 164   
         /**
 165   
          * Jikes has the nice feature to print error
 166   
          * messages in a form readable by emacs, so
 167   
          * that emacs can directly set the cursor
 168   
          * to the place, where the error occured.
 169   
          */
 170  0
         String emacsProperty = project.getProperty("build.compiler.emacs");
 171  0
         if (emacsProperty != null && Project.toBoolean(emacsProperty)) {
 172  0
             cmd.createArgument().setValue("+E");
 173   
         }
 174   
 
 175   
         /**
 176   
          * Jikes issues more warnings that javac, for
 177   
          * example, when you have files in your classpath
 178   
          * that don't exist. As this is often the case, these
 179   
          * warning can be pretty annoying.
 180   
          */
 181  0
         String warningsProperty = 
 182   
             project.getProperty("build.compiler.warnings");
 183  0
         if (warningsProperty != null) {
 184  0
             attributes.log("!! the build.compiler.warnings property is "
 185   
                            + "deprecated. !!", Project.MSG_WARN);
 186  0
             attributes.log("!! Use the nowarn attribute instead. !!",
 187   
                            Project.MSG_WARN);
 188  0
             if (!Project.toBoolean(warningsProperty)) {
 189  0
                 cmd.createArgument().setValue("-nowarn");
 190   
             }
 191  0
         } if (attributes.getNowarn()) {
 192   
             /* 
 193   
              * FIXME later
 194   
              *
 195   
              * let the magic property win over the attribute for backwards 
 196   
              * compatibility
 197   
              */
 198  0
             cmd.createArgument().setValue("-nowarn");
 199   
         }
 200   
 
 201   
         /**
 202   
          * Jikes can issue pedantic warnings. 
 203   
          */
 204  0
         String pedanticProperty = 
 205   
             project.getProperty("build.compiler.pedantic");
 206  0
         if (pedanticProperty != null && Project.toBoolean(pedanticProperty)) {
 207  0
             cmd.createArgument().setValue("+P");
 208   
         }
 209   
  
 210   
         /**
 211   
          * Jikes supports something it calls "full dependency
 212   
          * checking", see the jikes documentation for differences
 213   
          * between -depend and +F.
 214   
          */
 215  0
         String fullDependProperty = 
 216   
             project.getProperty("build.compiler.fulldepend");
 217  0
         if (fullDependProperty != null 
 218   
             && Project.toBoolean(fullDependProperty)) {
 219  0
             cmd.createArgument().setValue("+F");
 220   
         }
 221   
 
 222  0
         if (attributes.getSource() != null) {
 223  0
             cmd.createArgument().setValue("-source");
 224  0
             cmd.createArgument().setValue(attributes.getSource());
 225   
         }
 226   
 
 227  0
         addCurrentCompilerArgs(cmd);
 228   
 
 229  0
         int firstFileName = cmd.size();
 230  0
         logAndAddFilesToCompile(cmd);
 231   
 
 232  0
         return 
 233   
             executeExternalCompile(cmd.getCommandline(), firstFileName) == 0;
 234   
     }
 235   
 
 236   
 
 237   
 }
 238