ojvm.util
Class Descriptor

java.lang.Object
  |
  +--ojvm.util.Descriptor

public class Descriptor
extends java.lang.Object

The JVM spec. includes many ways to specify a class name. This file manages all the different naming conventions and maps among them. The first way to specify a class name is by using a descriptor. See Section 4.3 of the JVM Spec. In more detail: - Classes for primitive types are named using the descriptors B, C, D, F, I, J, S, and Z. In the return type of a method we also allow V. - Classes for reference types other than arrays are named using descriptors that start with L (e.g. Ljava/lang/Thread;) - Classes for array types are named using descriptors that start with [ (e.g., [I and [Ljava/lang/Thread;) Classes for references types can also be named using a string. The format of this string could be: - an external Java name (e.g., java.lang.Thread) - an internal form of a Java name as stored in class files (e.g., java/lang/Thread) - a filename using the host machine conventions (e.g., java\lang\Thread.class) Finally classes for primitive types are named using an integer tag in the newarray instruction. See p.343 of the JVM Spec. We have a constructor for each of the three above cases. Without proper care, a string argument called "B" could be confused as the descriptor for the class byte or as the name of a class B. We distinguish the two cases by using constructor one to take descriptor arguments and constructor two to take other string arguments.


Field Summary
static int INTERNAL_FORM
           
static int JAVA_FORM
           
protected  java.lang.String primitiveName
           
 
Constructor Summary
Descriptor(int atype)
           
Descriptor(java.lang.String desc)
           
Descriptor(java.lang.String desc, boolean allowVoid)
           
Descriptor(java.lang.String name, int kind)
           
 
Method Summary
 boolean equals(java.lang.Object other)
           
 Descriptor getBaseDesc()
           
static JavaValue getDefaultValue(Descriptor desc)
           
 java.lang.String getFilename()
           
 java.lang.String getInternalForm()
           
 java.lang.String getJavaForm()
           
 int getNumDimensions()
           
 java.lang.String getStringDescriptor()
           
 int getValueSize()
           
 int hashCode()
           
 boolean isArray()
           
 boolean isPrimitive()
           
 boolean isReference()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

JAVA_FORM

public static final int JAVA_FORM

INTERNAL_FORM

public static final int INTERNAL_FORM

primitiveName

protected java.lang.String primitiveName
Constructor Detail

Descriptor

public Descriptor(java.lang.String desc)
           throws BadDescriptorE

Descriptor

public Descriptor(java.lang.String desc,
                  boolean allowVoid)
           throws BadDescriptorE

Descriptor

public Descriptor(java.lang.String name,
                  int kind)
           throws BadDescriptorE

Descriptor

public Descriptor(int atype)
           throws BadDescriptorE
Method Detail

getJavaForm

public java.lang.String getJavaForm()

getInternalForm

public java.lang.String getInternalForm()

getFilename

public java.lang.String getFilename()

isPrimitive

public boolean isPrimitive()

isArray

public boolean isArray()

isReference

public boolean isReference()

getNumDimensions

public int getNumDimensions()

getBaseDesc

public Descriptor getBaseDesc()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

getStringDescriptor

public java.lang.String getStringDescriptor()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getValueSize

public int getValueSize()

getDefaultValue

public static JavaValue getDefaultValue(Descriptor desc)
                                 throws BadDescriptorE