Getting the .class of a Java5 generic 2005-12-22 - By Jeroen Wenting
Back > > private MockControl<List<WebForm>> controlWebFormList; > private List<WebForm> webFormList; > > public void setUp() > { > controlWebFormList = > MockControl.createControl(List<WebForm>.class); > webFormList = controlWebForm.getMock(); > } > > However, the compiler complains: > > Syntax error on token ">", void expected after this token > > How do I get the .class field from a typed generic at compile time? > > -
Easiest way I can think of is making an instance of the class and calling getClass() on that. Not something that will get an award for beauty (and possibly efficiency) but it should work as we're talking pretty much throwaway code here.
Jeroen Wenting jwenting@(protected)
=========================================================================== To unsubscribe, send email to listserv@(protected) and include in the body of the message "signoff J2EE-INTEREST". For general help, send email to listserv@(protected) and include in the body of the message "help".
|
|