src/share/classes/sun/invoke/util/Wrapper.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File jdk Sdiff src/share/classes/sun/invoke/util

src/share/classes/sun/invoke/util/Wrapper.java

Print this page
rev 9491 : 8037209: Improvements and cleanups to bytecode assembly for lambda forms
Reviewed-by: ?
Contributed-by: john.r.rose@oracle.com


 213         }
 214         return true;  // i.e., assert(true)
 215     }
 216 
 217     /** Produce a zero value for the given wrapper type.
 218      *  This will be a numeric zero for a number or character,
 219      *  false for a boolean, and null for a reference or void.
 220      *  The common thread is that this is what is contained
 221      *  in a default-initialized variable of the given primitive
 222      *  type.  (For void, it is what a reflective method returns
 223      *  instead of no value at all.)
 224      */
 225     public Object zero() { return zero; }
 226 
 227     /** Produce a zero value for the given wrapper type T.
 228      *  The optional argument must a type compatible with this wrapper.
 229      *  Equivalent to {@code this.cast(this.zero(), type)}.
 230      */
 231     public <T> T zero(Class<T> type) { return convert(zero, type); }
 232 
 233 //    /** Produce a wrapper for the given wrapper or primitive type. */
 234 //    public static Wrapper valueOf(Class<?> type) {
 235 //        if (isPrimitiveType(type))
 236 //            return forPrimitiveType(type);
 237 //        else
 238 //            return forWrapperType(type);
 239 //    }
 240 
 241     /** Return the wrapper that wraps values of the given type.
 242      *  The type may be {@code Object}, meaning the {@code OBJECT} wrapper.
 243      *  Otherwise, the type must be a primitive.
 244      *  @throws IllegalArgumentException for unexpected types
 245      */
 246     public static Wrapper forPrimitiveType(Class<?> type) {
 247         Wrapper w = findPrimitiveType(type);
 248         if (w != null)  return w;
 249         if (type.isPrimitive())
 250             throw new InternalError(); // redo hash function
 251         throw newIllegalArgumentException("not primitive: "+type);
 252     }
 253 
 254     static Wrapper findPrimitiveType(Class<?> type) {
 255         Wrapper w = FROM_PRIM[hashPrim(type)];
 256         if (w != null && w.primitiveType == type) {
 257             return w;
 258         }
 259         return null;
 260     }




 213         }
 214         return true;  // i.e., assert(true)
 215     }
 216 
 217     /** Produce a zero value for the given wrapper type.
 218      *  This will be a numeric zero for a number or character,
 219      *  false for a boolean, and null for a reference or void.
 220      *  The common thread is that this is what is contained
 221      *  in a default-initialized variable of the given primitive
 222      *  type.  (For void, it is what a reflective method returns
 223      *  instead of no value at all.)
 224      */
 225     public Object zero() { return zero; }
 226 
 227     /** Produce a zero value for the given wrapper type T.
 228      *  The optional argument must a type compatible with this wrapper.
 229      *  Equivalent to {@code this.cast(this.zero(), type)}.
 230      */
 231     public <T> T zero(Class<T> type) { return convert(zero, type); }
 232 








 233     /** Return the wrapper that wraps values of the given type.
 234      *  The type may be {@code Object}, meaning the {@code OBJECT} wrapper.
 235      *  Otherwise, the type must be a primitive.
 236      *  @throws IllegalArgumentException for unexpected types
 237      */
 238     public static Wrapper forPrimitiveType(Class<?> type) {
 239         Wrapper w = findPrimitiveType(type);
 240         if (w != null)  return w;
 241         if (type.isPrimitive())
 242             throw new InternalError(); // redo hash function
 243         throw newIllegalArgumentException("not primitive: "+type);
 244     }
 245 
 246     static Wrapper findPrimitiveType(Class<?> type) {
 247         Wrapper w = FROM_PRIM[hashPrim(type)];
 248         if (w != null && w.primitiveType == type) {
 249             return w;
 250         }
 251         return null;
 252     }


src/share/classes/sun/invoke/util/Wrapper.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File