edu.rice.cs.drjava.model.compiler
Class GJv6Compiler

java.lang.Object
  |
  +--edu.rice.cs.drjava.model.compiler.GJv6Compiler
All Implemented Interfaces:
CompilerInterface

public class GJv6Compiler
extends Object
implements CompilerInterface

The GJ compiler used by DrJava.

Version:
$Id: GJv6Compiler.java,v 1.21 2002/09/11 23:23:05 csreis Exp $

Inner Class Summary
private  class GJv6Compiler.OurLog
          put your documentation comment here
 
Field Summary
private  gjc.v6.JavaCompiler _compiler
           
private  GJv6Compiler.OurLog _compilerLog
          We need to explicitly make the compiler's log and pass it to JavaCompiler.make() so we can keep a pointer to the log, since the log is not retrievable from the compiler.
private  String _extraClassPath
           
static String COMPILER_CLASS_NAME
           
static CompilerInterface ONLY
          Singleton instance.
 
Constructor Summary
private GJv6Compiler()
          Create the compiler.
 
Method Summary
private  void _initCompiler(File[] sourceRoots)
          Set up new instance of the GJ compiler.
 void addToBootClassPath(File cp)
          This method allows us to set the JSR14 collections path across a class loader.
 CompilerError[] compile(File[] sourceRoots, File[] files)
          Compile the given files.
 CompilerError[] compile(File sourceRoot, File[] files)
          Compile the given files.
 String getName()
          Returns the name of this compiler, appropriate to show to the user.
protected  String getSourceRootString(File[] sourceRoots)
          Utility method for getting a properly formatted string with several source paths from an array of files.
 boolean isAvailable()
          Indicates whether this compiler is actually available.
 void setAllowAssertions(boolean allow)
          Sets whether to allow assertions in Java 1.4.
 void setExtraClassPath(String extraClassPath)
          Allows us to set the extra classpath for the compilers without referencing the config object in a loaded class file
 String toString()
          Should return info about compiler, at least including name.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

_extraClassPath

private String _extraClassPath

ONLY

public static final CompilerInterface ONLY
Singleton instance.

COMPILER_CLASS_NAME

public static final String COMPILER_CLASS_NAME

_compiler

private gjc.v6.JavaCompiler _compiler

_compilerLog

private GJv6Compiler.OurLog _compilerLog
We need to explicitly make the compiler's log and pass it to JavaCompiler.make() so we can keep a pointer to the log, since the log is not retrievable from the compiler. We need to use the log to determine if any errors occurred.
Constructor Detail

GJv6Compiler

private GJv6Compiler()
Create the compiler. Private because of singleton. Fail if we are on a JDK that won't work with GJv6!
Method Detail

_initCompiler

private void _initCompiler(File[] sourceRoots)
Set up new instance of the GJ compiler.

compile

public CompilerError[] compile(File sourceRoot,
                               File[] files)
Compile the given files.
Specified by:
compile in interface CompilerInterface
Parameters:
files - Source files to compile.
sourceRoot - Source root directory, the base of the package structure.
Returns:
Array of errors that occurred. If no errors, should be zero length array (not null).

compile

public CompilerError[] compile(File[] sourceRoots,
                               File[] files)
Compile the given files.
Specified by:
compile in interface CompilerInterface
Parameters:
files - Source files to compile.
sourceRoots - Array of source root directories, the base of the package structure for all files to compile.
Returns:
Array of errors that occurred. If no errors, should be zero length array (not null).

isAvailable

public boolean isAvailable()
Description copied from interface: CompilerInterface
Indicates whether this compiler is actually available. As in: Is it installed and located? This method should load the compiler class, which should hopefully prove whether the class can load. If this method returns true, the CompilerInterface.compile(java.io.File, java.io.File[]) method should not fail due to class not being found.
Specified by:
isAvailable in interface CompilerInterface

getName

public String getName()
Description copied from interface: CompilerInterface
Returns the name of this compiler, appropriate to show to the user.
Specified by:
getName in interface CompilerInterface

toString

public String toString()
Description copied from interface: CompilerInterface
Should return info about compiler, at least including name.
Specified by:
toString in interface CompilerInterface
Overrides:
toString in class Object

setExtraClassPath

public void setExtraClassPath(String extraClassPath)
Allows us to set the extra classpath for the compilers without referencing the config object in a loaded class file
Specified by:
setExtraClassPath in interface CompilerInterface

setAllowAssertions

public void setAllowAssertions(boolean allow)
Sets whether to allow assertions in Java 1.4.
Specified by:
setAllowAssertions in interface CompilerInterface

addToBootClassPath

public void addToBootClassPath(File cp)
This method allows us to set the JSR14 collections path across a class loader. (cannot cast a loaded class to a subclass, so all compiler interfaces must have this method)
Specified by:
addToBootClassPath in interface CompilerInterface

getSourceRootString

protected String getSourceRootString(File[] sourceRoots)
Utility method for getting a properly formatted string with several source paths from an array of files.