Re: New Reflection/Beans API
Markus Dahm <[email protected]>
| Newsgroups | gmane.comp.jakarta.bcel.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
> Also, is there a convenient method to create a Type object from a Class
> object?
Yes, now there is. Please tell me if I missed something.
/* That's an amzingly easy case, because getName() returns
* the signature. That's what we would have liked anyway.
*/
if(cl.isArray()) {
return getType(cl.getName());
} else if(cl.isPrimitive()) {
if(cl == Integer.TYPE) {
return INT;
} else if(cl == Void.TYPE) {
return VOID;
} else if(cl == Double.TYPE) {
return DOUBLE;
} else if(cl == Float.TYPE) {
return FLOAT;
} else if(cl == Boolean.TYPE) {
return BOOLEAN;
} else if(cl == Byte.TYPE) {
return BYTE;
} else if(cl == Short.TYPE) {
return SHORT;
} else if(cl == Byte.TYPE) {
return BYTE;
} else if(cl == Long.TYPE) {
return LONG;
} else if(cl == Character.TYPE) {
return CHAR;
} else {
throw new IllegalStateException("Ooops, what primitive type is " + cl);
}
} else { // "Real" class
return new ObjectType(cl.getName());
}
}