public class

BatchEnvironment

extends Environment
implements ErrorConsumer
java.lang.Object
   ↳ sun.tools.java.Environment
     ↳ sun.tools.javac.BatchEnvironment
Known Direct Subclasses

Class Overview

Main environment of the batch version of the Java compiler, this needs more work. 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.

Summary

[Expand]
Inherited Constants
From interface sun.tools.java.Constants
From interface sun.tools.java.RuntimeConstants
Fields
protected ClassPath binaryPath The path we use for finding class (binary) files.
public File covFile coverage data file
public int errorLimit Maximum number of errors to print.
public int flags flags
public short majorVersion Major and minor versions to use for generated class files.
public short minorVersion
public int ndeprecations
public int nerrors The number of errors and warnings
public int nwarnings
protected ClassPath sourcePath The path we use for finding source files.
[Expand]
Inherited Fields
From interface sun.tools.java.Constants
From interface sun.tools.java.RuntimeConstants
Public Constructors
BatchEnvironment(ClassPath path)
Old constructors -- these constructors build a BatchEnvironment with an old-style class path.
BatchEnvironment(OutputStream out, ClassPath path)
BatchEnvironment(OutputStream out, ClassPath path, ErrorConsumer errorConsumer)
BatchEnvironment(ClassPath sourcePath, ClassPath binaryPath)
New constructors -- these constructors build a BatchEnvironment with a source path and a binary path.
BatchEnvironment(OutputStream out, ClassPath sourcePath, ClassPath binaryPath)
BatchEnvironment(OutputStream out, ClassPath sourcePath, ClassPath binaryPath, ErrorConsumer errorConsumer)
Public Methods
boolean classExists(Identifier nm)
Check if a class exists Applies only to package members (non-nested classes).
void error(Object source, long where, String err, Object arg1, Object arg2, Object arg3)
Issue an error
String errorString(String err, Object arg1, Object arg2, Object arg3)
Error String
void flushErrors()
ClassDeclaration getClassDeclaration(Identifier nm)
Get a class, given the fully qualified class name
ClassDeclaration getClassDeclaration(Type t)
Return a class declaration given a type.
Enumeration getClasses()
Return an enumeration of all the currently defined classes in order of appearance to getClassDeclaration().
int getFlags()
Return flags
short getMajorVersion()
Return major version to use for generated class files
short getMinorVersion()
Return minor version to use for generated class files
Package getPackage(Identifier pkg)
Get the package path for a package
File getcovFile()
Return coverage data file
boolean isExemptPackage(Identifier id)
Tells whether an Identifier refers to a package which should be exempt from the "exists" check in Imports#resolve().
void loadDefinition(ClassDeclaration c)
Load the definition of a class or at least determine how to load it.
ClassDefinition makeClassDefinition(Environment toplevelEnv, long where, IdentifierToken name, String doc, int modifiers, IdentifierToken superClass, IdentifierToken[] interfaces, ClassDefinition outerClass)
Create a new class.
MemberDefinition makeMemberDefinition(Environment origEnv, long where, ClassDefinition clazz, String doc, int modifiers, Type type, Identifier name, IdentifierToken[] argNames, IdentifierToken[] expIds, Object value)
Create a new field.
void output(String msg)
Output a string.
void parseFile(ClassFile file)
Parse a source file
void pushError(String errorFileName, int line, String message, String referenceText, String referenceTextPointer)
Flush outstanding errors
void reportError(Object src, long where, String err, String msg)
Report error
void shutdown()
Release resources in classpath.
Protected Methods
static ClassPath[] classPaths(String srcPathString, String classPathString, String sysClassPathString, String extDirsString)
boolean insertError(long where, String message)
Insert an error message in the list of outstanding error messages.
[Expand]
Inherited Methods
From class sun.tools.java.Environment
From class java.lang.Object
From interface sun.tools.javac.ErrorConsumer

Fields

protected ClassPath binaryPath

The path we use for finding class (binary) files.

public File covFile

coverage data file

public int errorLimit

Maximum number of errors to print.

public int flags

flags

public short majorVersion

Major and minor versions to use for generated class files. Environments that extend BatchEnvironment (such as javadoc's Env class) get the default values below. javac itself may override these versions with values determined from the command line "-target" option.

public short minorVersion

public int ndeprecations

public int nerrors

The number of errors and warnings

public int nwarnings

protected ClassPath sourcePath

The path we use for finding source files.

Public Constructors

public BatchEnvironment (ClassPath path)

Old constructors -- these constructors build a BatchEnvironment with an old-style class path.

public BatchEnvironment (OutputStream out, ClassPath path)

public BatchEnvironment (OutputStream out, ClassPath path, ErrorConsumer errorConsumer)

public BatchEnvironment (ClassPath sourcePath, ClassPath binaryPath)

New constructors -- these constructors build a BatchEnvironment with a source path and a binary path.

public BatchEnvironment (OutputStream out, ClassPath sourcePath, ClassPath binaryPath)

public BatchEnvironment (OutputStream out, ClassPath sourcePath, ClassPath binaryPath, ErrorConsumer errorConsumer)

Public Methods

public boolean classExists (Identifier nm)

Check if a class exists Applies only to package members (non-nested classes).

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

Issue an error

public String errorString (String err, Object arg1, Object arg2, Object arg3)

Error String

public void flushErrors ()

public ClassDeclaration getClassDeclaration (Identifier nm)

Get a class, given the fully qualified class name

public ClassDeclaration getClassDeclaration (Type t)

Return a class declaration given a type. Only works for class types.

public Enumeration getClasses ()

Return an enumeration of all the currently defined classes in order of appearance to getClassDeclaration().

public int getFlags ()

Return flags

public short getMajorVersion ()

Return major version to use for generated class files

public short getMinorVersion ()

Return minor version to use for generated class files

public Package getPackage (Identifier pkg)

Get the package path for a package

Throws
IOException

public File getcovFile ()

Return coverage data file

public boolean isExemptPackage (Identifier id)

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

public void loadDefinition (ClassDeclaration c)

Load the definition of a class or at least determine how to load it. The caller must repeat calls to this method until it the state converges to CS_BINARY, CS_PARSED, or the like..

public ClassDefinition makeClassDefinition (Environment toplevelEnv, long where, IdentifierToken name, String doc, int modifiers, IdentifierToken superClass, IdentifierToken[] interfaces, ClassDefinition outerClass)

Create a new class.

public MemberDefinition makeMemberDefinition (Environment origEnv, long where, ClassDefinition clazz, String doc, int modifiers, Type type, Identifier name, IdentifierToken[] argNames, IdentifierToken[] expIds, Object value)

Create a new field.

public void output (String msg)

Output a string. This can either be an error message or something for debugging.

public void parseFile (ClassFile file)

Parse a source file

public void pushError (String errorFileName, int line, String message, String referenceText, String referenceTextPointer)

Flush outstanding errors

public void reportError (Object src, long where, String err, String msg)

Report error

public void shutdown ()

Release resources in classpath.

Protected Methods

protected static ClassPath[] classPaths (String srcPathString, String classPathString, String sysClassPathString, String extDirsString)

protected boolean insertError (long where, String message)

Insert an error message in the list of outstanding error messages. The list is sorted on input position and contains no duplicates. The return value indicates whether or not the message was actually inserted. The method flushErrors() used to check for duplicate error messages. It would only detect duplicates if they were contiguous. Removing non-contiguous duplicate error messages is slightly less complicated at insertion time, so the functionality was moved here. This also saves a miniscule number of allocations.