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 "Nikola Sprljan (JIRA)" <xe...@xml.apache.org> on 2015/09/30 10:53:04 UTC

[jira] [Commented] (XERCESJ-1665) DTDGrammar.QNameHashtable.get(String key) compares by reference

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

Nikola Sprljan commented on XERCESJ-1665:
-----------------------------------------

Hi Michael, thanks for commenting.
I get this is done for performance reasons. However my point is (and probably the summary I used did not help to indicate that) that getElementDeclIndex(String elementDeclName) and related methods don't behave as expected (violating [POLA|http://c2.com/cgi/wiki?PrincipleOfLeastAstonishment]), forcing user to step through the code to discover interning is expected from the arguments of the method. Either this should be noted in the docs, or interning should be done in getElementDeclIndex() (where call to fElementIndexMap.get() happens).

> DTDGrammar.QNameHashtable.get(String key) compares by reference
> ---------------------------------------------------------------
>
>                 Key: XERCESJ-1665
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-1665
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: DTD
>            Reporter: Nikola Sprljan
>            Priority: Minor
>
> When key is matched with bucket the reference comparison is done:
> {noformat}
> if ((String)bucket[j] == key) {
> {noformat}
> This will work if a string literal is provided as a key, but not for any String object. As a consequence dtdGrammar.getElementDeclIndex(String s) does not work for String objects. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org