United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6996759 Diamond syntax in certain cases causes compiler error.
JDK-6996759 : Diamond syntax in certain cases causes compiler error.

Details
Type:
Bug
Submit Date:
2010-11-02
Status:
Closed
Updated Date:
2012-03-20
Project Name:
JDK
Resolved Date:
2010-11-08
Component:
tools
OS:
linux
Sub-Component:
javac
CPU:
x86
Priority:
P4
Resolution:
Duplicate
Affected Versions:
7
Fixed Versions:

Related Reports
Duplicate:

Sub Tasks

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

                                    

Comments



Hardware and Software, Engineered to Work Together