fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10.  
  11. public class LambdaTypeInferenceProblem {
  12.  
  13. class ATest<E extends B>
  14. {
  15.  
  16. private E find(C<? extends E> CObj)
  17. {
  18. return null;
  19. }
  20.  
  21. public void findCs(List<? extends C<? extends E>> cList)
  22. {
  23.  
  24. find(new C());// This compiles fine
  25. for (C cObj : cList)
  26. {
  27. E cachedEntity = find(cObj); // This cause error in java 8 but works fine in java 7
  28. }
  29. }
  30. }
  31.  
  32. class B{
  33. }
  34.  
  35. class C <T> {
  36. }
  37. }
  38.  
  39.  
  40. public static void main (String[] args) throws java.lang.Exception
  41. {
  42. // your code goes here
  43. }
  44. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Java HotSpot(TM) Client VM warning: No monotonic clock was available - timed services may be adversely affected if the time-of-day clock changes
Main.java:27: error: incompatible types: Ideone.LambdaTypeInferenceProblem.B cannot be converted to E
    	            	E cachedEntity = find(cObj); // This cause error in java 8 but works fine in java 7
    	            	                     ^
  where E is a type-variable:
    E extends Ideone.LambdaTypeInferenceProblem.B declared in class Ideone.LambdaTypeInferenceProblem.ATest
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
stdout
Standard output is empty