You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by ant elder <an...@gmail.com> on 2006/08/11 14:03:31 UTC
Compile errors in Eclipse
When I set up the Tuscany eclipse projects with mvn -Peclipse
eclipse:eclipse there are some compile errors in the eclipse projects.
One in the Groovy container:
The method andReturn(capture-of ?) in the type
IExpectationSetters<capture-of ?> is not applicable for the arguments
(String) PropertyTestCase.java
groovy/src/test/java/org/apache/tuscany/container/groovy line 52 11
August 2006 12:54:04 11027
and half a dozen of these errors in the databinding code:
Type mismatch: cannot convert from DirectedGraph<String,Object>.Vertex to
DirectedGraph<V,E>.Vertex DirectedGraphTestCase.java
databinding-framework/src/test/java/org/apache/tuscany/databinding/impl
line 47 11 August 2006 12:53:36 10535
The code compiles fine outside of eclipse with mvn, so I guess this is an
eclipse compiler thing. Do others see these in eclipse or know how to fix
them?
...ant
Re: Compile errors in Eclipse
Posted by Yang ZHONG <le...@gmail.com>.
Thank Raymond for showing me the concerning code (andReturn), I feel SCA has
quite some misusages of <?> on Generic and compilers failing to complain
have defect(s).
Someone may want to open defect against corresponding compiler, I'll just
focus on illustrating the <?> misusage.
andReturn itself is declared in a Generic class:
class MyClass<T>
{
andReturn(T)
}
that's fine, however it's instantiated as
var = new MyClass<?>
or
class ChildClass extends MyClass<?>
therefore the signature becomes
andReturn(?)
No matter such signature comes from instantiation or original design, it may
be caused by misunderstanding of <?>.
<?> denotes *some* type, *not* any type which Object does.
Some type means some type, neither specifically String nor specifically
ArrayList, therefore
andReturn("bar")
is a *invalid* call and all compilers are supposed to catch that error which
is one of the beauties to introduce Generic.
For API design who wants any type instead of some type, Object can be used
or use *no* parameter to instantiate Generic such as
var = new MyClass
and
class ChildClass extends MyClass
Similarly, Bounded Wildcards is also *some* bounded type, *not* any bounded
type.
e.g. "? extends List" denotes some List subclass, not any List subclass.
I'm also pasting a paragraph for your reference, from
http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf
Collection<?> c = new ArrayList<String>();
c.add(new Object()); // compile time error
Since we don't know what the element type of c stands for, we cannot add
objects
to it. The add() method takes arguments of type E, the element type of the
collection.
When the actual type parameter is ?, it stands for some unknown type. Any
parameter
we pass to add would have to be a subtype of this unknown type. Since we
don't know
what type that is, we cannot pass anything in. The sole exception is null,
which is a
member of every type.
--
Yang ZHONG
Re: Compile errors in Eclipse
Posted by Yang ZHONG <le...@gmail.com>.
Code analyzing might be done by IDE, however I feel compilation is done by
compiler.
I know Eclpse can be configured with a compiler, and I guess IDEA can too.
I feel the compilation errors are from configured compiler, might not be an
Eclipse fault.
BTW, the complaints might be correct, and the compilers failing to report
might have a defect.
I don't have the andReturn signature. If it's
andReturn(? extends Object)
or
andReturn(? extends String)
I agree andReturn("bar") should be a valid call. However, if it's
andReturn(?)
I don't think andReturn("bar") is a valid call and I think the signature can
be changed to
andReturn(Object)
.
--
Yang ZHONG
Re: Compile errors in Eclipse
Posted by Jeremy Boynes <jb...@apache.org>.
On Aug 11, 2006, at 9:48 AM, Raymond Feng wrote:
> Hi,
>
> I'm seeing the same error on Groovy container inside Eclipse. And
> the following diff fixes the complaint (I assume the existing code
> is valid).
>
> - expect(factory.getInstance()).andReturn("bar");
> + expect((String) factory.getInstance()).andReturn("bar");
>
> I also ran into an issue that Eclipse cannot recognize Map<String,
> InboudWire>.
>
> It seems that it's an eclipse bug. BTW, I'm running Eclipse 3.2.
FWIW I do not get any errors reported by IDEA. With IDEA and the
compiler not having a problem I would agree this looks like an
Eclipse bug.
--
Jeremy
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org
Re: Compile errors in Eclipse
Posted by Raymond Feng <en...@gmail.com>.
Hi,
I'm seeing the same error on Groovy container inside Eclipse. And the
following diff fixes the complaint (I assume the existing code is valid).
- expect(factory.getInstance()).andReturn("bar");
+ expect((String) factory.getInstance()).andReturn("bar");
I also ran into an issue that Eclipse cannot recognize Map<String,
InboudWire>.
It seems that it's an eclipse bug. BTW, I'm running Eclipse 3.2.
Thanks,
Raymond
----- Original Message -----
From: "ant elder" <an...@gmail.com>
To: <tu...@ws.apache.org>
Sent: Friday, August 11, 2006 5:03 AM
Subject: Compile errors in Eclipse
> When I set up the Tuscany eclipse projects with mvn -Peclipse
> eclipse:eclipse there are some compile errors in the eclipse projects.
>
> One in the Groovy container:
>
> The method andReturn(capture-of ?) in the type
> IExpectationSetters<capture-of ?> is not applicable for the arguments
> (String) PropertyTestCase.java
> groovy/src/test/java/org/apache/tuscany/container/groovy line 52 11
> August 2006 12:54:04 11027
>
> and half a dozen of these errors in the databinding code:
>
> Type mismatch: cannot convert from DirectedGraph<String,Object>.Vertex to
> DirectedGraph<V,E>.Vertex DirectedGraphTestCase.java
> databinding-framework/src/test/java/org/apache/tuscany/databinding/impl
> line 47 11 August 2006 12:53:36 10535
>
> The code compiles fine outside of eclipse with mvn, so I guess this is an
> eclipse compiler thing. Do others see these in eclipse or know how to fix
> them?
>
> ...ant
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org