Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inner class inside a generic class

 
Piotr Trochim
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy

I've a problem:



Now - when I compile it the way it is, an error occurs in line ***2 :


Cannot perform instanceof check against parameterized type
A<E>.B. Use instead its raw form B since
generic type information will be erased at runtime


Now - if I parametrize the inner class, replacing line ***1 with the following piece of code:




The question is - why?

Cheerz m8s
Paksas
 
Piotr Trochim
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ups - silly of me - I forgot to mention that if I parametrize the inner class, everything works fine.

The question 'WHY' stands though

Awaiting a response.

Best,
Paksas
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe this has something to do with the ban on "rare" types where the outer class is parameterized, but the inner class is raw.

This is discussed in the Java Language Specification 4.8 Raw Types.
[ April 16, 2007: Message edited by: Keith Lynn ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic