271 if (type.isPrimitive()) |
271 if (type.isPrimitive()) |
272 throw new InternalError(); // redo hash function |
272 throw new InternalError(); // redo hash function |
273 throw newIllegalArgumentException("not primitive: "+type); |
273 throw newIllegalArgumentException("not primitive: "+type); |
274 } |
274 } |
275 |
275 |
|
276 /** Return the wrapper that corresponds to the provided basic type char. |
|
277 * The basic type char must be for one of the eight primitive types, or void. |
|
278 * @throws IllegalArgumentException for unexpected types |
|
279 */ |
|
280 public static Wrapper forPrimitiveType(char basicTypeChar) { |
|
281 switch (basicTypeChar) { |
|
282 case 'I': return INT; |
|
283 case 'J': return LONG; |
|
284 case 'S': return SHORT; |
|
285 case 'B': return BYTE; |
|
286 case 'C': return CHAR; |
|
287 case 'F': return FLOAT; |
|
288 case 'D': return DOUBLE; |
|
289 case 'Z': return BOOLEAN; |
|
290 case 'V': return VOID; |
|
291 default: throw newIllegalArgumentException("not primitive: " + basicTypeChar); |
|
292 } |
|
293 } |
|
294 |
276 static Wrapper findPrimitiveType(Class<?> type) { |
295 static Wrapper findPrimitiveType(Class<?> type) { |
277 Wrapper w = FROM_PRIM[hashPrim(type)]; |
296 Wrapper w = FROM_PRIM[hashPrim(type)]; |
278 if (w != null && w.primitiveType == type) { |
297 if (w != null && w.primitiveType == type) { |
279 return w; |
298 return w; |
280 } |
299 } |