bug-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug classpath/35482] regression: apache-tomcat-5.5.26 throws NPE with 0


From: gnu_andrew at member dot fsf dot org
Subject: [Bug classpath/35482] regression: apache-tomcat-5.5.26 throws NPE with 0.97
Date: 6 May 2008 01:52:28 -0000


------- Comment #3 from gnu_andrew at member dot fsf dot org  2008-05-06 01:52 
-------
After hours of chasing, I've found it's nothing to do with JMX at all or our
implementation.  The bug arises from Ian's change to String.toLowerCase(),
which now eats characters when they begin with lowercase letters.  Thus, the
lowercase variants of the descriptor keys become broken.

       int i = count;
        int x = offset - 1;
        while (--i >= 0)
          {
            char ch = value[++x];
            if (ch != Character.toLowerCase(ch))
              break;
          }
        if (i < 0)
          return this;

        // Now we perform the conversion. Fortunately, there are no
        // multi-character lowercase expansions in Unicode 3.0.0.
        //char[] newStr = (char[]) value.clone();
        char[] newStr = new char[count];
        VMSystem.arraycopy(value, offset, newStr, 0, count - (x - offset));
        do
          {
            char ch = value[x];
            // Hardcoded special case.
            newStr[x - offset] = Character.toLowerCase(ch);
            x++;
            //newStr[x++] = Character.toLowerCase(ch);
          }
        while (--i >= 0);
        // Package constructor avoids an array copy.
        return new String(newStr, 0, count, true);
        //return new String(newStr, offset, count, true);

The lowerCase algorithm above calculates a value of x which will differ
depending on how many lowercase letters are at the start of the string.
The upperCase algorithm works differently, taking account of larger lowercase
letters and doesn't optimise by only uppercasing non-uppercased starting
letters.  Thus it doesn't seem to suffer from this bug.

A string which starts with an uppercase letter will lowercase fine, because the
offset, x, will be 0 (the while loop immediately fails, incrementing x just
once).  However a string like 'descriptorType' (which is the lookup that fails
in this bug) becomes 'desctype' instead.

I'll attach a testcase that demonstrates this.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35482





reply via email to

[Prev in Thread] Current Thread [Next in Thread]