From 26bef5d3212c24dca5fc5ff0816728f59c247bbf Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Thu, 11 Jun 2015 14:13:55 +0100 Subject: [PATCH] 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 --- .../cdt/dsf/gdb/launching/LaunchMessages.java | 7 ++++--- .../dsf/mi/service/MIBreakpointsSynchronizer.java | 7 ++++++- .../dsf/mi/service/command/AbstractMIControl.java | 7 ++++--- .../cdt/dsf/datamodel/CompositeDMContext.java | 5 +++-- .../cdt/dsf/service/AbstractDsfService.java | 7 ++++--- .../cdt/dsf/service/DsfServicesTracker.java | 15 ++++++++------- 6 files changed, 29 insertions(+), 19 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/LaunchMessages.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/LaunchMessages.java index ed805b97235..9918bf15349 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/LaunchMessages.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/LaunchMessages.java @@ -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) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointsSynchronizer.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointsSynchronizer.java index d0aa81b3f35..f80d6284d0d 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointsSynchronizer.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointsSynchronizer.java @@ -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); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java index 9e20330e165..7cbaf6423bd 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java @@ -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); diff --git a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/datamodel/CompositeDMContext.java b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/datamodel/CompositeDMContext.java index c2a2b4d5357..c0f26c7df59 100644 --- a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/datamodel/CompositeDMContext.java +++ b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/datamodel/CompositeDMContext.java @@ -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 getAdapter(Class adapterType) { IDMContext[] parents = getParents(); if (parents.length > 0) { return parents[0].getAdapter(adapterType); diff --git a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/service/AbstractDsfService.java b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/service/AbstractDsfService.java index c8c08072686..7c1a458b325 100644 --- a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/service/AbstractDsfService.java +++ b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/service/AbstractDsfService.java @@ -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; } } \ No newline at end of file diff --git a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/service/DsfServicesTracker.java b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/service/DsfServicesTracker.java index 18b28162ce0..23906b0dcdf 100644 --- a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/service/DsfServicesTracker.java +++ b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/service/DsfServicesTracker.java @@ -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 fServiceReferences = new HashMap(); - private final Map fServices = new HashMap(); + private final Map> fServiceReferences = new HashMap>(); + private final Map,Object> fServices = new HashMap,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> itr = fServiceReferences.entrySet().iterator(); itr.hasNext();) { - Map.Entry entry = itr.next(); + for (Iterator>> itr = fServiceReferences.entrySet().iterator(); itr.hasNext();) { + Map.Entry> entry = itr.next(); if ( entry.getValue().equals(event.getServiceReference()) ) { itr.remove(); } @@ -221,7 +222,7 @@ public class DsfServicesTracker { */ @SuppressWarnings("unchecked") public V getService(Class 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 itr = fServices.keySet().iterator(); itr.hasNext();) { + for (Iterator> itr = fServices.keySet().iterator(); itr.hasNext();) { fBundleContext.ungetService(itr.next()); } } catch (IllegalStateException e) {