Package jadex.commons

Class SClassReader


  • public class SClassReader
    extends java.lang.Object
    Class using the internal fast class path scanner to provide some utility methods for inspecting raw binary classes.
    • 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
    • Constructor Detail

      • SClassReader

        public SClassReader()
    • 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.IOException
        Reads 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.IOException
        Skips 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.IOException
        Read 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.IOException
        Skips 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.