You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org> on 2010/06/20 11:26:22 UTC

[jira] Commented: (XERCESJ-1453) Remove extraneous intern() calls on String literals

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

Michael Glavassevich commented on XERCESJ-1453:
-----------------------------------------------

> They may disable compiler optimizations (because the fields are not initialized to a compile-time constant).

Whlie it's probably not the case for most of these fields there are times when you don't want the compiler to make this optimization, for example a field whose value may change in the future or a field that is not really a universal constant like javax.xml.datatype.DatatypeFactory.DATATYPEFACTORY_IMPLEMENTATION_CLASS.

> 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: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org