Need some help to get this compiled with javac -- Eclipse reportsno errors

H

Hendrik Maryns

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I have some issues where Eclipse compiles fine, but javac gives errors.
This seems to be a bug in both javac and the jls, but I want to get my
classes compiled anyway, be it in a buggy compiler...

I distilled the main problem down to this:

===========================
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.execute(input);
}
}

}
================================
package closure;

public interface Closure<I> {

public void execute(I input);

}
===============================
package closure;

public class ClosureUtils {

public static <I> Closure<I> chainedClosure(Closure<? super I>
closure1, Closure<? super I> closure2) {
return ChainedClosure.getInstance(closure1, closure2);
}

}

Eclipse compiles this without problems, javac gives the following error:

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

See Eclipse bugs 158531 and 158519, and java bugs 6302954, 6369605 and
6369608.

I’d be grateful for some hints on how to get this compiled with javac.

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)

iD8DBQFFGOAZe+7xMGD3itQRAvGYAJ9plCfWPuuh3cWZb+co3ra1n24uRgCfbpsf
yrc1t6e+duTVn228Sdm2zTk=
=D0mY
-----END PGP SIGNATURE-----
 
T

Tim Hallwyl

Hendrik said:
I have some issues where Eclipse compiles fine, but javac gives errors.
Are you using the same JDK in Eclipse as outside? Or at least same version?

--tim
 
H

Hendrik Maryns

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tim Hallwyl schreef:
Are you using the same JDK in Eclipse as outside? Or at least same version?

Yes. But Eclipse uses its own compiler, of course. Both are 1.5. As I
said, it is a bug in javac, but I want to work around it.

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)

iD8DBQFFGkZme+7xMGD3itQRAmzLAJsHDhrQneIFD9AimCmoJVzEQSRNcgCfRXi/
2Am7ZWs8tQOFmHSWuZxT+Vo=
=npaM
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top