Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Hendrik Maryns - 26 Sep 2006 09:08 GMT
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[i].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
Tim Hallwyl - 26 Sep 2006 17:46 GMT
> 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
Hendrik Maryns - 27 Sep 2006 10:37 GMT
Tim Hallwyl schreef:
>> 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?

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.