My code is as follows
package com.foo;
public class TestComposition {
public static void main(String[] args) {
try {
Class
The runtime system has no knowledge about generics and therfore it can only check that something is of type Class
, not if it is of type Class
. That is what the warning is about.
A method has specifically been added to the Class
class to avoid this warning. You can use this instead of casting yourself: http://download.oracle.com/javase/6/docs/api/java/lang/Class.html#asSubclass(java.lang.Class)