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

public Class ClassReader

extends Object
Class Inheritance
Imports
java.io.*, java.net.URI, .URISyntaxException, java.nio.CharBuffer, java.nio.file.ClosedFileSystemException, java.util.Arrays, .EnumSet, .HashMap, .HashSet, .Map, .Set, java.util.function.IntFunction, .Predicate, java.util.stream.IntStream, javax.lang.model.element.Modifier, .NestingKind, javax.tools.JavaFileManager, .JavaFileObject, com.sun.tools.javac.code.Source, .Source.Feature, com.sun.tools.javac.code.*, com.sun.tools.javac.code.Directive.*, .Scope.WriteableScope, com.sun.tools.javac.code.Symbol.*, .Symtab, com.sun.tools.javac.code.Type.*, .Scope.LookupKind, com.sun.tools.javac.comp.Annotate, .Annotate.AnnotationTypeCompleter, .Annotate.AnnotationTypeMetadata, com.sun.tools.javac.file.BaseFileManager, .PathFileObject, com.sun.tools.javac.jvm.ClassFile.Version, .PoolConstant.NameAndType, com.sun.tools.javac.main.Option, com.sun.tools.javac.resources.CompilerProperties.Errors, .CompilerProperties.Fragments, .CompilerProperties.LintWarnings, .CompilerProperties.Warnings, com.sun.tools.javac.util.*, .ByteBuffer.UnderflowException, .DefinedBy.Api, .JCDiagnostic.Fragment, .Log.DeferredDiagnosticHandler

This class provides operations to read a classfile into an internal representation. The internal representation is anchored in a ClassSymbol which contains in its scope symbol representations for all other definitions in the classfile. Top-level Classes themselves appear as members of the scopes of PackageSymbols.

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
pack-priv class
pack-priv class
pack-priv class
pack-priv static class
protected static enum
protected abstract class
pack-priv static class
private class
pack-priv static class
ClassReader.CompoundAnnotationProxy

A temporary proxy representing a compound attribute.

pack-priv static class
private static class
private static class
pack-priv static class
ClassReader.ParameterAnnotations

A holder for parameter annotations.

private class
pack-priv static interface
private static class
ClassReader.SourceFileObject

A subclass of JavaFileObject for the sourcefile attribute found in a classfile.

pack-priv class
pack-priv static class
ClassReader.TypeAnnotationProxy

A temporary proxy representing a type annotation.

private static class
ClassReader.TypeAnnotationStructuralTypeMapping

A type mapping that rewrites the type to include type annotations.

private static class
private class

Field Summary

Modifier and TypeField and Description
pack-priv boolean
allowModules

Switch: allow modules.

pack-priv boolean
allowRecords

Switch: allow records

pack-priv boolean
allowSealedTypes

Switch: allow sealed

pack-priv int[]
allParameterAccessFlags

A table to hold the access flags of the method parameters, for all parameters including synthetic and mandated ones.

private final Annotate
protected Map<Name, ClassReader.AttributeReader>
protected int
bp

The current input pointer.

pack-priv ByteBuffer
buf

The buffer containing the currently read class file.

protected Set<ClassReader.AttributeKind>
protected Set<ClassReader.AttributeKind>
protected static final Context.Key<ClassReader>
classReaderKey

The context key for the class reader.

protected JavaFileObject
currentClassFile

The path name of the class file currently being read.

protected Symbol.ModuleSymbol
currentModule

The module containing the class currently being read.

protected Symbol
currentOwner

The class or method currently being read.

pack-priv DeferredCompletionFailureHandler
pack-priv JCDiagnostic.Factory
diagFactory

Factory for diagnostics

private final JavaFileManager
fileManager

Access to files

public boolean
filling

We can only read a single class file at a time; this flag keeps track of when we are currently reading a class file.

private List<Type>
public static final int
private List<ClassReader.InterimProvidesDirective>
private List<ClassReader.InterimUsesDirective>
pack-priv final Log
log

The log to use for verbose output

pack-priv int
majorVersion

The major version number of the class file being read.

protected Set<ClassReader.AttributeKind>
pack-priv int
minorVersion

The minor version number of the class file being read.

private List<Type>
pack-priv final Names
names

The name table.

pack-priv int[]
parameterAccessFlags

A table to hold the access flags of the method parameters.

pack-priv ClassReader.ParameterAnnotations[]
parameterAnnotations

A table to hold annotations for method parameters.

pack-priv int[]
parameterNameIndicesLvt

A table to hold the constant pool indices for method parameter names, as given in LocalVariableTable attributes.

pack-priv int[]
parameterNameIndicesMp

A table to hold the constant pool indices for method parameter names, as given in the MethodParameters attribute.

pack-priv PoolReader
poolReader

The pool reader.

pack-priv Preview
preview

Support for preview language features.

pack-priv boolean
previewClassFile

true if the class file being read is a preview class file.

public final Profile
profile

The currently selected profile.

private boolean
pack-priv ClassReader.CompoundAnnotationProxy
repeatable

The prototype @Repeatable Attribute.Compound if this class is an annotation annotated with @Repeatable

public boolean
saveParameterNames

Switch: preserve parameter names from the variable table.

pack-priv int
pack-priv boolean
pack-priv int
pack-priv byte[]
signature

The unread portion of the currently read type is signature[sigp..siglimit-1].

pack-priv byte[]
pack-priv int
pack-priv Symtab
syms

The symbol table.

pack-priv ClassReader.CompoundAnnotationProxy
target

The prototype @Target Attribute.Compound if this class is an annotation annotated with @Target

pack-priv Types
protected Scope.WriteableScope
typevars

The current scope where type variables are entered.

pack-priv Convert.Validation
utf8validation

UTF-8 validation level

pack-priv boolean
verbose

Switch: verbose output.

pack-priv Set<Name>
warnedAttrs

The set of attribute names for which warnings have been generated for the current class

pack-priv boolean
warnOnIllegalUtf8

Switch: warn (instead of error) on illegal UTF-8

Constructor Summary

AccessConstructor and Description
protected
ClassReader(Context context)

Construct a new class reader.

Method Summary

Modifier and TypeMethod and Description
private void
addTypeAnnotationsToSymbol(Symbol s, List<Attribute.TypeCompound> attributes)

Rewrites types in the given symbol to include type annotations.

pack-priv long
adjustClassFlags(long flags)

pack-priv long
adjustFieldFlags(long flags)

pack-priv long
adjustMethodFlags(long flags)

private List<Type>
adjustMethodParams(long flags, List<Type> args)

pack-priv void
adjustParameterAnnotations(Symbol.MethodSymbol sym, Type methodDescriptor, boolean forceLocal)

pack-priv void
attachAnnotationDefault(final Symbol sym)

Attach the default value for an annotation element.

pack-priv void
attachAnnotations(final Symbol sym)

Attach annotations.

pack-priv void
attachAnnotations(final Symbol sym, List<ClassReader.CompoundAnnotationProxy> annotations)

Attach annotations.

pack-priv void
public ClassFinder.BadClassFile
badClassFile(String key, Object... args)

public ClassFinder.BadClassFile
public ClassFinder.BadClassFile
public ClassFinder.BadEnclosingMethodAttr
pack-priv Type
classSigToType()

Convert class signature to type, where signature is implicit.

private void
protected Symbol.ClassSymbol
protected Symbol.ClassSymbol
private void
enterMember(Symbol.ClassSymbol c, Symbol sym)

Add member to class unless it is synthetic.

protected void
enterTypevars(Symbol sym, Type t)

Enter type variables of this classtype and all enclosing ones in `typevars'.

private Symbol.MethodSymbol
findMethod(PoolConstant.NameAndType nt, Scope scope, long flags)

pack-priv Type
findTypeVar(Name name)

Find type variable with given name in `typevars' scope.

private void
pack-priv void
initParameterNames(Symbol.MethodSymbol sym)

Init the parameter names array.

public static ClassReader
instance(Context context)

Get the ClassReader instance for this invocation.

private static boolean
isAsciiDigit(char c)

Character.isDigit answers true to some non-ascii digits.

private boolean
isSameBinaryType(Type.MethodType mt1, Type.MethodType mt2)

Similar to Types.isSameType but avoids completion

private Symbol.MethodSymbol
lookupMethod(Symbol.TypeSymbol tsym, Name name, List<Type> argtypes)

pack-priv int
nextByte()

Read a byte.

pack-priv char
nextChar()

Read a character.

pack-priv int
nextInt()

Read an integer.

pack-priv <Z> Z
optPoolEntry(int index, IntFunction<Z> poolFunc, Z defaultValue)

Helper function to read an optional pool entry (with given function); this is used while parsing InnerClasses and EnclosingMethod attributes, as well as when parsing supertype descriptor, as per JVMS.

private Symbol.VarSymbol
parameter(int
the index of the parameter in the MethodParameters attribute
mpIndex
,
int
the index of the parameter in the LocalVariableTable attribute
lvtIndex
,
Type t, Symbol.MethodSymbol owner, Set<Name> exclude)

Creates the parameter at the position mpIndex in the parameter list of the owning method.

pack-priv String
quoteBadSignature()

Quote a bogus signature for display inside an error message.

pack-priv List<ClassReader.CompoundAnnotationProxy>
readAnnotations()

Save annotations.

pack-priv Attribute
pack-priv void
pack-priv void
readClass(Symbol.ClassSymbol c)

Read contents of a given class symbol `c'.

pack-priv void
readClassAttrs(Symbol.ClassSymbol c)

Read class attributes.

private void
readClassBuffer(Symbol.ClassSymbol c)

Read a class definition from the bytes in buf.

public void
pack-priv Code
readCode(Symbol owner)

Read code block.

pack-priv ClassReader.CompoundAnnotationProxy
protected void
pack-priv Set<Directive.ExportsFlag>
readExportsFlags(int flags)

Read exports_flags.

pack-priv Symbol.VarSymbol
readField()

Read a field.

pack-priv void
readInnerClasses(Symbol.ClassSymbol c)

Read inner class info.

pack-priv void
readMemberAttrs(Symbol sym)

Read member attributes.

pack-priv Symbol.MethodSymbol
readMethod()

Read a method.

pack-priv Set<Symbol.ModuleFlags>
readModuleFlags(int flags)

Read module_flags.

pack-priv Set<Symbol.ModuleResolutionFlags>
readModuleResolutionFlags(int flags)

Read resolution_flags.

private Name
readName(byte[] buf, int off, int len)

pack-priv Set<Directive.OpensFlag>
readOpensFlags(int flags)

Read opens_flags.

pack-priv void
readParameterAnnotations(Symbol meth)

Read parameter annotations.

pack-priv TypeAnnotationPosition
pack-priv Set<Directive.RequiresFlag>
readRequiresFlags(int flags)

Read requires_flags.

pack-priv ClassReader.TypeAnnotationProxy
pack-priv Type
pack-priv List<TypeAnnotationPosition.TypePathEntry>
pack-priv Type
private void
pack-priv void
setParameters(Symbol.MethodSymbol sym, Type jvmType)

Set the parameters for a method symbol, including any names and annotations that were read.

pack-priv Type
sigToType(byte[] sig, int offset, int len)

Convert signature to type, where signature is a byte array segment.

pack-priv Type
sigToType()

Convert signature to type, where signature is implicit.

pack-priv Type
sigToTypeParam()

Convert (implicit) signature to type parameter.

pack-priv List<Type>
sigToTypeParams(byte[] sig, int offset, int len)

Convert signature to type parameters, where signature is a byte array segment.

pack-priv List<Type>
sigToTypeParams()

Convert signature to type parameters, where signature is implicit.

pack-priv List<Type>
sigToTypes(char terminator)

Convert (implicit) signature to list of types until `terminator' is encountered.

private Name
simpleBinaryName(Name self, Name enclosing)

pack-priv void
skipBytes(int n)

skip n bytes

pack-priv void
pack-priv void
skipMember()

Skip a field or method

pack-priv void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait