Bug 217443

Summary: Documentation for JavaCore#CORE_ENCODING does not match the observed behavior
Product: [Eclipse Project] JDT Reporter: Maxime Daniel <maxime_daniel>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jarthana, Olivier_Thomann, srikanth_sankaran
Version: 3.4   
Target Milestone: 3.6 M1   
Hardware: PC   
OS: All   
Whiteboard:
Attachments:
Description Flags
Proposed fix + regression test none

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.