polyglot.types.reflect
Class ClassFile

java.lang.Object
  extended bypolyglot.types.reflect.ClassFile
All Implemented Interfaces:
LazyClassInitializer

public class ClassFile
extends java.lang.Object
implements LazyClassInitializer

ClassFile basically represents a Java classfile as it is found on disk. The classfile is modeled according to the Java Virtual Machine Specification. Methods are provided to edit the classfile at a very low level.

Author:
Nate Nystrom (nystrom@cs.purdue.edu)
See Also:
Attribute, Constant, Field, Method

Constructor Summary
ClassFile(byte[] code)
          Constructor.
 
Method Summary
 java.lang.String compilerVersion(java.lang.String ts)
          Get the encoded compiler version used to compile the source.
 java.lang.String encodedClassType(java.lang.String ts)
          Get the encoded class type.
 boolean fromClassFile()
          Return true if the class is from a class file.
 void initConstructors(ParsedClassType ct)
          Initialize ct's constructors.
 void initFields(ParsedClassType ct)
          Initialize ct's fields.
 void initInterfaces(ParsedClassType ct)
          Initialize ct's interfaces.
 void initMemberClasses(ParsedClassType ct)
          Initialize ct's member classes.
 void initMethods(ParsedClassType ct)
          Initialize ct's methods.
 java.lang.String name()
          Get the name of the class, including the package name.
 Position position()
          Create a position for the class file.
 long sourceLastModified(java.lang.String ts)
          Get the encoded source modified time.
 ParsedClassType type(TypeSystem ts)
          Extract the class type from the class file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassFile

public ClassFile(byte[] code)
Constructor. This constructor parses the class file from the byte array

Parameters:
code - A byte array containing the class data
Method Detail

fromClassFile

public boolean fromClassFile()
Description copied from interface: LazyClassInitializer
Return true if the class is from a class file.

Specified by:
fromClassFile in interface LazyClassInitializer

sourceLastModified

public long sourceLastModified(java.lang.String ts)
Get the encoded source modified time.


compilerVersion

public java.lang.String compilerVersion(java.lang.String ts)
Get the encoded compiler version used to compile the source.


encodedClassType

public java.lang.String encodedClassType(java.lang.String ts)
Get the encoded class type.


type

public ParsedClassType type(TypeSystem ts)
                     throws SemanticException
Extract the class type from the class file.

Throws:
SemanticException

initMemberClasses

public void initMemberClasses(ParsedClassType ct)
Initialize ct's member classes.

Specified by:
initMemberClasses in interface LazyClassInitializer

initInterfaces

public void initInterfaces(ParsedClassType ct)
Initialize ct's interfaces.

Specified by:
initInterfaces in interface LazyClassInitializer

initFields

public void initFields(ParsedClassType ct)
Initialize ct's fields.

Specified by:
initFields in interface LazyClassInitializer

initMethods

public void initMethods(ParsedClassType ct)
Initialize ct's methods.

Specified by:
initMethods in interface LazyClassInitializer

initConstructors

public void initConstructors(ParsedClassType ct)
Initialize ct's constructors.

Specified by:
initConstructors in interface LazyClassInitializer

position

public Position position()
Create a position for the class file.


name

public java.lang.String name()
Get the name of the class, including the package name.

Returns:
The name of the class.