FileDocCategorySizeDatePackage
ClassFile.javaAPI DocGlassfish v2 API5568Fri May 04 22:31:36 BST 2007com.sun.enterprise.deployment.annotation.introspection

ClassFile

public class ClassFile extends Object
This class is encapsulating binary .class file information as defined at http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html This is used by the annotation frameworks to quickly scan .class files for the presence of annotations. This avoid the annotation framework having to load each .class file in the class loader.
author
Jerome Dochez

Fields Summary
ByteBuffer
header
ConstantPoolInfo
constantPoolInfo
public short
majorVersion
public short
minorVersion
public ConstantPoolInfo[]
constantPool
public short
accessFlags
public ConstantPoolInfo
thisClass
public ConstantPoolInfo
superClass
public ConstantPoolInfo[]
interfaces
boolean
isValidClass
bunch of stuff I really don't care too much for now. FieldInfo fields[]; MethodInfo methods[]; AttributeInfo attributes[];
private static final int
magic
public static final int
ACC_PUBLIC
public static final int
ACC_PRIVATE
public static final int
ACC_PROTECTED
public static final int
ACC_STATIC
public static final int
ACC_FINAL
public static final int
ACC_SYNCHRONIZED
public static final int
ACC_THREADSAFE
public static final int
ACC_TRANSIENT
public static final int
ACC_NATIVE
public static final int
ACC_INTERFACE
public static final int
ACC_ABSTRACT
Constructors Summary
public ClassFile()
Creates a new instance of ClassFile

    
           
      
        header = ByteBuffer.allocate(12000);
    
Methods Summary
public booleancontainsAnnotation(java.nio.channels.ReadableByteChannel in, long size)
Read the input channel and initialize instance data structure.


        /**
         * this is the .class file layout
         *
        ClassFile {
            u4 magic;
            u2 minor_version;
            u2 major_version;
            u2 constant_pool_count;
            cp_info constant_pool[constant_pool_count-1];
            u2 access_flags;
            u2 this_class;
            u2 super_class;
            u2 interfaces_count;
            u2 interfaces[interfaces_count];
            u2 fields_count;
            field_info fields[fields_count];
            u2 methods_count;
            method_info methods[methods_count];
            u2 attributes_count;
            attribute_info attributes[attributes_count];
        }        
         **/
        header.clear();   
        if (size!=-1 && size>header.capacity()) {
            // time to expand...
            header = ByteBuffer.allocate((int) size);
        }
        long read = (long) in.read(header);
        if (size!=-1 && read!=size) {
            return false;            
        }        
        header.rewind();
                
        if (header.getInt()!=magic) {
            return false;
        }
        
        majorVersion = header.getShort();
        minorVersion = header.getShort();
        int constantPoolSize = header.getShort();

        return constantPoolInfo.containsAnnotation(constantPoolSize, header);
        
    
public voidsetConstantPoolInfo(ConstantPoolInfo poolInfo)

        constantPoolInfo = poolInfo;