JDK-8043374 : GLB ignores different parameterizations of the same type
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2014-05-16
  • 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.
Related Reports
Relates :  
Relates :  
The implementation of GLB (Types.glb, Types.union, etc.) compares types in terms of their classes.  If the classes are the same, the second type is discarded, regardless of its type arguments.

Test case:

public class MixedGlb {

    interface Box<T> { T get(); }
    static class Parent {}
    static class Child extends Parent { void poke() {} }

    interface I<X extends Box<Child>> {
        X get();

    <T extends Box<? extends Parent>> void test(I<? extends T> arg) {
        // expected: the type I<? extends T> is malformed, or the invocation succeeds
        // actual: error, cannot find method in type Parent

In the absence of wildcards, other checks (probably?) prevent this scenario from arising.  But wildcards introduce additional interesting use cases (for which the behavior is often unclear -- see JDK-7034922.

In any case, it's simply incorrect for glb to arbitrarily discard one of the types.
Probably best to do nothing here until JDK-7034922 is resolved.