Community
Participate
Working Groups
When running the java builder from a headless 0214 workbench, I enable (or disable) the java compiler debug support by the following code: Hashtable javaOptions=JavaCore.getOptions(); javaOptions.put("org.eclipse.jdt.core.compiler.debug.sourceFile", "do not generate"); javaOptions.put("org.eclipse.jdt.core.compiler.debug.lineNumber", "do not generate"); javaOptions.put("org.eclipse.jdt.core.compiler.debug.localVariable", "do not generate"); JavaCore.setOptions(javaOptions); When I have all three of those options set, I get the following exception in the Java builder. All three of the options work fine in isolation, but they fail when used in combination. java.lang.ArrayIndexOutOfBoundsException: 1800 at org.eclipse.jdt.internal.compiler.ClassFile.addAttributes (ClassFile.java:360) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode (TypeDeclaration.java:603) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode (TypeDeclaration.java:635) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode (CompilationUnitDeclaration.java:129) at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:530) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:332) at org.eclipse.jdt.internal.core.newbuilder.AbstractImageBuilder.compile (AbstractImageBuilder.java:209) at org.eclipse.jdt.internal.core.newbuilder.AbstractImageBuilder.compile (AbstractImageBuilder.java:156) at org.eclipse.jdt.internal.core.newbuilder.IncrementalImageBuilder.build (IncrementalImageBuilder.java:102) at org.eclipse.jdt.internal.core.newbuilder.JavaBuilder.buildDeltas (JavaBuilder.java:146) at org.eclipse.jdt.internal.core.newbuilder.JavaBuilder.build (JavaBuilder.java:98) at org.eclipse.core.internal.events.BuildManager$2.run (BuildManager.java:351) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:817) at org.eclipse.core.runtime.Platform.run(Platform.java:395) at org.eclipse.core.internal.events.BuildManager.basicBuild (BuildManager.java:109) at org.eclipse.core.internal.events.BuildManager.basicBuild (BuildManager.java:174) at org.eclipse.core.internal.events.BuildManager.basicBuild (BuildManager.java:184) at org.eclipse.core.internal.events.BuildManager$1.run (BuildManager.java:133) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:817) at org.eclipse.core.runtime.Platform.run(Platform.java:395) at org.eclipse.core.internal.events.BuildManager.basicBuild (BuildManager.java:147) at org.eclipse.core.internal.events.BuildManager.build (BuildManager.java:230) at org.eclipse.core.internal.resources.Project.build(Project.java:105)
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. ***