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

generic Collection compile issue

Jan Vervecken Journeyer
Currently Being Moderated
hi

In JDeveloper 10.1.3.2.0.4066 this code ...
package genericcollectioncompileissue;

import java.util.LinkedList;
import java.util.List;

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

     public static List<MyRowImpl> findMyRows()
     {
          return new LinkedList<MyRowImpl>();
     }

     public static void main(String[] pArguments)
     {
          System.out.println("GenericCollectionCompileIssue.main() : begin");
          List<MyRow> vMyRows = (List<MyRow>)findMyRows();
          System.out.println("GenericCollectionCompileIssue.main()"
               + " : vMyRows.size() = " + vMyRows.size());
          System.out.println("GenericCollectionCompileIssue.main() : end");
     }
}
... compiles and runs and produces this output:
GenericCollectionCompileIssue.main() : begin
GenericCollectionCompileIssue.main() : vMyRows.size() = 0
GenericCollectionCompileIssue.main() : end
But if you check the "Use Javac" Compiler option in the Project Properties dialog, the compiler reports an "inconvertible types" error at line 19.

How can this be explained?

many thanks
Jan Vervecken