Bug 130543 - [1.5][compiler] Error creating array of generics of inner class.
Summary: [1.5][compiler] Error creating array of generics of inner class.
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1.2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.2 M6   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-06 09:22 EST by Ramon Garcia CLA
Modified: 2006-03-28 06:51 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ramon Garcia CLA 2006-03-06 09:22:13 EST
The following example compiles without error with sun compiler, but it gives an error with Eclipse compiler:

public class testGeneric2<A> {
   void method()
   {
	   class t2<C,D> {};
	   t2<?,?>[] at = new  t2<?,?>[5];
   }
}
Comment 1 Philipe Mulet CLA 2006-03-06 13:24:09 EST
Using javac1.6b74:
testGeneric2.java:5: generic array creation
           t2<?,?>[] at = new  t2<?,?>[5];
                          ^
1 error
Comment 2 Ramon Garcia CLA 2006-03-06 14:42:44 EST
I am almost sure that the code is correct. Because it is necessary. Otherwise it would be imposible to create an array of inner generic classes. 

With generic classes one cannot create arrays of concrete generic classes, because there are some kind of errors that would not be caught by the compiler. So one has the alternative of creating arrays of unbound generic classes. With this error, this alternative becomes void.

Comment 3 Philipe Mulet CLA 2006-03-06 15:53:37 EST
The enclosing type must be reifiable too, in your case it is not.
t2<?,?> has testGeneric2<A> as its enclosing type, which isn't reifiable.

In a static method, this should be allowed though, as no enclosing type pertains there.
Comment 4 Philipe Mulet CLA 2006-03-06 16:25:00 EST
We actually missed the static method scenario.
Added GenericTypeTest#test0954.
Fixed
Comment 5 Philipe Mulet CLA 2006-03-06 16:25:16 EST
forgot to assign
Comment 6 Philipe Mulet CLA 2006-03-06 16:25:40 EST
fixed
Comment 7 Ramon Garcia CLA 2006-03-09 12:17:46 EST
Thanks, in my case it was a static method, so this fix will be useful for me.
Comment 8 David Audel CLA 2006-03-28 06:51:03 EST
Verified for 3.2 M6 using build I20060328-0010