Re: java.lang.TypeNotPresentException when using reflection
Awesome, thanks a lot for this. I will give it a try when I get back to a computer next week and let you know how I get on! Tom On 16/08/2008, Robert Lougher [EMAIL PROTECTED] wrote: Hi, On Wed, Aug 13, 2008 at 6:20 PM, Tom Spencer [EMAIL PROTECTED] wrote: I have been attempting to use reflection, in particular to get the superclass of a particular class, but this seems to fail when using Classpath v0.97.2 with JamVM 1.5.0. I've investigated this and there's a bug in JamVMs handling of generic signatures (rather than returning the raw generic signature, slashes are replaced by dots, as in other class names; the dots are then converted to $). This is fixed in CVS HEAD. Instructions for checking it out can be found here: http://developer.berlios.de/cvs/?group_id=6545 Alternatively, apply the attached patch to natives.c. This has been generated against JamVM 1.5.0. I have found the following older forum posts, but neither have been that helpful in trying to diagnose the issue. http://developer.classpath.org/pipermail/classpath/2006-November/001605.html http://www.nabble.com/Error-in-resolving-java.util.Set-td9779444.html No idea how I missed these (especially the second post)! Let me know how you get on. Thanks, Rob. Thanks! Tom -- Sent from my mobile device ___ Tom Spencer Isca Networks Corporation Limited Tel: +44 (0) 870 909 7813 http://www.iscanetworks.com
java.lang.TypeNotPresentException when using reflection
I have been attempting to use reflection, in particular to get the superclass of a particular class, but this seems to fail when using Classpath v0.97.2 with JamVM 1.5.0. In a stripped down version of what I am trying to achieve, I am attempting to run the following code, which I have unceremoniously poached from http://developer.classpath.org/pipermail/classpath/2006-November/001605.html: public class Main { static class A extends ArrayListString {}; public static void main(String[] args) { A a = new A(); Object x = a; ((Collection)x).add(new Byte((byte) 1)); System.out.println(x.getClass().getGenericSuperclass()); System.out.println(We have a list parametrized with: + ((ParameterizedType)x.getClass().getGenericSuperclass()).getActualTypeArguments()[0]); } } This code is compiled using the Eclipse Compiler and run on a PowerPC implementation. Classpath was compiled using Sun's javac compiler, version 1.6. Running the code, however, yields the following stack trace: # jamvm -Xbootclasspath:/share/jamvm/classes:/usr/local/classpath/share/classpath Main java.lang.TypeNotPresentException: type java$util$ArrayList not found at gnu.java.lang.reflect.ParameterizedTypeImpl.resolve(GenericSignatureParser.java:127) at gnu.java.lang.reflect.TypeImpl.resolve(TypeImpl.java:59) at gnu.java.lang.reflect.ClassSignatureParser.getSuperclassType(ClassSignatureParser.java:83) at java.lang.Class.getGenericSuperclass(Class.java:1712) at Main.main(Main.java:16) Caused by: java.lang.ClassNotFoundException: java$util$ArrayList at java.lang.VMClass.forName(Native Method) at java.lang.Class.forName(Class.java:233) at gnu.java.lang.reflect.ParameterizedTypeImpl.resolve(GenericSignatureParser.java:123) ...4 more It seems to me that the refelction doesn't seem to be finding the type correctly. Does anybody have any insight as to why this might be? I have found the following older forum posts, but neither have been that helpful in trying to diagnose the issue. http://developer.classpath.org/pipermail/classpath/2006-November/001605.html http://www.nabble.com/Error-in-resolving-java.util.Set-td9779444.html Thanks! Tom
Re: java.lang.TypeNotPresentException when using reflection
On Wed, 2008-08-13 at 18:20 +0100, Tom Spencer wrote: This code is compiled using the Eclipse Compiler and run on a PowerPC implementation. Classpath was compiled using Sun's javac compiler, version 1.6. Running the code, however, yields the following stack trace: When I run this code with current CVS of GNU Classpath I get: $ cacao Main java.util.ArrayListjava.lang.String We have a list parametrized with: class java.lang.String Maybe try to update GNU Classpath? - twisti
Re: java.lang.TypeNotPresentException when using reflection
Hi, On Wed, Aug 13, 2008 at 6:20 PM, Tom Spencer [EMAIL PROTECTED] wrote: I have been attempting to use reflection, in particular to get the superclass of a particular class, but this seems to fail when using Classpath v0.97.2 with JamVM 1.5.0. I've investigated this and there's a bug in JamVMs handling of generic signatures (rather than returning the raw generic signature, slashes are replaced by dots, as in other class names; the dots are then converted to $). This is fixed in CVS HEAD. Instructions for checking it out can be found here: http://developer.berlios.de/cvs/?group_id=6545 Alternatively, apply the attached patch to natives.c. This has been generated against JamVM 1.5.0. I have found the following older forum posts, but neither have been that helpful in trying to diagnose the issue. http://developer.classpath.org/pipermail/classpath/2006-November/001605.html http://www.nabble.com/Error-in-resolving-java.util.Set-td9779444.html No idea how I missed these (especially the second post)! Let me know how you get on. Thanks, Rob. Thanks! Tom natives.c-patch Description: Binary data