jltools.types
Class LoadedClassResolver
java.lang.Object
|
+--jltools.types.ClassResolver
|
+--jltools.types.LoadedClassResolver
- All Implemented Interfaces:
- Resolver
- public class LoadedClassResolver
- extends ClassResolver
Loads class information from source files, class files, or serialized
class infomation from within class files. An outline of the steps is
given below.
- When the jltools translator looks for a class by the name
"foo.bar.Quux" it first searches for that class in any file given
on the command line. If the class is found one of these files, then
this definition is used and the remainder of the steps are
skipped.
- If none of these files contain the desired class, then the source
path is searched next. For example, if the source extension is
".jl" and the source path is "mydir:." then the translator looks
for files "mydir/foo/bar/Quux.jl" and "./foo/bar/Quux.jl". (The
source path may be set using the -S options, see above.)
- Regardless of whether or not a source file is found, the translator
searches the classpath (defined as normal through the environment
and command-line options to the interpreter) for the desired class.
- If no source file exists, and no class is found then an error is
reported (skipping the rest of the steps below).
- If a source file is found, but no class, then the source file is
parsed. If it contains the desired class definition (which it
should) then that definition is used and the remainder of the steps
are skipped. (If it does not contain this definition, an error is
reported and the remainder of the steps are skipped.
- If a class is found but no source file, then the class is examined
for jlc class type information. If the class contains no class type
information (this is the case if the class file was compiled from
raw Java source rather than jlc translated output) then this class
is used as the desired class definition (skipping all steps below).
- (class, but no still no source) If the class does contain jlc class
type information, then the version number of translator used to
translate the source which created the given class file is compared
against the version of the current instantiation of the translator.
If the versions are compatible, then the jlc class type information
is used as the desired definiton. If the versions are incompatible
(see the documentation in Compiler.java) then an error is reported.
In either case, all remaining steps are skipped.
- If both a suitable source file and class are found then we have a
choice. If the class definition does not contain jlc class type
information then the source file is parsed as the definition found
in this file is used as desired definiton and we stop here. If the
class does contain jlc class type information, then continue.
- (source and class with jlc info) Next the last modification date of
the source file is compared to the last modification date of the
source file used to generate the class file. If the source file is
more recent, the it is parsed as used as the desired definition and
all remaining steps are skipped.
- (source and class with jlc info) Next the jlc version of the class
and of the current translator are compared (as in 7.). If the
verisions are incompatible, then we use the definition from the
parsed source file. If the versions are compatible, then we use
the definition given by the jlc class type information.
Finally, if at any point an error occurs while reading jlc class type
information (e.g. if this information exists but is corrupted), then
an error is reported.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NOT_COMPATIBLE
protected static final int NOT_COMPATIBLE
MINOR_NOT_COMPATIBLE
protected static final int MINOR_NOT_COMPATIBLE
COMPATIBLE
protected static final int COMPATIBLE
LoadedClassResolver
public LoadedClassResolver(Compiler compiler,
TypeSystem ts,
boolean no_source_check)
loadType
public Type loadType(java.lang.String name)
throws SemanticException
- Load a type from a class file.
findType
public Type findType(java.lang.String name)
throws SemanticException
- Overrides:
findType
in class ClassResolver
getTypeFromSource
protected Type getTypeFromSource(Source source,
java.lang.String name)
throws SemanticException
getTypeFromClass
protected Type getTypeFromClass(java.lang.Class clazz,
java.lang.String name)
throws SemanticException
checkCompilerVersion
protected int checkCompilerVersion(java.lang.String clazzVersion)