[jboss-user] [JBoss Seam] - Generic List with @DataModel

lightbulb432 do-not-reply at jboss.com
Tue Jan 16 00:31:14 EST 2007


When using generic Lists, I get compiler warnings. If I want to have a generic return type, which of the following two options should be done? (Note the use of a cast in the second option.)

Also, what's the disadvantage to not using @SuppressWarnings? It seems like it's optional...

	@DataModel
  | 	@SuppressWarnings("unchecked")
  | 	public List<Something> getSomethings() {
  | 		return myQuery.getResultList();
  | 	}

	Without @SuppressWarnings, the above gives the warning: 
	Type safety: The expression of type List needs unchecked conversion to conform to List<Something>	

	@DataModel
  | 	@SuppressWarnings("unchecked")
  | 	public List<Something> getSomethings() {
  | 		return (List<Something>) myQuery.getResultList();
  | 	}

	Without @SuppressWarnings, the above gives the warning: 
	Type safety: The cast from List to List<Something> is actually checking against the erased type List

Why is this error showing up in the second case. If I'm casting, shouldn't I be able to leave off @SuppressWarnings with no problem?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4002125#4002125

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4002125



More information about the jboss-user mailing list