Search in sources :

Example 26 with ClassFile

use of org.hotswap.agent.javassist.bytecode.ClassFile in project HotswapAgent by HotswapProjects.

the class FieldInitLink method makeClassInitializer.

public CtConstructor makeClassInitializer() throws CannotCompileException {
    CtConstructor clinit = getClassInitializer();
    if (clinit != null)
        return clinit;
    checkModify();
    ClassFile cf = getClassFile2();
    Bytecode code = new Bytecode(cf.getConstPool(), 0, 0);
    modifyClassConstructor(cf, code, 0, 0);
    return getClassInitializer();
}
Also used : ClassFile(org.hotswap.agent.javassist.bytecode.ClassFile) BadBytecode(org.hotswap.agent.javassist.bytecode.BadBytecode) Bytecode(org.hotswap.agent.javassist.bytecode.Bytecode)

Example 27 with ClassFile

use of org.hotswap.agent.javassist.bytecode.ClassFile in project HotswapAgent by HotswapProjects.

the class FieldInitLink method getAnnotations.

private Object[] getAnnotations(boolean ignoreNotFound) throws ClassNotFoundException {
    ClassFile cf = getClassFile2();
    AnnotationsAttribute ainfo = (AnnotationsAttribute) cf.getAttribute(AnnotationsAttribute.invisibleTag);
    AnnotationsAttribute ainfo2 = (AnnotationsAttribute) cf.getAttribute(AnnotationsAttribute.visibleTag);
    return toAnnotationType(ignoreNotFound, getClassPool(), ainfo, ainfo2);
}
Also used : ClassFile(org.hotswap.agent.javassist.bytecode.ClassFile) AnnotationsAttribute(org.hotswap.agent.javassist.bytecode.AnnotationsAttribute) ParameterAnnotationsAttribute(org.hotswap.agent.javassist.bytecode.ParameterAnnotationsAttribute)

Example 28 with ClassFile

use of org.hotswap.agent.javassist.bytecode.ClassFile in project HotswapAgent by HotswapProjects.

the class FieldInitLink method toBytecode.

public void toBytecode(DataOutputStream out) throws CannotCompileException, IOException {
    try {
        if (isModified()) {
            checkPruned("toBytecode");
            ClassFile cf = getClassFile2();
            if (gcConstPool) {
                cf.compact();
                gcConstPool = false;
            }
            modifyClassConstructor(cf);
            modifyConstructors(cf);
            if (debugDump != null)
                dumpClassFile(cf);
            cf.write(out);
            out.flush();
            fieldInitializers = null;
            if (doPruning) {
                // to save memory
                cf.prune();
                wasPruned = true;
            }
        } else {
            classPool.writeClassfile(getName(), out);
        // to save memory
        // classfile = null;
        }
        getCount = 0;
        wasFrozen = true;
    } catch (NotFoundException e) {
        throw new CannotCompileException(e);
    } catch (IOException e) {
        throw new CannotCompileException(e);
    }
}
Also used : ClassFile(org.hotswap.agent.javassist.bytecode.ClassFile) IOException(java.io.IOException)

Aggregations

ClassFile (org.hotswap.agent.javassist.bytecode.ClassFile)28 MethodInfo (org.hotswap.agent.javassist.bytecode.MethodInfo)5 IOException (java.io.IOException)4 InnerClassesAttribute (org.hotswap.agent.javassist.bytecode.InnerClassesAttribute)4 ArrayList (java.util.ArrayList)3 AnnotationsAttribute (org.hotswap.agent.javassist.bytecode.AnnotationsAttribute)3 ParameterAnnotationsAttribute (org.hotswap.agent.javassist.bytecode.ParameterAnnotationsAttribute)3 DataInputStream (java.io.DataInputStream)2 InputStream (java.io.InputStream)2 List (java.util.List)2 EnclosingMethodAttribute (org.hotswap.agent.javassist.bytecode.EnclosingMethodAttribute)2 BufferedInputStream (java.io.BufferedInputStream)1 BufferedOutputStream (java.io.BufferedOutputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataOutputStream (java.io.DataOutputStream)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 LinkedList (java.util.LinkedList)1 CtClass (org.hotswap.agent.javassist.CtClass)1 NotFoundException (org.hotswap.agent.javassist.NotFoundException)1