Generic Signatures

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I can't get even simple tests with generic signatures to work.  Like
this:

public class test2
{
  static class A extends ArrayList<String> {};

  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]);
  }
}

should do this:

java.util.ArrayList<java.lang.String>
We have a list parametrized with: class java.lang.String

but does this:

Exception in thread "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:1232)
   at test2.main(test2.java:12)
Caused by: java.lang.ClassNotFoundException: java$util$ArrayList not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
   at java.net.URLClassLoader.findClass(URLClassLoader.java:1081)
   at gnu.gcj.runtime.SystemClassLoader.findClass(natSystemClassLoader.cc:27)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:317)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:260)
   at java.lang.Class.forName(natClass.cc:103)
   at gnu.java.lang.reflect.ParameterizedTypeImpl.resolve(GenericSignatureParser.java:123)
   ...4 more

Is it the case that this stuff hasn't ever worked?  I'll allow that we
have an older cut of the generics branch in gcj.

Thanks,
Andrew.


[Index of Archives]     [Linux Kernel]     [Linux Cryptography]     [Fedora]     [Fedora Directory]     [Red Hat Development]

  Powered by Linux