java.lang.Object | |
↳ | sun.tools.java.Environment |
Known Direct Subclasses |
Known Indirect Subclasses |
This class defines the environment for a compilation. It is used to load classes, resolve class names and report errors. It is an abstract class, a subclass must define implementations for some of the functions.
An environment has a source object associated with it. This is the thing against which errors are reported, it is usually a file name, a field or a class.
Environments can be nested to change the source object.
WARNING: The contents of this source file are not part of any supported API. Code that depends on them does so at its own risk: they are subject to change or removal without notice.
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
sun.tools.java.Constants
| |||||||||||
From interface
sun.tools.java.RuntimeConstants
|
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
sun.tools.java.Constants
| |||||||||||
From interface
sun.tools.java.RuntimeConstants
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Check if a class exists (without actually loading it).
| |||||||||||
get flag of generation the coverage data file
| |||||||||||
get coverage flag
| |||||||||||
Debugging flags.
| |||||||||||
Dependencies
| |||||||||||
Deprecation warnings are enabled.
| |||||||||||
Dump debugging stuff
| |||||||||||
Issue an error.
| |||||||||||
Return true if an explicit cast from this type to
the given type is allowed.
| |||||||||||
Return character encoding name
| |||||||||||
Return a class declaration given a fully qualified class name.
| |||||||||||
Return a class declaration given a type.
| |||||||||||
Return a class definition given a fully qualified class name.
| |||||||||||
Return a class definition given a type.
| |||||||||||
Flags.
| |||||||||||
Get the imports used to resolve class names.
| |||||||||||
Return major version to use in generated class files.
| |||||||||||
Return minor version to use in generated class files.
| |||||||||||
Get the package path for a package
| |||||||||||
Like 'getClassDefinition(env)', but check access on each component.
| |||||||||||
Return the source of the environment (ie: the thing being compiled/parsed).
| |||||||||||
Return the coverage data file
| |||||||||||
Return true if an implicit cast from this type to
the given type is allowed.
| |||||||||||
Returns true if the given method is applicable to the given arguments
| |||||||||||
Tells whether an Identifier refers to a package which should be
exempt from the "exists" check in Imports#resolve().
| |||||||||||
Returns true if "from" is a more specific type than "to"
| |||||||||||
Returns true if "best" is in every argument at least as good as "other"
| |||||||||||
Load the definition of a class.
| |||||||||||
Create a new class.
| |||||||||||
Create a new field.
| |||||||||||
Optimization flags.
| |||||||||||
Output a string.
| |||||||||||
Print Dependencies to stdout
| |||||||||||
Resolve a type.
| |||||||||||
Resolve a class name, using only package and import directives.
| |||||||||||
Given its fully-qualified name, verify that a class is defined and accessible.
| |||||||||||
Resolve a class name, using only package and import directives.
| |||||||||||
Resolve the names within a type, returning the adjusted type.
| |||||||||||
Discover if name consists of a package prefix, followed by the
name of a class (that actually exists), followed possibly by
some inner class names.
| |||||||||||
set character encoding name
| |||||||||||
Release resources, if any.
| |||||||||||
Floating point is strict by default
| |||||||||||
Verbose
| |||||||||||
Do not support virtual machines before version 1.2.
| |||||||||||
Verbose
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Check if a class exists (without actually loading it). (Since inner classes cannot in general be examined without loading source, this method does not accept inner names.)
get flag of generation the coverage data file
get coverage flag
Debugging flags. There used to be a method debug() that has been replaced because -g has changed meaning (it now cooperates with -O and line number, variable range and source file info can be toggled separately).
Dependencies
Deprecation warnings are enabled.
Dump debugging stuff
Issue an error. source - the input source, usually a file name string offset - the offset in the source of the error err - the error number (as defined in this interface) arg1 - an optional argument to the error (null if not applicable) arg2 - a second optional argument to the error (null if not applicable) arg3 - a third optional argument to the error (null if not applicable)
Return true if an explicit cast from this type to the given type is allowed.
ClassNotFound |
---|
Return a class declaration given a fully qualified class name.
Return a class declaration given a type. Only works for class types.
Return a class definition given a fully qualified class name.
Should be called only with 'internal' class names, i.e., the result of a call to 'resolveName' or a synthetic class name.
ClassNotFound |
---|
Return a class definition given a type. Only works for class types.
ClassNotFound |
---|
Flags.
Return major version to use in generated class files.
Return minor version to use in generated class files.
Like 'getClassDefinition(env)', but check access on each component. Currently called only by 'resolve' above. It is doubtful that calls to 'getClassDefinition(env)' are appropriate now.
ClassNotFound |
---|
Return the source of the environment (ie: the thing being compiled/parsed).
Return true if an implicit cast from this type to the given type is allowed.
ClassNotFound |
---|
Returns true if the given method is applicable to the given arguments
ClassNotFound |
---|
Tells whether an Identifier refers to a package which should be exempt from the "exists" check in Imports#resolve().
Returns true if "from" is a more specific type than "to"
ClassNotFound |
---|
Returns true if "best" is in every argument at least as good as "other"
ClassNotFound |
---|
Create a new class.
Create a new field.
Optimization flags. There used to be a method optimize() that has been replaced because -O has changed meaning in javac to be replaced with -O and -O:interclass.
Output a string. This can either be an error message or something for debugging. This should be used instead of println.
Print Dependencies to stdout
Resolve a type. Make sure that all the classes referred to by the type have a definition. Report errors. Return true if the type is well-formed. Presently used for types appearing in member declarations, which represent named types internally as qualified identifiers. Type names appearing in local variable declarations and within expressions are represented as identifier or field expressions, and are resolved by 'toType', which delegates handling of the non-inner portion of the name to this method.
In 'toType', the various stages of qualification are represented by separate AST nodes. Here, we are given a single identifier which contains the entire qualification structure. It is not possible in general to set the error location to the exact position of a component that is in error, so an error message must refer to the entire qualified name. An attempt to keep track of the string length of the components of the name and to offset the location accordingly fails because the initial prefix of the name may have been rewritten by an earlier call to 'resolveName'. See 'SourceMember.resolveTypeStructure'. The situation is actually even worse than this, because only a single location is passed in for an entire declaration, which may contain many type names. All error messages are thus poorly localized. These checks should be done while traversing the parse tree for the type, not the type descriptor.
DESIGN NOTE: As far as I can tell, the two-stage resolution of names represented in string form is an artifact of the late implementation of inner classes and the use of mangled names internally within the compiler. All qualified names should have their hiearchical structure made explicit in the parse tree at the phase at which they are presented for static semantic checking. This would affect class names appearing in 'extends', 'implements', and 'throws' clauses, as well as in member declarations.
Resolve a class name, using only package and import directives.
ClassNotFound |
---|
Given its fully-qualified name, verify that a class is defined and accessible. Used to check components of qualified names in contexts where a class is expected. Like 'resolve', but is given a single type name, not a type descriptor.
Resolve a class name, using only package and import directives. Report no errors.
Resolve the names within a type, returning the adjusted type. Adjust class names to reflect scoping. Do not report errors.
NOTE: It would be convenient to check for errors here, such as verifying that each component of a qualified name exists and is accessible. Why must this be done in a separate phase?
If the 'synth' argument is true, indicating that the member whose type is being resolved is synthetic, names are resolved with respect to the package scope. (Fix for 4097882)
Discover if name consists of a package prefix, followed by the name of a class (that actually exists), followed possibly by some inner class names. If we can't find a class that exists, return the name unchanged.
This routine is used after a class name fails to be resolved by means of imports or inner classes. However, import processing uses this routine directly, since import names must be exactly qualified to start with.
Release resources, if any.
Floating point is strict by default
Verbose
Do not support virtual machines before version 1.2. This option is not supported and is only here for testing purposes.
Verbose