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.
This issue tracks implementation of Generify refactoring.
Created attachment 28043 [details] A patch to look at for ideas
I think this is quite an important feature but may be much harder than you suspect. Look through the attached (edited) patch to see some of the things that might happen. The patch also does a few other JDK 5 changes such as use of varargs, enhanced for-loop, and autoboxing. Besides the obvious introduction of type parameters into collections etc., - some pre-generic usages of maps might have been incorrect (I found one bad cast in my own code) - you can't make arrays of a generic type without a warning, so some idioms may need to be rewritten to use e.g. List/ArrayList to compile cleanly - it is often useful to generify a class, which is not easy at all - you cannot store instantiated types in a static field (e.g. a queue or cache) without a warning, so you need to do some tricks - some usages of Object which were tested for different types in turn should be replaced by a type-safe struct - Collections.EMPTY_* constants need to be replaced with methods In light of what "generifying" code really involves, it may be wise to use a more modest term for the refactoring. E.g. "introduce type parameters". Even with that limited scope I would be impressed if a mechanical refactoring can do half of the things it should do.
*** Bug 174375 has been marked as a duplicate of this bug. ***
*** Bug 55762 has been marked as a duplicate of this bug. ***
(In reply to comment #2) > you can't make arrays of a generic type without a warning Though in -source 7 it may be easier (@SafeVarargs). contrib/javahints/src/org/netbeans/modules/javahints/jdk5/IteratorToFor.java does some very modest conversions to enhanced for-loops; much more to be done there. (Unfortunately bug #200978 and abuse of implementation dependencies makes it hard to keep this module enabled in dev builds.)