Class JarAnalyzer

    • Field Detail

      • instrument

        protected boolean instrument
      • rename

        protected boolean rename
      • classCount

        protected int classCount
      • enumCount

        protected int enumCount
      • interfaceCount

        protected int interfaceCount
      • workDir

        protected Path workDir
    • Constructor Detail

      • JarAnalyzer

        public JarAnalyzer()
    • Method Detail

      • setInstrument

        public void setInstrument​(boolean _instrument)

        Setter for the field instrument.

        Parameters:
        _instrument - a boolean.
      • getPath

        public Path getPath()

        getPath.

        Returns:
        a Path object.
      • setParent

        public void setParent​(JarAnalyzer ja)

        Setter for the field parent.

        Parameters:
        ja - a JarAnalyzer object.
      • getFileSize

        public long getFileSize()
        Returns the size of the original JAR file (before instrumentation).
        Returns:
        a long.
        See Also:
        getInstrumentedFileSize()
      • getInstrumentedFileSize

        public long getInstrumentedFileSize()
        Returns the size of the instrumented JAR file (or -1 if no instrumentation took place).
        Returns:
        a long.
        See Also:
        getFileSize()
      • setWorkDir

        public void setWorkDir​(Path _p)
        Specifies the work directory into which instrumented JARs are written. If null, a temporary directory will be created.
        Parameters:
        _p - a Path object.
      • setRename

        public void setRename​(boolean _b)
        Determines whether the instrumented JAR is renamed or not. If yes, the new file name follows the following format: - If app context is provided: [originalJarName]-vulas-[appGroupId]-[appArtifactId]-[appVersion].jar - Otherwise: [originalJarName]-vulas-instr.jar
        Parameters:
        _b - a boolean.
      • setLibraryId

        public void setLibraryId​(org.eclipse.steady.shared.json.model.LibraryId _id)
        Sets the Maven Id for the JAR to be analyzed. The Maven ID is already known in some contexts (e.g., during Maven plugin execution).
        Parameters:
        _id - a LibraryId object.
      • getLibrary

        public org.eclipse.steady.shared.json.model.Library getLibrary()
                                                                throws FileAnalysisException
        Returns a Library representing the analyzed Java archive.
        Returns:
        a Library object.
        Throws:
        FileAnalysisException
      • getSHA1

        public String getSHA1()
        Returns the SHA1 digest of the JAR. Either taken from the manifest (entry VULAS-originalSHA1, in case the original JAR has been instrumented offline), or by computing it on the fly.
        Returns:
        the SHA1 digest of the JAR
      • getFileName

        public String getFileName()

        getFileName.

        Returns:
        a String object.
      • createInstrumentedArchive

        protected void createInstrumentedArchive()
                                          throws JarAnalysisException
        See here: http://docs.oracle.com/javase/7/docs/technotes/guides/jar/jar.html
        Throws:
        JarAnalysisException
      • getInstrumentedArchive

        public final File getInstrumentedArchive()

        getInstrumentedArchive.

        Returns:
        a File object.
      • getClassNames

        public Set<String> getClassNames()
        Returns the class names for all class files found in the given archive.
        Returns:
        a Set object.
      • hasJARConstructs

        public boolean hasJARConstructs()

        hasJARConstructs.

        Returns:
        a boolean.
      • getConstructIds

        public Set<ConstructId> getConstructIds()
        Identifies all ConstructIds of all methods and constructors.
        Returns:
        a Set object.
      • isJavaIdentifier

        public static boolean isJavaIdentifier​(String _name)

        isJavaIdentifier.

        Parameters:
        _name - a String object.
        Returns:
        a boolean.
      • getFqClassname

        public static String getFqClassname​(String _jar_entry_name)
        Returns the fully-qualified Java class identifier for a given JAR entry. This is done by removing the file extension and by interpreting folders as packages. If anything goes wrong, null is returned.
        Parameters:
        _jar_entry_name - a String object.
        Returns:
        a String object.
      • setAppContext

        public static void setAppContext​(org.eclipse.steady.shared.json.model.Application _ctx)

        setAppContext.

        Parameters:
        _ctx - a Application object.
      • getAppContext

        public static org.eclipse.steady.shared.json.model.Application getAppContext()

        getAppContext.

        Returns:
        a Application object.
      • insertClasspath

        public static void insertClasspath​(String _url)
                                    throws javassist.NotFoundException
        Adds a given URL to the classpath of the class pool. This allows maintaining dependencies needed for the compilation of instrumented classes.
        Parameters:
        _url - a String object.
        Throws:
        javassist.NotFoundException
      • getClassPool

        protected static javassist.ClassPool getClassPool()

        getClassPool.

        Returns:
        a ClassPool object.