Community
Participate
Working Groups
I'm getting an ArrayIndexOutOfBoundsException from trying to compile SimpleToken.java in CDT 3.0.0: [javac] 20. ERROR in /home/build/BUILD/common-devrocket-2.1.0/plugins/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/token/SimpleToken.java [javac] (at line 0) [javac] /******************************************************************************* [javac] ^ [javac] Internal compiler error [javac] java.lang.ArrayIndexOutOfBoundsException: 800 [javac] at org.eclipse.jdt.internal.compiler.codegen.CodeStream.ldc(CodeStream.java:4276) [javac] at org.eclipse.jdt.internal.compiler.codegen.CodeStream.generateConstant(CodeStream.java:1393) [javac] at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.generateCode(ReturnStatement.java:136) [javac] at org.eclipse.jdt.internal.compiler.ast.SwitchStatement.generateCode(SwitchStatement.java:202) [javac] at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:222) [javac] at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:169) [javac] at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:561) [javac] at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:615) [javac] at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode(CompilationUnitDeclaration.java:184) [javac] at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:510) [javac] at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:329) [javac] at org.eclipse.jdt.internal.compiler.batch.Main.performCompilation(Main.java:2691) [javac] at org.eclipse.jdt.internal.compiler.batch.Main.compile(Main.java:1151) [javac] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [javac] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [javac] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [javac] at java.lang.reflect.Method.invoke(Method.java:324) [javac] at org.eclipse.jdt.core.JDTCompilerAdapter.execute(JDTCompilerAdapter.java:63) [javac] at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:931) [javac] at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:757) ...
Which Eclipse build are you using ? Olivier - could be a good candidate for backporting to 3.1.2.
I am investigating.
Raise severity to blocker since this prevents the file from being compiled without any workaround.
So far I cannot reproduce. Please provide the build id.
I'm using the JDT compiler in Eclipse 3.1.0 (CVS tag: R3_1). I'll try to find out what the build id is, if you still need it. I'll be atatching the CDT file SimpleToken.java shortly. Sorry for not providing this info earlier and thanks for looking into this!
Created attachment 29549 [details] CDT source file.
I cannot reproduce with HEAD. Could you please send me all the files I need to compile this version of the SimpleToken class. I'll try to reproduce with an older version.
Reducing severity since I cannot reproduce with 3.1 maintenance HEAD stream, current 3.2 HEAD and 3.0 maintenance HEAD stream. I definitely need all dependant source files. I'll try to get all source files from CDT 3.0.0 out of CVS.
I got all source tagged as CDT_3_0 and I still could not reproduce.
Olivier, did you test this in the workbench? The failure we're seeing is when building outside the workbench, in the command-line. We need to be able to do this. Does the JDT compiler require any special options to be set?
I tried in the workbench and on the command line. I could not reproduce. Could you please provide the exact same set of source files that you are using? Also give me the command line and all possible details in order to reproduce the problem. Thanks for your help.
Sure, I'll attach what I think you'll need shortly. BTW, I'm sorry for not pointing out that I was building in batch mode at the very beginning. Thanks for your patience!
Created attachment 29577 [details] ecj.jar and build.xml for cdt.core
I could not reproduce the problem. Can you reproduce it all the time? If yes, could you please provide the source files you are compiling?
I think the only file is different is the build.xml file for org.eclipse.cdt.core. The one I'm using is attached. I also provided ecj.jar, in it's different. I'm using the same version of Ant as in Eclipse 3.1.0, i.e. version 1.6.5. The command line used to kick off the CDT build is as follows: rc=0 ; \ JAVA_HOME=/opt/montavista/common/jdk/jre \ ANT_HOME=/opt/montavista/common/apache-ant \ CLASSPATH=/home/build/SOURCES/ecj.jar \ /opt/montavista/common/apache-ant/bin/ant \ -buildfile `/home/build/SOURCES/cygpath -w /home/build/BUILD/common-devrocket-2.1.0/build/tools/build.xml` \ -Dos=linux \ -Dws=gtk \ -Darch=x86 \ -Dbasedir=`/home/build/SOURCES/cygpath -w /home/build/BUILD/common-devrocket-2.1.0/` \ -Dbootclasspath=`/home/build/SOURCES/cygpath -wp /opt/montavista/common/jdk/jre/lib/rt.jar:/opt/montavista/common/jdk/jre/lib/jsse.jar` \ -Dbuild.compiler=org.eclipse.jdt.core.JDTCompilerAdapter \ -DjavacDebugInfo=off \ -DjavacFailOnError=false \ -DjavacSource=1.4 \ -DjavacTarget=1.4 \ -DjavacVerbose=false \ init compile ; \ [ $rc -eq 0 ] || exit $rc Buildfile: /home/build/BUILD/common-devrocket-2.1.0/build/tools/build.xml I'll also attach /home/build/BUILD/common-devrocket-2.1.0/build/tools/build.xml in case its of any help. It's a top-level build file to launch the build of the various CDT plugins. The CDT source is the same as CDT 3.0.0.
Created attachment 29578 [details] top-level tools build.xml
Yes, the failure occurs consistently for me. How did you build in the command line? Perhaps I should build the way you did to make this work.
Created attachment 29579 [details] org.eclipse.cdt.core source from CDT 3.0.0
I've attached the source for the org.eclipse.cdt.core plugin. You may find changes which my team has made (there may not be any) but SimpleToken.java was definitely not changed. Please let me know if you need anything else from me.
Thank you. I will continue to investigate this issue. Hopefully I will be able to reproduce the failure.
I could not reproduce it. I don't know what I am doing that could be different from your settings. Did you try with 3.1.1 to see if this problem is fixed? I used the jar file of JDT/Core plugin from the 3.1 build. I used your source file and the build.xml located in the project folder. The build is successful. Could you please try to run using the following compiler arg: <compilerarg line="${temp.folder}/cdtcorelog.xml"/> And send me the log file. I'd like to know what files are compiled during your compilation. If this doesn't work, I can try to send you a patch based on 3.1.1 that could fix this issue. I simply wanted to understand how the failure occured. Thanks for your help tracking down this issue.
I got it. Don't know why suddenly I could reproduce it, but this is the case. I am working on a fix.
I could not reproduce because in my testing I was generating the debug attributes. To reproduce the failures, the debug attributes must not be generated. Fixed and released in HEAD. Regression test added in org.eclipse.jdt.core.tests.compiler.regression.XLargeTest.test008
Backported to 3.1 maintenance and 3.0 maintenance streams. Same regression test added in both streams
Thanks very much for getting this fixed so quickly, Olivier! Would you please attach the patch to this bug so that I can apply it to our source repository?
Olivier, do you know why the exception is not thrown when building in the workbench? Is it because the debug attributes are generated when building in the workbench?
Yes, if you have debug attribute the situation described below won't happen. The fix is very simple. Replace the resizeByteArray() method in org.eclipse.jdt.internal.compiler.codegen.CodeStream with: private final void resizeByteArray() { int length = bCodeStream.length; int requiredSize = length + length; if (classFileOffset >= requiredSize) { // must be sure to grow enough requiredSize = classFileOffset + length; } System.arraycopy(bCodeStream, 0, bCodeStream = new byte[requiredSize], 0, length); } Note the >= instead of >. In your case the byte array size was 400 and the classFileOffset was 800. So the resize checked wrongly (using >) that doubling the size was sufficient. So after the resize, the byte array size is 800 and the classFileOffset is still 800. So writing at index 800 in an array of 800 elements leads to the exception you got. By checking >=, we will then resize the byte array to 1200 and there is enough space to put what needs to be added. Let me know if you could patch it successfully. Next 3.1.2 build or integration/nightly build will contain the fix.
I see. What a difference ">=" makes. :-) Are debug attributes not generated when the build is done in batch mode? What's the option to turn this on and off?
I think this is an ant feature. In the script you send me, I can see: <property name="javacDebugInfo" value="on"/> And in the javac task, you have: debug="${javacDebugInfo}" But it seems that this is overriden when properties are passed on the command line. And your command line contains: -DjavacDebugInfo=off \ So no debug attributes are generated. By default in the workbench, line number attribute and source attribute are generated. This is configurable in the compiler preferences per project or for the whole workbench.
I understand now. I'll test the fix and update this bug shortly. Thanks for all your help, Olivier!
Fix verified with CDT 3.0.0 source.
Reopen to close as FIXED. We will verify it again prior to 3.2M4. Thanks for annotating it.
Fixed.
Verified for 3.2 M4 using build I20051212-0010
Reopen for 3.1.2 verification
We also need to verify that's this bug fix is in R3_1_maintenance stream as well before 3.1.2 delivery...
Verified for 3.1.2 using build M20060109-1200.
Verified for 3.1.2 using build M20060109-1200 (maxime)