[jboss-dev-forums] [Design of POJO Server] - Re: Serialization, NoSuchMethodException in ProfileServiceUn
alesj
do-not-reply at jboss.com
Mon Dec 17 13:41:11 EST 2007
Yes.
This is when you are trying to transform runtime type instance - which is generics unaware.
If you did something like this:
| public class MyClass
| {
| public byte[] someBytes();
| }
|
And then (pseudo) MyClass.getMethod("someBytes").getGenericReturnType().
Then it would fail.
In this code
| public T get(Type type)
| {
| if (type == null)
| throw new IllegalArgumentException("Null type");
|
| if (type instanceof ParameterizedType)
| return getParameterizedType((ParameterizedType) type);
| else if (type instanceof Class)
| return getClass((Class<?>) type);
| else if (type instanceof TypeVariable)
| // TODO Figure out why we need this cast with the Sun compiler?
| return (T) getTypeVariable((TypeVariable) type);
| else if (type instanceof GenericArrayType)
| return getGenericArrayType((GenericArrayType) type);
| else if (type instanceof WildcardType)
| return getWildcardType((WildcardType) type);
| else
| throw new UnsupportedOperationException("Unknown type: " + type + " class=" + type.getClass());
| }
|
The first example is picked up by (instance of Class), where the 2nd one is by the method I mentioned before.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4113512#4113512
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4113512
More information about the jboss-dev-forums
mailing list