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();
        method(s);

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


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. .text alignment problem

hi, everybody.

i made a simple C program.

it use signal.
but, it does not work in my modified kernel.

I think the problem is byte aligned.

Android system binary is aligned  odd( address& 0x01 == 1).

ex)
#strace dalvikvm
..
..
sigaction(SIGILL, {0xb0001a99, [], SA_RESTART}, {SIG_DFL}, 0) = 0
sigaction(SIGABRT, {0xb0001a99, [], SA_RESTART}, {SIG_DFL}, 0) = 0
sigaction(SIGBUS, {0xb0001a99, [], SA_RESTART}, {SIG_DFL}, 0) = 0
sigaction(SIGFPE, {0xb0001a99, [], SA_RESTART}, {SIG_DFL}, 0) = 0
sigaction(SIGSEGV, {0xb0001a99, [], SA_RESTART}, {SIG_DFL}, 0) = 0
sigaction(SIGSTKFLT, {0xb0001a99, [], SA_RESTART}, {SIG_DFL}, 0) = 0
sigaction(SIGPIPE, {0xb0001a99, [], SA_RESTART}, {SIG_DFL}, 0) = 0
..
..
signal handler address is odd.

so, it cause alignment trap

how can i fix it?


--~--~---------~--~----~------------~-------~--~----~
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

2. ImageView 's layout_width and layout_height

Hi,

I have created a ImageView

    BitmapDrawable bitmapDrawalbe = new BitmapDrawable();

        ImageView imageView = new ImageView(this);
        imageView.setBackgroundDrawable(bitmapDrawalbe);


where BitmapDrawable has an attribute of 'Bitmap' and its getWidth and
getHeight are:
   public int getMinimumWidth() {
        return mBitmap.getWidth();
    }

    public int getMinimumHeight() {
        return mBitmap.getHeight();
    }

But when I load my application in HierarchyView, the layout_width is
80 and layout_height is 100, but my Bitmap i put in BitmapDrawable is
96 (width) and 144 (height).
Do I need to set the height/width specifically for my ImageView to
match my backgroundDrawable? Or it will pick up automatically.

Thank you.

--~--~---------~--~----~------------~-------~--~----~

3. ScrollView and Programmatically Scrolling

4. how to develop Android app?

5. How to display text and picture in a line?

6. Is there a way to navigate android SDK documentation online for multiple releases??

7. issue in emulator compare to HTC Dream