This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: How to create an instance of a java class with type parameter
On 11/05/2010 06:27 PM, Santosh Rajan wrote:
I am trying to create an instance of a java class that requires a type
parameter. The compiler does not show an error.
Presumably, it treats it as an unknown variable. Try compiling
with --warn-undefined-variable --warn-unknown-member --warn-as-error
However I get an error at run time. Here is the code.
(android.widget.ArrayAdapter<String> (this)
android.R$layout:simple_list_item_1))
It treats is as the variable android.widget.ArrayAdapter<String>,
and then at runtime you get an "unbound location" exception, right?
I seem to be doing something wrong here. Is there a correct way to do it?
Kawa does not support parameterized types. Which is OK, since neither
does the JVM, nor (I presume) Dalvik.
Just write android.widget.ArrayAdapter .
(Adding support for parameterized types is on the wishlist, since it
would allow better type inference and better type checking. But other
items have higher priority ...)
--
--Per Bothner
per@bothner.com http://per.bothner.com/