This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
wildcards in parameterized types?
- From: Jamison Hope <jrh at theptrgroup dot com>
- To: Kawa mailing list <kawa at sourceware dot org>
- Date: Thu, 29 Sep 2011 22:21:50 -0400
- Subject: wildcards in parameterized types?
I've got a method that looks like this:
public void foo(Class<?> c) { ... }
which I call from Scheme like this:
(*obj*:foo
com.example.SomeClass)
and now (it's been a while since I recompiled this stuff, so
'now' probably means ever since Kawa started having generics
a few months ago) I'm seeing this spurious warning message:
[kawac] /path/to/usage.scm:94:2: warning - cannot convert literal
(of type java.lang.Class) to ClassType java.lang.Class<? extends
ClassType java.lang.Object>
Obviously the compiler is forgetting that java.lang.Object is
a superclass of every Java class and therefore my usage here
is necessarily safe.
In Java, if the parameter type were "Class<? extends U>",
I could suppress the warning by calling *.asSubclass(U.class).
But Kawa didn't like that, either:
[kawac] /path/to/usage.scm:95:17: warning - cannot convert
literal (of type java.lang.Class) to ClassType java.lang.Class<Type U>
The last I recall is that Kawa does not have syntax to express
wildcards. Is that still true? Is there any way to write an
invocation of foo(Class<?>) that won't trigger a warning?
Thanks,
Jamie
--
Jamison Hope
The PTR Group
www.theptrgroup.com