Bug 241710 - [1.5][compiler] Generics handling differs from Sun/Apple javac1.6
Summary: [1.5][compiler] Generics handling differs from Sun/Apple javac1.6
Status: VERIFIED DUPLICATE of bug 142897
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2.2   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 3.5 M2   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-22 13:10 EDT by Julia Smith CLA
Modified: 2008-09-16 07:57 EDT (History)
3 users (show)

See Also:


Attachments
The project tar that I tried to attach in the original. (20.00 KB, application/x-tar)
2008-07-22 13:13 EDT, Julia Smith CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Julia Smith CLA 2008-07-22 13:10:28 EDT
Build ID: M20080221-1800 (Why oh why do I need to add the Eclipse version if the Build Id is supplied -- this is a GUI blooper: making a user fill information already determinable. It's like having to fill out ZIP code _and_ state address information).

Note this bug probably needs to go to JDT:Core, but the wizard doesn't make that easy or apparent.

Steps To Reproduce:

1) see attached project tar file.

2) Load up project. Compile project. Everything is fine.

3) Set up for java1.6 from Apple. Perform "ant clean; ant" and observe the compiler error.

4) Determine if Sun/Apple has a bug or conform Eclipse to java1.6 spec. This bug probably plagues 1.5 as well.




More information:
Comment 1 Julia Smith CLA 2008-07-22 13:13:10 EDT
Created attachment 108098 [details]
The project tar that I tried to attach in the original.

Attaching tar files seems to be problematic, the original post failed to attach the tar file. Additionally, using the BACK button to correct errors loses information in form to used to attach files (such as the tar file I am trying to attach). :/ GOOIE Blooper.
Comment 2 Remy Suen CLA 2008-07-22 16:40:18 EDT
(In reply to comment #0)
> Build ID: M20080221-1800 (Why oh why do I need to add the Eclipse version if
> the Build Id is supplied -- this is a GUI blooper: making a user fill
> information already determinable. It's like having to fill out ZIP code _and_
> state address information).

The version field is not always sufficient actually. If a user uses a weekly build or something, then that build is not going to be a match for the entries that's in the version field. And by the way, you've set the version field as 3.2.2 but the build id you have (presumably) copy/pasted is actually the build id for the 3.3.2 build. :)

Anyway, I seem to be able to reproduce this using Sun's 1.6.0.05 JDK on Linux. This is my output from Ant (although I modified the build file a little).

    [javac] Compiling 1 source file to /home/rcjsuen/eclipse-workspace/GenericsTestCase/build
    [javac] /home/rcjsuen/eclipse-workspace/GenericsTestCase/src/SubClassOfGeneric.java:18: cannot select from a type variable
    [javac]             V.MyInnerClass foo = m_test.getMyInnerClass();
    [javac]              ^
    [javac] 1 error

This is how it looks from a straight command-line JDK 6 javac invocation.

rcjsuen@ivalice ~/eclipse-workspace/GenericsTestCase/src $ /opt/sun-jdk-1.6.0.05/bin/javac *.java
SubClassOfGeneric.java:18: cannot select from a type variable
                V.MyInnerClass foo = m_test.getMyInnerClass();
                 ^
1 error

And here's my JDK 5 javac invocation.

rcjsuen@ivalice ~/eclipse-workspace/GenericsTestCase/src $ /opt/sun-jdk-1.5.0.15/bin/javac *.java
SubClassOfGeneric.java:18: incompatible types
found   : GenericWithInner<T>.MyInnerClass
required: GenericWithInner.MyInnerClass
                V.MyInnerClass foo = m_test.getMyInnerClass();
                                                           ^
1 error
Comment 3 Remy Suen CLA 2008-08-15 07:33:06 EDT
This continues to compile fine with I20080731-0950 and fails with Sun's JDK 1.5.0.16 and 1.6.0.7.
Comment 4 Kent Johnson CLA 2008-09-10 09:38:39 EDT
The testcase can be reduce to :

class GenericWithInner<T> {
	class M {}
}

class SubClassOfGeneric<V extends GenericWithInner<V>> {
	void testMethod(V.M m) {} // error: cannot select from a type variable
}


Same error should be detected from any other qualified reference that attempts to extract a member type from a type variable
Comment 5 Kent Johnson CLA 2008-09-10 11:02:01 EDT
Here's another testcase with a few more references :

class X<T> {
	class M {}
	static int i;
	static int foo() { return i; }
}
class Y<T extends X<T>> {
	int i = T.i + T.foo();

	void test(T.M m) {} // javac error: cannot select from a type variable
}


javac allows inherited field and method references thru T's upperbound X<T>, but javac doesn't allow a reference to a member type.


Philippe - any comment ?
Comment 6 Kent Johnson CLA 2008-09-10 11:18:31 EDT
Just found the javac bug report

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6569404

Closing as a duplicate of bug 142897

*** This bug has been marked as a duplicate of bug 142897 ***
Comment 7 Kent Johnson CLA 2008-09-10 11:25:14 EDT
See GenericTypeTest#test0997 for a testcase with a qualified reference to a member type thru a type variable.
Comment 8 Jerome Lanneluc CLA 2008-09-16 07:57:53 EDT
Verified for 3.5M2 that this is a dup of bug 142897