aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes inner class inside a generic class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "inner class inside a generic class" Watch "inner class inside a generic class" New topic
Author

inner class inside a generic class

Piotr Trochim
Ranch Hand

Joined: Dec 29, 2006
Posts: 35
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

Joined: Dec 29, 2006
Posts: 35
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

Joined: Feb 07, 2005
Posts: 2367
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 ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: inner class inside a generic class