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.
[ BUILD # : 20101215 ] [ JDK VERSION : 1.6.22 ] Examine the following class; import java.util.List; /** * @author Kent */ public class mainClass { List<a1.NewClass> s2 = needToBeCasted(); private Object needToBeCasted() { return null; } } - - - It apparently need a typecase for the method call, but, when using the error-hint to insert one the code will look like this; mport a1.NewClass; import java.util.List; /** * @author Kent */ public class mainClass { List<a1.NewClass> s2 = (List<NewClass>) needToBeCasted(); private Object needToBeCasted() { return null; } } - - - As you see it has used the short form of NewClass even if it is specified fully on the lVal and it has also added an import for the class, there is actually nothing wrong with this, but, it can be very confusing if you have a lot of classes with same name in different packages. As I see it it the rVal should have the same specification of class as the lVal.
Come to think of it, this could be a configurable warning; Explicit package on the left imported on the right. Reason: If you have multiple packages with same name and erasure and you for some reason change the import statement the construct will no longer point to the correct package and thus give an error.
Copying the exact type specification in this case: http://hg.netbeans.org/jet-main/rev/1a84ce109c2c
Integrated into 'main-golden', will be available in build *201012230001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/1a84ce109c2c User: Jan Lahoda <jlahoda@netbeans.org> Log: #193625: when creating cast in variable initializer, keep the exact variable's type in the cast.