Bugs item #988787, was opened at 2004-07-11 14:43
Message generated for change (Comment added) made by chiba
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=988787&group_id=22866

Category: Javassist
Group: CVS HEAD
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Tsuyoshi Murakami (tymu)
Assigned to: Shigeru Chiba (chiba)
Summary: CodeIterator#insertGap0() is not fine.

Initial Comment:
I use with my class file, which has constant pool over
0x100 indexes.
When load my class which are copied method with ldc
opecode, throw CannotCompileException.

Perhaps, LineNumberAttribute#shiftPc() and
LocalVariableAttribute#shiftPc(), which are called from
CodeIterator#insertGap0() are wrong.

My class:

package example.app;

public final class Example {

    private static final int INTVALUE = 100000;
    private int i1, i2, i3, i4, i5, i6, i7, i8, i9, i10;
    private int i11, i12, i13, i14, i15, i16, i17, i18,
i19, i20;
    private int i21, i22, i23, i24, i25, i26, i27, i28,
i29, i30;
    private int i31, i32, i33, i34, i35, i36, i37, i38,
i39, i40;

    public void doit() {

        i1 = INTVALUE;
        i2 = INTVALUE;
        i3 = INTVALUE;
        i4 = INTVALUE;
        i5 = INTVALUE;
        i6 = INTVALUE;
        i7 = INTVALUE;
        i8 = INTVALUE;
        i9 = INTVALUE;
        i10 = INTVALUE;
        i11 = INTVALUE;
        i12 = INTVALUE;
        i13 = INTVALUE;
        i14 = INTVALUE;
        i15 = INTVALUE;
        i16 = INTVALUE;
        i17 = INTVALUE;
        i18 = INTVALUE;
        i19 = INTVALUE;
        i20 = INTVALUE;
        i21 = INTVALUE;
        i22 = INTVALUE;
        i23 = INTVALUE;
        i24 = INTVALUE;
        i25 = INTVALUE;
        i26 = INTVALUE;
        i27 = INTVALUE;
        i28 = INTVALUE;
        i29 = INTVALUE;
        i20 = INTVALUE;
        i21 = INTVALUE;
        i22 = INTVALUE;
        i23 = INTVALUE;
        i24 = INTVALUE;
        i25 = INTVALUE;
        i26 = INTVALUE;
        i27 = INTVALUE;
        i28 = INTVALUE;
        i29 = INTVALUE;
        i30 = INTVALUE;
        i31 = INTVALUE;
        i32 = INTVALUE;
        i33 = INTVALUE;
        i34 = INTVALUE;
        i35 = INTVALUE;
        i36 = INTVALUE;
        i37 = INTVALUE;
        i38 = INTVALUE;
        i39 = INTVALUE;
        i40 = INTVALUE;
    }
}

Test class:

package example.app;

import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtMethod;
import javassist.CtNewMethod;
import javassist.NotFoundException;
import javassist.bytecode.CodeAttribute;
import junit.framework.TestCase;

public final class ExampleTest extends TestCase {

    public void testExample() throws Throwable {

        ClassPool pool = ClassPool.getDefault();
        CtClass cc = pool.get("example.app.Example");

        CtMethod[] ms = cc.getDeclaredMethods();
        for (int i = 0; i < ms.length; i++) {
            addMethod(ms[i], cc);
        }
        
        cc.writeFile();
        Class c = cc.toClass();
    }

    private void addMethod(CtMethod method, CtClass target)
        throws CannotCompileException, NotFoundException {

        CtClass[] ts = method.getParameterTypes();
        CtClass[] newts = new CtClass[ts.length + 1];
        for (int i = 0; i < ts.length; i++) {
            newts[i] = ts[i];
        }
        ClassPool p =
method.getDeclaringClass().getClassPool();
        newts[ts.length] = target;

        CtMethod m =
            CtNewMethod.make(
                method.getModifiers(),
                method.getReturnType(),
                method.getName(),
                newts,
                method.getExceptionTypes(),
                null,
                method.getDeclaringClass());

        m.setBody(method, null);

        CodeAttribute ca =
m.getMethodInfo().getCodeAttribute();
        ca.setMaxLocals(ca.getMaxLocals() + 1);

        target.addMethod(m);
    }
}

----------------------------------------------------------------------

>Comment By: Shigeru Chiba (chiba)
Date: 2004-07-19 21:39

Message:
Logged In: YES 
user_id=388745

Thanks.  This bug has been fixed.
Please download the files with CVS tag "bugfix988787".

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=988787&group_id=22866


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to