Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6360779

Compilation of java.util.concurrent.ExecutorService.invokeAll() fails.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P5 P5
    • None
    • 5.0
    • tools
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      Java 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
      Java Hotspot (TM) Client VM (build 1.5.0-b64, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      The following code fails to compile:

      // MyCallable.java
      import java.util.*;
      import java.util.concurrent.*;

      public class MyCallable<V extends Boolean> implements Callable<Boolean> {
      public Boolean call() {
      return new Boolean(true);
      }

      public static void main(String[] main) throws Exception {
      Collection<Callable> callables = new TreeSet<Callable>();
      callables.add(new MyCallable());
      ExecutorService executor = Executors.newCachedThreadPool();
      executor.invokeAll(callables);
      }
      }
      // end of MyCallable.java

      javac produces the following error message:
      MyCallable.java:13: cannot find symbol
      symbol : method invokeAll(java.util.Collection<java.util.concurrent.Callable>
      location: interface java.util.concurrent.ExecutorService

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      javac -source 1.5 MyCallable.java

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I was exepecting the code to compile without problems. The code compiles fine with the Eclipse compile on Eclipse on 3.1.0 build 200412162000
      ACTUAL -
      MyCallable.java:13: cannot find symbol
      symbol : method invokeAll(java.util.Collection<java.util.concurrent.Callable>
      location: interface java.util.concurrent.ExecutorService

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      MyCallable.java:13: cannot find symbol
      symbol : method invokeAll(java.util.Collection<java.util.concurrent.Callable>
      location: interface java.util.concurrent.ExecutorService

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      // MyCallable.java
      import java.util.*;
      import java.util.concurrent.*;

      public class MyCallable<V extends Boolean> implements Callable<Boolean> {
      public Boolean call() {
      return new Boolean(true);
      }

      public static void main(String[] main) throws Exception {
      Collection<Callable> callables = new TreeSet<Callable>();
      callables.add(new MyCallable());
      ExecutorService executor = Executors.newCachedThreadPool();
      executor.invokeAll(callables);
      }
      }
      // end of MyCallable.java
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      The code compile if you remove generics from the Collection callables.

            ahe Peter Ahe
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: