Community
Participate
Working Groups
Hi, This code works fine for javac: public class Test<T> { private T data; private Test(T data){ this.data=data; } public static <S> Test<S> createObject(S data){ return new Test<S>(data); } public static void main(String[] args) { Test<String> res=Test.createObject("Hallo"); } }
I also would expect the following to work: Test<String> res=Test.<String>createObject("Hallo");
Resolved along with fix for bug 77052. Added regression test: GenericTypeTest#test340. *** This bug has been marked as a duplicate of 77052 ***
Actually, this wasn't a dup.
Fixed (generic static method of raw type remains generic)
*** Bug 77142 has been marked as a duplicate of this bug. ***
I tried this out in N20041028, and the compiler no longer gives an error, but it still gives a warning, which javac doesn't: Type safety: The method createObject(String) belongs to the raw type Test. References to generic type Test<T> should be parameterized
The warning disappeared today with my latest changes.
Verified for 3.1M3 with build I200411040100