Community
Participate
Working Groups
When using a text file encoding, which increases the byte length of Java input file, compiler reports errors like 'Syntax error, insert "}" to complete ClassBody', but the file in editor looks good and is syntactically and semantically correct. Reproducing the error: Encoding example which causes this error you can find at http://www.vortoj.com/sjpp/readme.html This is a preprocessor which 'abuses' the encodimg mechanism of Java to provide a transparent preprocessing of #ifdef/#ifndef directives in a Java file by adding a special line comment, e.g. //!!! to preprocessor directives and removed source code during the decoding of Java file and removing these comment lines during encoding of file. Analysis: Problem is caused in file org/eclipse/jdt/internal/core/util/Util.java line 1061 by calling method org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsCharArray(InputStream stream, int length, String encoding) with parameter length is length of file to read. If method getInputStreamAsCharArray is called with length value != -1 it returns a buffer of the given length independent of the data size after encoding. If encoding adds bytes, the end of file does not fit into the buffer and is skipped. This leads to compiler errors since file is read incomplete. If line 1061 is changed to return org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsCharArray(stream, -1, encoding); everything works fine. Old version of this file in eclipse version 3.1.1 was implemented that way. Conclusion: I think this is a bug, since it is not possible to limit the length of data to read, when an encoding might increase length of read data compared to length of file. Perhaps it is neccessary to check other parts of the eclipse sources for similar problems. If you have any questions please send me a mail.
This bug was mis-filed and never redirected to the correct component.
*** This bug has been marked as a duplicate of bug 149028 ***
Verified during 3.5M2 milestone verification process...