I'm stuck at an issue that maybe someone on the list can help
The nice thing about the Type class is that I can hand it a "Class"
object and get back the appropriate type.
public static getType(Class cls)...
I need to keep generic-ness in my application (which is a small BCEL
taglibrary for Jelly to manipulate Beans). This means I have something like
*
<bcel:property name="foo" type="java.lang.String" ...>
*
so I'm passing around String representations of Classes to methods like
*
public void addProperty(String name, String type,...){
Type propType = Type.getType(Class.forName(type));
...
*
which works great for regular Classes, unfortunately it doesn't work for
primitive types. Calls like:
*
Class.forName("int")
*
just don't work, which is frustrating because for the reciprical case:
*
java.lang.Object.class.toString() returns "java.lang.Object"
java.lang.Object.getClass().getName() returns "java.lang.Object"
Class.forName("java.lang.Object").toString() returns "java.lang.Object"
*
while
*
int.class.toString() returns "int"
int.getClass().getName() returns "int"
*
but
*
Class.forName("int").toString()
*
fails with a ClassNotFoundException.
This is something that sucks about primitive type names in the Java API.
My question, is there a simple way in BCEL to get around this issue, I
could require the type parameter of my method to require a signature,
but that is hard for users (who don't know what they are) to use my
tools, I'd rather be able to just capture the Class object for any
String representation of a primitive type ("int", "double", "byte" ...)
and do it simply and elegantly.
Thanks for any comments,
Mark
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
- How to get instance of my new Class. Mark R. Diggory
- Re: How to get instance of my new Class. Juozas Baliuka
- Re: How to get instance of my new Class. Andreas Schlapbach
- Re: How to get instance of my new Class. Mark R. Diggory
- Re: How to get instance of my new Class. Juozas Baliuka
- Re: How to get instance of my new Clas... Mark R. Diggory
- Which version of regexp is sugges... Mark R. Diggory
- Re: [OT - sort of] Primitives... Mark R. Diggory
- Re: [OT - sort of] Primit... Huw Evans
- Re: [OT - sort of] Primit... Mark R. Diggory
- Re: [OT - sort of] Primit... Juozas Baliuka
