Package jadex.commons
Class SClassReader
- java.lang.Object
-
- jadex.commons.SClassReader
-
public class SClassReader extends java.lang.ObjectClass using the internal fast class path scanner to provide some utility methods for inspecting raw binary classes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSClassReader.AnnotatedEntityEntity with optional annotationsstatic classSClassReader.AnnotationInfoClass containing annotation infos.static classSClassReader.ClassEntityEntity contained in a class.static classSClassReader.ClassFileInfoClass for infos about a class with full filename.static classSClassReader.ClassInfoClass for infos about a class.static classSClassReader.EnumInfoInfo object for an enum.static classSClassReader.FieldInfoInfo object describing a field.static classSClassReader.MethodInfoInfo object describing a method.
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.Map<java.lang.String,java.lang.String>BASE_TYPE_MAPprotected static java.util.Map<java.lang.ClassLoader,java.util.Map<java.lang.String,SClassReader.ClassInfo>>CI_NAME_CACHE
-
Constructor Summary
Constructors Constructor Description SClassReader()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static java.lang.StringconvertTypeName(java.lang.String type)Converts a type name to Java style.protected static java.lang.StringdecodeModifiedUtf8(byte[] data)Decodes a Java-style modified UTF8 string as used in class files.static SClassReader.ClassInfogetClassInfo(java.io.InputStream inputstream)Get infos about a class.static SClassReader.ClassInfogetClassInfo(java.io.InputStream inputstream, boolean includefields, boolean includemethods)Get infos about a class.static SClassReader.ClassInfogetClassInfo(java.lang.String cachekey, java.io.InputStream inputstream, java.util.Date lastmodified)Get infos about a class.static SClassReader.ClassInfogetClassInfo(java.lang.String classname, java.lang.ClassLoader cl)static SClassReader.ClassInfogetClassInfo(java.lang.String classname, java.lang.ClassLoader cl, boolean includefields, boolean includemethods)protected static SClassReader.AnnotationInforeadAnnotation(java.io.DataInputStream is, java.util.Map<java.lang.Integer,byte[]> strings)Read a specific annotation.protected static java.util.List<SClassReader.AnnotationInfo>readAnnotations(java.io.DataInputStream is, java.util.Map<java.lang.Integer,byte[]> strings)Read a set of annotations.protected static java.lang.ObjectreadAnnotationValue(java.io.DataInputStream is, java.util.Map<java.lang.Integer,byte[]> strings)Read an annotation value.protected static java.util.Map<java.lang.Integer,byte[]>readConstantPoolStrings(java.io.DataInputStream is)Reads strings from the constant pool.protected static java.util.List<SClassReader.FieldInfo>readFields(java.io.DataInputStream is, java.util.Map<java.lang.Integer,byte[]> strings)Reads the class fields.protected static java.util.List<SClassReader.MethodInfo>readMethods(java.io.DataInputStream is, java.util.Map<java.lang.Integer,byte[]> strings)Reads the class methods.protected static java.util.List<SClassReader.AnnotationInfo>readVisibleAnnotations(java.io.DataInputStream is, java.util.Map<java.lang.Integer,byte[]> strings, boolean cancelread)Read runtime visible annotations.protected static voidskip(java.io.DataInputStream is, int len)Skips a number of bytes.protected static voidskipAttributes(java.io.DataInputStream is)protected static voidskipFieldsOrMethods(java.io.DataInputStream is)Skips the field or method section of the class file.
-
-
-
Field Detail
-
CI_NAME_CACHE
protected static final java.util.Map<java.lang.ClassLoader,java.util.Map<java.lang.String,SClassReader.ClassInfo>> CI_NAME_CACHE
-
BASE_TYPE_MAP
protected static final java.util.Map<java.lang.String,java.lang.String> BASE_TYPE_MAP
-
-
Method Detail
-
getClassInfo
public static final SClassReader.ClassInfo getClassInfo(java.lang.String cachekey, java.io.InputStream inputstream, java.util.Date lastmodified)
Get infos about a class.- Parameters:
inputstream- The input stream of the class file.- Returns:
- The class infos.
-
getClassInfo
public static final SClassReader.ClassInfo getClassInfo(java.io.InputStream inputstream)
Get infos about a class.- Parameters:
inputstream- The input stream of the class file.- Returns:
- The class infos.
-
getClassInfo
public static final SClassReader.ClassInfo getClassInfo(java.lang.String classname, java.lang.ClassLoader cl)
-
getClassInfo
public static final SClassReader.ClassInfo getClassInfo(java.lang.String classname, java.lang.ClassLoader cl, boolean includefields, boolean includemethods)
-
getClassInfo
public static final SClassReader.ClassInfo getClassInfo(java.io.InputStream inputstream, boolean includefields, boolean includemethods)
Get infos about a class.- Parameters:
inputstream- The input stream of the class file.- Returns:
- The class infos.
-
readConstantPoolStrings
protected static final java.util.Map<java.lang.Integer,byte[]> readConstantPoolStrings(java.io.DataInputStream is) throws java.io.IOExceptionReads strings from the constant pool.- Parameters:
is- The input stream.- Returns:
- The constant pool strings.
- Throws:
java.io.IOException
-
skipFieldsOrMethods
protected static final void skipFieldsOrMethods(java.io.DataInputStream is) throws java.io.IOExceptionSkips the field or method section of the class file.- Parameters:
is- The input stream.strings-- Throws:
java.io.IOException
-
skipAttributes
protected static final void skipAttributes(java.io.DataInputStream is) throws java.io.IOException- Throws:
java.io.IOException
-
readFields
protected static final java.util.List<SClassReader.FieldInfo> readFields(java.io.DataInputStream is, java.util.Map<java.lang.Integer,byte[]> strings) throws java.io.IOException
Reads the class fields.- Parameters:
is- Inputstream.strings- Strings from constant table.- Returns:
- Fields.
- Throws:
java.io.IOException
-
readMethods
protected static final java.util.List<SClassReader.MethodInfo> readMethods(java.io.DataInputStream is, java.util.Map<java.lang.Integer,byte[]> strings) throws java.io.IOException
Reads the class methods.- Parameters:
is- Inputstream.strings- Strings from constant table.- Returns:
- Methods.
- Throws:
java.io.IOException
-
readVisibleAnnotations
protected static final java.util.List<SClassReader.AnnotationInfo> readVisibleAnnotations(java.io.DataInputStream is, java.util.Map<java.lang.Integer,byte[]> strings, boolean cancelread) throws java.io.IOException
Read runtime visible annotations.- Throws:
java.io.IOException
-
readAnnotations
protected static final java.util.List<SClassReader.AnnotationInfo> readAnnotations(java.io.DataInputStream is, java.util.Map<java.lang.Integer,byte[]> strings) throws java.io.IOException
Read a set of annotations.- Throws:
java.io.IOException
-
readAnnotation
protected static final SClassReader.AnnotationInfo readAnnotation(java.io.DataInputStream is, java.util.Map<java.lang.Integer,byte[]> strings) throws java.io.IOException
Read a specific annotation.- Throws:
java.io.IOException
-
readAnnotationValue
protected static final java.lang.Object readAnnotationValue(java.io.DataInputStream is, java.util.Map<java.lang.Integer,byte[]> strings) throws java.io.IOExceptionRead an annotation value.- Throws:
java.io.IOException
-
decodeModifiedUtf8
protected static final java.lang.String decodeModifiedUtf8(byte[] data)
Decodes a Java-style modified UTF8 string as used in class files.- Parameters:
data- The string data.- Returns:
- The string.
-
skip
protected static final void skip(java.io.DataInputStream is, int len) throws java.io.IOExceptionSkips a number of bytes.- Parameters:
is- Inputstream.len- number of bytes skipped.- Throws:
java.io.IOException
-
convertTypeName
protected static final java.lang.String convertTypeName(java.lang.String type)
Converts a type name to Java style.- Parameters:
type- Internal name.- Returns:
- Converted name.
-
-