This discussion is archived
3 Replies Latest reply: Aug 14, 2007 3:53 AM by Jan Vervecken RSS

generic Comparator compile issue

Jan Vervecken Journeyer
Currently Being Moderated

In JDeveloper this code ...
package genericcomparatorcompileissue;

import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;

public class GenericComparatorCompileIssue
     private static interface MyRow {};
     private static class MyRowImpl implements MyRow {};

     private static class MyRowComparator implements Comparator<MyRowImpl>
          public int compare(MyRowImpl pFirstMyRowImpl, MyRowImpl pSecondMyRowImpl)
               return 0;

     public static void main(String[] pArguments)
          System.out.println("GenericComparatorCompileIssue.main() : begin");
          List<MyRow> vMyRowList = new LinkedList<MyRow>();
          Collections.sort(vMyRowList, new MyRowComparator());
          System.out.println("GenericComparatorCompileIssue.main() : end");
... compiles and runs and produces this output:
GenericComparatorCompileIssue.main() : begin
GenericComparatorCompileIssue.main() : end
But if you check the "Use Javac" Compiler option in the Project Properties dialog, the compiler reports a "cannot find symbol" error at line 25.

How can this be explained?

many thanks
Jan Vervecken