Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 475481 - Inconsistent IField#getConstant() for source and binary types
Summary: Inconsistent IField#getConstant() for source and binary types
Status: CLOSED DUPLICATE of bug 449244
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.5   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-20 09:02 EDT by Igor Fedorenko CLA
Modified: 2015-08-24 06:25 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Igor Fedorenko CLA 2015-08-20 09:02:33 EDT
Consider the following type


   interface I {
     String S = "stringValue";
   }


For field "S", IField#getConstant() returns "stringValue" (i.e. with quotes) when the type is source, and stringValue without quotes if I is a binary type. I expect the same value, regardless if the field is source or binary.
Comment 1 Jay Arthanareeswaran CLA 2015-08-24 02:27:46 EDT
Also see bug 449244, though that one requires lot more effort.

This has a much narrow scope and can be fixed without much effort. I prefer the constant _not_ to have the enclosing quotes.
Comment 2 Markus Keller CLA 2015-08-24 06:25:07 EDT
As said in bug 449244, it's not only about the double-quotes. The result of SourceField#getConstant() is currently the initializer source, which doesn't even have to start and end with a double-quote character:

    static final String CONST = "Hello\tWorld: \"" + 4 + '2';

Touching this will inevitably break existing clients, so we either leave it as is or provide a complete fix.

*** This bug has been marked as a duplicate of bug 449244 ***