[jboss-jira] [JBoss JIRA] Commented: (JASSIST-74) modifying a method containing a switch statement using IBM JVM throws ArrayIndexOutOfBoundsException

Shigeru Chiba (JIRA) jira-events at lists.jboss.org
Wed Mar 18 08:22:22 EDT 2009


    [ https://jira.jboss.org/jira/browse/JASSIST-74?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12457889#action_12457889 ] 

Shigeru Chiba commented on JASSIST-74:
--------------------------------------

I downloaded IBM JVM 1.4.2.  Thanks for the info.

It seems that the problem is a bug of that JVM (a bug of the JIT compiler).
But, because WAS 5.1/6.0 is an important platform :-), I modified Javassist to avoid this bug.
Please try the latest version of Javassist available from the CVS head.

I modified the following loop in javassist.bytecode.CodeIterator.insertGap2:

while (i0 < i2) {
    newcode[j++] = code[i0++];

The new code is the following:

while (i0 < i2) {
    if (i0 >= code.length)
        throw new RuntimeException("jassist-74");
     newcode[j++] = 0; i0++;
}

because code[i0++] is always 0.
When I ran the new code with MyTest2, it works fine.  The if statement never threw an exception, either
(this if statement was removed before I checked in the code).




> modifying a method containing a switch statement using IBM JVM throws ArrayIndexOutOfBoundsException
> ----------------------------------------------------------------------------------------------------
>
>                 Key: JASSIST-74
>                 URL: https://jira.jboss.org/jira/browse/JASSIST-74
>             Project: Javassist
>          Issue Type: Bug
>    Affects Versions: 3.8.1.GA
>         Environment: OS: Probably all. I produced it on Windows
> JVM: does not happen with Sun JVM (at least the versions I used). Does happen with IBM's JVM. I used the following version: 
> java version "1.5.0"
> Java(TM) 2 Runtime Environment, Standard Edition (build pwi32dev-20060511 (SR2))
> IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 Windows XP x86-32 j9vmwi3223-20060504 (JIT enabled)
> J9VM - 20060501_06428_lHdSMR
> JIT  - 20060428_1800_r8
> GC   - 20060501_AA)
> JCL  - 20060511a
> This version comes bundled with Websphere 6.1 ND. The Exact version that I used is "WebSphere Platform 6.1 [ND 6.1.0.0 b0620.14]"
>            Reporter: Mooky Grand
>            Assignee: Shigeru Chiba
>         Attachments: Bla.class, Bla.class, Bla.java, MyTest2.java
>
>
> First the exception that I see:
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -2147483648
>         at javassist.bytecode.CodeIterator.insertGap2(CodeIterator.java(Compiled Code))
>         at javassist.bytecode.CodeIterator.insertGap0(CodeIterator.java:656)
>         at javassist.bytecode.CodeIterator.insertGap(CodeIterator.java:640)
>         at javassist.bytecode.CodeIterator.insertGapCore(CodeIterator.java:467)
>         at javassist.bytecode.CodeIterator.insert0(CodeIterator.java:370)
>         at javassist.bytecode.CodeIterator.insertEx(CodeIterator.java:339)
>         at javassist.CtBehavior.insertBefore(CtBehavior.java:671)
>         at javassist.CtBehavior.insertBefore(CtBehavior.java:640)
>         at sample.MyTest2.main(MyTest2.java:26)
> From the little analysis I did I discovered the following:
> 1. The problem is not reproduced using Sun's JVM.
> 2. The method being modified must be of a certain length
> 3. The method must have a switch statement.
> 4. The added code should be containe dinside a try-catch block.
> When I remove some of the repeating statements from Bla.java, the exception goes away (BTW, if I remove just one there's no exception but the resulting file is corrupted).
> Essentially, this prevents me from using Javassist under IBM's JVM for large methods that contain switch statements.
> I've reproduced this problem using javassist 3.4, 3.8 & 3.9.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list