ProGuard

proguard.classfile
Class LibraryClassFile

java.lang.Object
  extended byproguard.classfile.LibraryClassFile
All Implemented Interfaces:
ClassFile, VisitorAccepter

public class LibraryClassFile
extends Object
implements ClassFile

This is a compact representation of the essential data in a Java class file. A LibraryClassFile instance representing a *.class file can be generated using the static create(DataInput) method, but not persisted back.


Field Summary
 LibraryFieldInfo[] fields
           
 ClassFile[] interfaceClasses
          An extra field pointing to the interfaces of this class.
 String[] interfaceNames
           
 LibraryMethodInfo[] methods
           
 ClassFile[] subClasses
          An extra field pointing to the subclasses of this class.
 ClassFile superClass
          An extra field pointing to the superclass of this class.
 String superClassName
           
 String thisClassName
           
 int u2accessFlags
           
 Object visitorInfo
          An extra field in which visitors can store information.
 
Method Summary
 void accept(ClassFileVisitor classFileVisitor)
          Accepts the given class file visitor.
 void addSubClass(ClassFile classFile)
          Notifies this ClassFile that it is being subclassed by another class.
 void attributesAccept(AttrInfoVisitor attrInfoVisitor)
          Lets the given attribute info visitor visit all attributes of this class.
 void constantPoolEntriesAccept(CpInfoVisitor cpInfoVisitor)
          Lets the given constant pool entry visitor visit all constant pool entries of this class.
 void constantPoolEntryAccept(CpInfoVisitor cpInfoVisitor, int index)
          Lets the given constant pool entry visitor visit the constant pool entry at the specified index.
static LibraryClassFile create(DataInput din, boolean skipNonPublic)
          Creates a new LibraryClassFile from the class file format data in the DataInput stream.
 boolean extends_(ClassFile classFile)
          Returns whether this class extends the given class.
 void fieldAccept(MemberInfoVisitor memberInfoVisitor, String name, String descriptor)
          Lets the given member info visitor visit the specified field.
 void fieldsAccept(MemberInfoVisitor memberInfoVisitor)
          Lets the given member info visitor visit all fields of this class.
 FieldInfo findField(String name, String descriptor)
          Returns the field with the given name and descriptor.
 MethodInfo findMethod(String name, String descriptor)
          Returns the method with the given name and descriptor.
 int getAccessFlags()
          Returns the access flags of this class.
 String getCpClassNameString(int cpIndex)
          Returns the class name of ClassCpEntry at the specified index.
 String getCpNameString(int cpIndex)
          Returns the name of the NameAndTypeCpEntry at the specified index.
 String getCpString(int cpIndex)
          Returns the String value of the StringCpEntry at the specified index.
 int getCpTag(int cpIndex)
          Returns the tag value of the CpEntry at the specified index.
 String getCpTypeString(int cpIndex)
          Returns the type of the NameAndTypeCpEntry at the specified index.
 ClassFile getInterface(int index)
          Returns the interface at the given index.
 String getInterfaceName(int index)
          Returns the full internal name of the interface at the given index of this class.
 String getName()
          Returns the full internal name of this class.
 ClassFile getSuperClass()
          Returns the super class of this class.
 String getSuperName()
          Returns the full internal name of the super class of this class, or null if this class represents java.lang.Object.
 Object getVisitorInfo()
          Gets the visitor information of the visitor accepter.
 void hierarchyAccept(boolean visitThisClass, boolean visitSuperClass, boolean visitInterfaces, boolean visitSubclasses, ClassFileVisitor classFileVisitor)
          Accepts the given class file visitor in the class hierarchy.
 boolean implements_(ClassFile classFile)
          Returns whether this class implements the given class.
 void methodAccept(MemberInfoVisitor memberInfoVisitor, String name, String descriptor)
          Lets the given member info visitor visit the specified method.
 void methodsAccept(MemberInfoVisitor memberInfoVisitor)
          Lets the given member info visitor visit all methods of this class.
 void setVisitorInfo(Object visitorInfo)
          Sets the visitor information of the visitor accepter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

u2accessFlags

public int u2accessFlags

thisClassName

public String thisClassName

superClassName

public String superClassName

interfaceNames

public String[] interfaceNames

fields

public LibraryFieldInfo[] fields

methods

public LibraryMethodInfo[] methods

superClass

public ClassFile superClass
An extra field pointing to the superclass of this class. This field is filled out by the ClassFileReferenceInitializer.


interfaceClasses

public ClassFile[] interfaceClasses
An extra field pointing to the interfaces of this class. This field is filled out by the ClassFileReferenceInitializer.


subClasses

public ClassFile[] subClasses
An extra field pointing to the subclasses of this class. This field is filled out by the ClassFileReferenceInitializer.


visitorInfo

public Object visitorInfo
An extra field in which visitors can store information.

Method Detail

create

public static LibraryClassFile create(DataInput din,
                                      boolean skipNonPublic)
                               throws IOException
Creates a new LibraryClassFile from the class file format data in the DataInput stream. If specified, this method may return null if the class file is not visible.

Throws:
IOException - if the class file is corrupt or incomplete

getAccessFlags

public int getAccessFlags()
Description copied from interface: ClassFile
Returns the access flags of this class.

Specified by:
getAccessFlags in interface ClassFile
See Also:
ClassConstants

getName

public String getName()
Description copied from interface: ClassFile
Returns the full internal name of this class.

Specified by:
getName in interface ClassFile

getSuperName

public String getSuperName()
Description copied from interface: ClassFile
Returns the full internal name of the super class of this class, or null if this class represents java.lang.Object.

Specified by:
getSuperName in interface ClassFile

getInterfaceName

public String getInterfaceName(int index)
Description copied from interface: ClassFile
Returns the full internal name of the interface at the given index of this class.

Specified by:
getInterfaceName in interface ClassFile

getCpTag

public int getCpTag(int cpIndex)
Description copied from interface: ClassFile
Returns the tag value of the CpEntry at the specified index.

Specified by:
getCpTag in interface ClassFile

getCpString

public String getCpString(int cpIndex)
Description copied from interface: ClassFile
Returns the String value of the StringCpEntry at the specified index.

Specified by:
getCpString in interface ClassFile

getCpClassNameString

public String getCpClassNameString(int cpIndex)
Description copied from interface: ClassFile
Returns the class name of ClassCpEntry at the specified index.

Specified by:
getCpClassNameString in interface ClassFile

getCpNameString

public String getCpNameString(int cpIndex)
Description copied from interface: ClassFile
Returns the name of the NameAndTypeCpEntry at the specified index.

Specified by:
getCpNameString in interface ClassFile

getCpTypeString

public String getCpTypeString(int cpIndex)
Description copied from interface: ClassFile
Returns the type of the NameAndTypeCpEntry at the specified index.

Specified by:
getCpTypeString in interface ClassFile

addSubClass

public void addSubClass(ClassFile classFile)
Description copied from interface: ClassFile
Notifies this ClassFile that it is being subclassed by another class.

Specified by:
addSubClass in interface ClassFile

getSuperClass

public ClassFile getSuperClass()
Description copied from interface: ClassFile
Returns the super class of this class.

Specified by:
getSuperClass in interface ClassFile

getInterface

public ClassFile getInterface(int index)
Description copied from interface: ClassFile
Returns the interface at the given index.

Specified by:
getInterface in interface ClassFile

extends_

public boolean extends_(ClassFile classFile)
Description copied from interface: ClassFile
Returns whether this class extends the given class. A class is always considered to extend itself. Interfaces are considered to only extend the root Object class.

Specified by:
extends_ in interface ClassFile

implements_

public boolean implements_(ClassFile classFile)
Description copied from interface: ClassFile
Returns whether this class implements the given class. A class is always considered to implement itself. Interfaces are considered to implement all their superinterfaces.

Specified by:
implements_ in interface ClassFile

findField

public FieldInfo findField(String name,
                           String descriptor)
Description copied from interface: ClassFile
Returns the field with the given name and descriptor.

Specified by:
findField in interface ClassFile

findMethod

public MethodInfo findMethod(String name,
                             String descriptor)
Description copied from interface: ClassFile
Returns the method with the given name and descriptor.

Specified by:
findMethod in interface ClassFile

accept

public void accept(ClassFileVisitor classFileVisitor)
Description copied from interface: ClassFile
Accepts the given class file visitor.

Specified by:
accept in interface ClassFile

hierarchyAccept

public void hierarchyAccept(boolean visitThisClass,
                            boolean visitSuperClass,
                            boolean visitInterfaces,
                            boolean visitSubclasses,
                            ClassFileVisitor classFileVisitor)
Description copied from interface: ClassFile
Accepts the given class file visitor in the class hierarchy.

Specified by:
hierarchyAccept in interface ClassFile
Parameters:
visitThisClass - specifies whether to visit this class.
visitSuperClass - specifies whether to visit the super classes.
visitInterfaces - specifies whether to visit the interfaces.
visitSubclasses - specifies whether to visit the subclasses.
classFileVisitor - the ClassFileVisitor that will visit the class hierarchy.

constantPoolEntriesAccept

public void constantPoolEntriesAccept(CpInfoVisitor cpInfoVisitor)
Description copied from interface: ClassFile
Lets the given constant pool entry visitor visit all constant pool entries of this class.

Specified by:
constantPoolEntriesAccept in interface ClassFile

constantPoolEntryAccept

public void constantPoolEntryAccept(CpInfoVisitor cpInfoVisitor,
                                    int index)
Description copied from interface: ClassFile
Lets the given constant pool entry visitor visit the constant pool entry at the specified index.

Specified by:
constantPoolEntryAccept in interface ClassFile

fieldsAccept

public void fieldsAccept(MemberInfoVisitor memberInfoVisitor)
Description copied from interface: ClassFile
Lets the given member info visitor visit all fields of this class.

Specified by:
fieldsAccept in interface ClassFile

fieldAccept

public void fieldAccept(MemberInfoVisitor memberInfoVisitor,
                        String name,
                        String descriptor)
Description copied from interface: ClassFile
Lets the given member info visitor visit the specified field.

Specified by:
fieldAccept in interface ClassFile

methodsAccept

public void methodsAccept(MemberInfoVisitor memberInfoVisitor)
Description copied from interface: ClassFile
Lets the given member info visitor visit all methods of this class.

Specified by:
methodsAccept in interface ClassFile

methodAccept

public void methodAccept(MemberInfoVisitor memberInfoVisitor,
                         String name,
                         String descriptor)
Description copied from interface: ClassFile
Lets the given member info visitor visit the specified method.

Specified by:
methodAccept in interface ClassFile

attributesAccept

public void attributesAccept(AttrInfoVisitor attrInfoVisitor)
Description copied from interface: ClassFile
Lets the given attribute info visitor visit all attributes of this class.

Specified by:
attributesAccept in interface ClassFile

getVisitorInfo

public Object getVisitorInfo()
Description copied from interface: VisitorAccepter
Gets the visitor information of the visitor accepter.

Specified by:
getVisitorInfo in interface VisitorAccepter

setVisitorInfo

public void setVisitorInfo(Object visitorInfo)
Description copied from interface: VisitorAccepter
Sets the visitor information of the visitor accepter.

Specified by:
setVisitorInfo in interface VisitorAccepter

ProGuard