|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jikesrvm.classloader.TypeDescriptorParsing
public abstract class TypeDescriptorParsing
A Java class for parsing type descriptors and class names. The class
is abstract
to eliminate the temptation to instantiate it,
since it contains only static methods.
There are five similar kinds of descriptors and names that we have to deal with. We don't have methods for parsing all of them.
In this documentation, I will refer to The Java Native Interface Programmer's Guide and Specification as the JNI Guide.
Some of the types I discuss below are described in 12.3 of the JNI Guide.
We can validate these with the static method #isJavaClassName(String) in this class.
java.lang.String
is "java/lang/String
”
Array classes are formed using the "[" character followed by the field
descriptor of the element type. The class descrpitor for "int[]" is "[I".
We do not have an interface for parsing these right now.
Method Descriptors are formed by placing the field descriptors of all argument types in a pair of parentheses, and following that by the field descriptor of the return type. There are no spaces or other separator characters between the argument types. "Example: The method with signature "V
" is used to denote thevoid
method return type. Constructors use "V
" as their return type and use "<init>" as their name.
byte f(int i, String s)
"
has the Method Descriptor "(ILjava/lang/String;)B
"
Field Summary |
---|
Constructor Summary | |
---|---|
TypeDescriptorParsing()
|
Method Summary | |
---|---|
static boolean |
isJavaClassName(String s)
Is the string s a legal name for a Java class or interface? |
static boolean |
isJavaClassNameInternalForm(char[] val,
int first,
int last)
Is this the internal form of a Java class name? |
private static boolean |
isJavaPrimitive(byte b)
|
private static boolean |
isJavaPrimitive(char c)
|
static boolean |
isValidTypeDescriptor(Atom a)
|
static boolean |
isValidTypeDescriptor(String s)
|
static boolean |
isVMIdentifierPart(char c)
Java 1.5 relaxes the historical convention that class file identifiers (i.e. class, field, and method names) must be drawn from the characters specified by JLS identifiers (i.e. implemented by java.lang.Character.isJavaIdentifierPart()). |
static boolean |
isVMIdentifierStart(char c)
Java 1.5 relaxes the historical convention that class file identifiers (i.e. class, field, and method names) must be drawn from the characters specified by JLS identifiers (i.e. implemented by java.lang.Character.isJavaIdentifierStart()). |
private static void |
malformed(String msg,
String typeName)
Gripe and throw IllegalArgumentException if we get a
malformed type name. |
static void |
validateAsTypeDescriptor(Atom a)
|
static void |
validateAsTypeDescriptor(String s)
Validate that the String @param s is a valid type descriptor. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TypeDescriptorParsing()
Method Detail |
---|
public static boolean isJavaClassName(String s)
s
a legal name for a Java class or interface?
This will take either fully-qualified names or names that are not fully
qualified.
s
- The string to check for whether it's a valid name for a Java
class. This is a string of the form, for example:
"java.lang.String
"
true
if s
is valid, false
otherwise.
Implementation Question for wiser heads than mine:
Would it be more efficient for me to convert this to a char
array?
That's the way the example in The Java Class Libraries for
Character.isJavaIdentifier*()
is written. Or is the
String.charAt()
method inexpensive?
public static boolean isVMIdentifierStart(char c)
Given that, parsing rules for internal and external VM identifier
dictates that identifiers may not contain the following
characters: { '.'
, ';'
, '['
,
or '/'
}. Method identifiers, excluding <init>
and <clinit>
, are further constrained to not include
the characters '<'
or '>'
.
To avoid word boundary ambiguity, identifiers are presumed to not begin with a space character. Although not stated explicitly, this remains convention.
This method evaluates whether c
is compatible as the starting
character for a VM identifier.
c
- character to evaluate for VM identifier compatibility
true
iff c
represents a valid VM identifier starting characterpublic static boolean isVMIdentifierPart(char c)
Given that, parsing rules for internal and external VM identifier
dictates that identifiers may not contain the following
characters: { '.'
, ';'
, '['
,
or '/'
}. Method identifiers, excluding <init>
and <clinit>
, are further constrained to not include
the characters '<'
or '>'
.
This method evaluates whether c
is compatible as a non-starting
character for a VM identifier.
c
- character to evaluate for VM identifier compatibility
true
iff c
represents a valid VM identifier non-starting characterpublic static boolean isJavaClassNameInternalForm(char[] val, int first, int last)
public static boolean isValidTypeDescriptor(String s)
public static boolean isValidTypeDescriptor(Atom a)
public static void validateAsTypeDescriptor(Atom a) throws IllegalArgumentException
IllegalArgumentException
public static void validateAsTypeDescriptor(String s) throws IllegalArgumentException
IllegalArgumentException
- if it isn't.private static boolean isJavaPrimitive(char c)
private static boolean isJavaPrimitive(byte b)
private static void malformed(String msg, String typeName) throws IllegalArgumentException
IllegalArgumentException
if we get a
malformed type name.
IllegalArgumentException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |