Need help with error message
Vicente-Arturo Romero-Zaldivar
vicente.romero at oracle.com
Mon Sep 9 06:43:27 PDT 2013
Hi Boaz,
The compiler is indicating that there are unchecked warnings in the
code, if you don't solve them and go on, then you can't expect the
compiler to do all the checking or figure out what the correct type
should be.
Here the code should be:
List<Integer> keys = new ArrayList<>(); or:
List<Integer> keys = new ArrayList<Integer>()
also lambda repo is not up to date anymore, you should use tl/langtools
instead.
Thanks,
Vicente
On 09/09/13 13:53, Boaz Nahum wrote:
> Build lambda/lambda repo today.
>
> The compiler error is strange
>
> public List<String> getList(List<Integer> keys) {
> return null;
> }
>
> MyData data = new MyData();
>
> //this is wrong, should be List<Integer>
> List keys = new ArrayList();
>
> String item= data.getList(keys).get(0);
>
> The error message is:
> java: incompatible types: java.lang.Object cannot be converted to
> java.lang.String
>
> But if I split it to:
> List<String> list = data.getList(keys);
> String item = list.get(0);
>
> then it compile fine.
>
> The error message remind smells like compiler treats getList as
> generic method.
>
> Thanks
> Boa
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20130909/a52f427f/attachment.html
More information about the compiler-dev
mailing list