Search in sources :

Example 16 with ClassReader

use of jodd.asm5.ClassReader in project apex-core by apache.

the class FastClassIndexReaderTest method testPerformance.

@Test
public void testPerformance() throws Exception {
    String javahome = System.getProperty("java.home");
    String jdkJar = javahome + "/lib/rt.jar";
    JarFile jar = new JarFile(jdkJar);
    java.util.Enumeration<JarEntry> entriesEnum = jar.entries();
    long time = System.currentTimeMillis();
    while (entriesEnum.hasMoreElements()) {
        JarEntry jarEntry = entriesEnum.nextElement();
        if (jarEntry.getName().endsWith("class")) {
            InputStream ins = jar.getInputStream(jarEntry);
            //FastClassSignatureReader fastClassSignatureReader = new FastClassSignatureReader(ins);
            ClassReader classReader = new ClassReader(ins);
            ClassNodeType classN = new ClassNodeType();
            classReader.accept(classN, ClassReader.SKIP_CODE);
            CompactClassNode ccn = CompactUtil.compactClassNode(classN);
            ins.close();
        }
    }
    LOG.info("The time to scan jdk using ASM ClassReader {} ", System.currentTimeMillis() - time);
    jar.close();
    jar = new JarFile(jdkJar);
    entriesEnum = jar.entries();
    time = System.currentTimeMillis();
    while (entriesEnum.hasMoreElements()) {
        JarEntry jarEntry = entriesEnum.nextElement();
        if (jarEntry.getName().endsWith("class")) {
            InputStream ins = jar.getInputStream(jarEntry);
            FastClassIndexReader fastClassIndexReader = new FastClassIndexReader(ins);
            ins.close();
        }
    }
    jar.close();
    LOG.info("The time to scan jdk using FastClassIndexReader {} ", System.currentTimeMillis() - time);
}
Also used : InputStream(java.io.InputStream) ClassReader(org.apache.xbean.asm5.ClassReader) JarFile(java.util.jar.JarFile) JarEntry(java.util.jar.JarEntry) Test(org.junit.Test)

Aggregations

ClassReader (org.apache.xbean.asm5.ClassReader)11 IOException (java.io.IOException)9 InputStream (java.io.InputStream)7 ClassReader (jodd.asm5.ClassReader)4 URL (java.net.URL)2 JarEntry (java.util.jar.JarEntry)2 JarFile (java.util.jar.JarFile)2 ProxyGenerationException (org.apache.openejb.util.proxy.ProxyGenerationException)2 ClassVisitor (org.apache.xbean.asm5.ClassVisitor)2 Test (org.junit.Test)2 SoftReference (com.intellij.reference.SoftReference)1 BufferedInputStream (java.io.BufferedInputStream)1 Reference (java.lang.ref.Reference)1 WeakReference (java.lang.ref.WeakReference)1 Constructor (java.lang.reflect.Constructor)1 Method (java.lang.reflect.Method)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 JarInputStream (java.util.jar.JarInputStream)1