Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ecf-dev] Using native datatypes as method parameters

Title: Using native datatypes as method parameters
Fabian,

On 2/21/2011 4:37 AM, Fabian Meyer wrote:

Hi,

is it possible to use primitive data types as method parameter in ECF?


Currently...for remote services and the ECF generic provider...no.

Since 1.4 (or some earlier version...I can't remember exactly) Java does autoboxing of primitive data types, and this complicates things tremendously for the remote services use case.

Its possible that autoboxing could be worked around...contributions welcomed as always.

Scott



It seems to me that the deserialization of the shared message objects doesn't work correctly. A java.lang.NoSuchMethodException is always thrown, because ECF is trying to find a method with "class java.lang.Integer" as parameter data type instead of the primitive int data type. I wrote a little example application:

Interface:
public interface Test {
        void doSomething(int pBla);
}

Server:
public void start(BundleContext bundleContext) throws Exception {
        Activator.context = bundleContext;
        Properties props = new Properties();
        props.put("service.exported.interfaces", "*");         
        context.registerService(Test.class.getName(), new Test() {
               
                @Override
                public void doSomething(int pBla) {
                       
                }
        }, props);
}

Client:
Test t = (Test) getContext().getService(reference);
t.doSomething(42);

Throws:
java.lang.NoSuchMethodException: No such method: doSomething([class java.lang.Integer])
        at org.eclipse.ecf.core.sharedobject.SharedObjectMsg.doInvoke(SharedObjectMsg.java:310)
        at org.eclipse.ecf.core.sharedobject.SharedObjectMsg.invoke(SharedObjectMsg.java:290)
        at org.eclipse.ecf.provider.remoteservice.generic.RemoteServiceRegistrationImpl.callService(RemoteServiceRegistrationImpl.java:342)
        at org.eclipse.ecf.provider.remoteservice.generic.RegistrySharedObject$11.run(RegistrySharedObject.java:1423)
        at org.eclipse.equinox.concurrent.future.SingleOperationFuture$1.run(SingleOperationFuture.java:96)
        at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
        at org.eclipse.equinox.concurrent.future.SingleOperationFuture.runWithProgress(SingleOperationFuture.java:89)
        at org.eclipse.ecf.core.jobs.JobsExecutor.safeRun(JobsExecutor.java:52)
        at org.eclipse.ecf.core.jobs.JobsExecutor$1.run(JobsExecutor.java:79)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

Configuration:
JDK 1.6_20
ECF 1.4 with patch for Eclipse 3.5, 3.6


_______________________________________________ ecf-dev mailing list ecf-dev@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/ecf-dev


Back to the top