JDK-6996759 : Diamond syntax in certain cases causes compiler error.
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2010-11-02
  • Updated: 2012-03-20
  • Resolved: 2010-11-08
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b116)
Java HotSpot(TM) 64-Bit Server VM (build 20.0-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Linux 64bit 2.6.35

A DESCRIPTION OF THE PROBLEM :
In certain cases, the usage of the diamond inference operator causes a compiler error causes compiler error: "cannot infer type arguments". Please see example source code.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No error in example code at all.
ACTUAL -
Second occurrence of diamond operator causes error "cannot infer type arguments for SimpleFileVisitor<>"

ERROR MESSAGES/STACK TRACES THAT OCCUR :
cannot infer type arguments for SimpleFileVisitor<>

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.nio.file.*;

public final class _DiamondSyntaxErrors {
  public interface InterfaceA<T> {
  }

  public abstract static class ClassA<T>
      implements InterfaceA<T> {
    protected ClassA() {
    }
  }

  public static void main(String... args) {
    // no error
    InterfaceA<Path> classA = new ClassA<>() {
    };

    // error: cannot infer type arguments for SimpleFileVisitor<>
    FileVisitor<Path> visitor = new SimpleFileVisitor<>() {
    };
  }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Unknown