Package jadex.classreader
Class SClassReader
java.lang.Object
jadex.classreader.SClassReader
Class using the internal fast class path scanner to provide
some utility methods for inspecting raw binary classes.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Entity with optional annotationsstatic class
Class containing annotation infos.static class
Entity contained in a class.static class
Class for infos about a class with full filename.static class
Class for infos about a class.static class
Info object for an enum.static class
Info object describing a field.static class
Info object describing a method. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Map
<ClassLoader, Map<String, SClassReader.ClassInfo>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static final String
convertTypeName
(String type) Converts a type name to Java style.protected static final String
convertTypeNameList
(String type) Converts a type list to Java style.protected static final String
decodeModifiedUtf8
(byte[] data) Decodes a Java-style modified UTF8 string as used in class files.static final SClassReader.ClassInfo
getClassInfo
(InputStream inputstream) Get infos about a class.static final SClassReader.ClassInfo
getClassInfo
(InputStream inputstream, boolean includefields, boolean includemethods) Get infos about a class.static final SClassReader.ClassInfo
getClassInfo
(String cachekey, InputStream inputstream, Date lastmodified) Get infos about a class.static final SClassReader.ClassInfo
getClassInfo
(String classname, ClassLoader cl) static final SClassReader.ClassInfo
getClassInfo
(String classname, ClassLoader cl, boolean includefields, boolean includemethods) protected static final String
Returns the visibility of a ClassEntity.protected static final SClassReader.AnnotationInfo
readAnnotation
(DataInputStream is, Map<Integer, byte[]> strings) Read a specific annotation.protected static final List
<SClassReader.AnnotationInfo> readAnnotations
(DataInputStream is, Map<Integer, byte[]> strings) Read a set of annotations.protected static final Object
readAnnotationValue
(DataInputStream is, Map<Integer, byte[]> strings) Read an annotation value.Reads strings from the constant pool.protected static final List
<SClassReader.FieldInfo> readFields
(DataInputStream is, Map<Integer, byte[]> strings) Reads the class fields.protected static final List
<SClassReader.MethodInfo> readMethods
(DataInputStream is, Map<Integer, byte[]> strings) Reads the class methods.protected static final List
<SClassReader.AnnotationInfo> readVisibleAnnotations
(DataInputStream is, Map<Integer, byte[]> strings, boolean cancelread) Read runtime visible annotations.static Set
<SClassReader.ClassFileInfo> scanForClassFileInfos
(URL[] urls, jadex.common.IFilter<Object> filefilter, jadex.common.IFilter<SClassReader.ClassFileInfo> classfilter) Scan for component classes in the classpath.static Set
<SClassReader.ClassInfo> scanForClassInfos
(URL[] urls, jadex.common.IFilter<Object> filefilter, jadex.common.IFilter<SClassReader.ClassInfo> classfilter) Scan for component classes in the classpath.protected static final void
skip
(DataInputStream is, int len) Skips a number of bytes.protected static final void
protected static final void
Skips the field or method section of the class file.
-
Field Details
-
CI_NAME_CACHE
-
BASE_TYPE_MAP
-
-
Constructor Details
-
SClassReader
public SClassReader()
-
-
Method Details
-
getClassInfo
public static final SClassReader.ClassInfo getClassInfo(String cachekey, InputStream inputstream, Date lastmodified) Get infos about a class.- Parameters:
inputstream
- The input stream of the class file.- Returns:
- The class infos.
-
getClassInfo
Get infos about a class.- Parameters:
inputstream
- The input stream of the class file.- Returns:
- The class infos.
-
getClassInfo
-
getClassInfo
public static final SClassReader.ClassInfo getClassInfo(String classname, ClassLoader cl, boolean includefields, boolean includemethods) -
getClassInfo
public static final SClassReader.ClassInfo getClassInfo(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 Map<Integer,byte[]> readConstantPoolStrings(DataInputStream is) throws IOException Reads strings from the constant pool.- Parameters:
is
- The input stream.- Returns:
- The constant pool strings.
- Throws:
IOException
-
skipFieldsOrMethods
Skips the field or method section of the class file.- Parameters:
is
- The input stream.strings
-- Throws:
IOException
-
skipAttributes
- Throws:
IOException
-
readFields
protected static final List<SClassReader.FieldInfo> readFields(DataInputStream is, Map<Integer, byte[]> strings) throws IOExceptionReads the class fields.- Parameters:
is
- Inputstream.strings
- Strings from constant table.- Returns:
- Fields.
- Throws:
IOException
-
readMethods
protected static final List<SClassReader.MethodInfo> readMethods(DataInputStream is, Map<Integer, byte[]> strings) throws IOExceptionReads the class methods.- Parameters:
is
- Inputstream.strings
- Strings from constant table.- Returns:
- Methods.
- Throws:
IOException
-
readVisibleAnnotations
protected static final List<SClassReader.AnnotationInfo> readVisibleAnnotations(DataInputStream is, Map<Integer, byte[]> strings, boolean cancelread) throws IOExceptionRead runtime visible annotations.- Throws:
IOException
-
readAnnotations
protected static final List<SClassReader.AnnotationInfo> readAnnotations(DataInputStream is, Map<Integer, byte[]> strings) throws IOExceptionRead a set of annotations.- Throws:
IOException
-
readAnnotation
protected static final SClassReader.AnnotationInfo readAnnotation(DataInputStream is, Map<Integer, byte[]> strings) throws IOExceptionRead a specific annotation.- Throws:
IOException
-
readAnnotationValue
protected static final Object readAnnotationValue(DataInputStream is, Map<Integer, byte[]> strings) throws IOExceptionRead an annotation value.- Throws:
IOException
-
decodeModifiedUtf8
Decodes a Java-style modified UTF8 string as used in class files.- Parameters:
data
- The string data.- Returns:
- The string.
-
skip
Skips a number of bytes.- Parameters:
is
- Inputstream.len
- number of bytes skipped.- Throws:
IOException
-
convertTypeName
Converts a type name to Java style.- Parameters:
type
- Internal name.- Returns:
- Converted name.
-
convertTypeNameList
Converts a type list to Java style.- Parameters:
type
- Internal name list.- Returns:
- Converted names.
-
getVisibility
Returns the visibility of a ClassEntity.- Parameters:
e
- The entity.- Returns:
- The visibility as a String.
-
scanForClassInfos
public static Set<SClassReader.ClassInfo> scanForClassInfos(URL[] urls, jadex.common.IFilter<Object> filefilter, jadex.common.IFilter<SClassReader.ClassInfo> classfilter) Scan for component classes in the classpath. -
scanForClassFileInfos
public static Set<SClassReader.ClassFileInfo> scanForClassFileInfos(URL[] urls, jadex.common.IFilter<Object> filefilter, jadex.common.IFilter<SClassReader.ClassFileInfo> classfilter) Scan for component classes in the classpath.
-