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 73573

Summary: Use 1.5 lang features in openide/util internally
Product: platform Reporter: Jaroslav Tulach <jtulach>
Component: -- Other --Assignee: apireviews <apireviews>
Status: RESOLVED DUPLICATE    
Severity: blocker CC: jglick, jtulach
Priority: P1 Keywords: API_REVIEW_FAST
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: TASK Exception Reporter:
Bug Depends on:    
Bug Blocks: 67888    
Attachments: The patch to allow javac.source=1.5 without a bunch of warnings
Fix for everything even APIs except Lookup
Same as previous, just better type for topologicalSort

Description Jaroslav Tulach 2006-03-14 12:09:12 UTC
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
Comment 1 Jesse Glick 2006-03-15 09:44:50 UTC
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...).
Comment 2 Jaroslav Tulach 2006-03-15 13:02:13 UTC
Created attachment 29248 [details]
The patch to allow javac.source=1.5 without a bunch of warnings
Comment 3 Jaroslav Tulach 2006-03-15 13:03:04 UTC
I'd like to apply the UsageOf15InUtilities.diff first and then move to other 
fixes in the API of openide/util
Comment 4 Jesse Glick 2006-03-15 15:08:07 UTC
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...
Comment 5 Jesse Glick 2006-03-15 16:55:13 UTC
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...)
Comment 6 Jaroslav Tulach 2006-03-16 13:24:06 UTC
Created attachment 29262 [details]
Fix for everything even APIs except Lookup
Comment 7 Jaroslav Tulach 2006-03-16 13:28:54 UTC
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
Comment 8 Jaroslav Tulach 2006-03-16 13:53:13 UTC
Created attachment 29267 [details]
Same as previous, just better type for topologicalSort
Comment 9 Jesse Glick 2006-03-16 15:04:42 UTC
Re. topologicalSort - there are only a few usages, so just make sure those can
be adapted and it will probably be OK.
Comment 10 Jaroslav Tulach 2006-03-21 08:18:55 UTC
Will be merged together with issue 67888 soon.

*** This issue has been marked as a duplicate of 67888 ***