javac vs. eclipse: another try
This is a multi-part message in MIME format.
--------------030201070802050009030108
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
(this time with attachments)
Hello all,
a while ago I reported I had problems getting a project to compile from
the command line which eclipse compiles fine. There seem to be some
differences on how they handle generics (see
http://groups.google.com/group/comp.lang.java.programmer/browse_thread/thread/faca2633a3adeef4/ce48585945d47a0f?#ce48585945d47a0f)
Now I trimmed down my problem to the first error I encounter and want
your advice on how I can solve this.
So I would like to get this running with javac, but preferable also get
to know which of both is wrong, so I can file a bug for them.
So here is the problem: I attached three files: ClosureUtils invokes
ChainedClosure.getInstance(Closure<? super I> closure1, Closure<? super
I> closure2).
javac gives following error:
hendrik@lichtenstein:~/workspace/test Java> javac -classpath
/home/hendrik/workspace/test\ Java/ collections/ClosureUtils.java
collections/ClosureUtils.java:8: <I>getInstance(collections.Closure<?
super I>,collections.Closure<? super I>) in
collections.functors.ChainedClosure cannot be applied to
(collections.Closure<capture of ? super I>,collections.Closure<capture
of ? super I>)
return ChainedClosure.getInstance(closure1, closure2);
^
1 error
TIA, H.
- --
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
iD8DBQFFE8DSf8wVQAnB0SYRAj1GAJ9yPtkprRNtqWSPYMJwCMr66gLBXACglInl
GqxBzg/qSp/1rvAh1j6ZnoU=
=U57F
-----END PGP SIGNATURE-----
--
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
--------------030201070802050009030108
Content-Type: text/x-java;
name="ChainedClosure.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="ChainedClosure.java"
package closure;
import java.io.Serializable;
public class ChainedClosure<I> implements Closure<I>, Serializable {
private final Closure<? super I>[] iClosures;
@SuppressWarnings("unchecked")
public static <I> Closure<I> getInstance(Closure<? super I> closure1, Closure<? super I> closure2) {
if (closure1 == null || closure2 == null) {
throw new IllegalArgumentException("Closures must not be null");
}
Closure<I>[] closures = new Closure[] { closure1, closure2 };
return new ChainedClosure<I>(closures);
}
public ChainedClosure(Closure<? super I>[] closures) {
super();
iClosures = closures;
}
public void execute(I input) {
for (int i = 0; i < iClosures.length; i++) {
iClosures[i].execute(input);
}
}
}
--------------030201070802050009030108
Content-Type: text/x-java;
name="Closure.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="Closure.java"
package closure;
public interface Closure<I> {
public void execute(I input);
}
--------------030201070802050009030108
Content-Type: text/x-java;
name="ClosureUtils.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="ClosureUtils.java"
package closure;
public class ClosureUtils {
public static <I> Closure<I> chainedClosure(Closure<? super I> closure1, Closure<? super I> closure2) {
return ChainedClosure.getInstance(closure1, closure2);
}
}
--------------030201070802050009030108--