Bug 290741 - Workspace encoding is ignored
Summary: Workspace encoding is ignored
Status: RESOLVED FIXED
Alias: None
Product: AJDT
Classification: Tools
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal with 2 votes (vote)
Target Milestone: 2.1.3   Edit
Assignee: AJDT-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 254557 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-09-28 15:39 EDT by Oliver CLA
Modified: 2011-04-04 19:25 EDT (History)
5 users (show)

See Also:


Attachments
Java project with UTF-8 encoding (1.87 KB, application/zip)
2009-09-28 15:40 EDT, Oliver CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver CLA 2009-09-28 15:39:07 EDT
User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3
Build Identifier: M20090917-0800

I have a workspace with UTF-8 as default encoding. And I have a normal Java project which some string constants using this encoding. When I start the JUnit tests which rely on the correct encoding they are green. But when I convert the project into an AspectJ project and start the JUnit tests again, they fail.

Could it be that the AspectJ compiler ignores the encoding settings in the workspace? With Linux this problem does not appear but there the OS enviroment uses UTF-8 as default encoding.

Reproducible: Always

Steps to Reproduce:
1. Switch the text file encoding in the preferences to "UTF-8" (General > Workspace > Text file encoding)
2. Import the attached Java project
3. Start the JUnit tests (should be ok)
4. Convert to AspectJ Project
5. Start the JUnit tests again (now one test will fail)
Comment 1 Oliver CLA 2009-09-28 15:40:56 EDT
Created attachment 148271 [details]
Java project with UTF-8 encoding

it was originally created under Linux and imported under MacOS-X
Comment 2 Andrew Eisenberg CLA 2009-09-30 14:29:35 EDT
*** Bug 254557 has been marked as a duplicate of this bug. ***
Comment 3 Andrew Eisenberg CLA 2009-09-30 14:37:50 EDT
Move to the 2.0.2 release.
Comment 4 Andrew Eisenberg CLA 2010-04-28 19:25:46 EDT
Try to solve for 2.1.0.
Comment 5 Andrew Eisenberg CLA 2010-06-16 18:12:13 EDT
Determining what will be tackled for 2.1.1 release.
Comment 6 Kaj Hejer CLA 2010-12-21 02:56:44 EST
I can reproduce this issue with AJDT 2.1.2.e36x-20101113-1400, eclipse 3.6.1 and MacOS X 10.6.5. This issue cause some of our unittests to fail when running them in eclipse.

Is there any hope to get this issue fixed in the 2.1.2 release?
Comment 7 Andrew Eisenberg CLA 2011-04-04 14:04:16 EDT
Didn't make the 2.1.2 release, but taking a real look now as more users have been hitting this.

If we are to properly support encodings specified by the eclipse workspace there are several things we need to do.

It is possible to specify a workspace-wide encoding and it is also possible to set encodings on a per-resource basis.  This is stored in the project settings.  AJC does not have any concept of the eclipse workspace, so it would need to use a callback into AJDT to get the encodings of all files.

There are two ways I can see implementing this:

1. before each build, AJC asks AJDT for the default encoding as well as all resources that do not use the default encoding.  The benefit of this is that it will likely be more efficient since there is only one callback per project rather than callbacks for each file (especially when most files use the default encoding).

2. Callback for each file when AJC is about to read the file.  The benefit here is that it is much simpler to implement.

I'll go have a peek at how JDT does this and see if it makes sense for us to do something similar.
Comment 8 Andrew Eisenberg CLA 2011-04-04 14:15:21 EDT
Another reasonable possibility is to simply ignore all but the default project encoding.  Ie- AJDT passes to AJC the project's encoding only (or the workspace's if the project uses the default encoding).  

This would obviously mean that users can't specify individual encodings for files, but I think that's a reasonable restriction.
Comment 9 Andrew Clement CLA 2011-04-04 14:44:23 EDT
I extended the ICompilerConfiguration to support passing encoding across. Used Olivers test program to check it works.  Committed that into AJDT for 3.6 and 3.7.  It does not handle per-file encoding.
Comment 10 Andrew Eisenberg CLA 2011-04-04 19:25:53 EDT
Committed appropriate fixes into AJDT.  Test project now passes.  Issue is now fixed.