Home » openjdk-7 » com.sun.tools » javac » jvm » [javadoc | source]
public class: ClassReader [javadoc | source]

All Implemented Interfaces:

Direct Known Subclasses:

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 Class Summary:
public class  ClassReader.BadClassFile  Error Diagnoses *************************************************************** 
protected enum class  ClassReader.AttributeKind  Reading Attributes ************************************************************ 
abstract protected class  ClassReader.AttributeReader   
interface  ClassReader.ProxyVisitor   
static class  ClassReader.EnumAttributeProxy   
static class  ClassReader.ArrayAttributeProxy   
static class  ClassReader.CompoundAnnotationProxy  A temporary proxy representing a compound attribute. 
static class  ClassReader.TypeAnnotationProxy  A temporary proxy representing a type annotation. 
class  ClassReader.AnnotationDeproxy   
class  ClassReader.AnnotationDefaultCompleter   
class  ClassReader.AnnotationCompleter   
public interface  ClassReader.SourceCompleter   
Field Summary
protected static final  Key<ClassReader> classReaderKey    The context key for the class reader. 
public static final  int INITIAL_BUFFER_SIZE     
 Annotate annotate     
 boolean verbose    Switch: verbose output. 
 boolean checkClassFile    Switch: check class file for correct minor version, unrecognized attributes. 
public  boolean readAllOfClassFile    Switch: read constant pool and code sections. This switch is initially set to false but can be turned on from outside. 
 boolean allowGenerics    Switch: read GJ signature information. 
 boolean allowVarargs    Switch: read varargs attribute. 
 boolean allowAnnotations    Switch: allow annotations. 
 boolean allowSimplifiedVarargs    Switch: allow simplified varargs. 
 boolean lintClassfile    Lint option: warn about classfile issues 
public  boolean saveParameterNames    Switch: preserve parameter names from the variable table. 
public  boolean preferSource    Switch: prefer source files instead of newer when both source and class are available * 
final  Log log    The log to use for verbose output 
 Symtab syms    The symbol table. 
 Types types     
final  Names names    The name table. 
final  Name completionFailureName    Force a completion failure on this name 
 Factory diagFactory    Factory for diagnostics 
public  SourceCompleter sourceCompleter    Can be reassigned from outside: the completer to be used for ".java" files. If this remains unassigned ".java" files will not be loaded. 
protected  Scope typevars    The current scope where type variables are entered. 
protected  JavaFileObject currentClassFile    The path name of the class file currently being read. 
protected  Symbol currentOwner    The class or method currently being read. 
 byte[] buf    The buffer containing the currently read class file. 
 int bp    The current input pointer. 
 Object[] poolObj    The objects of the constant pool. 
 int[] poolIdx    For every constant pool entry, an index into buf where the defining section of the entry is found. 
 int majorVersion    The major version number of the class file being read. 
 int minorVersion    The minor version number of the class file being read. 
 int[] parameterNameIndices    A table to hold the constant pool indices for method parameter names, as given in LocalVariableTable attributes. 
 boolean haveParameterNameIndices    Whether or not any parameter names have been found. 
 Set<Name> warnedAttrs    The set of attribute names for which warnings have been generated for the current class 
 byte[] signature    The unread portion of the currently read type is signature[sigp..siglimit-1]. 
 int sigp     
 int siglimit     
 boolean sigEnterPhase     
 byte[] signatureBuffer     
 int sbp     
protected  Set<AttributeKind> CLASS_ATTRIBUTE     
protected  Set<AttributeKind> MEMBER_ATTRIBUTE     
protected  Set<AttributeKind> CLASS_OR_MEMBER_ATTRIBUTE     
protected  Map<Name, AttributeReader> attributeReaders     
protected  Location currentLoc     
 protected ClassReader(Context context,
    boolean definitive) 
    Construct a new class reader, optionally treated as the definitive classreader for this invocation.
Method from com.sun.tools.javac.jvm.ClassReader Summary:
adjustClassFlags,   adjustFieldFlags,   adjustMethodFlags,   attachAnnotationDefault,   attachAnnotations,   attachParameterAnnotations,   badClassFile,   classSigToType,   complete,   defineClass,   enterClass,   enterClass,   enterClass,   enterPackage,   enterPackage,   enterTypevars,   enterTypevars,   extraFileActions,   findTypeVar,   getChar,   getDouble,   getFloat,   getInt,   getLong,   getPackageFileKinds,   includeClassFile,   indexPool,   init,   initParameterNames,   instance,   loadClass,   nextByte,   nextChar,   nextInt,   packageExists,   preferredFileObject,   readAttributeValue,   readAttrs,   readClass,   readClassAttrs,   readClassOrType,   readClassSymbol,   readCode,   readCompoundAnnotation,   readEnclosingMethodAttr,   readEnumType,   readField,   readInnerClasses,   readMemberAttrs,   readMethod,   readName,   readPool,   readType,   readTypeOrClassSymbol,   readTypeParams,   setParameterNames,   sigToType,   sigToType,   sigToTypeParam,   sigToTypeParams,   sigToTypeParams,   sigToTypes,   skipBytes,   skipMember,   unrecognized
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.sun.tools.javac.jvm.ClassReader Detail:
 long adjustClassFlags(long flags) 
 long adjustFieldFlags(long flags) 
    Adjusting flags ***************************************************************
 long adjustMethodFlags(long flags) 
  void attachAnnotationDefault(Symbol sym) 
    Attach the default value for an annotation element.
  void attachAnnotations(Symbol sym) 
    Attach annotations.
  void attachParameterAnnotations(Symbol method) 
    Attach parameter annotations.
 public BadClassFile badClassFile(String key,
    Object args) 
 Type classSigToType() 
    Convert class signature to type, where signature is implicit.
 public  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.
 public ClassSymbol defineClass(Name name,
    Symbol owner) 
    Define a new class given its name and owner.
 public ClassSymbol enterClass(Name flatname) 
    Create a new member or toplevel class symbol with given flat name and enter in `classes' unless already there.
 public ClassSymbol enterClass(Name name,
    TypeSymbol owner) 
    Create a new toplevel or member class symbol with given name and owner and enter in `classes' unless already there.
 public ClassSymbol enterClass(Name flatName,
    JavaFileObject classFile) 
    Creates a new toplevel class symbol with given flat name and given class (or source) file.
 public PackageSymbol enterPackage(Name fullname) 
    Make a package, given its fully qualified name.
 public PackageSymbol enterPackage(Name name,
    PackageSymbol owner) 
    Make a package, given its unqualified name and enclosing package.
 protected  void enterTypevars(Type t) 
    Enter type variables of this classtype and all enclosing ones in `typevars'.
 protected  void enterTypevars(Symbol sym) 
 protected  void extraFileActions(PackageSymbol pack,
    JavaFileObject fe) 
    this is used to support javadoc
 Type findTypeVar(Name name) 
    Find type variable with given name in `typevars' scope.
 char getChar(int bp) 
    Extract a character at position bp from buf.
 double getDouble(int bp) 
    Extract a double at position bp from buf.
 float getFloat(int bp) 
    Extract a float at position bp from buf.
 int getInt(int bp) 
    Extract an integer at position bp from buf.
 long getLong(int bp) 
    Extract a long integer at position bp from buf.
 protected EnumSet<Kind> getPackageFileKinds() 
    specifies types of files to be read when filling in a package symbol
 protected  void includeClassFile(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.
  void indexPool() 
    Index all constant pool entries, writing their start addresses into poolIdx.
 public  void init(Symtab syms) 
    Initialize classes and packages, treating this as the definitive classreader.
  void initParameterNames(MethodSymbol sym) 
    Init the parameter names array. Parameter names are currently inferred from the names in the LocalVariableTable attributes of a Code attribute. (Note: this means parameter names are currently not available for methods without a Code attribute.) This method initializes an array in which to store the name indexes of parameter names found in LocalVariableTable attributes. It is slightly supersized to allow for additional slots with a start_pc of 0.
 public static ClassReader instance(Context context) 
    Get the ClassReader instance for this invocation.
 public ClassSymbol loadClass(Name flatname) throws CompletionFailure 
    Load a toplevel class with given fully qualified name The class is entered into `classes' only if load was successful.
 byte nextByte() 
    Read a byte.
 char nextChar() 
    Read a character.
 int nextInt() 
    Read an integer.
 public boolean packageExists(Name fullname) 
    Check to see if a package exists, given its fully qualified name.
 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.
 Attribute readAttributeValue() 
  void readAttrs(Symbol sym,
    AttributeKind kind) 
  void readClass(ClassSymbol c) 
    Read contents of a given class symbol `c'. Both external and internal versions of an inner class are read.
  void readClassAttrs(ClassSymbol c) 
    Read class attributes.
 Object readClassOrType(int i) 
    If name is an array type or class signature, return the corresponding type; otherwise return a ClassSymbol with given name.
 ClassSymbol readClassSymbol(int i) 
    Read class entry.
 Code readCode(Symbol owner) 
    Read code block.
 CompoundAnnotationProxy readCompoundAnnotation() 
  void readEnclosingMethodAttr(Symbol sym) 
 Type readEnumType(int i) 
 VarSymbol readField() 
    Read a field.
  void readInnerClasses(ClassSymbol c) 
    Read inner class info. For each inner/outer pair allocate a member class.
  void readMemberAttrs(Symbol sym) 
    Read member attributes.
 MethodSymbol readMethod() 
    Read a method.
 Name readName(int i) 
    Read name.
 Object readPool(int i) 
    Read constant pool entry at start address i, use pool as a cache.
 Type readType(int i) 
    Read signature and convert to type.
 Type readTypeOrClassSymbol(int i) 
 List<Type> readTypeParams(int i) 
    Read signature and convert to type parameters.
  void setParameterNames(MethodSymbol sym,
    Type jvmType) 
    Set the parameter names for a symbol from the name index in the parameterNameIndicies array. The type of the symbol may have changed while reading the method attributes (see the Signature attribute). This may be because of generic information or because anonymous synthetic parameters were added. The original type (as read from the method descriptor) is used to help guess the existence of anonymous synthetic parameters. On completion, sym.savedParameter names will either be null (if no parameter names were found in the class file) or will be set to a list of names, one per entry in sym.type.getParameterTypes, with any missing names represented by the empty name.
 Type sigToType() 
    Convert signature to type, where signature is implicit.
 Type sigToType(byte[] sig,
    int offset,
    int len) 
    Convert signature to type, where signature is a byte array segment.
 Type sigToTypeParam() 
    Convert (implicit) signature to type parameter.
 List<Type> sigToTypeParams() 
    Convert signature to type parameters, where signature is implicit.
 List<Type> sigToTypeParams(byte[] sig,
    int offset,
    int len) 
    Convert signature to type parameters, where signature is a byte array segment.
 List<Type> sigToTypes(char terminator) 
    Convert (implicit) signature to list of types until `terminator' is encountered.
  void skipBytes(int n) 
    skip n bytes
  void skipMember() 
    Skip a field or method
  void unrecognized(Name attrName) 
    Report unrecognized attribute.