Class BatchEnvironment

  • All Implemented Interfaces:
    Constants, RuntimeConstants, ErrorConsumer
    Direct Known Subclasses:
    BatchEnvironment

    public class BatchEnvironment
    extends Environment
    implements ErrorConsumer
    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.
    • Field Detail

      • USE_LEGACY_PARSING_PROPERTY

        private static final java.lang.String USE_LEGACY_PARSING_PROPERTY
        See Also:
        Constant Field Values
      • JAVA_VERSION_PROPERTY

        private static final java.lang.String JAVA_VERSION_PROPERTY
        See Also:
        Constant Field Values
      • out

        private java.io.OutputStream out
        The stream where error message are printed.
      • binaryPath

        protected ClassPath binaryPath
        The path we use for finding class (binary) files.
      • packages

        private java.util.Hashtable<Identifier,​Package> packages
        A hashtable of resource contexts.
      • classesOrdered

        private java.util.Vector<ClassDeclaration> classesOrdered
        The classes, in order of appearance.
      • classes

        private java.util.Hashtable<Type,​ClassDeclaration> classes
        The classes, keyed by ClassDeclaration.
      • flags

        public int flags
        flags
      • majorVersion

        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.
      • minorVersion

        public short minorVersion
      • covFile

        private java.io.File covFile
        coverage data file
      • nerrors

        public int nerrors
        The number of errors and warnings
      • nwarnings

        public int nwarnings
      • ndeprecations

        private int ndeprecations
      • deprecationFiles

        private java.util.Vector<java.lang.Object> deprecationFiles
        A list of files containing deprecation warnings.
      • errorConsumer

        private ErrorConsumer errorConsumer
        writes out error messages
      • exemptPackages

        private java.util.Set<Identifier> exemptPackages
        A set of Identifiers for all packages exempt from the "exists" check in Imports#resolve(). These are the current packages for all classes being compiled as of the first call to isExemptPackage.
      • errorFileName

        private java.lang.String errorFileName
        The filename where the last errors have occurred
      • errors

        private ErrorMessage errors
        List of outstanding error messages
      • errorsPushed

        private int errorsPushed
      • errorLimit

        private int errorLimit
        Maximum number of errors to print.
      • hitErrorLimit

        private boolean hitErrorLimit
    • Constructor Detail

      • BatchEnvironment

        public BatchEnvironment​(java.io.OutputStream out,
                                ClassPath binaryPath)
      • BatchEnvironment

        public BatchEnvironment​(java.io.OutputStream out,
                                ClassPath binaryPath,
                                ErrorConsumer errorConsumer)
    • Method Detail

      • getMaxSupportedClassVersion

        public static int getMaxSupportedClassVersion()
      • useBinaryClassFactory

        private static boolean useBinaryClassFactory()
      • mayUseBinaryClassFactory

        public static boolean mayUseBinaryClassFactory()
      • isBinaryClassCompatibleJavaVersion

        private static boolean isBinaryClassCompatibleJavaVersion​(java.lang.String property)
      • getVersionPortion

        private static int getVersionPortion​(java.lang.String versionString)
      • getMajorVersion

        public short getMajorVersion()
        Return major version to use for generated class files
        Overrides:
        getMajorVersion in class Environment
      • getMinorVersion

        public short getMinorVersion()
        Return minor version to use for generated class files
        Overrides:
        getMinorVersion in class Environment
      • getcovFile

        public java.io.File getcovFile()
        Return coverage data file
        Overrides:
        getcovFile in class Environment
      • getClasses

        public java.util.Enumeration<ClassDeclaration> getClasses()
        Return an enumeration of all the currently defined classes in order of appearance to getClassDeclaration().
      • getGeneratedClasses

        public java.lang.Iterable<ClassDeclaration> getGeneratedClasses()
        Return the declarations for all generated classes. These can be recognized as having the 'parsed' status
      • isExemptPackage

        public boolean isExemptPackage​(Identifier id)
        Tells whether an Identifier refers to a package which should be exempt from the "exists" check in Imports#resolve().
        Overrides:
        isExemptPackage in class Environment
      • setExemptPackages

        private void setExemptPackages()
        Set the set of packages which are exempt from the exists check in Imports#resolve().
      • classExists

        public boolean classExists​(Identifier nm)
        Check if a class exists Applies only to package members (non-nested classes).
        Overrides:
        classExists in class Environment
      • parseFile

        public void parseFile​(ClassFile file)
                       throws java.io.FileNotFoundException
        Parse a source file
        Throws:
        java.io.FileNotFoundException
      • loadFile

        private ClassDefinition loadFile​(ClassFile file)
                                  throws java.io.IOException
        Load a binary file
        Throws:
        java.io.IOException
      • shutdown

        public void shutdown()
        Release resources in classpath.
        Overrides:
        shutdown in class Environment
      • errorString

        public java.lang.String errorString​(java.lang.String err,
                                            java.lang.Object arg1,
                                            java.lang.Object arg2,
                                            java.lang.Object arg3)
        Error String
      • insertError

        private boolean insertError​(long where,
                                    java.lang.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.
      • pushError

        public void pushError​(java.lang.String errorFileName,
                              int line,
                              java.lang.String message,
                              java.lang.String referenceText,
                              java.lang.String referenceTextPointer)
        Flush outstanding errors
        Specified by:
        pushError in interface ErrorConsumer
      • flushErrors

        public void flushErrors()
      • reportError

        private void reportError​(java.lang.Object src,
                                 long where,
                                 java.lang.String err,
                                 java.lang.String msg)
        Report error
      • error

        public void error​(java.lang.Object source,
                          long where,
                          java.lang.String err,
                          java.lang.Object arg1,
                          java.lang.Object arg2,
                          java.lang.Object arg3)
        Issue an error
        Overrides:
        error in class Environment
      • output

        public void output​(java.lang.String msg)
        Output a string. This can either be an error message or something for debugging.
        Overrides:
        output in class Environment