Community
Participate
Working Groups
The JavaDoc of javax.lang.model.util.Elements.getConstantExpression(Object) says that the text returned should be "in a form suitable for representing the value in source code". For strings, one would assume that would include escaping relevant characters -- e.g. "'\ and control characters. The javac implementation does the quoting correctly. The Eclipse implementation in ElementImpl does not. https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/tree/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/ElementsImpl.java } else if (value instanceof String) { StringBuilder builder = new StringBuilder(); builder.append('\"').append(value).append('\"'); return String.valueOf(builder); } I believe that the javac implementation is correct according to the specification. I can attach a patch if it's useful.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.
Well, this is sad that we didn't respond to this sooner. @Mathew, if the bug is still relevant and offer to fix is available, I can take a look at the patch.