JDK-5042920 : (inference) underconstrained type variable cannot be dereferenced
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_8
  • CPU: generic
  • Submitted: 2004-05-06
  • Updated: 2004-09-06
  • Resolved: 2004-09-06
Related Reports
Duplicate :  
Description
The following program is correct but rejected by javac:

X.java:3: X cannot be dereferenced
       String s = new X().foo().bar();
                  ^

/////////////////////////////////////////
public class X {
   public static void main(String[] args) {
       String s = new X().foo().bar();
   }
   <V extends X> V foo() {
       return null;
     }
   String bar() {
       return "";
   }
}

Comments
EVALUATION A bug. Workaround by assigning the value that "can't be dereferenced" to a temporary variable: X x = new X().foo(); String s = x.bar(); ###@###.### 2004-05-05
05-05-2004