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
Fix For: 2.10.0
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]