JDK-8062900 : generic method return type inference regression
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7u72,8u25
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86_64
  • Submitted: 2014-11-04
  • Updated: 2014-11-10
  • Resolved: 2014-11-10
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :


A DESCRIPTION OF THE PROBLEM :
The following works in Eclipse and javac 1.8.0_11.
javac 1.8.0_20 and 1.8.0_25 are broken:

import java.util.LinkedList;

public class Test
{
	public static void main(String[] args)
	{
		LinkedList<Animal> l = new LinkedList<Animal>();
		l.add(l.getFirst().copy());
	}

	static class Animal
	{
		<T> T copy()
		{
			return null;
		}
	}
}

REGRESSION.  Last worked in version 8u11

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
javac compiles the class
ACTUAL -
Test.java:8: error: no suitable method found for add(Object)
                l.add(l.getFirst().copy());
                 ^
    method Collection.add(Animal) is not applicable
      (argument mismatch; Object cannot be converted to Animal)
    method List.add(Animal) is not applicable
      (argument mismatch; Object cannot be converted to Animal)
    method AbstractCollection.add(Animal) is not applicable
      (argument mismatch; Object cannot be converted to Animal)
    method AbstractList.add(Animal) is not applicable
      (argument mismatch; Object cannot be converted to Animal)
    method LinkedList.add(Animal) is not applicable
      (argument mismatch; Object cannot be converted to Animal)
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error

REPRODUCIBILITY :
This bug can be reproduced always.


Comments
Seems like a duplicate of JDK-8056014.
10-11-2014

The test case provided compiled successfully with JDK 8u5, 8u11 and 8u40 (b11). Whereas it failed with 7u72 and 8u25. Moving this further for evaluation.
05-11-2014