jasm.lang
Class ClassFile

java.lang.Object
  extended by jasm.lang.ClassFile

public class ClassFile
extends java.lang.Object


Nested Class Summary
static class ClassFile.Field
           
static class ClassFile.Method
           
static class ClassFile.Parameter
           
 
Field Summary
protected  java.util.ArrayList<BytecodeAttribute> attributes
           
protected  java.util.ArrayList<ClassFile.Field> fields
           
protected  java.util.List<JvmType.Clazz> interfaces
           
protected  java.util.ArrayList<ClassFile.Method> methods
           
protected  java.util.List<Modifier> modifiers
           
protected  JvmType.Clazz superClazz
           
protected  JvmType.Clazz type
           
protected  int version
           
 
Constructor Summary
ClassFile(int version, JvmType.Clazz type, JvmType.Clazz superClazz, java.util.List<JvmType.Clazz> interfaces, java.util.List<Modifier> modifiers, BytecodeAttribute... attributes)
           
ClassFile(int version, JvmType.Clazz type, JvmType.Clazz superClazz, java.util.List<JvmType.Clazz> interfaces, java.util.List<Modifier> modifiers, java.util.Collection<BytecodeAttribute> attributes)
           
 
Method Summary
 BytecodeAttribute attribute(java.lang.String name)
           
 java.util.List<BytecodeAttribute> attributes()
           
 java.util.ArrayList<Constant.Info> constantPool()
          This method builds a constant pool for this class file.
static java.lang.String descriptor(JvmType t, boolean generic)
          This method returns a JVM descriptor string for the type in question.
 ClassFile.Field field(java.lang.String name)
           
 java.util.List<ClassFile.Field> fields()
           
 boolean hasModifier(java.lang.Class modClass)
          Check whether this method has one of the "base" modifiers (e.g.
 java.util.List<JvmType.Clazz> inners()
           
 java.util.List<JvmType.Clazz> interfaces()
           
 boolean isAbstract()
          Check whether this method is abstract
 boolean isFinal()
          Check whether this method is final
 boolean isInnerClass()
          Check whether or not this is an inner class.
 boolean isInterface()
          Check whether this method is abstract
 boolean isNative()
          Check whether this method is native
 boolean isPrivate()
          Check whether this method is private
 boolean isProtected()
          Check whether this method is protected
 boolean isPublic()
          Check whether this method is public
 boolean isStatic()
          Check whether this method is static
 boolean isSynchronized()
          Check whether this method is synchronized
 boolean isSynthetic()
          Check whether this method is synthetic
 java.util.List<ClassFile.Method> methods()
           
 java.util.List<ClassFile.Method> methods(java.lang.String name)
           
 java.util.List<Modifier> modifiers()
           
 java.lang.String name()
           
 void setType(JvmType.Clazz t)
           
static int slotSize(JvmType type)
          Determine the slot size for the corresponding Java type.
 JvmType.Clazz superClass()
           
 JvmType.Clazz type()
           
 int version()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

protected int version

type

protected JvmType.Clazz type

superClazz

protected JvmType.Clazz superClazz

interfaces

protected java.util.List<JvmType.Clazz> interfaces

modifiers

protected java.util.List<Modifier> modifiers

attributes

protected java.util.ArrayList<BytecodeAttribute> attributes

fields

protected java.util.ArrayList<ClassFile.Field> fields

methods

protected java.util.ArrayList<ClassFile.Method> methods
Constructor Detail

ClassFile

public ClassFile(int version,
                 JvmType.Clazz type,
                 JvmType.Clazz superClazz,
                 java.util.List<JvmType.Clazz> interfaces,
                 java.util.List<Modifier> modifiers,
                 BytecodeAttribute... attributes)

ClassFile

public ClassFile(int version,
                 JvmType.Clazz type,
                 JvmType.Clazz superClazz,
                 java.util.List<JvmType.Clazz> interfaces,
                 java.util.List<Modifier> modifiers,
                 java.util.Collection<BytecodeAttribute> attributes)
Method Detail

type

public JvmType.Clazz type()

name

public java.lang.String name()

superClass

public JvmType.Clazz superClass()

interfaces

public java.util.List<JvmType.Clazz> interfaces()

inners

public java.util.List<JvmType.Clazz> inners()

attributes

public java.util.List<BytecodeAttribute> attributes()

attribute

public BytecodeAttribute attribute(java.lang.String name)

modifiers

public java.util.List<Modifier> modifiers()

fields

public java.util.List<ClassFile.Field> fields()

field

public ClassFile.Field field(java.lang.String name)

methods

public java.util.List<ClassFile.Method> methods()

methods

public java.util.List<ClassFile.Method> methods(java.lang.String name)

version

public int version()

hasModifier

public boolean hasModifier(java.lang.Class modClass)
Check whether this method has one of the "base" modifiers (e.g. static, public, private, etc). These are found in java.lang.reflect.Modifier.

Parameters:
modifier -
Returns:
true if it does!

isInterface

public boolean isInterface()
Check whether this method is abstract


isAbstract

public boolean isAbstract()
Check whether this method is abstract


isFinal

public boolean isFinal()
Check whether this method is final


isStatic

public boolean isStatic()
Check whether this method is static


isPublic

public boolean isPublic()
Check whether this method is public


isProtected

public boolean isProtected()
Check whether this method is protected


isPrivate

public boolean isPrivate()
Check whether this method is private


isNative

public boolean isNative()
Check whether this method is native


isSynchronized

public boolean isSynchronized()
Check whether this method is synchronized


isSynthetic

public boolean isSynthetic()
Check whether this method is synthetic


isInnerClass

public boolean isInnerClass()
Check whether or not this is an inner class.

Returns:

setType

public void setType(JvmType.Clazz t)

constantPool

public java.util.ArrayList<Constant.Info> constantPool()
This method builds a constant pool for this class file.

Returns:

descriptor

public static java.lang.String descriptor(JvmType t,
                                          boolean generic)
This method returns a JVM descriptor string for the type in question. The format of the string is defined in "The JavaTM Virtual Machine Specification, 2nd ed", Section 4.3. Example descriptor strings include:
Type Descriptor
int
I
boolean
Z
float[]
F[
java.lang.Integer
Ljava/lang/Integer;
int(Double,Float)
(DF)I

The descriptor string is used, amongst other things, to uniquely identify a class in the ClassTable.

See the JVM Specification for more information.

Parameters:
t - The type to generate the descriptor for
generic - True indicates generic information should be included.
Returns:

slotSize

public static int slotSize(JvmType type)
Determine the slot size for the corresponding Java type.

Parameters:
type - The type to determine the slot size for.
Returns:
the slot size in slots.


Copyright © 2013 David J. Pearce. All Rights Reserved.