Java Doc for Environment.java in  » 6.0-JDK-Modules-sun » tools » sun » tools » java » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules sun » tools » sun.tools.java 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   sun.tools.java.Environment

All known Subclasses:   sun.tools.javac.BatchEnvironment,
Environment
public class Environment implements Constants(Code)
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.
author:
   Arthur van Hoff
version:
   1.82, 05/05/07



Field Summary
 Stringencoding
    
 Environmentenv
     The actual environment to which everything is forwarded.
 Objectsource
     The object that is currently being parsed/compiled.

Constructor Summary
public  Environment(Environment env, Object source)
    
public  Environment()
    

Method Summary
public  booleanclassExists(Identifier nm)
     Check if a class exists (without actually loading it).
final public  booleanclassExists(Type t)
    
final public  booleancovdata()
    
final public  booleancoverage()
    
public static  voiddebugOutput(Object msg)
    
final public  booleandebug_lines()
     Debugging flags.
final public  booleandebug_source()
    
final public  booleandebug_vars()
    
final public  booleandependencies()
    
final public  booleandeprecation()
     Deprecation warnings are enabled.
public  voiddtEnter(String s)
    
public  voiddtEvent(String s)
    
public  voiddtExit(String s)
    
final public  booleandump()
    
public  booleandumpModifiers()
    
public  voiderror(Object source, long where, String err, Object arg1, Object arg2, Object arg3)
     Issue an error.
final public  voiderror(long where, String err, Object arg1, Object arg2, Object arg3)
    
final public  voiderror(long where, String err, Object arg1, Object arg2)
    
final public  voiderror(long where, String err, Object arg1)
    
final public  voiderror(long where, String err)
    
public  booleanexplicitCast(Type from, Type to)
     Return true if an explicit cast from this type to the given type is allowed.
public  StringgetCharacterEncoding()
    
public  ClassDeclarationgetClassDeclaration(Identifier nm)
     Return a class declaration given a fully qualified class name.
public  ClassDeclarationgetClassDeclaration(Type t)
     Return a class declaration given a type.
final public  ClassDefinitiongetClassDefinition(Identifier nm)
     Return a class definition given a fully qualified class name.
final public  ClassDefinitiongetClassDefinition(Type t)
     Return a class definition given a type.
public  intgetFlags()
     Flags.
public  ImportsgetImports()
     Get the imports used to resolve class names.
public  shortgetMajorVersion()
     Return major version to use in generated class files.
public  shortgetMinorVersion()
     Return minor version to use in generated class files.
public  PackagegetPackage(Identifier pkg)
    
final public  ClassDefinitiongetQualifiedClassDefinition(long where, Identifier nm, ClassDefinition ctxClass, boolean isExtends)
     Like 'getClassDefinition(env)', but check access on each component. Currently called only by 'resolve' above.
final public  ObjectgetSource()
     Return the source of the environment (ie: the thing being compiled/parsed).
public  FilegetcovFile()
    
public  booleanimplicitCast(Type from, Type to)
     Return true if an implicit cast from this type to the given type is allowed.
public  booleanisApplicable(MemberDefinition m, Type args)
    
public  booleanisExemptPackage(Identifier id)
     Tells whether an Identifier refers to a package which should be exempt from the "exists" check in Imports#resolve().
public  booleanisMoreSpecific(MemberDefinition best, MemberDefinition other)
    
public  booleanisMoreSpecific(Type from, Type to)
    
public  voidloadDefinition(ClassDeclaration c)
     Load the definition of a class.
public  ClassDefinitionmakeClassDefinition(Environment origEnv, long where, IdentifierToken name, String doc, int modifiers, IdentifierToken superClass, IdentifierToken interfaces, ClassDefinition outerClass)
     Create a new class.
public  MemberDefinitionmakeMemberDefinition(Environment origEnv, long where, ClassDefinition clazz, String doc, int modifiers, Type type, Identifier name, IdentifierToken argNames, IdentifierToken expIds, Object value)
     Create a new field.
final public  booleanopt()
     Optimization flags.
final public  booleanopt_interclass()
    
public  voidoutput(String msg)
     Output a string.
final public  booleanprint_dependencies()
    
public  booleanresolve(long where, ClassDefinition c, Type t)
     Resolve a type.
public  Identifierresolve(Identifier nm)
     Resolve a class name, using only package and import directives.
public  booleanresolveByName(long where, ClassDefinition c, Identifier nm)
     Given its fully-qualified name, verify that a class is defined and accessible.
public  booleanresolveExtendsByName(long where, ClassDefinition c, Identifier nm)
    
public  IdentifierresolveName(Identifier name)
     Resolve a class name, using only package and import directives.
public  TyperesolveNames(ClassDefinition c, Type t, boolean synth)
     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.

final public  IdentifierresolvePackageQualifiedName(Identifier name)
     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.
public  voidsetCharacterEncoding(String encoding)
    
public  voidshutdown()
     Release resources, if any.
final public  booleanstrictdefault()
    
final public  booleanverbose()
    
final public  booleanversion12()
     Do not support virtual machines before version 1.2.
final public  booleanwarnings()
    

Field Detail
encoding
String encoding(Code)
External character encoding name



env
Environment env(Code)
The actual environment to which everything is forwarded.



source
Object source(Code)
The object that is currently being parsed/compiled. It is either a file name (String) or a field (MemberDefinition) or a class (ClassDeclaration or ClassDefinition).




Constructor Detail
Environment
public Environment(Environment env, Object source)(Code)



Environment
public Environment()(Code)




Method Detail
classExists
public boolean classExists(Identifier nm)(Code)
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.)



classExists
final public boolean classExists(Type t)(Code)



covdata
final public boolean covdata()(Code)
get flag of generation the coverage data file



coverage
final public boolean coverage()(Code)
get coverage flag



debugOutput
public static void debugOutput(Object msg)(Code)



debug_lines
final public boolean debug_lines()(Code)
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).



debug_source
final public boolean debug_source()(Code)



debug_vars
final public boolean debug_vars()(Code)



dependencies
final public boolean dependencies()(Code)
Dependencies



deprecation
final public boolean deprecation()(Code)
Deprecation warnings are enabled.



dtEnter
public void dtEnter(String s)(Code)



dtEvent
public void dtEvent(String s)(Code)



dtExit
public void dtExit(String s)(Code)



dump
final public boolean dump()(Code)
Dump debugging stuff



dumpModifiers
public boolean dumpModifiers()(Code)



error
public void error(Object source, long where, String err, Object arg1, Object arg2, Object arg3)(Code)
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)



error
final public void error(long where, String err, Object arg1, Object arg2, Object arg3)(Code)



error
final public void error(long where, String err, Object arg1, Object arg2)(Code)



error
final public void error(long where, String err, Object arg1)(Code)



error
final public void error(long where, String err)(Code)



explicitCast
public boolean explicitCast(Type from, Type to) throws ClassNotFound(Code)
Return true if an explicit cast from this type to the given type is allowed.



getCharacterEncoding
public String getCharacterEncoding()(Code)
Return character encoding name



getClassDeclaration
public ClassDeclaration getClassDeclaration(Identifier nm)(Code)
Return a class declaration given a fully qualified class name.



getClassDeclaration
public ClassDeclaration getClassDeclaration(Type t)(Code)
Return a class declaration given a type. Only works for class types.



getClassDefinition
final public ClassDefinition getClassDefinition(Identifier nm) throws ClassNotFound(Code)
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.




getClassDefinition
final public ClassDefinition getClassDefinition(Type t) throws ClassNotFound(Code)
Return a class definition given a type. Only works for class types.



getFlags
public int getFlags()(Code)
Flags.



getImports
public Imports getImports()(Code)
Get the imports used to resolve class names.



getMajorVersion
public short getMajorVersion()(Code)
Return major version to use in generated class files.



getMinorVersion
public short getMinorVersion()(Code)
Return minor version to use in generated class files.



getPackage
public Package getPackage(Identifier pkg) throws IOException(Code)
Get the package path for a package



getQualifiedClassDefinition
final public ClassDefinition getQualifiedClassDefinition(long where, Identifier nm, ClassDefinition ctxClass, boolean isExtends) throws ClassNotFound(Code)
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.



getSource
final public Object getSource()(Code)
Return the source of the environment (ie: the thing being compiled/parsed).



getcovFile
public File getcovFile()(Code)
Return the coverage data file



implicitCast
public boolean implicitCast(Type from, Type to) throws ClassNotFound(Code)
Return true if an implicit cast from this type to the given type is allowed.



isApplicable
public boolean isApplicable(MemberDefinition m, Type args) throws ClassNotFound(Code)
Returns true if the given method is applicable to the given arguments



isExemptPackage
public boolean isExemptPackage(Identifier id)(Code)
Tells whether an Identifier refers to a package which should be exempt from the "exists" check in Imports#resolve().



isMoreSpecific
public boolean isMoreSpecific(MemberDefinition best, MemberDefinition other) throws ClassNotFound(Code)
Returns true if "best" is in every argument at least as good as "other"



isMoreSpecific
public boolean isMoreSpecific(Type from, Type to) throws ClassNotFound(Code)
Returns true if "from" is a more specific type than "to"



loadDefinition
public void loadDefinition(ClassDeclaration c)(Code)
Load the definition of a class.



makeClassDefinition
public ClassDefinition makeClassDefinition(Environment origEnv, long where, IdentifierToken name, String doc, int modifiers, IdentifierToken superClass, IdentifierToken interfaces, ClassDefinition outerClass)(Code)
Create a new class.



makeMemberDefinition
public MemberDefinition makeMemberDefinition(Environment origEnv, long where, ClassDefinition clazz, String doc, int modifiers, Type type, Identifier name, IdentifierToken argNames, IdentifierToken expIds, Object value)(Code)
Create a new field.



opt
final public boolean opt()(Code)
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.



opt_interclass
final public boolean opt_interclass()(Code)



output
public void output(String msg)(Code)
Output a string. This can either be an error message or something for debugging. This should be used instead of println.



print_dependencies
final public boolean print_dependencies()(Code)
Print Dependencies to stdout



resolve
public boolean resolve(long where, ClassDefinition c, Type t)(Code)
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
public Identifier resolve(Identifier nm) throws ClassNotFound(Code)
Resolve a class name, using only package and import directives.



resolveByName
public boolean resolveByName(long where, ClassDefinition c, Identifier nm)(Code)
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.



resolveExtendsByName
public boolean resolveExtendsByName(long where, ClassDefinition c, Identifier nm)(Code)



resolveName
public Identifier resolveName(Identifier name)(Code)
Resolve a class name, using only package and import directives. Report no errors.




resolveNames
public Type resolveNames(ClassDefinition c, Type t, boolean synth)(Code)
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)




resolvePackageQualifiedName
final public Identifier resolvePackageQualifiedName(Identifier name)(Code)
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.




setCharacterEncoding
public void setCharacterEncoding(String encoding)(Code)
set character encoding name



shutdown
public void shutdown()(Code)
Release resources, if any.



strictdefault
final public boolean strictdefault()(Code)
Floating point is strict by default



verbose
final public boolean verbose()(Code)
Verbose



version12
final public boolean version12()(Code)
Do not support virtual machines before version 1.2. This option is not supported and is only here for testing purposes.



warnings
final public boolean warnings()(Code)
Verbose



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.