APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.tools.javac.code

public Class ClassFinder

extends Object
Class Inheritance
Imports
java.io.IOException, java.nio.file.Path, java.util.EnumSet, .HashMap, .Iterator, .Map, .NoSuchElementException, .Set, java.util.function.Supplier, javax.lang.model.SourceVersion, javax.tools.JavaFileManager, .JavaFileManager.Location, .JavaFileObject, .JavaFileObject.Kind, .StandardJavaFileManager, .StandardLocation, com.sun.tools.javac.code.Scope.WriteableScope, .Symbol.ClassSymbol, .Symbol.Completer, .Symbol.CompletionFailure, .Symbol.ModuleSymbol, .Symbol.PackageSymbol, .Symbol.TypeSymbol, .Symbol, .Symbol.CompletionFailure, com.sun.tools.javac.comp.Annotate, com.sun.tools.javac.file.JRTIndex, .JavacFileManager, com.sun.tools.javac.jvm.ClassReader, .Profile, com.sun.tools.javac.main.Option, .DelegatingJavaFileManager, com.sun.tools.javac.platform.PlatformDescription, com.sun.tools.javac.resources.CompilerProperties.Fragments, com.sun.tools.javac.util.*, .Dependencies.CompletionCause

This class provides operations to locate class definitions from the source and class files on the paths provided to javac.

This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ClassFinder.BadClassFile

Used for bad class definition files, such as bad .class files or for .java files with unexpected package or class names.

public static class

Field Summary

Modifier and TypeField and Description
private final Annotate
private boolean
cacheCompletionFailure

Switch: cache completion failures unless -XDdev is used

private final Symbol.CompletionFailure
protected static final Context.Key<ClassFinder>
classFinderKey

The context key for the class finder.

pack-priv final Name
completionFailureName

Force a completion failure on this name

protected JavaFileObject
currentClassFile

The path name of the class file currently being read.

protected JavaFileManager.Location
protected Symbol
currentOwner

The class or method currently being read.

pack-priv final DeferredCompletionFailureHandler
private final Dependencies
dependencies

Dependency tracker

pack-priv JCDiagnostic.Factory
diagFactory

Factory for diagnostics

private final JavaFileManager
fileManager

Access to files

private final JRTIndex
jrtIndex

Use direct access to the JRTIndex to access the temporary replacement for the info that used to be in ct.sym.

pack-priv final Log
log

The log to use for verbose output

pack-priv final Names
names

The name table.

private boolean
protected boolean
preferSource

Switch: prefer source files instead of newer when both source and class are available

private final Profile
profile

The currently selected profile.

pack-priv ClassReader
public Symbol.Completer
sourceCompleter

Can be reassigned from outside: the completer to be used for ".java" files.

private Map<Symbol.PackageSymbol, Long>
pack-priv Symtab
syms

The symbol table.

private final Symbol.Completer
thisCompleter

Completer that delegates to the complete-method of this class.

protected boolean
userPathsFirst

Switch: Search classpath and sourcepath for classes before the bootclasspath

pack-priv boolean
verbose

Switch: verbose output.

private boolean

Constructor Summary

AccessConstructor and Description
protected
ClassFinder(Context context)

Construct a new class finder.

Method Summary

Modifier and TypeMethod and Description
private Symbol.CompletionFailure
private void
complete(Symbol sym)

Completion for classes to be loaded.

private void
completeEnclosing(Symbol.ClassSymbol c)

Tries to complete lexically enclosing classes if c looks like a nested class.

private void
completeOwners(Symbol o)

complete up through the enclosing package.

protected void
extraFileActions(Symbol.PackageSymbol pack, JavaFileObject fe)

this is used to support javadoc

pack-priv void
fillIn(Symbol.ClassSymbol c)

Fill in definition of class `c' from corresponding class or source file.

private void
fillIn(Symbol.PackageSymbol p)

Load directory of package into members scope.

private void
public Symbol.Completer
protected EnumSet<JavaFileObject.Kind>
getPackageFileKinds()

specifies types of files to be read when filling in a package symbol

pack-priv long
getSupplementaryFlags(Symbol.ClassSymbol c)

Returns any extra flags for a class symbol.

protected void
includeClassFile(Symbol.PackageSymbol p, JavaFileObject file)

Include class corresponding to given class file in package, unless (1) we already have one the same kind (.class or .java), or (2) we have one of the other kind, and the given class file is older.

public static ClassFinder
instance(Context context)

Get the ClassFinder instance for this invocation.

pack-priv Iterable<JavaFileObject>
public Symbol.ClassSymbol
loadClass(Symbol.ModuleSymbol msym, Name flatname)

Load a toplevel class with given fully qualified name The class is entered into `classes' only if load was successful.

private Symbol.CompletionFailure
newCompletionFailure(Symbol.TypeSymbol c, Supplier<JCDiagnostic> diag)

Static factory for CompletionFailure objects.

protected JavaFileObject
preferredFileObject(JavaFileObject a, JavaFileObject b)

Implement policy to choose to derive information from a source file or a class file when both are present.

private void
private void
scanPlatformPath(Symbol.PackageSymbol p)

Scans platform class path for files in given package.

private void
scanUserPaths(Symbol.PackageSymbol p, boolean includeSourcePath)

Scans class path and source path for files in given package.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

annotateback to summary
private final Annotate annotate
cacheCompletionFailureback to summary
private boolean cacheCompletionFailure

Switch: cache completion failures unless -XDdev is used

cachedCompletionFailureback to summary
private final Symbol.CompletionFailure cachedCompletionFailure
classFinderKeyback to summary
protected static final Context.Key<ClassFinder> classFinderKey

The context key for the class finder.

completionFailureNameback to summary
pack-priv final Name completionFailureName

Force a completion failure on this name

currentClassFileback to summary
protected JavaFileObject currentClassFile

The path name of the class file currently being read.

currentLocback to summary
protected JavaFileManager.Location currentLoc
currentOwnerback to summary
protected Symbol currentOwner

The class or method currently being read.

dcfhback to summary
pack-priv final DeferredCompletionFailureHandler dcfh
dependenciesback to summary
private final Dependencies dependencies

Dependency tracker

diagFactoryback to summary
pack-priv JCDiagnostic.Factory diagFactory

Factory for diagnostics

fileManagerback to summary
private final JavaFileManager fileManager

Access to files

jrtIndexback to summary
private final JRTIndex jrtIndex

Use direct access to the JRTIndex to access the temporary replacement for the info that used to be in ct.sym. In time, this will go away and be replaced by the module system.

logback to summary
pack-priv final Log log

The log to use for verbose output

namesback to summary
pack-priv final Names names

The name table.

preferCurrentback to summary
private boolean preferCurrent
preferSourceback to summary
protected boolean preferSource

Switch: prefer source files instead of newer when both source and class are available

profileback to summary
private final Profile profile

The currently selected profile.

readerback to summary
pack-priv ClassReader reader
sourceCompleterback to summary
public Symbol.Completer sourceCompleter

Can be reassigned from outside: the completer to be used for ".java" files. If this remains unassigned ".java" files will not be loaded.

supplementaryFlagsback to summary
private Map<Symbol.PackageSymbol, Long> supplementaryFlags
symsback to summary
pack-priv Symtab syms

The symbol table.

thisCompleterback to summary
private final Symbol.Completer thisCompleter

Completer that delegates to the complete-method of this class.

userPathsFirstback to summary
protected boolean userPathsFirst

Switch: Search classpath and sourcepath for classes before the bootclasspath

verboseback to summary
pack-priv boolean verbose

Switch: verbose output.

verbosePathback to summary
private boolean verbosePath

Constructor Detail

ClassFinderback to summary
protected ClassFinder(Context context)

Construct a new class finder.

Annotations
@SuppressWarnings:this-escape

Method Detail

classFileNotFoundback to summary
private Symbol.CompletionFailure classFileNotFound(Symbol.ClassSymbol c)
completeback to summary
private void complete(Symbol sym) throws CompletionFailure

Completion for classes to be loaded. Before a class is loaded we make sure its enclosing class (if any) is loaded.

completeEnclosingback to summary
private void completeEnclosing(Symbol.ClassSymbol c)

Tries to complete lexically enclosing classes if c looks like a nested class. This is similar to completeOwners but handles the situation when a nested class is accessed directly as it is possible with the Tree API or javax.lang.model.*.

completeOwnersback to summary
private void completeOwners(Symbol o)

complete up through the enclosing package.

extraFileActionsback to summary
protected void extraFileActions(Symbol.PackageSymbol pack, JavaFileObject fe)

this is used to support javadoc

fillInback to summary
pack-priv void fillIn(Symbol.ClassSymbol c)

Fill in definition of class `c' from corresponding class or source file.

fillInback to summary
private void fillIn(Symbol.PackageSymbol p) throws IOException

Load directory of package into members scope.

fillInback to summary
private void fillIn(Symbol.PackageSymbol p, JavaFileManager.Location location, Iterable<JavaFileObject> files)
getCompleterback to summary
public Symbol.Completer getCompleter()
getPackageFileKindsback to summary
protected EnumSet<JavaFileObject.Kind> getPackageFileKinds()

specifies types of files to be read when filling in a package symbol

getSupplementaryFlagsback to summary
pack-priv long getSupplementaryFlags(Symbol.ClassSymbol c)

Returns any extra flags for a class symbol. This information used to be provided using private annotations in the class file in ct.sym; in time, this information will be available from the module system.

includeClassFileback to summary
protected void includeClassFile(Symbol.PackageSymbol p, JavaFileObject file)

Include class corresponding to given class file in package, unless (1) we already have one the same kind (.class or .java), or (2) we have one of the other kind, and the given class file is older.

instanceback to summary
public static ClassFinder instance(Context context)

Get the ClassFinder instance for this invocation.

listback to summary
pack-priv Iterable<JavaFileObject> list(JavaFileManager.Location location, Symbol.PackageSymbol p, String packageName, Set<JavaFileObject.Kind> kinds) throws IOException
loadClassback to summary
public Symbol.ClassSymbol loadClass(Symbol.ModuleSymbol msym, Name flatname) throws CompletionFailure

Load a toplevel class with given fully qualified name The class is entered into `classes' only if load was successful.

newCompletionFailureback to summary
private Symbol.CompletionFailure newCompletionFailure(Symbol.TypeSymbol c, Supplier<JCDiagnostic> diag)

Static factory for CompletionFailure objects. In practice, only one can be used at a time, so we share one to reduce the expense of allocating new exception objects.

preferredFileObjectback to summary
protected JavaFileObject preferredFileObject(JavaFileObject a, JavaFileObject b)

Implement policy to choose to derive information from a source file or a class file when both are present. May be overridden by subclasses.

scanModulePathsback to summary
private void scanModulePaths(Symbol.PackageSymbol p, Symbol.ModuleSymbol msym) throws IOException
scanPlatformPathback to summary
private void scanPlatformPath(Symbol.PackageSymbol p) throws IOException

Scans platform class path for files in given package.

scanUserPathsback to summary
private void scanUserPaths(Symbol.PackageSymbol p, boolean includeSourcePath) throws IOException

Scans class path and source path for files in given package.

com.sun.tools.javac.code back to summary

public Class ClassFinder.BadClassFile

extends CompletionFailure
Class Inheritance
Known Direct Subclasses
com.sun.tools.javac.code.ClassFinder.BadEnclosingMethodAttr

Used for bad class definition files, such as bad .class files or for .java files with unexpected package or class names.

Field Summary

Modifier and TypeField and Description
private static final long
Inherited from com.sun.tools.javac.code.Symbol.CompletionFailure:
dcfhsym

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static JCDiagnostic
Inherited from com.sun.tools.javac.code.Symbol.CompletionFailure:
getDetailValuegetDiagnosticgetMessageinitCauseresetDiagnostic

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.sun.tools.javac.code.Symbol.CompletionFailure.serialVersionUID.

Constructor Detail

BadClassFileback to summary
public BadClassFile(Symbol.TypeSymbol sym, JavaFileObject file, JCDiagnostic diag, JCDiagnostic.Factory diagFactory, DeferredCompletionFailureHandler dcfh)

Method Detail

createBadClassFileDiagnosticback to summary
private static JCDiagnostic createBadClassFileDiagnostic(JavaFileObject file, JCDiagnostic diag, JCDiagnostic.Factory diagFactory)
com.sun.tools.javac.code back to summary

public Class ClassFinder.BadEnclosingMethodAttr

extends BadClassFile
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
public

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.sun.tools.javac.code.ClassFinder.BadClassFile.serialVersionUID.

Constructor Detail

BadEnclosingMethodAttrback to summary
public BadEnclosingMethodAttr(Symbol.TypeSymbol sym, JavaFileObject file, JCDiagnostic diag, JCDiagnostic.Factory diagFactory, DeferredCompletionFailureHandler dcfh)