diff options
author | John Arthorne | 2013-10-04 19:57:11 +0000 |
---|---|---|
committer | John Arthorne | 2013-10-04 19:57:11 +0000 |
commit | 31d231e66c2153c781982346e03342ad94529dd6 (patch) | |
tree | 88bdf3a12b0ad64c7958b8c9b5779ff500557872 | |
parent | e7ac5a380f7b7c4d2f9e07eb8ab79363bda13f8a (diff) | |
download | eclipse.platform.runtime-31d231e66c2153c781982346e03342ad94529dd6.tar.gz eclipse.platform.runtime-31d231e66c2153c781982346e03342ad94529dd6.tar.xz eclipse.platform.runtime-31d231e66c2153c781982346e03342ad94529dd6.zip |
Bug 418664 - Get rid of compile warnings in official build
15 files changed, 112 insertions, 113 deletions
diff --git a/bundles/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs index 71353f51e..ede196a30 100644 --- a/bundles/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs +++ b/bundles/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs @@ -8,6 +8,7 @@ org.eclipse.jdt.core.circularClasspath=error org.eclipse.jdt.core.classpath.exclusionPatterns=enabled org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=error +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault @@ -66,6 +67,7 @@ org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignor org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error org.eclipse.jdt.core.compiler.problem.nullReference=warning org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error @@ -86,6 +88,7 @@ org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled @@ -109,6 +112,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference= org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=enabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.5 diff --git a/bundles/org.eclipse.core.runtime/META-INF/MANIFEST.MF b/bundles/org.eclipse.core.runtime/META-INF/MANIFEST.MF index 67ff966c6..ecff50e52 100644 --- a/bundles/org.eclipse.core.runtime/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.core.runtime/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName -Bundle-Version: 3.9.100.qualifier +Bundle-Version: 3.10.0.qualifier Bundle-SymbolicName: org.eclipse.core.runtime; singleton:=true Bundle-Vendor: %providerName Bundle-Activator: org.eclipse.core.internal.runtime.PlatformActivator diff --git a/bundles/org.eclipse.core.runtime/pom.xml b/bundles/org.eclipse.core.runtime/pom.xml index 4098994fa..9a5837127 100644 --- a/bundles/org.eclipse.core.runtime/pom.xml +++ b/bundles/org.eclipse.core.runtime/pom.xml @@ -19,7 +19,7 @@ </parent> <groupId>org.eclipse.core</groupId> <artifactId>org.eclipse.core.runtime</artifactId> - <version>3.9.100-SNAPSHOT</version> + <version>3.10.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> <build> <plugins> diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/legacy/PreferenceForwarder.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/legacy/PreferenceForwarder.java index 6d98cbf2e..9e3375dad 100644 --- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/legacy/PreferenceForwarder.java +++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/legacy/PreferenceForwarder.java @@ -16,9 +16,7 @@ import java.util.Properties; import org.eclipse.core.internal.preferences.*; import org.eclipse.core.internal.runtime.RuntimeLog; import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.preferences.DefaultScope; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.core.runtime.preferences.InstanceScope; +import org.eclipse.core.runtime.preferences.*; import org.osgi.service.prefs.BackingStoreException; /** @@ -29,6 +27,7 @@ import org.osgi.service.prefs.BackingStoreException; * hierarchy. * * @since 3.0 + * @deprecated to avoid warnings for interacting with deprecated Preferences class. */ public class PreferenceForwarder extends Preferences implements IEclipsePreferences.IPreferenceChangeListener, IEclipsePreferences.INodeChangeListener { @@ -840,7 +839,7 @@ public class PreferenceForwarder extends Preferences implements IEclipsePreferen private void convertFromProperties(Properties props) { IEclipsePreferences preferences = getPluginPreferences(true); - for (Iterator i = props.keySet().iterator(); i.hasNext();) { + for (Iterator<Object> i = props.keySet().iterator(); i.hasNext();) { String key = (String) i.next(); String value = props.getProperty(key); if (value != null) diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/AuthorizationHandler.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/AuthorizationHandler.java index 039bb17b3..e99331536 100644 --- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/AuthorizationHandler.java +++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/AuthorizationHandler.java @@ -10,12 +10,10 @@ *******************************************************************************/ package org.eclipse.core.internal.runtime; -import java.lang.reflect.InvocationTargetException; import java.io.File; import java.lang.reflect.*; import java.net.URL; -import java.util.HashMap; -import java.util.Map; +import java.util.*; import org.eclipse.core.runtime.*; import org.eclipse.osgi.service.datalocation.Location; import org.eclipse.osgi.util.NLS; @@ -37,14 +35,14 @@ public class AuthorizationHandler { private static Object keyring = null; //reflective access to legacy authentication implementation - private static Class authClass; + private static Class<?> authClass; private static boolean authNotAvailableLogged = false; /** * Get the legacy class that implemented the authorization API. Return <code>null</code> * if the legacy implementation is not present. */ - private static Class getAuthClass() { + private static Class<?> getAuthClass() { if (authClass == null) { try { authClass = Class.forName("org.eclipse.core.internal.runtime.auth.AuthorizationDatabase"); //$NON-NLS-1$ @@ -73,25 +71,26 @@ public class AuthorizationHandler { if (keyring != null && new File(keyringFile).lastModified() == keyringTimeStamp) return true; if (keyringFile == null) { - ServiceReference[] refs = null; + Collection<ServiceReference<Location>> refs = null; try { - refs = PlatformActivator.getContext().getServiceReferences(Location.class.getName(), Location.CONFIGURATION_FILTER); - if (refs == null || refs.length == 0) + refs = PlatformActivator.getContext().getServiceReferences(Location.class, Location.CONFIGURATION_FILTER); + if (refs == null || refs.isEmpty()) return true; } catch (InvalidSyntaxException e) { // ignore this. It should never happen as we have tested the above format. return true; } - Location configurationLocation = (Location) PlatformActivator.getContext().getService(refs[0]); + ServiceReference<Location> serviceRef = refs.iterator().next(); + Location configurationLocation = PlatformActivator.getContext().getService(serviceRef); if (configurationLocation == null) return true; File file = new File(configurationLocation.getURL().getPath() + "/org.eclipse.core.runtime"); //$NON-NLS-1$ - PlatformActivator.getContext().ungetService(refs[0]); + PlatformActivator.getContext().ungetService(serviceRef); file = new File(file, F_KEYRING); keyringFile = file.getAbsolutePath(); } try { - Constructor constructor = authClass.getConstructor(new Class[] {String.class, String.class}); + Constructor<?> constructor = authClass.getConstructor(new Class[] {String.class, String.class}); keyring = constructor.newInstance(new Object[] {keyringFile, password}); } catch (Exception e) { log(e); @@ -100,7 +99,7 @@ public class AuthorizationHandler { //try deleting the file and loading again - format may have changed new java.io.File(keyringFile).delete(); try { - Constructor constructor = authClass.getConstructor(new Class[] {String.class, String.class}); + Constructor<?> constructor = authClass.getConstructor(new Class[] {String.class, String.class}); keyring = constructor.newInstance(new Object[] {keyringFile, password}); } catch (Exception e) { //don't bother logging a second failure and let it flows to the callers @@ -165,12 +164,12 @@ public class AuthorizationHandler { * </ul> * XXX Move to a plug-in to be defined (JAAS plugin). */ - public static synchronized void addAuthorizationInfo(URL serverUrl, String realm, String authScheme, Map info) throws CoreException { + public static synchronized void addAuthorizationInfo(URL serverUrl, String realm, String authScheme, Map<String,String> info) throws CoreException { if (!loadKeyring()) return; try { Method method = authClass.getMethod("addAuthorizationInfo", new Class[] {URL.class, String.class, String.class, Map.class}); //$NON-NLS-1$ - method.invoke(keyring, new Object[] {serverUrl, realm, authScheme, new HashMap(info)}); + method.invoke(keyring, new Object[] {serverUrl, realm, authScheme, new HashMap<String,String>(info)}); } catch (Exception e) { log(e); } @@ -258,21 +257,22 @@ public class AuthorizationHandler { * such information exists *XXX Move to a plug-in to be defined (JAAS plugin). */ - public static synchronized Map getAuthorizationInfo(URL serverUrl, String realm, String authScheme) { - Map info = null; + public static synchronized Map<String,String> getAuthorizationInfo(URL serverUrl, String realm, String authScheme) { + Map<String,String> info = null; try { if (!loadKeyring()) return null; try { + @SuppressWarnings("unchecked") Method method = authClass.getMethod("getAuthorizationInfo", new Class[] {URL.class, String.class, String.class}); //$NON-NLS-1$ - info = (Map) method.invoke(keyring, new Object[] {serverUrl, realm, authScheme}); + info = (Map<String,String>) method.invoke(keyring, new Object[] {serverUrl, realm, authScheme}); } catch (Exception e) { log(e); } } catch (CoreException e) { // The error has already been logged in loadKeyring() } - return info == null ? null : new HashMap(info); + return info == null ? null : new HashMap<String,String>(info); } /** diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/CompatibilityHelper.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/CompatibilityHelper.java index 2fd839960..2ab9e220e 100644 --- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/CompatibilityHelper.java +++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/CompatibilityHelper.java @@ -58,7 +58,7 @@ public class CompatibilityHelper { if (compatibility == null) throw new IllegalStateException(); - Class oldInternalPlatform = null; + Class<?> oldInternalPlatform = null; try { oldInternalPlatform = compatibility.loadClass("org.eclipse.core.internal.plugins.InternalPlatform"); //$NON-NLS-1$ Method getPluginDescriptor = oldInternalPlatform.getMethod("getPluginDescriptor", new Class[] {String.class}); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java index 8ace8e8a6..4eea8c83c 100644 --- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java +++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2012 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -60,7 +60,7 @@ public final class InternalPlatform { private static String keyringFile; //XXX This is not synchronized - private static Map logs = new HashMap(5); + private static Map<Bundle,Log> logs = new HashMap<Bundle,Log>(5); private static final String[] OS_LIST = {Platform.OS_AIX, Platform.OS_HPUX, Platform.OS_LINUX, Platform.OS_MACOSX, Platform.OS_QNX, Platform.OS_SOLARIS, Platform.OS_WIN32}; private static String password = ""; //$NON-NLS-1$ @@ -89,28 +89,28 @@ public final class InternalPlatform { private static final String[] WS_LIST = {Platform.WS_CARBON, Platform.WS_COCOA, Platform.WS_GTK, Platform.WS_MOTIF, Platform.WS_PHOTON, Platform.WS_WIN32, Platform.WS_WPF}; private Path cachedInstanceLocation; // Cache the path of the instance location - private ServiceTracker configurationLocation = null; + private ServiceTracker<Location,Location> configurationLocation = null; private BundleContext context; - private Map groupProviders = new HashMap(3); - private ServiceTracker installLocation = null; - private ServiceTracker instanceLocation = null; + private Map<IBundleGroupProvider,ServiceRegistration<IBundleGroupProvider>> groupProviders = new HashMap<IBundleGroupProvider,ServiceRegistration<IBundleGroupProvider>>(3); + private ServiceTracker<Location,Location> installLocation = null; + private ServiceTracker<Location,Location> instanceLocation = null; + private ServiceTracker<Location,Location> userLocation = null; private Plugin runtimeInstance; // Keep track of the plugin object for runtime in case the backward compatibility is run. - private ServiceRegistration legacyPreferencesService = null; - private ServiceRegistration customPreferencesService = null; + private ServiceRegistration<ILegacyPreferences> legacyPreferencesService = null; + private ServiceRegistration<IProductPreferencesService> customPreferencesService = null; - private ServiceTracker environmentTracker = null; - private ServiceTracker logTracker = null; - private ServiceTracker bundleTracker = null; - private ServiceTracker debugTracker = null; - private ServiceTracker contentTracker = null; - private ServiceTracker preferencesTracker = null; - private ServiceTracker userLocation = null; - private ServiceTracker groupProviderTracker = null; - private ServiceTracker logReaderTracker = null; - private ServiceTracker extendedLogTracker = null; + private ServiceTracker<EnvironmentInfo,EnvironmentInfo> environmentTracker = null; + private ServiceTracker<FrameworkLog,FrameworkLog> logTracker = null; + private ServiceTracker<PackageAdmin,PackageAdmin> bundleTracker = null; + private ServiceTracker<DebugOptions,DebugOptions> debugTracker = null; + private ServiceTracker<IContentTypeManager,IContentTypeManager> contentTracker = null; + private ServiceTracker<IPreferencesService,IPreferencesService> preferencesTracker = null; + private ServiceTracker<IBundleGroupProvider,IBundleGroupProvider> groupProviderTracker = null; + private ServiceTracker<ExtendedLogReaderService,ExtendedLogReaderService> logReaderTracker = null; + private ServiceTracker<ExtendedLogService,ExtendedLogService> extendedLogTracker = null; private IProduct product; @@ -212,17 +212,12 @@ public final class InternalPlatform { } public IBundleGroupProvider[] getBundleGroupProviders() { - Object[] objectArray = groupProviderTracker.getServices(); - if (objectArray == null) // getServices may return null; but we can not. - return new IBundleGroupProvider[0]; - IBundleGroupProvider[] result = new IBundleGroupProvider[objectArray.length]; - System.arraycopy(objectArray, 0, result, 0, objectArray.length); - return result; + return groupProviderTracker.getServices(new IBundleGroupProvider[0]); } public void registerBundleGroupProvider(IBundleGroupProvider provider) { // get the bundle context and register the provider as a service - ServiceRegistration registration = getBundleContext().registerService(IBundleGroupProvider.class.getName(), provider, null); + ServiceRegistration<IBundleGroupProvider> registration = getBundleContext().registerService(IBundleGroupProvider.class, provider, null); // store the service registration (map provider -> registration) synchronized (groupProviders) { groupProviders.put(provider, registration); @@ -231,9 +226,9 @@ public final class InternalPlatform { public void unregisterBundleGroupProvider(IBundleGroupProvider provider) { // get the service reference (map provider -> reference) - ServiceRegistration registration; + ServiceRegistration<IBundleGroupProvider> registration; synchronized (groupProviders) { - registration = (ServiceRegistration) groupProviders.remove(provider); + registration = groupProviders.remove(provider); } if (registration == null) return; @@ -274,7 +269,7 @@ public final class InternalPlatform { public Location getConfigurationLocation() { assertInitialized(); - return (Location) configurationLocation.getService(); + return configurationLocation.getService(); } /** @@ -308,7 +303,7 @@ public final class InternalPlatform { public Location getInstallLocation() { assertInitialized(); - return (Location) installLocation.getService(); + return installLocation.getService(); } public URL getInstallURL() { @@ -322,7 +317,7 @@ public final class InternalPlatform { public Location getInstanceLocation() { assertInitialized(); - return (Location) instanceLocation.getService(); + return instanceLocation.getService(); } /** @@ -348,13 +343,13 @@ public final class InternalPlatform { * The system log listener needs to be optional: turned on or off. What about a system property? :-) */ public ILog getLog(Bundle bundle) { - Log result = (Log) logs.get(bundle); + Log result = logs.get(bundle); if (result != null) return result; - ExtendedLogService logService = (ExtendedLogService) extendedLogTracker.getService(); + ExtendedLogService logService = extendedLogTracker.getService(); Logger logger = logService == null ? null : logService.getLogger(bundle, PlatformLogWriter.EQUINOX_LOGGER_NAME); result = new Log(bundle, logger); - ExtendedLogReaderService logReader = (ExtendedLogReaderService) logReaderTracker.getService(); + ExtendedLogReaderService logReader = logReaderTracker.getService(); logReader.addLogListener(result, result); logs.put(bundle, result); return result; @@ -407,10 +402,10 @@ public final class InternalPlatform { public PlatformAdmin getPlatformAdmin() { if (context == null) return null; - ServiceReference platformAdminReference = context.getServiceReference(PlatformAdmin.class.getName()); + ServiceReference<PlatformAdmin> platformAdminReference = context.getServiceReference(PlatformAdmin.class); if (platformAdminReference == null) return null; - return (PlatformAdmin) context.getService(platformAdminReference); + return context.getService(platformAdminReference); } //TODO I guess it is now time to get rid of that @@ -517,18 +512,19 @@ public final class InternalPlatform { } private IApplicationContext getApplicationContext() { - ServiceReference[] ref; + Collection<ServiceReference<IApplicationContext>> references; try { - ref = context.getServiceReferences(IApplicationContext.class.getName(), "(eclipse.application.type=main.thread)"); //$NON-NLS-1$ + references = context.getServiceReferences(IApplicationContext.class, "(eclipse.application.type=main.thread)"); //$NON-NLS-1$ } catch (InvalidSyntaxException e) { return null; } - if (ref == null || ref.length == 0) + if (references == null || references.isEmpty()) return null; // assumes the application context is available as a service - IApplicationContext result = (IApplicationContext) context.getService(ref[0]); + ServiceReference<IApplicationContext> firstRef = references.iterator().next(); + IApplicationContext result = context.getService(firstRef); if (result != null) { - context.ungetService(ref[0]); + context.ungetService(firstRef); return result; } return null; @@ -556,7 +552,7 @@ public final class InternalPlatform { public Location getUserLocation() { assertInitialized(); - return (Location) userLocation.getService(); + return userLocation.getService(); } public String getWS() { @@ -667,21 +663,21 @@ public final class InternalPlatform { } catch (IOException e) { return null; } - Vector result = new Vector(5); - for (Enumeration groups = ini.propertyNames(); groups.hasMoreElements();) { + List<URL>result = new ArrayList<URL>(5); + for (Enumeration<?> groups = ini.propertyNames(); groups.hasMoreElements();) { String group = (String) groups.nextElement(); for (StringTokenizer entries = new StringTokenizer(ini.getProperty(group), ";"); entries.hasMoreElements();) { //$NON-NLS-1$ String entry = (String) entries.nextElement(); if (!entry.equals("")) //$NON-NLS-1$ try { - result.addElement(new URL(entry)); + result.add(new URL(entry)); } catch (MalformedURLException e) { //intentionally ignore bad URLs System.err.println("Ignoring plugin: " + entry); //$NON-NLS-1$ } } } - return (URL[]) result.toArray(new URL[result.size()]); + return result.toArray(new URL[result.size()]); } /** @@ -747,7 +743,7 @@ public final class InternalPlatform { } catch (InvalidSyntaxException e) { // ignore this. It should never happen as we have tested the above format. } - instanceLocation = new ServiceTracker(context, filter, null); + instanceLocation = new ServiceTracker<Location,Location>(context, filter, null); instanceLocation.open(); try { @@ -755,7 +751,7 @@ public final class InternalPlatform { } catch (InvalidSyntaxException e) { // ignore this. It should never happen as we have tested the above format. } - userLocation = new ServiceTracker(context, filter, null); + userLocation = new ServiceTracker<Location,Location>(context, filter, null); userLocation.open(); try { @@ -763,7 +759,7 @@ public final class InternalPlatform { } catch (InvalidSyntaxException e) { // ignore this. It should never happen as we have tested the above format. } - configurationLocation = new ServiceTracker(context, filter, null); + configurationLocation = new ServiceTracker<Location,Location>(context, filter, null); configurationLocation.open(); try { @@ -771,26 +767,26 @@ public final class InternalPlatform { } catch (InvalidSyntaxException e) { // ignore this. It should never happen as we have tested the above format. } - installLocation = new ServiceTracker(context, filter, null); + installLocation = new ServiceTracker<Location,Location>(context, filter, null); installLocation.open(); if (context != null) { - logTracker = new ServiceTracker(context, FrameworkLog.class.getName(), null); + logTracker = new ServiceTracker<FrameworkLog,FrameworkLog>(context, FrameworkLog.class, null); logTracker.open(); } if (context != null) { - bundleTracker = new ServiceTracker(context, PackageAdmin.class.getName(), null); + bundleTracker = new ServiceTracker<PackageAdmin,PackageAdmin>(context, PackageAdmin.class, null); bundleTracker.open(); } if (context != null) { - contentTracker = new ServiceTracker(context, IContentTypeManager.class.getName(), null); + contentTracker = new ServiceTracker<IContentTypeManager,IContentTypeManager>(context, IContentTypeManager.class, null); contentTracker.open(); } if (context != null) { - preferencesTracker = new ServiceTracker(context, IPreferencesService.class.getName(), null); + preferencesTracker = new ServiceTracker<IPreferencesService,IPreferencesService>(context, IPreferencesService.class, null); preferencesTracker.open(); } @@ -799,31 +795,31 @@ public final class InternalPlatform { } catch (InvalidSyntaxException e) { // ignore this, it should never happen } - groupProviderTracker = new ServiceTracker(context, filter, null); + groupProviderTracker = new ServiceTracker<IBundleGroupProvider,IBundleGroupProvider>(context, filter, null); groupProviderTracker.open(); - logReaderTracker = new ServiceTracker(context, ExtendedLogReaderService.class.getName(), null); + logReaderTracker = new ServiceTracker<ExtendedLogReaderService,ExtendedLogReaderService>(context, ExtendedLogReaderService.class.getName(), null); logReaderTracker.open(); - extendedLogTracker = new ServiceTracker(context, ExtendedLogService.class.getName(), null); + extendedLogTracker = new ServiceTracker<ExtendedLogService,ExtendedLogService>(context, ExtendedLogService.class, null); extendedLogTracker.open(); - environmentTracker = new ServiceTracker(context, EnvironmentInfo.class.getName(), null); + environmentTracker = new ServiceTracker<EnvironmentInfo,EnvironmentInfo>(context, EnvironmentInfo.class, null); environmentTracker.open(); - debugTracker = new ServiceTracker(context, DebugOptions.class.getName(), null); + debugTracker = new ServiceTracker<DebugOptions,DebugOptions>(context, DebugOptions.class, null); debugTracker.open(); } private void startServices() { // The check for getProduct() is relatively expensive (about 3% of the headless startup), // so we don't want to enforce it here. - customPreferencesService = context.registerService(IProductPreferencesService.class.getName(), new ProductPreferencesService(), new Hashtable()); + customPreferencesService = context.registerService(IProductPreferencesService.class, new ProductPreferencesService(), new Hashtable<String,String>()); // Only register this interface if compatibility is installed - the check for a bundle presence // is a quick test that doesn't consume much. if (getBundle(CompatibilityHelper.PI_RUNTIME_COMPATIBILITY) != null) - legacyPreferencesService = context.registerService(ILegacyPreferences.class.getName(), new InitLegacyPreferences(), new Hashtable()); + legacyPreferencesService = context.registerService(ILegacyPreferences.class, new InitLegacyPreferences(), new Hashtable<String, String>()); } private void stopServices() { diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/Log.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/Log.java index e57401ec3..cf86417eb 100644 --- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/Log.java +++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/Log.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2012 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -23,7 +23,7 @@ import org.osgi.service.log.LogEntry; public class Log implements ILog, SynchronousLogListener, LogFilter { final Bundle bundle; private final Logger logger; - private final Set logListeners = new HashSet(5); + private final Set<ILogListener> logListeners = new HashSet<ILogListener>(5); public Log(Bundle plugin, Logger logger) { if (plugin == null) @@ -82,7 +82,7 @@ public class Log implements ILog, SynchronousLogListener, LogFilter { // create array to avoid concurrent access ILogListener[] listeners; synchronized (logListeners) { - listeners = (ILogListener[]) logListeners.toArray(new ILogListener[logListeners.size()]); + listeners = logListeners.toArray(new ILogListener[logListeners.size()]); } for (int i = 0; i < listeners.length; i++) { final ILogListener listener = listeners[i]; diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PerformanceStatsProcessor.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PerformanceStatsProcessor.java index c44d4810d..6b72add43 100644 --- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PerformanceStatsProcessor.java +++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PerformanceStatsProcessor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2011 IBM Corporation and others. + * Copyright (c) 2005, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,8 +11,7 @@ package org.eclipse.core.internal.runtime; import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.HashMap; +import java.util.*; import org.eclipse.core.runtime.*; import org.eclipse.core.runtime.PerformanceStats.PerformanceListener; import org.eclipse.core.runtime.jobs.Job; @@ -33,13 +32,13 @@ public class PerformanceStatsProcessor extends Job { /** * Events that have occurred but have not yet been broadcast. */ - private final ArrayList changes = new ArrayList(); + private final ArrayList<PerformanceStats> changes = new ArrayList<PerformanceStats>(); /** * Event failures that have occurred but have not yet been broadcast. * Maps (PerformanceStats -> Long). */ - private final HashMap failures = new HashMap(); + private final HashMap<PerformanceStats,Long> failures = new HashMap<PerformanceStats,Long>(); /** * Event listeners. @@ -147,13 +146,13 @@ public class PerformanceStatsProcessor extends Job { setPriority(DECORATE); BundleContext context = PlatformActivator.getContext(); String filter = '(' + FrameworkLog.SERVICE_PERFORMANCE + '=' + Boolean.TRUE.toString() + ')'; - ServiceReference[] references; + Collection<ServiceReference<FrameworkLog>> references; FrameworkLog perfLog = null; try { - references = context.getServiceReferences(FrameworkLog.class.getName(), filter); - if (references != null && references.length > 0) { + references = context.getServiceReferences(FrameworkLog.class, filter); + if (references != null && !references.isEmpty()) { //just take the first matching service - perfLog = (FrameworkLog) context.getService(references[0]); + perfLog = context.getService(references.iterator().next()); //make sure correct location is set IPath logLocation = Platform.getLogFileLocation(); logLocation = logLocation.removeLastSegments(1).append("performance.log"); //$NON-NLS-1$ @@ -192,10 +191,10 @@ public class PerformanceStatsProcessor extends Job { PerformanceStats[] failedEvents; Long[] failedTimes; synchronized (this) { - events = (PerformanceStats[]) changes.toArray(new PerformanceStats[changes.size()]); + events = changes.toArray(new PerformanceStats[changes.size()]); changes.clear(); - failedEvents = (PerformanceStats[]) failures.keySet().toArray(new PerformanceStats[failures.size()]); - failedTimes = (Long[]) failures.values().toArray(new Long[failures.size()]); + failedEvents = failures.keySet().toArray(new PerformanceStats[failures.size()]); + failedTimes = failures.values().toArray(new Long[failures.size()]); failures.clear(); } diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformActivator.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformActivator.java index e9fb558f1..4a6b2eefb 100644 --- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformActivator.java +++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformActivator.java @@ -11,9 +11,10 @@ *******************************************************************************/ package org.eclipse.core.internal.runtime; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.Plugin; import org.eclipse.equinox.internal.app.CommandLineArgs; -import org.osgi.framework.*; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; /** * Activator for the Eclipse runtime. diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/IPluginDescriptor.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/IPluginDescriptor.java index 77d0088d8..b63febaa9 100644 --- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/IPluginDescriptor.java +++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/IPluginDescriptor.java @@ -519,5 +519,5 @@ public interface IPluginDescriptor { * where <code>bundle</code> is the bundle associated with * the relevant plug-in. */ - public URL find(IPath path, Map override); + public URL find(IPath path, Map<String,String> override); } diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/PerformanceStats.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/PerformanceStats.java index 2e2e2b668..195a3f931 100644 --- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/PerformanceStats.java +++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/PerformanceStats.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Platform.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Platform.java index 61c1dd422..794ef80cc 100644 --- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Platform.java +++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Platform.java @@ -475,7 +475,7 @@ public final class Platform { * Consider using <code>ISecurePreferences#put(String, String, boolean)</code> as a replacement of this method. * This API will be deleted in a future release. See bug 370248 for details. */ - public static void addAuthorizationInfo(URL serverUrl, String realm, String authScheme, Map info) throws CoreException { + public static void addAuthorizationInfo(URL serverUrl, String realm, String authScheme, Map<String,String> info) throws CoreException { AuthorizationHandler.addAuthorizationInfo(serverUrl, realm, authScheme, info); } @@ -618,7 +618,7 @@ public final class Platform { * Consider using <code>ISecurePreferences#get(String, String)</code> as a replacement of this method. * This API will be deleted in a future release. See bug 370248 for details. */ - public static Map getAuthorizationInfo(URL serverUrl, String realm, String authScheme) { + public static Map<String,String> getAuthorizationInfo(URL serverUrl, String realm, String authScheme) { return AuthorizationHandler.getAuthorizationInfo(serverUrl, realm, authScheme); } @@ -753,7 +753,7 @@ public final class Platform { if (compatibility == null) throw new IllegalStateException(); - Class oldInternalPlatform = null; + Class<?> oldInternalPlatform = null; try { oldInternalPlatform = compatibility.loadClass("org.eclipse.core.internal.plugins.InternalPlatform"); //$NON-NLS-1$ Method getPluginRegistry = oldInternalPlatform.getMethod("getPluginRegistry"); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Plugin.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Plugin.java index 49f8d9e3d..9da7cc836 100644 --- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Plugin.java +++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Plugin.java @@ -135,7 +135,7 @@ public abstract class Plugin implements BundleActivator { /** * DebugOptions service tracker */ - private ServiceTracker debugTracker = null; + private ServiceTracker<DebugOptions,DebugOptions> debugTracker = null; /** The plug-in descriptor. * @deprecated Marked as deprecated to suppress deprecation warnings. @@ -260,7 +260,7 @@ public abstract class Plugin implements BundleActivator { * @return a URL for the given path or <code>null</code> * @deprecated use {@link FileLocator#find(Bundle, IPath, Map)} */ - public final URL find(IPath path, Map override) { + public final URL find(IPath path, Map<String,String> override) { return FileLocator.find(getBundle(), path, override); } @@ -580,10 +580,10 @@ public abstract class Plugin implements BundleActivator { BundleContext context = debugBundle.getBundleContext(); if (context == null) return null; - debugTracker = new ServiceTracker(context, DebugOptions.class.getName(), null); + debugTracker = new ServiceTracker<DebugOptions,DebugOptions>(context, DebugOptions.class.getName(), null); debugTracker.open(); } - return (DebugOptions) this.debugTracker.getService(); + return this.debugTracker.getService(); } /** diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Preferences.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Preferences.java index 9f7530da9..1d3076189 100644 --- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Preferences.java +++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Preferences.java @@ -1211,7 +1211,7 @@ public class Preferences { * @return an array of property names */ public String[] propertyNames() { - return (String[]) properties.keySet().toArray(EMPTY_STRING_ARRAY); + return properties.keySet().toArray(EMPTY_STRING_ARRAY); } /** @@ -1221,7 +1221,7 @@ public class Preferences { * @return an array of property names */ public String[] defaultPropertyNames() { - return (String[]) defaultProperties.keySet().toArray(EMPTY_STRING_ARRAY); + return defaultProperties.keySet().toArray(EMPTY_STRING_ARRAY); } /** |