Bug in sun.dyn.util.Wrapper.forWrapperType

Rémi Forax forax at univ-mlv.fr
Thu Aug 13 01:42:18 PDT 2009


I was playing with findbugs on jdk7
and it find a bug in sun.dyn.util.Wrapper

  /** Return the wrapper that wraps values into the given wrapper type.
      *  If it is {@code Object} or an interface, return {@code OBJECT}.
      *  Otherwise, it must be a wrapper type.
      *  The type must not be a primitive type.
      *  @throws IllegalArgumentException for unexpected types
      */
     public static Wrapper forWrapperType(Class<?> type) {
         Wrapper w = findWrapperType(type);
         if (w != null)  return w;
         for (Wrapper x : values())
             if (w.wrapperType == type)
                 throw new InternalError(); // redo hash function
         throw newIllegalArgumentException("not wrapper: "+type);
     }

here
if (w.wrapperType == type)
should be
if (x.wrapperType == type)

Rémi



More information about the mlvm-dev mailing list