Community
Participate
Working Groups
Reporter: Gao Yin Yin Language: Simplfied Chinese Build driver: eclipse-sourceBuild-srcIncluded-3.0M9 JDK Version: IBM J2SDK 1.4.1 Severity: 1 Summary: DBCS – The GB18030 character cannot be correctly generated into “.classpath” file when new a source folder named with GB18030 character. Steps to recreate problem: 1. Start up "New Source Folder" wizard; 2. Set the new folder's name contain GB18030 character, for example “newfolder\u3400”; 3. Click "Finish", new folder infor cannot be generated into '${PROJECT_BASE}/.classpath' file as "<classpathentry kind="..." path="..."/>" correctly. The GB18030 character is encoded in error; 4. Delete this source folder from the project, '${PROJECT_BASE}/.classpath' can't be updated correspondingly. <<Error>> The GB18030 character cannot be correctly generated into “.classpath” file when new a source folder named with GB18030 character. <<Expected Result>> The GB18030 character can be correctly generated into “.classpath” file when new a source folder named with GB18030 character. <<Cause>> Eclipse maintains “.classpath” file for each project using UTF8 encoding. When new a source folder, Eclipse insert a new "<classpathentry>" element into the “.classpath” file using system's default encoding. So error occurs when the system's default encoing is not UTF8. <<Solution>> Modify “getSharedProperty” and “setSharedProperty” methods in JavaProject.java. Keep the encoding being UTF8 during reading and writing “.classpath” file.
Created attachment 13348 [details] Modified source file with diff
May consider for 3.0.1, will mark it as such for now.
Assuming that on a chinese platform the correct encoding is set for the workspace, shouldn't the workspace encoding be used instead of hardcoding "UTF- 8" ?
In my chinese platform, the encoding of the workplace is set as "gb18030". ".classpath" is a XML file and eclipse creates and maintains it with "utf8" encoding. When new a source folder, Eclipse insert a "<classpathentry>" element into the “.classpath” file using system's default encoding, that's "gb18030" in my system. So error occurs.
Thanks. So we would use the .classpath encoding and not the workspace encoding. I want to avoid hardcoding "UTF-8".
Actually hardcoding "UTF-8" is fine as this encoding is always used to encode the .classpath.
Changed JavaProject#getSharedProperty(...) and setSharedProperty(...) (as proposed in the attached patch) to use an UTF-8 encoding when reading/writing the .classpath. Added regression test ClasspathTests#testEncoding(). Release to both R3_0_maintenance and HEAD.
Verified for 3.0.1 RC1