-
Enhancement
-
Resolution: Won't Fix
-
P4
-
6
-
None
-
generic
-
generic
Please extend the typing of java.lang.Class.forName by adding either a static method:
public static <U> Class<? extends U> forName(String className, Class<U> bound) {
return bound.cast(forName(className));
}
Or a non-static method:
public Class<? extends T> forSubclassName(String className) {
return cast(forName(className));
}
This would help in situations like:
import java.util.EventListener;
import javax.swing.event.EventListenerList;
class Test {
void test(String name, EventListenerList list, EventListener l)
throws ClassNotFoundException
{
list.add((Class)Class.forName(name), l);
}
}
###@###.### 10/8/04 21:34 GMT
public static <U> Class<? extends U> forName(String className, Class<U> bound) {
return bound.cast(forName(className));
}
Or a non-static method:
public Class<? extends T> forSubclassName(String className) {
return cast(forName(className));
}
This would help in situations like:
import java.util.EventListener;
import javax.swing.event.EventListenerList;
class Test {
void test(String name, EventListenerList list, EventListener l)
throws ClassNotFoundException
{
list.add((Class)Class.forName(name), l);
}
}
###@###.### 10/8/04 21:34 GMT
- relates to
-
JDK-5049523 Inference should compute glb of type arguments
- Closed
-
JDK-6184376 Wrong generification of javax.swing.event.EventListenerList
- Closed