Clover coverage report - Ant Coverage
Coverage timestamp: Tue Apr 8 2003 20:43:55 EST
file stats: LOC: 162   Methods: 2
NCLOC: 69   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) 2000,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   
 package org.apache.tools.ant.taskdefs;
 55   
 
 56   
 import java.io.File;
 57   
 import java.io.FileWriter;
 58   
 import java.io.IOException;
 59   
 import java.io.PrintWriter;
 60   
 import java.util.Random;
 61   
 import org.apache.tools.ant.BuildException;
 62   
 import org.apache.tools.ant.Project;
 63   
 
 64   
 /**
 65   
  * Encapsulates a Jikes compiler, by directly executing an external
 66   
  * process.
 67   
  *
 68   
  * <p><strong>As of Ant 1.2, this class is considered to be dead code
 69   
  * by the Ant developers and is unmaintained.  Don't use
 70   
  * it.</strong></p>
 71   
  *
 72   
  * @author skanthak@muehlheim.de
 73   
  * @deprecated merged into the class Javac.
 74   
  */
 75   
 public class Jikes {
 76   
 
 77   
     protected JikesOutputParser jop;
 78   
     protected String command;
 79   
     protected Project project;
 80   
 
 81   
     /**
 82   
      * Constructs a new Jikes obect.
 83   
      * @param jop - Parser to send jike's output to
 84   
      * @param command - name of jikes executeable
 85   
      */
 86  0
     protected Jikes(JikesOutputParser jop, String command, Project project) {
 87  0
         super();
 88   
 
 89  0
         System.err.println("As of Ant 1.2 released in October 2000, " 
 90   
             + "the Jikes class");
 91  0
         System.err.println("is considered to be dead code by the Ant " 
 92   
             + "developers and is unmaintained.");
 93  0
         System.err.println("Don\'t use it!");
 94   
 
 95  0
         this.jop = jop;
 96  0
         this.command = command;
 97  0
         this.project = project;
 98   
     }
 99   
 
 100   
     /**
 101   
      * Do the compile with the specified arguments.
 102   
      * @param args - arguments to pass to process on command line
 103   
      */
 104  0
     protected void compile(String[] args) {
 105  0
         String[] commandArray = null;
 106  0
         File tmpFile = null;
 107   
 
 108  0
         try {
 109  0
             String myos = System.getProperty("os.name");
 110   
 
 111   
             // Windows has a 32k limit on total arg size, so
 112   
             // create a temporary file to store all the arguments
 113   
 
 114   
             // There have been reports that 300 files could be compiled
 115   
             // so 250 is a conservative approach
 116  0
             if (myos.toLowerCase().indexOf("windows") >= 0 
 117   
                 && args.length > 250) {
 118  0
                 PrintWriter out = null;
 119  0
                 try {
 120  0
                     tmpFile = new File("jikes" + (new Random(System.currentTimeMillis())).nextLong());
 121  0
                     out = new PrintWriter(new FileWriter(tmpFile));
 122  0
                     for (int i = 0; i < args.length; i++) {
 123  0
                         out.println(args[i]);
 124   
                     }
 125  0
                     out.flush();
 126  0
                     commandArray = new String[] { command, 
 127   
                                                   "@" + tmpFile.getAbsolutePath()};
 128   
                 } catch (IOException e) {
 129  0
                     throw new BuildException("Error creating temporary file", 
 130   
                                              e);
 131   
                 } finally {
 132  0
                     if (out != null) {
 133  0
                         try {out.close();} catch (Throwable t) {}
 134   
                     }
 135   
                 }
 136   
             } else {
 137  0
                 commandArray = new String[args.length + 1];
 138  0
                 commandArray[0] = command;
 139  0
                 System.arraycopy(args, 0, commandArray, 1, args.length);
 140   
             }
 141   
             
 142   
             // We assume, that everything jikes writes goes to
 143   
             // standard output, not to standard error. The option
 144   
             // -Xstdout that is given to Jikes in Javac.doJikesCompile()
 145   
             // should guarantee this. At least I hope so. :)
 146  0
             try {
 147  0
                 Execute exe = new Execute(jop);
 148  0
                 exe.setAntRun(project);
 149  0
                 exe.setWorkingDirectory(project.getBaseDir());
 150  0
                 exe.setCommandline(commandArray);
 151  0
                 exe.execute();
 152   
             } catch (IOException e) {
 153  0
                 throw new BuildException("Error running Jikes compiler", e);
 154   
             }
 155   
         } finally {
 156  0
             if (tmpFile != null) {
 157  0
                 tmpFile.delete();
 158   
             }
 159   
         }
 160   
     }
 161   
 }
 162