Hi Stephane,
On 25/05/2009 14:53, Stephane Drapeau wrote:
Hi Lionel,
You're right about these 3 issues. Can you open a bug?
Thanks for having solved these issues.
I'd like to report another issue which I'm facing. It is related to the
ComponentContext interface and the 2 cast methods which are declared:
-------------
<B, R extends CallableReference<B>> R cast(B target) throws
IllegalArgumentException;
<B> ServiceReference<B> cast(B target) throws IllegalArgumentException;
-------------
These two declarations are apparently consistent with the specs (see p13
of Java Client and Implementation Specification 1.00). I'm saying
apparently since the comment which follows on p14 only provides some
information for the 1st one.
-------------
cast(B target) - Casts a type-safe reference to a CallableReference
-------------
So it is not really clear to me whether the intent of the authors was to
really define 2 methods or if the 2nd version can be considered as a
typo which should have been removed from the final version of the specs.
Anyway, assuming that both versions should be present, the issue arises
when compiling some code which uses ComponentContext. E.g.
-------------
ComponentContext cc = null; // a non-null value fits also
A a = new A();
ServiceReference<A> sr = cc.cast(a);
-------------
Both Sun JDK 5 and 6 javac (on Windows - I haven't try but I guess this
is the same under Linux and MacOS) fails with the following error message:
-------------
src\org\osoa\sca\A.java:8: reference to cast is ambiguous, both method
<B,R>cast(B) in org.osoa.sca.ComponentContext and method <B>cast(B) in
org.osoa.sca.ComponentContext match
ServiceReference<A> sr = cc.cast(a);
^
1 error
-------------
JDK is unable to lookup the correct version of cast. JDT is more
optimistic and compiles the code, but in fact, select the first version
(which is wrong since the intent is here to select the 2nd one.)
So my first remark is: is there a Java generics guru who can explain how
to use these two versions correctly?
My second remark consists in reporting that some friends chose to keep
only the first version of the cast method and to remove the second one:
see
http://svn.apache.org/repos/asf/tuscany/java/sca/modules/sca-api-osoa/src/main/java/org/osoa/sca/ComponentContext.java
I find that this choice is the most logical one. I would then suggest
that we consider that this is the de facto standard and that the 2nd
version of cast() should be removed from the
org.eclipse.stp.sca.osoa.java module.
WDYT?
Lionel.