diff options
author | slewis | 2010-10-02 05:11:48 +0000 |
---|---|---|
committer | slewis | 2010-10-02 05:11:48 +0000 |
commit | 0d7d12423595c49e3b9f4bf529e064e6c55d808e (patch) | |
tree | f04baacd3d0e95ec2a206c4c5284f3386f0320d1 /framework | |
parent | a267e5544295a97c893caf8d62ce837f97c4a2ca (diff) | |
download | org.eclipse.ecf-0d7d12423595c49e3b9f4bf529e064e6c55d808e.tar.gz org.eclipse.ecf-0d7d12423595c49e3b9f4bf529e064e6c55d808e.tar.xz org.eclipse.ecf-0d7d12423595c49e3b9f4bf529e064e6c55d808e.zip |
Fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=326481
Diffstat (limited to 'framework')
2 files changed, 43 insertions, 1 deletions
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice/META-INF/MANIFEST.MF b/framework/bundles/org.eclipse.ecf.remoteservice/META-INF/MANIFEST.MF index c0c94bd08..7286e4bbf 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice/META-INF/MANIFEST.MF +++ b/framework/bundles/org.eclipse.ecf.remoteservice/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %plugin.name Bundle-SymbolicName: org.eclipse.ecf.remoteservice;singleton:=true -Bundle-Version: 4.1.0.qualifier +Bundle-Version: 4.2.0.qualifier Bundle-Activator: org.eclipse.ecf.internal.remoteservice.Activator Bundle-Vendor: %plugin.provider Bundle-Localization: plugin diff --git a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/AbstractRemoteService.java b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/AbstractRemoteService.java index 182e31341..a568ab857 100644 --- a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/AbstractRemoteService.java +++ b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/AbstractRemoteService.java @@ -282,4 +282,46 @@ public abstract class AbstractRemoteService implements IRemoteService, Invocatio a.log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, string)); } + /** + * @param aClass The Class providing method under question (Must not be null) + * @param aMethodName The method name to search for (Must not be null) + * @param someParameterTypes Method arguments (May be null or parameters) + * @return A match. If more than one method matched (due to overloading) an abitrary match is taken + * @throws NoSuchMethodException If a match cannot be found + * + * @since 4.2 + */ + public static Method getMethod(final Class aClass, String aMethodName, final Class[] someParameterTypes) throws NoSuchMethodException { + // no args makes matching simple + if (someParameterTypes == null || someParameterTypes.length == 0) { + return aClass.getMethod(aMethodName, (Class[]) null); + } + + // match parameters to determine callee + final Method[] methods = aClass.getMethods(); + final int parameterCount = someParameterTypes.length; + aMethodName = aMethodName.intern(); + + OUTER: for (int i = 0; i < methods.length; i++) { + Method candidate = methods[i]; + String candidateMethodName = candidate.getName().intern(); + Class[] candidateParameterTypes = candidate.getParameterTypes(); + int candidateParameterCount = candidateParameterTypes.length; + if (candidateParameterCount == parameterCount && aMethodName == candidateMethodName) { + for (int j = 0; j < candidateParameterCount; j++) { + Class<?> clazzA = candidateParameterTypes[j]; + Class clazzB = someParameterTypes[j]; + // clazzA must be non-null, but clazzB could be null (null given as parameter value) + // so in that case we consider it a match and continue + if (!(clazzB == null || clazzA.isAssignableFrom(clazzB))) { + continue OUTER; + } + } + return candidate; + } + } + // if no match has been found, fail with NSME + throw new NoSuchMethodException("No such method: " + aMethodName + "(" + Arrays.asList(someParameterTypes) + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } + } |