Summary: | Exception in Java Builder when debug options turned off | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Tim Francis <francis> |
Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> |
Status: | RESOLVED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P2 | CC: | dandunn |
Version: | 2.0 | ||
Target Milestone: | 2.0 M4 | ||
Hardware: | PC | ||
OS: | Windows 2000 | ||
Whiteboard: |
Description
Tim Francis
2002-03-14 16:22:57 EST
Would you have a piece of code that could help us to reproduce the problem? When no attributes are generated, we can get an ArrayIndexOutOfBoundsException. // update the number of attributes contents[attributeOffset++] = (byte) (attributeNumber >> 8); contents[attributeOffset] = (byte) attributeNumber; We reach these two lines without checking that we have enough spaces to write inside this array. I suggest: if (attributeOffset + 2 >= (contentsLength = contents.length)) { System.arraycopy( contents, 0, (contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength); } // update the number of attributes contents[attributeOffset++] = (byte) (attributeNumber >> 8); contents[attributeOffset] = (byte) attributeNumber; It would be nice to see if this really fixes the problem. But for that we need a test case. I don't have a simple testcase, but I will try the proposed fix, and will let you know. I do not have a simple testcase.... but I do have a reproducible testcase, and after I applied your fix, the problem went away - so in addition to just looking right, this fix seems correct. Thanks for the prompt response! (One nit, there was a syntax error in your code snippit - this is what works for me) int contentsLength = contents.length; if (attributeOffset + 2 >= contentsLength) { System.arraycopy( contents, 0, (contents = new byte[contentsLength + INCREMENT_SIZE]), 0, contentsLength); } Olivier - please apply the fix to HEAD for M4. Thanks for checking the fix. In fact the code snippet I gave worked on my machine, because I put the local at the beginning of the method. This will be fixed for M4. Fixed and released in HEAD. Olivier - please backport this fix in 1.0 stream as well. Done. *** Bug 13852 has been marked as a duplicate of this bug. *** |