All Packages Class Hierarchy This Package Previous Next Index
Class DE.fub.inf.JVM.JavaClass.Utility
java.lang.Object
|
+----DE.fub.inf.JVM.JavaClass.Utility
- public abstract class Utility
- extends Object
- implements Constants
Utility functions that do not really belong to any class in particular.
- Version:
- 971017
- Author:
- M. Dahm
-
Utility()
-
-
accessToString(short)
- Convert bit field of flags into string such as `static final'.
-
accessToString(short, boolean)
- Convert bit field of flags into string such as `static final'.
-
bytesToInt(byte, byte, byte, byte)
- Obtains the signed 32-bit value from 4 bytes,
bytesToInt((byte) 0, (byte) 0, b1, b1) obtains the unsigned 16-bit value
from 2 bytes.
-
bytesToShort(byte, byte)
- bytesToShort(b0, b1) obtains the signed 16-bit value from 2 bytes.
-
byteToShort(byte)
- Convert (signed) byte to (unsigned) short value, i.e.
-
codeToString(byte[], ConstantPool, int, int)
- Disassemble a byte array of JVM byte codes starting from code line
`index' and return the dissambled string representation.
-
codeToString(ByteSequence, ConstantPool)
- Disassemble a stream of byte codes and return the
string representation.
-
compactClassName(String)
- Shorten long class names, java/lang/String becomes
String.
-
compactClassName(String, boolean)
- Shorten long class names, java/lang/String becomes
java.lang.String,
e.g..
-
compactClassName(String, String, boolean)
- Shorten long class name str, i.e.
-
methodSignatureArgumentTypes(String)
-
-
methodSignatureArgumentTypes(String, boolean)
-
-
methodSignatureReturnType(String)
-
-
methodSignatureReturnType(String, boolean)
-
-
methodSignatureToString(String, String, String)
- Converts method signature to string with all class names compacted.
-
methodSignatureToString(String, String, String, boolean)
- A returntype signature represents the return value from a method.
-
replace(String, String, String)
- Replace all occurences of old in str with new.
-
signatureToString(String)
- Converts signature to string with all class names compacted.
-
signatureToString(String, boolean)
- The field signature represents the value of an argument to a function or
the value of a variable.
-
toHexString(byte[])
-
-
typeOfMethodSignature(String)
-
-
typeOfSignature(String)
- Return type of signature as a byte value as defined in Constants
Utility
public Utility()
accessToString
public static final String accessToString(short access_flags)
- Convert bit field of flags into string such as `static final'.
- Parameters:
- access_flags - Access flags
- Returns:
- String representation of flags
accessToString
public static final String accessToString(short access_flags,
boolean for_class)
- Convert bit field of flags into string such as `static final'.
Special case: Classes compiled with new compilers and with the
`ACC_SUPER' flag would be said to be "synchronized". This is
because SUN used the same value for the flags `ACC_SUPER' and
`ACC_SYNCHRONIZED'.
- Parameters:
- access_flags - Access flags
- for_class - access flags are for class qualifiers ?
- Returns:
- String representation of flags
bytesToInt
public static final int bytesToInt(byte b0,
byte b1,
byte b2,
byte b3)
- Obtains the signed 32-bit value from 4 bytes,
bytesToInt((byte) 0, (byte) 0, b1, b1) obtains the unsigned 16-bit value
from 2 bytes.
bytesToShort
public static final short bytesToShort(byte b0,
byte b1)
- bytesToShort(b0, b1) obtains the signed 16-bit value from 2 bytes.
byteToShort
public static final short byteToShort(byte b)
- Convert (signed) byte to (unsigned) short value, i.e. all negative
values become positive.
codeToString
public static final String codeToString(byte code[],
ConstantPool constant_pool,
int index,
int length)
- Disassemble a byte array of JVM byte codes starting from code line
`index' and return the dissambled string representation. Decode only
`num' opcodes (including their operands), use -1 if you want to
decompile everything.
- Parameters:
- code - byte code array
- constant_pool - Array of constants
- index - offset in `code' array
(number of opcodes, not bytes!)
- length - number of opcodes to decompile, -1 for all
- Returns:
- String representation of byte codes
codeToString
public static final String codeToString(ByteSequence bytes,
ConstantPool constant_pool)
- Disassemble a stream of byte codes and return the
string representation.
- Parameters:
- stream - data input stream
- constant_pool - Array of constants
- Returns:
- String representation of byte code
compactClassName
public static final String compactClassName(String str)
- Shorten long class names, java/lang/String becomes
String.
- Parameters:
- str - The long class name
- Returns:
- Compacted class name
compactClassName
public static final String compactClassName(String str,
String prefix,
boolean chopit)
- Shorten long class name str, i.e. chop off the prefix,
if the
class name starts with this string and the flag chopit is true.
Slashes / are converted to dots ..
- Parameters:
- str - The long class name
- prefix - The prefix the get rid off
- chopit - Flag that determines whether chopping is executed or not
- Returns:
- Compacted class name
compactClassName
public static final String compactClassName(String str,
boolean chopit)
- Shorten long class names, java/lang/String becomes
java.lang.String,
e.g.. If chopit is true the prefix java.lang
is also removed.
- Parameters:
- str - The long class name
- chopit - Flag that determines whether chopping is executed or not
- Returns:
- Compacted class name
methodSignatureArgumentTypes
public static final String[] methodSignatureArgumentTypes(String signature) throws ClassFormatError
- Parameters:
- signature - Method signature
- Returns:
- Array of argument types
methodSignatureArgumentTypes
public static final String[] methodSignatureArgumentTypes(String signature,
boolean chopit) throws ClassFormatError
- Parameters:
- signature - Method signature
- chopit - Shorten class names ?
- Returns:
- Array of argument types
methodSignatureReturnType
public static final String methodSignatureReturnType(String signature) throws ClassFormatError
- Parameters:
- signature - Method signature
- Returns:
- return type of method
methodSignatureReturnType
public static final String methodSignatureReturnType(String signature,
boolean chopit) throws ClassFormatError
- Parameters:
- signature - Method signature
- chopit - Shorten class names ?
- Returns:
- return type of method
methodSignatureToString
public static final String methodSignatureToString(String signature,
String name,
String access)
- Converts method signature to string with all class names compacted.
- Parameters:
- signature - to convert
- name - of method
- access - flags of method
- Returns:
- Human readable signature
methodSignatureToString
public static final String methodSignatureToString(String signature,
String name,
String access,
boolean chopit) throws ClassFormatError
- A returntype signature represents the return value from a method.
It is a series of bytes in the following grammar:
::= | V
The character V indicates that the method returns no value. Otherwise, the
signature indicates the type of the return value.
An argument signature represents an argument passed to a method:
::=
A method signature represents the arguments that the method expects, and
the value that it returns.
::= ()
::= *
This method converts such a string into a Java type declaration like
`void main(String[])' and throws a `ClassFormatError' when the parsed
type is invalid.
- Parameters:
- signature - Method signature
- name - Method name
- access - Method access rights
- Returns:
- Java type declaration
replace
public static final String replace(String str,
String old,
String new_)
- Replace all occurences of old in str with new.
- Parameters:
- str - String to permute
- old - String to be replaced
- new - Replacement string
- Returns:
- new String object
signatureToString
public static final String signatureToString(String signature)
- Converts signature to string with all class names compacted.
- Parameters:
- signature - to convert
- Returns:
- Human readable signature
signatureToString
public static final String signatureToString(String signature,
boolean chopit) throws ClassFormatError
- The field signature represents the value of an argument to a function or
the value of a variable. It is a series of bytes generated by the
following grammar:
::=
::= ||
::= B|C|D|F|I|J|S|Z
::= L;
::= [
::= [09]*
The meaning of the base types is as follows:
B byte signed byte
C char character
D double double precision IEEE float
F float single precision IEEE float
I int integer
J long long integer
L; ... an object of the given class
S short signed short
Z boolean true or false
[ ... array
This method converts this string into a Java type declaration such as
`String[]' and throws a `ClassFormatError' when the parsed type is
invalid.
- Parameters:
- signature - Class signature
- Returns:
- Java type declaration
typeOfMethodSignature
public static final byte typeOfMethodSignature(String signature) throws ClassFormatError
- Parameters:
- signature - in format described above
- Returns:
- type of method signature
- See Also:
- Constants
typeOfSignature
public static final byte typeOfSignature(String signature) throws ClassFormatError
- Return type of signature as a byte value as defined in Constants
- Parameters:
- signature - in format described above
- Returns:
- type of signature
- See Also:
- Constants
toHexString
public static final String toHexString(byte bytes[])
All Packages Class Hierarchy This Package Previous Next Index