This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
I thought I understood Java Generics.... I can't figure out what the compiler is complaining about in a recent code snippet that I wrote.
I've got a class that wants a class as its argument.
In the sample below, the "Inventor" class implements PatentBase. So the result of the two calls to the constructor are identical, to my eyes. But the compiler thinks differently.
The specific error from the compiler is:
/Users/pfarrell/sandbox/wayserver/wayfinderlib/test/com/wayfinderdigital/struct/ContainedPboListTest.java:67: cannot find symbol
symbol : constructor ContainedPboList(java.lang.Class<capture#480 of ? extends com.wayfinderdigital.busobj.Inventor>)
location: class com.wayfinderdigital.struct.ContainedPboList<com.wayfinderdigital.busobj.Inventor,com.wayfinderdigital.busobj.Patent>
instance = new ContainedPboList<Inventor, Patent>(wizard.getClass());
I think that lines 3 and 4 are functionally identical in the second code segment. How is "Inventor.class" different from "wizard.getClass()" when the wizard is an Inventor?