Java Guru needed -- compiler bug?

by Zsolt Vasvari » Fri, 20 May 2011 16:50:55 GMT

Sponsored Links
 private void method(Collection<String> s)
        // Nothing

    private void caller()
       // Complies fine
        Collection<String> s = Collections.emptyList();

       // Doesn't compile -- gives error message
       // The method method(Collection<String>) in the type Import is
not applicable for the arguments
       //  (List<Object>)

What's going on here?   The two statements look identical to me...


Re: Java Guru needed -- compiler bug?

by Nikolay Elenkov » Fri, 20 May 2011 16:57:01 GMT


I'm not going to pretend to be a guru, but here goes :)

It's a generic method:

public static final <T> List<T> emptyList()

In the second call there is no way to determine the type of the generic
parameter, so you get a list of Object.


Sponsored Links

Other Threads

1. How to open new sub activity by item of ListView......

I want to set SubActivity on the item of ListView.please guide me how
i do it...i am new in android......


2. HessianProxyFactory Problem

While importing external hessian to replace webservice, I have
application crashes if I use the library from
anyone encountered error if code below wrote


HessianProxyFactory factor = new HessianFactoryProxy();

 WARN/dalvikvm(196): Link of class 'Lcom/caucho/hessian/client/
HessianProxyFactory;' failed

WARN/dalvikvm(196): VFY: unable to resolve new-instance 76 (Lcom/
caucho/hessian/client/HessianProxyFactory;) in Lcom/android/vaka/ui/

 WARN/dalvikvm(196): VFY:  rejecting opcode 0x22 at 0x001c


3. ADT - Eclipse

4. Seek Bar Problem

5. Cool Apps for weddings

6. Utterly confounded trying to create horizontal scrolling

7. Ordering the European version of the dev phone in the US?