JDK-8027386 : Compiler regression error on multi-level abstract generic class with intersection types
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6u37,7u45,8
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2013-10-22
  • Updated: 2015-12-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbd_majorUnresolved
Related Reports
Blocks :  
Blocks :  
Blocks :  
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_37"
Java(TM) SE Runtime Environment (build 1.6.0_37-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01, mixed mode)

java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b109)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b51, mixed mode)

A DESCRIPTION OF THE PROBLEM :
This code used to compile in JDK 1.6.0_37, but does not compiles in JDK 1.7.0_45 nor in JDK 1.8.0-ea-b109:

interface A {}

abstract class B<X> {
    abstract X m();
}

abstract class C<Y> extends B<Y> {
    @Override
    abstract Y m();
}

class MyBug<Z extends C<?> & A> {}


REGRESSION.  Last worked in version 6u43

ADDITIONAL REGRESSION INFORMATION:
java version "1.6.0_37"
Java(TM) SE Runtime Environment (build 1.6.0_37-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01, mixed mode)

java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b109)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b51, mixed mode)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the program using JDK 1.7.0 or JDK 8 EA b109.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The code should compile in JDK 7 and JDK 8, as it used to compile in JDK 6.
ACTUAL -
error: m() in C cannot override m() in B
class MyBug<Z extends C<?> & A> {}
  return type CAP#1 is not compatible with CAP#2
  where Y,X are type-variables:
    Y extends Object declared in class C
    X extends Object declared in class B
  where CAP#1,CAP#2 are fresh type-variables:
    CAP#1 extends Object from capture of ?
    CAP#2 extends Object from capture of ?
1 error

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
interface A {}

abstract class B<X> {
    abstract X m();
}

abstract class C<Y> extends B<Y> {
    @Override
    abstract Y m();
}

class MyBug<Z extends C<?> & A> {}

---------- END SOURCE ----------
Comments
Reducing priority to 4, consistent with similar bugs of this nature. Impact=high (regression) Liklihood=low (corner case code) Workaround=low (use a raw type)
23-01-2015

Assigning to Dan Smith, as this deals with spec issues he is currently investigating.
21-01-2015

Release team: Approved for deferral.
21-11-2013

SQE/OK to defer
20-11-2013

8-defer-request: After discussions, the javac team has decided it is inadvisable to commit this patch for 8, for the following reasons: 1) This bug has apparently been around since the introduction of wildcards 2) We do not have good test coverage in the areas where collateral damage might occur from the patch 3) There is uncertainty as to what the spec says, which raises questions as to whether this is actually a bug.
13-11-2013

Under review, but requires development of a test.
12-11-2013

I have a patch that fixes this. However, it needs to be scrutinized for possible risks. Changing override behavior is a rather significant delta, and we need to consider whether it is advisable at this point.
12-11-2013

I had the same problem recently with a lambda bug and it was because of a missing substitution. Probably it's the same in this case. You can check the changeset for bug JDK-8025290. The substitution you probably need is the one in com/sun/tools/javac/comp/Check.java
11-11-2013

Apparent cause: distinct capture variables from the same wildcard are not equal. I am not certain why there end up being two distinct capture variables.
11-11-2013

Changed bug title, as this deals with intersection types. Union types are something else entirely.
11-11-2013

Do we know which bugID corresponds to the fix in some version of 6, thus it may have had an accompmanying test case(??). This is a regression in 7; is there a bugID for when it regressed in 7 (test case for the above fix would have failed) ?
06-11-2013

This is not just a windows issue.
04-11-2013

Possibly related to these issues, should wait until the change that caused them is backed out.
01-11-2013