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.
For people writing modules on top of java5 it would be excelent to have support for generic versions of certain API interfaces, especially Lookup.
The Lookup has been generified on a branch. Currently just three files are branched (while the common.xml is needed just to enable -Xlint:unchecked): nbbuild/templates/common.xml openide/util/nbproject/project.properties openide/util/src/org/openide/util/Lookup.java the name of the branch is generic_67888 and its root is generic_67888_root
Created attachment 29222 [details] Changes in openide/util to have generified Lookup interface
Trung builds are now switched to Java5 and we so slowly start to use new features of Java5. There are many things to updated, but one of the most externally visible things to change is to generify our APIs. And where else shall we start than with an API that everyone uses and everyone relies on - Lookup. The Lookup is an example of an API that greatly benefits from usage of generics. It turns out that the one can completely remove all casts if using Java5 and new "generified" version of lookup interface. This is a great improvement to original state where casts were necessary to achieve anything when using Lookup API. There are two puproses of the review: #1 - review the API change and confirm that is it using Java5 generics correctly, I'd like to ask people with insight into Java5 to add comment into this issue #2 - identify necessary precondition that need to be fulfilled before the API change can be merged into the trunk. If anyones sees any blocker, please report it as separate issue and make this one depend on it. Long live generics!
How does new Lookup.Template(null, ...) work? Can you do e.g. new Lookup.Template((Class<Object>) null, ...) instead? Should Result.allClasses return Set<Class<? extends T>> instead? And similarly Item.getType might return Class<? extends T>? I think it is OK for Lookup.Result.allInstances to return simply Collection<T> but Collection<? extends T> could also be considered - AFAIK only affects subclassers. Some other related things like certain Lookups.* methods, LookupEvent, etc. probably need to be generified too. Otherwise looks fine. BTW I know of a number of other APIs in openide/util that need to be generified. E.g.: WeakSet, Enumerations, Utilities.topologicalSort, Utilities.activeReferenceQueue, Mutex.{,Exception}Action and methods which use them, NbBundle.getLocalizedValue, Queue, SharedClassObject.findObject, WeakListeners.create, SystemAction.get, maybe a few others. Should these be handled here, or file them separately?
What aboud pseudo-lookup interfaces like debuggercore...org.netbeans.spi.debugger.ContextProvider?
Re: debuggercore - unrelated to this effort, someone needs to file another issue. Re: "number of other APIs in openide/util" - imho it is better to track them separately. Doing one big review would give a change for a lot of small mistakes to sneak in. Re: "Class<? extends T>" - right this is necessary. Thanks. Re: "Collection<? extends T>" - this is not necessary at all, but it may be helpful as in fact it defacto turns the returned collection into immutable one (except c.add(null)). Anyway I am going to also change the implementation of AbstractLookup to generics and make it without warnings - that way we'll be more sure the types are right. I've just branched the whole openide/util to generic_67888 with root generic_67888_root
Before any cleanup of API happens, we need to start to use 1.5 internally - issue 73573 is here to track that task.
Created attachment 29299 [details] Patch fixing everything in openide/util including lookup and all warnings
The changes are available in the generic_67888 branch, if there are no major objections I merge to trunk on Tuesday.
Ok, thanks for all your feedback.
*** Issue 73573 has been marked as a duplicate of this issue. ***
IDE:------------------------------------------------- IDE: [21.3.06 9:16] Committing started Checking in src/org/openide/util/IconManager.java; /cvs/openide/util/src/org/openide/util/IconManager.java,v <-- IconManager.java new revision: 1.3; previous revision: 1.2 done Checking in src/org/openide/util/Utilities.java; /cvs/openide/util/src/org/openide/util/Utilities.java,v <-- Utilities.java new revision: 1.11; previous revision: 1.10 done Checking in src/org/openide/util/TimedSoftReference.java; /cvs/openide/util/src/org/openide/util/TimedSoftReference.java,v <-- TimedSoftReference.java new revision: 1.2; previous revision: 1.1 done Checking in src/org/openide/util/UtilitiesCompositeActionMap.java; /cvs/openide/util/src/org/openide/util/UtilitiesCompositeActionMap.java,v <-- UtilitiesCompositeActionMap.java new revision: 1.2; previous revision: 1.1 done Checking in src/org/openide/util/WeakListenerImpl.java; /cvs/openide/util/src/org/openide/util/WeakListenerImpl.java,v <-- WeakListenerImpl.java new revision: 1.5; previous revision: 1.4 done Checking in src/org/openide/util/RE13.java; /cvs/openide/util/src/org/openide/util/RE13.java,v <-- RE13.java new revision: 1.2; previous revision: 1.1 done Checking in src/org/openide/util/Task.java; /cvs/openide/util/src/org/openide/util/Task.java,v <-- Task.java new revision: 1.3; previous revision: 1.2 done Checking in src/org/openide/util/Enumerations.java; /cvs/openide/util/src/org/openide/util/Enumerations.java,v <-- Enumerations.java new revision: 1.2; previous revision: 1.1 done Checking in src/org/openide/util/Lookup.java; /cvs/openide/util/src/org/openide/util/Lookup.java,v <-- Lookup.java new revision: 1.6; previous revision: 1.5 done Checking in src/org/openide/util/RequestProcessor.java; /cvs/openide/util/src/org/openide/util/RequestProcessor.java,v <-- RequestProcessor.java new revision: 1.13; previous revision: 1.12 done Checking in src/org/openide/util/Queue.java; /cvs/openide/util/src/org/openide/util/Queue.java,v <-- Queue.java new revision: 1.2; previous revision: 1.1 done Checking in src/org/openide/util/WeakSet.java; /cvs/openide/util/src/org/openide/util/WeakSet.java,v <-- WeakSet.java new revision: 1.3; previous revision: 1.2 done Checking in src/org/openide/util/NbBundle.java; /cvs/openide/util/src/org/openide/util/NbBundle.java,v <-- NbBundle.java new revision: 1.7; previous revision: 1.6 done Checking in src/org/openide/util/Mutex.java; /cvs/openide/util/src/org/openide/util/Mutex.java,v <-- Mutex.java new revision: 1.7; previous revision: 1.6 done Checking in src/org/openide/util/TopologicalSortException.java; /cvs/openide/util/src/org/openide/util/TopologicalSortException.java,v <-- TopologicalSortException.java new revision: 1.2; previous revision: 1.1 done Checking in src/org/openide/util/WeakListeners.java; /cvs/openide/util/src/org/openide/util/WeakListeners.java,v <-- WeakListeners.java new revision: 1.2; previous revision: 1.1 done Checking in src/org/openide/util/SharedClassObject.java; /cvs/openide/util/src/org/openide/util/SharedClassObject.java,v <-- SharedClassObject.java new revision: 1.5; previous revision: 1.4 done Checking in src/org/openide/util/actions/CallbackSystemAction.java; /cvs/openide/util/src/org/openide/util/actions/CallbackSystemAction.java,v <-- CallbackSystemAction.java new revision: 1.7; previous revision: 1.6 done Checking in src/org/openide/util/actions/CallableSystemAction.java; /cvs/openide/util/src/org/openide/util/actions/CallableSystemAction.java,v <-- CallableSystemAction.java new revision: 1.5; previous revision: 1.4 done Checking in src/org/openide/util/actions/SystemAction.java; /cvs/openide/util/src/org/openide/util/actions/SystemAction.java,v <-- SystemAction.java new revision: 1.5; previous revision: 1.4 done Checking in src/org/openide/util/lookup/InstanceContent.java; /cvs/openide/util/src/org/openide/util/lookup/InstanceContent.java,v <-- InstanceContent.java new revision: 1.2; previous revision: 1.1 done Checking in src/org/openide/util/lookup/WaitableResult.java; /cvs/openide/util/src/org/openide/util/lookup/WaitableResult.java,v <-- WaitableResult.java new revision: 1.3; previous revision: 1.2 done Checking in src/org/openide/util/lookup/SimpleProxyLookup.java; /cvs/openide/util/src/org/openide/util/lookup/SimpleProxyLookup.java,v <-- SimpleProxyLookup.java new revision: 1.5; previous revision: 1.4 done Checking in src/org/openide/util/lookup/Lookups.java; /cvs/openide/util/src/org/openide/util/lookup/Lookups.java,v <-- Lookups.java new revision: 1.3; previous revision: 1.2 done Checking in src/org/openide/util/lookup/ExcludingLookup.java; /cvs/openide/util/src/org/openide/util/lookup/ExcludingLookup.java,v <-- ExcludingLookup.java new revision: 1.3; previous revision: 1.2 done Checking in src/org/openide/util/lookup/DelegatingStorage.java; /cvs/openide/util/src/org/openide/util/lookup/DelegatingStorage.java,v <-- DelegatingStorage.java new revision: 1.2; previous revision: 1.1 done Checking in src/org/openide/util/lookup/InheritanceTree.java; /cvs/openide/util/src/org/openide/util/lookup/InheritanceTree.java,v <-- InheritanceTree.java new revision: 1.3; previous revision: 1.2 done Checking in src/org/openide/util/lookup/MetaInfServicesLookup.java; /cvs/openide/util/src/org/openide/util/lookup/MetaInfServicesLookup.java,v <-- MetaInfServicesLookup.java new revision: 1.4; previous revision: 1.3 done Checking in src/org/openide/util/lookup/AbstractLookup.java; /cvs/openide/util/src/org/openide/util/lookup/AbstractLookup.java,v <-- AbstractLookup.java new revision: 1.7; previous revision: 1.6 done Checking in src/org/openide/util/lookup/ArrayStorage.java; /cvs/openide/util/src/org/openide/util/lookup/ArrayStorage.java,v <-- ArrayStorage.java new revision: 1.3; previous revision: 1.2 done Checking in src/org/openide/util/lookup/ALPairComparator.java; /cvs/openide/util/src/org/openide/util/lookup/ALPairComparator.java,v <-- ALPairComparator.java new revision: 1.2; previous revision: 1.1 done Checking in src/org/openide/util/lookup/SimpleLookup.java; /cvs/openide/util/src/org/openide/util/lookup/SimpleLookup.java,v <-- SimpleLookup.java new revision: 1.5; previous revision: 1.4 done Checking in src/org/openide/util/lookup/ProxyLookup.java; /cvs/openide/util/src/org/openide/util/lookup/ProxyLookup.java,v <-- ProxyLookup.java new revision: 1.7; previous revision: 1.6 done Checking in test/unit/src/org/openide/util/UtilitiesTopologicalSortTest.java; /cvs/openide/util/test/unit/src/org/openide/util/UtilitiesTopologicalSortTest.java,v <-- UtilitiesTopologicalSortTest.java new revision: 1.2; previous revision: 1.1 done Checking in test/unit/src/org/openide/util/WeakListenersTest.java; /cvs/openide/util/test/unit/src/org/openide/util/WeakListenersTest.java,v <-- WeakListenersTest.java new revision: 1.5; previous revision: 1.4 done Checking in src/org/openide/util/datatransfer/ExTransferable.java; /cvs/openide/util/src/org/openide/util/datatransfer/ExTransferable.java,v <-- ExTransferable.java new revision: 1.3; previous revision: 1.2 done Checking in src/org/openide/util/io/NbObjectOutputStream.java; /cvs/openide/util/src/org/openide/util/io/NbObjectOutputStream.java,v <-- NbObjectOutputStream.java new revision: 1.4; previous revision: 1.3 done Checking in test/unit/src/org/openide/util/lookup/AbstractLookupMemoryTest.java; /cvs/openide/util/test/unit/src/org/openide/util/lookup/AbstractLookupMemoryTest.java,v <-- AbstractLookupMemoryTest.java new revision: 1.2; previous revision: 1.1 done Checking in nbproject/project.properties; /cvs/openide/util/nbproject/project.properties,v <-- project.properties new revision: 1.10; previous revision: 1.9 done Checking in src/org/openide/ServiceType.java; /cvs/openide/util/src/org/openide/ServiceType.java,v <-- ServiceType.java new revision: 1.4; previous revision: 1.3 done Checking in src/org/openide/ErrorManager.java; /cvs/openide/util/src/org/openide/ErrorManager.java,v <-- ErrorManager.java new revision: 1.4; previous revision: 1.3 done Checking in src/org/openide/xml/EntityCatalog.java; /cvs/openide/util/src/org/openide/xml/EntityCatalog.java,v <-- EntityCatalog.java new revision: 1.2; previous revision: 1.1 done Checking in src/org/openide/xml/XMLUtil.java; /cvs/openide/util/src/org/openide/xml/XMLUtil.java,v <-- XMLUtil.java new revision: 1.10; previous revision: 1.9 done IDE: [21.3.06 9:16] Committing finished
Changes used successfully in Ant module, which now compiles without warnings.