Bug 317173 - cleanup warnings

- Add generics for ServiceRegistration and ServiceReference
  (added <?>), See Bug 322007 which added generics to OSGI
- Add generics for getAdapter, See Bug Bug 442021
- Fix calls to MessageFormat.format()
- Cross reference some unused/commented out code for dprintf with
  associated @SuppressWarnings("unused")

Change-Id: I4bacb3b37b69c97ab35615413f0f1f3e71aa2092
Signed-off-by: Jonah Graham <jonah@kichwacoders.com>
This commit is contained in:
Jonah Graham 2015-06-11 14:13:55 +01:00 committed by Gerrit Code Review @ Eclipse.org
parent 835288f558
commit 26bef5d321
6 changed files with 29 additions and 19 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2009 QNX Software Systems and others.
* Copyright (c) 2008, 2015 QNX Software Systems 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
@ -8,6 +8,7 @@
* Contributors:
* QNX Software Systems - initial API and implementation
* Ericsson - Update for DSF
* Jonah Graham (Kichwa Coders) - Bug 317173 - cleanup warnings
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.launching;
@ -31,11 +32,11 @@ public class LaunchMessages {
private LaunchMessages() {}
public static String getFormattedString(String key, String arg) {
return MessageFormat.format(getString(key), new String[]{arg});
return MessageFormat.format(getString(key), arg);
}
public static String getFormattedString(String key, String[] args) {
return MessageFormat.format(getString(key), args);
return MessageFormat.format(getString(key), (Object[])args);
}
public static String getString(String key) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2014 Mentor Graphics and others.
* Copyright (c) 2012, 2015 Mentor Graphics 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
@ -10,6 +10,7 @@
* Salvatore Culcasi (ST) - Bug 407163 - GDB Console: breakpoint not added with MinGW and gdb
* Marc Khouzam (Ericsson) - Update breakpoint handling for GDB >= 7.4 (Bug 389945)
* Marc Khouzam (Ericsson) - Support for dynamic printf (Bug 400628)
* Jonah Graham (Kichwa Coders) - Bug 317173 - cleanup warnings
*******************************************************************************/
package org.eclipse.cdt.dsf.mi.service;
@ -737,6 +738,8 @@ public class MIBreakpointsSynchronizer extends AbstractDsfService implements IMI
return createPlatformAddressDynamicPrintf(fileName, miBpt);
}
// TODO This is currently causing problems because we think a normal dprintf is a function one
// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=400628#c16 which says:
// "synchronization of function dprintf does not work"
// else if (isFunctionBreakpoint(miBpt)) {
// return createPlatformFunctionDynamicPrintf(fileName, miBpt);
// }
@ -774,6 +777,8 @@ public class MIBreakpointsSynchronizer extends AbstractDsfService implements IMI
}
}
// Unused, see TODO in createPlatformDynamicPrintf and Bug 400628 Comment 16
@SuppressWarnings("unused")
private ICBreakpoint createPlatformFunctionDynamicPrintf(String fileName, MIBreakpoint miBpt) throws CoreException {
IResource resource = getResource(fileName);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2012 Wind River Systems and others.
* Copyright (c) 2006, 2015 Wind River Systems 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
@ -12,6 +12,7 @@
* Onur Akdemir (TUBITAK BILGEM-ITI) - Multi-process debugging (Bug 237306)
* Marc Khouzam (Ericsson) - New method to properly created ErrorThread (Bug 350837)
* Jason Litton (Sage Electronic Engineering, LLC) - Use Dynamic Tracing option (Bug 379169)
* Jonah Graham (Kichwa Coders) - Bug 317173 - cleanup warnings
*******************************************************************************/
package org.eclipse.cdt.dsf.mi.service.command;
@ -819,7 +820,7 @@ public abstract class AbstractMIControl extends AbstractDsfService
clientMsg.append("Error message from debugger back end:\n"); //$NON-NLS-1$
if (parameters != null) {
try {
clientMsg.append(MessageFormat.format(message, parameters));
clientMsg.append(MessageFormat.format(message, (Object[])parameters));
} catch(IllegalArgumentException e2) {
// Message format string invalid. Fallback to just appending the strings.
clientMsg.append(message);
@ -870,7 +871,7 @@ public abstract class AbstractMIControl extends AbstractDsfService
if (message != null) {
if (parameters != null) {
try {
clientMsg.append(MessageFormat.format(message, parameters));
clientMsg.append(MessageFormat.format(message, (Object[])parameters));
} catch(IllegalArgumentException e2) {
// Message format string invalid. Fallback to just appending the strings.
clientMsg.append(message);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2009 Wind River Systems and others.
* Copyright (c) 2007, 2015 Wind River Systems 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
@ -7,6 +7,7 @@
*
* Contributors:
* Wind River Systems - initial API and implementation
* Jonah Graham (Kichwa Coders) - Bug 317173 - cleanup warnings
*******************************************************************************/
package org.eclipse.cdt.dsf.datamodel;
@ -75,7 +76,7 @@ public class CompositeDMContext implements IDMContext {
* @see #getSessionId()
*/
@Override
public Object getAdapter(Class adapterType) {
public <T> T getAdapter(Class<T> adapterType) {
IDMContext[] parents = getParents();
if (parents.length > 0) {
return parents[0].getAdapter(adapterType);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2010 Wind River Systems and others.
* Copyright (c) 2006, 2015 Wind River Systems 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
@ -7,6 +7,7 @@
*
* Contributors:
* Wind River Systems - initial API and implementation
* Jonah Graham (Kichwa Coders) - Bug 317173 - cleanup warnings
*******************************************************************************/
package org.eclipse.cdt.dsf.service;
@ -41,7 +42,7 @@ abstract public class AbstractDsfService
private int fStartupNumber;
/** Registration object for this service. */
private ServiceRegistration fRegistration;
private ServiceRegistration<?> fRegistration;
/** Tracker for services that this service depends on. */
private DsfServicesTracker fTracker;
@ -264,5 +265,5 @@ abstract public class AbstractDsfService
}
/** Returns the registration object that was obtained when this service was registered */
protected ServiceRegistration getServiceRegistration() { return fRegistration; }
protected ServiceRegistration<?> getServiceRegistration() { return fRegistration; }
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2010 Wind River Systems and others.
* Copyright (c) 2009, 2015 Wind River Systems 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
@ -7,6 +7,7 @@
*
* Contributors:
* Wind River Systems - initial API and implementation
* Jonah Graham (Kichwa Coders) - Bug 317173 - cleanup warnings
*******************************************************************************/
package org.eclipse.cdt.dsf.service;
@ -90,8 +91,8 @@ public class DsfServicesTracker {
private final String fSessionId;
private volatile boolean fDisposed = false;
private final BundleContext fBundleContext;
private final Map<ServiceKey,ServiceReference> fServiceReferences = new HashMap<ServiceKey,ServiceReference>();
private final Map<ServiceReference,Object> fServices = new HashMap<ServiceReference,Object>();
private final Map<ServiceKey,ServiceReference<?>> fServiceReferences = new HashMap<ServiceKey,ServiceReference<?>>();
private final Map<ServiceReference<?>,Object> fServices = new HashMap<ServiceReference<?>,Object>();
private final String fServiceFilter;
private final ServiceListener fListner = new ServiceListener() {
@ -127,8 +128,8 @@ public class DsfServicesTracker {
};
private void handleUnregisterEvent(ServiceEvent event) {
for (Iterator<Map.Entry<ServiceKey, ServiceReference>> itr = fServiceReferences.entrySet().iterator(); itr.hasNext();) {
Map.Entry<ServiceKey, ServiceReference> entry = itr.next();
for (Iterator<Map.Entry<ServiceKey, ServiceReference<?>>> itr = fServiceReferences.entrySet().iterator(); itr.hasNext();) {
Map.Entry<ServiceKey, ServiceReference<?>> entry = itr.next();
if ( entry.getValue().equals(event.getServiceReference()) ) {
itr.remove();
}
@ -221,7 +222,7 @@ public class DsfServicesTracker {
*/
@SuppressWarnings("unchecked")
public <V> V getService(Class<V> serviceClass, String filter) {
ServiceReference serviceRef = getServiceReference(serviceClass, filter);
ServiceReference<?> serviceRef = getServiceReference(serviceClass, filter);
if (serviceRef == null) {
return null;
} else {
@ -270,7 +271,7 @@ public class DsfServicesTracker {
private void doDispose() {
try {
fBundleContext.removeServiceListener(fListner);
for (Iterator<ServiceReference> itr = fServices.keySet().iterator(); itr.hasNext();) {
for (Iterator<ServiceReference<?>> itr = fServices.keySet().iterator(); itr.hasNext();) {
fBundleContext.ungetService(itr.next());
}
} catch (IllegalStateException e) {