Bug 217443 - Documentation for JavaCore#CORE_ENCODING does not match the observed behavior
Summary: Documentation for JavaCore#CORE_ENCODING does not match the observed behavior
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.6 M1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-01 09:37 EST by Maxime Daniel CLA
Modified: 2009-08-04 07:16 EDT (History)
3 users (show)

See Also:


Attachments
Proposed fix + regression test (3.92 KB, patch)
2009-07-21 16:24 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Maxime Daniel CLA 2008-02-01 09:37:15 EST
3.4 M5

The following test case, which I suggest we add to OptionTests, fails on the second assertion:

public void test13_immutable_option() {
	Hashtable options = JavaCore.getDefaultOptions();
	String immutableValue = (String) options.get(JavaCore.CORE_ENCODING);
	assertEquals(ResourcesPlugin.getEncoding(), immutableValue); // ok
	options.put(JavaCore.CORE_ENCODING, immutableValue + "_extra_tail");
	JavaCore.setOptions(options);
	assertEquals(immutableValue, JavaCore.getOptions().get(JavaCore.CORE_ENCODING)); // ko
}

I cannot really relate the 'immutable' term in the javadoc to the observed behavior. I would suggest that the doc be explained further (what do we mean by immutable?) and that the behavior be fixed (while modifying the map in client code is unavoidable and OK anyway, JavaCore.getOptions().get(JavaCore.CORE_ENCODING) should always return the same value as ResourcesPlugin.getEncoding()).
Comment 1 Olivier Thomann CLA 2009-07-21 16:06:26 EDT
If the user modifies the value, then it cannot expect it to be equal to the ResourcesPlugin.getEncoding() value.
Closing as INVALID.
Please reopen if you disagree.
Comment 2 Olivier Thomann CLA 2009-07-21 16:07:36 EDT
Sorry. Reopen.
The value of this option should not be changed.
Comment 3 Olivier Thomann CLA 2009-07-21 16:19:59 EDT
The problem comes from the cached value set in the JavaModelManager.setOptions(HashTable) call.

CORE_ENCODING option is properly skipped, but the value of the given table is not reset for this key.
Comment 4 Olivier Thomann CLA 2009-07-21 16:24:54 EDT
Created attachment 142181 [details]
Proposed fix + regression test
Comment 5 Olivier Thomann CLA 2009-07-21 16:25:27 EDT
Released for 3.6M1.
Regression test added in org.eclipse.jdt.core.tests.model.OptionTests#test13
Comment 6 Jay Arthanareeswaran CLA 2009-08-04 06:00:37 EDT
Verified for 3.6M1 by code inspection and regression test verification.