Wednesday, September 7, 2011

Evil call to Character.getNumericValue(char)

In the Eclipse compiler, to detect a valid unicode, we call the method:
Character.getNumericValue(char) and we check that the returned value is between 0 and 15 to validate that only character between 0..F are allowed (see the JLS)
This was a mistake. Some characters can have a numeric value between 0 and 15 and they would not belong to the character between 0..F (including lowercase letters).
This bug report which shows why this was wrong was opened this week.

Here is a screenshot that shows the bogus code:

The fix is trivial, but it is surprising that this has never been found before. 10 years with that bug!

Enough for today.... back to work!

No comments: