intersection type confusion (or javac or JLS error?)

I am confused about what methods are available for a type parameter with multiple bounds.

Consider the slightly modified version of the jls [url http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#120149]discussion [/url] on type variables:

package TypeVarMembers;

class C{

void mCDefault(){}

publicvoid mCPublic(){}

privatevoid mCPrivate(){}

protectedvoid mCProtected(){}

}

abstractclass CTextends Cimplements I{}

interface I{

void mI();

}

class X

{

<Textends C & I>void test(T t, CT ct){

t.mI();// OK

t.mCDefault();// OK

t.mCPublic();// OK

t.mCPrivate();// compile-time error

t.mCProtected();// OK

ct.mCDefault();

}

}

The modification are declaring CT abstract, putting the method test inside the class X and adding parameter of type CT to test.

When I try to compile this I get error

$ javac -g Intersection.java

Intersection.java:20: cannot find symbol

symbol: method mCDefault()

t.mCDefault(); // OK

Note that I do not get the error for similar call to CT.

Is this something I have misunderstood?

Thanks in advance for your time and responses.

[2534 byte] By [hemalpandyaa] at [2007-11-26 17:52:47]
# 1

I found [url http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5073060]bug 5073060[/url], Package private members not found for intersection types which is the issue I was confused about.

Thankfully, I seem to have understood the spec correctly. The fix won't be available till Jaguar but at least I found a work-around.

Sorry to bother you all without looking first, but it was only because I felt it was probably my lack of understanding rather then compiler bug.

hemalpandyaa at 2007-7-9 5:05:44 > top of Java-index,Core,Core APIs...