edu.rice.cs.drjava.model
Class JDKDescriptor

java.lang.Object
  extended by edu.rice.cs.drjava.model.JDKDescriptor
Direct Known Subclasses:
JDKDescriptor.None

public abstract class JDKDescriptor
extends Object

A description of a JDK. Put subclasses of JDKDescriptor in the edu.rice.cs.drjava.model.compiler.descriptors package for DrJava to find.


Nested Class Summary
private static class JDKDescriptor.None
          Class for the singleton representing a JDK that doesn't have a descriptor.
static class JDKDescriptor.Util
          Utilities for JDK descriptors.
 
Field Summary
static JDKDescriptor NONE
          Singleton representing a JDK that doesn't have a descriptor.
 
Constructor Summary
JDKDescriptor()
           
 
Method Summary
abstract  boolean containsCompiler(File f)
          Return true if the file (jar file or directory) contains the compiler.
abstract  String getAdapterForCompiler()
          Return the class name of the compiler adapter.
 String getAdapterForCompiler(JavaVersion.FullVersion guessedVersion)
          Return the class name of the compiler adapter.
abstract  String getAdapterForDebugger()
          Return the class name of the debugger adapter.
 String getAdapterForDebugger(JavaVersion.FullVersion guessedVersion)
          Return the class name of the debugger adapter.
abstract  Iterable<File> getAdditionalCompilerFiles(File compiler)
          Return the list of additional files required to use the compiler.
 String getDescription(JavaVersion.FullVersion version)
          Return a description of this JDK.
abstract  JavaVersion getMinimumMajorVersion()
          Return the minimum Java version required to use this JDK.
abstract  String getName()
          Return the name of this JDK.
abstract  Iterable<File> getSearchDirectories()
          Returns a list of directories that should be searched for tools.jar and classes.jar files.
abstract  Iterable<File> getSearchFiles()
          Returns a list of files that should be searched if they contain a compiler.
abstract  Set<String> getToolsPackages()
          Packages to shadow when loading a new tools.jar.
 JavaVersion.FullVersion guessVersion(File f)
          Return the guessed version for the compiler in the specified file (jar file or directory).
 boolean isBaseForCompound()
          True if this is a JDK that can serve as base for a compound JDK.
abstract  boolean isCompound()
          True if this is a compound JDK and needs a fully featured JDK to operate.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final JDKDescriptor NONE
Singleton representing a JDK that doesn't have a descriptor.

Constructor Detail

JDKDescriptor

public JDKDescriptor()
Method Detail

getName

public abstract String getName()
Return the name of this JDK.

Returns:
name

getToolsPackages

public abstract Set<String> getToolsPackages()
Packages to shadow when loading a new tools.jar. If we don't shadow these classes, we won't be able to load distinct versions for each tools.jar library. These should be verified whenever a new Java version is released. (We can't just shadow *everything* because some classes, at least in OS X's classes.jar, can only be loaded by the JVM.)

Returns:
set of packages that need to be shadowed

getSearchDirectories

public abstract Iterable<File> getSearchDirectories()
Returns a list of directories that should be searched for tools.jar and classes.jar files.

Returns:
list of directories to search

getSearchFiles

public abstract Iterable<File> getSearchFiles()
Returns a list of files that should be searched if they contain a compiler.

Returns:
list of files to search

isCompound

public abstract boolean isCompound()
True if this is a compound JDK and needs a fully featured JDK to operate.

Returns:
true if compound JDK (e.g. NextGen, Mint, Habanero).

isBaseForCompound

public boolean isBaseForCompound()
True if this is a JDK that can serve as base for a compound JDK.

Returns:
true if base for a compound JDK (e.g. Sun JDK, OpenJDK, AppleJDK).

getAdapterForCompiler

public abstract String getAdapterForCompiler()
Return the class name of the compiler adapter.

Returns:
class name of compiler, or null if no compiler

getAdapterForCompiler

public String getAdapterForCompiler(JavaVersion.FullVersion guessedVersion)
Return the class name of the compiler adapter.

Parameters:
guessedVersion - the guessed version of the compiler
Returns:
class name of compiler, or null if no compiler

getAdapterForDebugger

public abstract String getAdapterForDebugger()
Return the class name of the debugger adapter.

Returns:
class name of debugger, or null if no debugger

getAdapterForDebugger

public String getAdapterForDebugger(JavaVersion.FullVersion guessedVersion)
Return the class name of the debugger adapter.

Parameters:
guessedVersion - the guessed version of the compiler
Returns:
class name of debugger, or null if no debugger

containsCompiler

public abstract boolean containsCompiler(File f)
Return true if the file (jar file or directory) contains the compiler.

Returns:
true if the file contains the compiler

guessVersion

public JavaVersion.FullVersion guessVersion(File f)
Return the guessed version for the compiler in the specified file (jar file or directory). Note that this is the Java version that this compiler is compatible to, not the internal compiler version. For full (non-compound) JDKs, this is equal to the version, i.e. JDK6 should guess Java 6.0. For compound JDKs, this is equal to the version of the full JDK that the compound JDK needs, i.e. if a version of the HJ compiler requires JDK6, it should guess JDK6.

Returns:
guessed version

getMinimumMajorVersion

public abstract JavaVersion getMinimumMajorVersion()
Return the minimum Java version required to use this JDK.

Returns:
minimum version

getAdditionalCompilerFiles

public abstract Iterable<File> getAdditionalCompilerFiles(File compiler)
                                                   throws FileNotFoundException
Return the list of additional files required to use the compiler. The compiler was found in the specified file. This method may have to search the user's hard drive, e.g. by looking relative to compiler.getParentFile(), by checking environment variables, or by looking in certain OS-specific directories. // for example: public Iterable getAdditionalCompilerFiles(File compiler) throws FileNotFoundException { File parent = compiler.getParentFile(); File nextgen2orgjar = new File(parent, "nextgen2org.jar"); if (!Util.exists(nextgen2orgjar, "org/apache/bcel/classfile/Node.class")) { throw new FileNotFoundException("org/apache/bcel/classfile/Node.class"); } return IterUtil.singleton(nextgen2orgjar); }

Parameters:
compiler - location where the compiler was fund
Returns:
list of additional files that need to be available
Throws:
FileNotFoundException

getDescription

public String getDescription(JavaVersion.FullVersion version)
Return a description of this JDK.

Parameters:
version - the specific version of the compiler
Returns:
description

toString

public String toString()
Overrides:
toString in class Object