Community
Participate
Working Groups
Dear Bugteam! The Eclipse Java Compiler (Eclipse 3.0.2) accepts string constants which UTF-8 representation exceeds 64kB. Since Sun's Class File specification (see http://java.sun.com/docs/books/vmspec/html/ClassFile.doc.html) defines a CONSTANT_Utf8_info structure with a length attribute of 2 byte unsigned, string constants with utf8-representation larger 65535 Bytes should not be possible. Suns Java Compiler (JDK 1.4.2_07 in my case) causes a compilation error, Eclipse compiler does not. Although the Eclipse compiled java class seems as if it works correctly, it is unclear if this behaviour is always correct. How to reproduce: Simply define a main class and assign a very large string constant (> 64kb) to a string object. regards Martin Purkert Martin.Purkert@bawagpsk.com
To be sure that we do reproduce the problem you noticed, could you please provide a test case that fails with javac, but works with Eclipse's compiler? As soon as I get it, I will investigate. Thanks.
Reproduced. I am investigating.
The Eclipse compiler is splitting the long string into smaller pieces. Then we concatenate all the pieces and at the end we call the intern() method. I don't know if this is illegal to do that. As long as we generate valid bytecodes and we respect the fact that CONSTANT == CONSTANT returns true, where CONSTANT is the long string. Do you have an example in the JLS that states this is wrong? Let me know. I would be very interested to clarify this issue. For now I am closing as INVALID since I didn't find anything against the way we treat long strings. Don't hesitate to reopen if you believe this is wrong. Thanks for your bug report.
Added regression test org.eclipse.jdt.core.tests.compiler.regression.XLargeTest.test009