code: static Object castWrapper(
          Class<?> toType, Object value )
      {
          value = Primitive.unwrap(value);
          if ( !(Primitive.isWrapperType(toType) || toType.isPrimitive()) )
              throw new InterpreterError("invalid type in castWrapper: "+toType);
          if ( value == null )
              throw new InterpreterError("null value in castWrapper, guard");
          if ( value instanceof Boolean )
          {
              if ( toType != Boolean.TYPE )
                  throw new InterpreterError("bad wrapper cast of boolean");
              return value;
          }
  
          // first promote char to Number type to avoid duplicating code
          if ( value instanceof Character )
              value = Integer.valueOf(((Character)value).charValue());
  
          if ( !(value instanceof Number) )
              throw new InterpreterError("bad type in cast "+StringUtil.typeValueString(value));
  
          return castNumber(toType, (Number) value);
      }
docs: Cast a primitive value represented by its java.lang wrapper type to the
  specified java.lang wrapper type.  e.g.  Byte(5) to Integer(5) or
  Integer(5) to Byte(5)
  @param toType is the java TYPE type
  @param value is the value in java.lang wrapper.
  value may not be null.