Search in sources :

Example 16 with JavaClassFormatError

use of com.jopdesign.common.misc.JavaClassFormatError in project jop by jop-devel.

the class RelinkInvokesuper method relinkInvokeSuper.

private void relinkInvokeSuper(InvokeSite is) {
    // this already resolves to the correct method..
    MethodRef invokee = is.getInvokeeRef();
    MethodInfo target = invokee.getMethodInfo();
    if (target == null) {
        // .. or not (class or method excluded or unknown)
        logger.warn("Cannot try to relink invokespecial to unknown super method " + invokee);
        return;
    }
    // now simply relink instruction (no need to check if it changes)
    int index = is.getInvoker().getClassInfo().addConstantInfo(new ConstantMethodInfo(invokee));
    if (!(is.getInvokeInstruction() instanceof INVOKESPECIAL)) {
        throw new JavaClassFormatError("Invokesuper is not an invokespecial instruction!");
    }
    is.getInvokeInstruction().setIndex(index);
}
Also used : ConstantMethodInfo(com.jopdesign.common.type.ConstantMethodInfo) MethodRef(com.jopdesign.common.type.MethodRef) JavaClassFormatError(com.jopdesign.common.misc.JavaClassFormatError) MethodInfo(com.jopdesign.common.MethodInfo) ConstantMethodInfo(com.jopdesign.common.type.ConstantMethodInfo) INVOKESPECIAL(org.apache.bcel.generic.INVOKESPECIAL)

Aggregations

JavaClassFormatError (com.jopdesign.common.misc.JavaClassFormatError)16 ClassInfo (com.jopdesign.common.ClassInfo)4 MethodInfo (com.jopdesign.common.MethodInfo)3 Iterator (java.util.Iterator)3 LinkedList (java.util.LinkedList)3 InstructionHandle (org.apache.bcel.generic.InstructionHandle)3 AppInfo (com.jopdesign.common.AppInfo)2 CallString (com.jopdesign.common.code.CallString)2 ClassHierarchyTraverser (com.jopdesign.common.graphutils.ClassHierarchyTraverser)2 ClassVisitor (com.jopdesign.common.graphutils.ClassVisitor)2 ConstantMethodInfo (com.jopdesign.common.type.ConstantMethodInfo)2 MethodRef (com.jopdesign.common.type.MethodRef)2 LinkedHashSet (java.util.LinkedHashSet)2 ConstantClass (org.apache.bcel.classfile.ConstantClass)2 ConstantFieldref (org.apache.bcel.classfile.ConstantFieldref)2 ConstantInterfaceMethodref (org.apache.bcel.classfile.ConstantInterfaceMethodref)2 ConstantMethodref (org.apache.bcel.classfile.ConstantMethodref)2 ConstantNameAndType (org.apache.bcel.classfile.ConstantNameAndType)2 ConstantString (org.apache.bcel.classfile.ConstantString)2 ConstantPoolGen (org.apache.bcel.generic.ConstantPoolGen)2