Project

Profile

Help

NamePool

Added by Anonymous over 15 years ago

Legacy ID: #5474194 Legacy Poster: Ivan Latysh (ivanlatysh)

I just stepped on IndexOutOfBoundsException in NamePool.java, and when I had a look at the code I saw that namespace code is treated differently in the following methods. So code 1050303 throws an exception in getURIFromNamespaceCode but not in getPrefixFromNamespaceCode. 1050303 >> 16 = 16 but 1050303 & 0xffff = 1727 [code] public String getURIFromNamespaceCode(int code) { return uris[code & 0xffff]; } public String getPrefixFromNamespaceCode(int code) { return prefixes[code >> 16]; } [/code] My question is: Should both methods behave the same ?


Replies (1)

RE: NamePool - Added by Anonymous over 15 years ago

Legacy ID: #5474222 Legacy Poster: Michael Kay (mhkay)

For both methods the effect is undefined if you supply a value that is not a correct namespace code. That may include throwing an exception, returning an arbitrary result, or anything else.

    (1-1/1)

    Please register to reply