← Back to team overview

openjdk team mailing list archive

[Bug 611284] [NEW] OpenJDK compiler 6b20pre on Maverick doesn't recognize Generics Correctly

 

Public bug reported:

OpenJDK compiler can't unify custom type defined in signature by
generics.

Example:

import java.util.List;
public class GenericBug {
    public <X extends String, Y extends List<X>, Z extends List<X>> Z add(X element, Y list){
        list.add(element);
        return list;
    }
}

This code compile correctly on Sun JDK but OpenJDK compiler displays error:
"incompatible types
required: Z
found:    Y"
But btw Z and Y is the same type: List<X>

** Affects: openjdk-6 (Ubuntu)
     Importance: Undecided
         Status: New

** Description changed:

  OpenJDK compiler can't unify custom type defined in signature by
  generics.
  
  Example:
  
  import java.util.List;
  public class GenericBug {
-     public <X extends List<?>, Y extends List<X>, Z extends List<X>> Z add(X element, Y list){
-         list.add(element);
-         return list;
-     }
+     public <X extends List<?>, Y extends List<X>, Z extends List<X>> Z add(X element, Y list){
+         list.add(element);
+         return list;
+     }
  }
  
- This code compile correctly on Sun JDK but OpenJDK compiler show error:
+ This code compile correctly on Sun JDK but OpenJDK compiler displays error:
  "incompatible types
  required: Z
  found:    Y"
  But btw Z and Y is the same type: List<X>

** Description changed:

  OpenJDK compiler can't unify custom type defined in signature by
  generics.
  
  Example:
  
  import java.util.List;
  public class GenericBug {
-     public <X extends List<?>, Y extends List<X>, Z extends List<X>> Z add(X element, Y list){
+     public <X extends String, Y extends List<X>, Z extends List<X>> Z add(X element, Y list){
          list.add(element);
          return list;
      }
  }
  
  This code compile correctly on Sun JDK but OpenJDK compiler displays error:
  "incompatible types
  required: Z
  found:    Y"
  But btw Z and Y is the same type: List<X>

-- 
OpenJDK compiler 6b20pre on Maverick doesn't recognize Generics Correctly
https://bugs.launchpad.net/bugs/611284
You received this bug notification because you are a member of OpenJDK,
which is subscribed to openjdk-6 in ubuntu.

Status in “openjdk-6” package in Ubuntu: New

Bug description:
OpenJDK compiler can't unify custom type defined in signature by generics.

Example:

import java.util.List;
public class GenericBug {
    public <X extends String, Y extends List<X>, Z extends List<X>> Z add(X element, Y list){
        list.add(element);
        return list;
    }
}

This code compile correctly on Sun JDK but OpenJDK compiler displays error:
"incompatible types
required: Z
found:    Y"
But btw Z and Y is the same type: List<X>







Follow ups

References