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.

Bug 56726 - Generify Refactoring
Summary: Generify Refactoring
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 4.x
Hardware: All All
: P3 blocker with 1 vote (vote)
Assignee: Jan Becicka
: 55762 174375 (view as bug list)
Depends on:
Blocks: 55762
  Show dependency tree
Reported: 2005-03-21 12:21 UTC by Jan Becicka
Modified: 2012-05-03 15:34 UTC (History)
2 users (show)

See Also:
Exception Reporter:

A patch to look at for ideas (126.60 KB, patch)
2005-12-22 17:44 UTC, Jesse Glick
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Becicka 2005-03-21 12:21:31 UTC
This issue tracks implementation of Generify refactoring.
Comment 1 Jesse Glick 2005-12-22 17:44:49 UTC
Created attachment 28043 [details]
A patch to look at for ideas
Comment 2 Jesse Glick 2005-12-22 17:55:14 UTC
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.
Comment 3 Jan Pokorsky 2009-12-02 08:01:33 UTC
*** Bug 174375 has been marked as a duplicate of this bug. ***
Comment 4 Jan Becicka 2011-01-06 13:21:39 UTC
*** Bug 55762 has been marked as a duplicate of this bug. ***
Comment 5 Jesse Glick 2012-05-03 15:34:15 UTC
(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/ 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.)