edu.rice.cs.drjava.model
Class JarJDKToolsLibrary

java.lang.Object
  extended by edu.rice.cs.drjava.model.JDKToolsLibrary
      extended by edu.rice.cs.drjava.model.JarJDKToolsLibrary

public class JarJDKToolsLibrary
extends JDKToolsLibrary

A JDKToolsLibrary that was loaded from a specific jar file.


Field Summary
private  List<File> _bootClassPath
           
private  File _location
           
private static Set<String> TOOLS_PACKAGES
          Packages to shadow when loading a new tools.jar.
 
Fields inherited from class edu.rice.cs.drjava.model.JDKToolsLibrary
LOG_STRINGWRITER
 
Constructor Summary
private JarJDKToolsLibrary(File location, JavaVersion.FullVersion version, JDKDescriptor jdkDescriptor, CompilerInterface compiler, Debugger debugger, JavadocModel javadoc, List<File> bootClassPath)
           
 
Method Summary
private static void addIfDir(File f, JDKDescriptor c, Map<? super File,Set<JDKDescriptor>> map)
          Add a canonicalized f to the given set if it is an existing directory or link
private static void addIfDir(File f, Map<? super File,Set<JDKDescriptor>> map)
          Add a canonicalized f to the given set if it is an existing directory or link
private static void addIfFile(File f, JDKDescriptor c, Map<? super File,Set<JDKDescriptor>> map)
          Add a canonicalized f to the given set if it is an existing file
private static void addIfFile(File f, Map<? super File,Set<JDKDescriptor>> map)
          Add a canonicalized f to the given set if it is an existing file
private static void addIfFile(File f, Set<JDKDescriptor> cs, Map<? super File,Set<JDKDescriptor>> map)
          Add a canonicalized f to the given set if it is an existing file
protected static Iterable<JDKDescriptor> attemptToLoadDescriptor(Iterable<JDKDescriptor> descriptors, String name)
          Attempt to load a JDK descriptor, append it to the list if succesful.
 List<File> bootClassPath()
           
protected static void collectValidResults(GlobalModel model, LinkedHashMap<File,Set<JDKDescriptor>> jars, Map<JavaVersion.FullVersion,Iterable<JarJDKToolsLibrary>> results, Map<JavaVersion.FullVersion,Iterable<JarJDKToolsLibrary>> compoundResults)
          Check which jars are valid JDKs, and determine if they are compound or full (non-compound) JDKs.
protected static Map<JavaVersion.FullVersion,Iterable<JarJDKToolsLibrary>> getCompletedCompoundResults(GlobalModel model, Iterable<JarJDKToolsLibrary> collapsed, Iterable<JarJDKToolsLibrary> compoundCollapsed)
          Get completed compound JDKs by going through the list of compound JDKs and finding full JDKs that complete them.
protected static LinkedHashMap<File,Set<JDKDescriptor>> getDefaultSearchRoots()
          return a collection with the default roots.
static JavaVersion.FullVersion guessVersion(File f, JDKDescriptor desc)
           
 File location()
           
static JarJDKToolsLibrary makeFromFile(File f, GlobalModel model, JDKDescriptor desc)
          Create a JarJDKToolsLibrary from a specific "tools.jar" or "classes.jar" file.
static JarJDKToolsLibrary makeFromFile(File f, GlobalModel model, JDKDescriptor desc, List<File> additionalBootClassPath)
          Create a JarJDKToolsLibrary from a specific "tools.jar" or "classes.jar" file.
static Iterable<JarJDKToolsLibrary> search(GlobalModel model)
          Produce a list of tools libraries discovered on the file system.
private static Iterable<JDKDescriptor> searchForJDKDescriptors()
          Search for JDK descriptors.
protected static void searchRootsForJars(LinkedHashMap<File,Set<JDKDescriptor>> roots, LinkedHashMap<File,Set<JDKDescriptor>> jars)
           
 String toString()
           
 
Methods inherited from class edu.rice.cs.drjava.model.JDKToolsLibrary
adapterForCompiler, adapterForDebugger, compiler, debugger, getCompilerInterface, isValid, javadoc, jdkDescriptor, makeFromRuntime, msg, version
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TOOLS_PACKAGES

private static final Set<String> TOOLS_PACKAGES
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.)


_location

private final File _location

_bootClassPath

private final List<File> _bootClassPath
Constructor Detail

JarJDKToolsLibrary

private JarJDKToolsLibrary(File location,
                           JavaVersion.FullVersion version,
                           JDKDescriptor jdkDescriptor,
                           CompilerInterface compiler,
                           Debugger debugger,
                           JavadocModel javadoc,
                           List<File> bootClassPath)
Method Detail

location

public File location()

bootClassPath

public List<File> bootClassPath()

toString

public String toString()
Overrides:
toString in class JDKToolsLibrary

makeFromFile

public static JarJDKToolsLibrary makeFromFile(File f,
                                              GlobalModel model,
                                              JDKDescriptor desc)
Create a JarJDKToolsLibrary from a specific "tools.jar" or "classes.jar" file.


makeFromFile

public static JarJDKToolsLibrary makeFromFile(File f,
                                              GlobalModel model,
                                              JDKDescriptor desc,
                                              List<File> additionalBootClassPath)
Create a JarJDKToolsLibrary from a specific "tools.jar" or "classes.jar" file.


guessVersion

public static JavaVersion.FullVersion guessVersion(File f,
                                                   JDKDescriptor desc)

getDefaultSearchRoots

protected static LinkedHashMap<File,Set<JDKDescriptor>> getDefaultSearchRoots()
return a collection with the default roots.


searchRootsForJars

protected static void searchRootsForJars(LinkedHashMap<File,Set<JDKDescriptor>> roots,
                                         LinkedHashMap<File,Set<JDKDescriptor>> jars)

collectValidResults

protected static void collectValidResults(GlobalModel model,
                                          LinkedHashMap<File,Set<JDKDescriptor>> jars,
                                          Map<JavaVersion.FullVersion,Iterable<JarJDKToolsLibrary>> results,
                                          Map<JavaVersion.FullVersion,Iterable<JarJDKToolsLibrary>> compoundResults)
Check which jars are valid JDKs, and determine if they are compound or full (non-compound) JDKs.


getCompletedCompoundResults

protected static Map<JavaVersion.FullVersion,Iterable<JarJDKToolsLibrary>> getCompletedCompoundResults(GlobalModel model,
                                                                                                       Iterable<JarJDKToolsLibrary> collapsed,
                                                                                                       Iterable<JarJDKToolsLibrary> compoundCollapsed)
Get completed compound JDKs by going through the list of compound JDKs and finding full JDKs that complete them.


search

public static Iterable<JarJDKToolsLibrary> search(GlobalModel model)
Produce a list of tools libraries discovered on the file system. A variety of locations are searched; only those files that can produce a valid library (see JDKToolsLibrary.isValid() are returned. The result is sorted by version. Where one library of the same version might be preferred over another, the preferred library appears earlier in the result list.


addIfDir

private static void addIfDir(File f,
                             Map<? super File,Set<JDKDescriptor>> map)
Add a canonicalized f to the given set if it is an existing directory or link


addIfDir

private static void addIfDir(File f,
                             JDKDescriptor c,
                             Map<? super File,Set<JDKDescriptor>> map)
Add a canonicalized f to the given set if it is an existing directory or link


addIfFile

private static void addIfFile(File f,
                              Map<? super File,Set<JDKDescriptor>> map)
Add a canonicalized f to the given set if it is an existing file


addIfFile

private static void addIfFile(File f,
                              JDKDescriptor c,
                              Map<? super File,Set<JDKDescriptor>> map)
Add a canonicalized f to the given set if it is an existing file


addIfFile

private static void addIfFile(File f,
                              Set<JDKDescriptor> cs,
                              Map<? super File,Set<JDKDescriptor>> map)
Add a canonicalized f to the given set if it is an existing file


searchForJDKDescriptors

private static Iterable<JDKDescriptor> searchForJDKDescriptors()
Search for JDK descriptors. Note: This does not work properly if not all classes are in a jar or in the same directory. For example, when doing an "ant run", the classes are spread across classes/base and classes/lib, with the edu.rice.cs.drjava.DrJava class in classes/base but the descriptors in classes/lib.


attemptToLoadDescriptor

protected static Iterable<JDKDescriptor> attemptToLoadDescriptor(Iterable<JDKDescriptor> descriptors,
                                                                 String name)
Attempt to load a JDK descriptor, append it to the list if succesful.