[ 
https://issues.apache.org/jira/browse/XERCESJ-1453?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12880683#action_12880683
 ] 

Michael Ernst commented on XERCESJ-1453:
----------------------------------------

I agree that a field whose value may change in the future shouldn't be made
public, final, and initialized to a compile-time constant.  The example you
gave isn't affected by my patch.  (It isn't initialized to a compile-time
constant, though it would be good for the source code to document why not.)
If there are any examples in my patch, they can be left as is and properly
documented, and the other changes can be applied.


> Remove extraneous intern() calls on String literals
> ---------------------------------------------------
>
>                 Key: XERCESJ-1453
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1453
>             Project: Xerces2-J
>          Issue Type: Improvement
>    Affects Versions: 2.10.0
>         Environment: All.
>            Reporter: Michael Ernst
>            Priority: Minor
>         Attachments: xerces-j-remove-unnecessary-interning.diff
>
>   Original Estimate: 0.08h
>  Remaining Estimate: 0.08h
>
> Xerces contains 159 unnecessary calls to String.intern(); for
> example,
>         private static final String fAndSymbol = "and".intern();
> should be
>         private static final String fAndSymbol = "and";
> These calls are unnecessary because the Java Language Specification,
> section 3.10.5, guarantees that every String literal in the program is
> already interned
> (http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.10.5).
> Therefore, the calls have no semantic effect and serve no positive purpose.
> However, they do have some negative consequences:
>  * They clutter the code.
>  * They are confusing to anyone who reads them and wonders why the
>    extraneous calls are being made.
>  * They may disable compiler optimizations (because the fields are not
>    initialized to a compile-time constant).
> Therefore, it would be best to remove the extraneous calls to intern().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to