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.
openide/util offers a bunch of APIs that are candidates to be converted to generics. However no attempt like that can happen until we clean up the code base and start to use 1.5 generified libraries internally - e.g. until we remove all the warnings produced by 1.5 javac running with -Xlint check on. This patch removes or at leasts supresses all the warnings for all classes except those that are Lookup related (this is going to be solved by work in issue 67888). It intends to do minimal changes to public signatures. The only ones are: Enumerations.empty() and modification of WeakSet to match Set<T> contract[1]. The rest of the warnings has been supressed and marked with "// NEED.*API comment" they will be fixed as soon as we decide to modify those APIs. [1] without the second change we could not fix a lot of other code that uses WeakSet
Sounds good. For tracking purposes, from 67888, API-visible generics changes possible in openide/util: WeakSet, Enumerations, Utilities.topologicalSort, Utilities.activeReferenceQueue, Mutex.{,Exception}Action and methods which use them, NbBundle.getLocalizedValue, Queue, SharedClassObject.findObject, WeakListeners.create, SystemAction.get. Others: use varargs for NbBundle.getMessage(Class,String,Object...) and Lookups.fixed(Object...).
Created attachment 29248 [details] The patch to allow javac.source=1.5 without a bunch of warnings
I'd like to apply the UsageOf15InUtilities.diff first and then move to other fixes in the API of openide/util
BTW diff -u is a lot easier to read for this kind of patch. Value types of IconManager.{map,localizedMap} could use union type. @SuppressWarnings should not be needed on IconManager.ActiveRef if we fix Utilities.activeReferenceQueue. Enumerations.empty() could read return Collections.enumeration(Collections.<T>emptyList()); More to come...
Why is WeakSet.Entry not <E>? IMHO all of WeakSet.java should compile without warnings, no? TimedSoftReference can be fully generified - it is not public. NbBundle.propsToStringMap could be written to actually wrap its arg in a type-safe proxy map (not copy). Generally I think it would be a bit simpler to update the APIs to be generic at the same time as you update the impl, because in a lot of cases you have to do some hacks to make the impl generic and the API nongeneric. For example, if SharedClassObject was fixed, to use public static <T extends SharedClassObject> T findObject(Class<T>, boolean); then the impl would be cleaner since SetAccessibleAction would be SetAccessibleAction<T extends SharedClassObject> implements PrivilegedExceptionAction<T> and be constructed using Class<T>, so e.g. the SharedClassObject.class.cast call would be unnecessary. (In this case the impl will get more complicated because of the static cache, but...)
Created attachment 29262 [details] Fix for everything even APIs except Lookup
Jesse, I have fixed most of your requests. I changed all the non-lookup APIs that needed change (in order to prevent warnings). I am realatively satisfied with the signature changes, except topologicalSort, I am not sure if it is typed in the most generic way[1]. Anyway I hope this is integratable. [1] Map<Object,List<String>> m; Collection<String> c; topoSort(c, m); // does not compile
Created attachment 29267 [details] Same as previous, just better type for topologicalSort
Re. topologicalSort - there are only a few usages, so just make sure those can be adapted and it will probably be OK.
Will be merged together with issue 67888 soon. *** This issue has been marked as a duplicate of 67888 ***