This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Example (import java.util.*): List raw = null; Collections.<String> unmodifiableList(raw); "Assign Return Value To New Variable" on the second line results in: List unmodifiableList = Collections.<String> unmodifiableList(raw); ...although the result type here is List<String>. The expected result would have been: List<String> unmodifiableList = Collections.<String> unmodifiableList(raw);
The result is strictly speaking, the result is correct. An unchecked conversion is needed for the method invocation, and in such a case the return type is always an erasure of the methods return type (JLS 15.12.2.6). The question is whether the IDE should produce the unerased return type, or not. The difference is that: Collections.<String> unmodifiableList(raw).get(0).length(); will not compile, but: List<String> unmodifiableList = Collections.<String> unmodifiableList(raw); unmodifiableList.get(0).length(); will (and may throw unexpected ClassCastException in runtime).
I see, I wasn't aware of that. The important thing to realize (I guess) is that the code compiles (with warnings) even if the type arguments don't match, as for example in: List<Integer> list = Collections.<String> unmodifiableList(raw); The warning for 'raw' here covers the warning vor assigning a raw List to List<Integer>. Resolving the issue as invalid.