-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
9
-
x86_64
-
generic
FULL PRODUCT VERSION :
javac full version "9-ea+102-2016-01-21-002725.javare.4316.nc"
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
There is an apparent type inference regression in Java 9-ea, where a suitable method cannot be found. Please refer to the test case below on how to reproduce.
REGRESSION. Last worked in version 8u72
ADDITIONAL REGRESSION INFORMATION:
java full version "1.8.0_72-b15"
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Save the source code to a file named Issue.java and try to compile it
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compilation succeeds
ACTUAL -
Compilation fails
ERROR MESSAGES/STACK TRACES THAT OCCUR :
warning: [options] bootstrap class path not set in conjunction with -source 1.8
Issue.java:7: error: no suitable method found for lessThan(JpaPath<Object>,LocalDate)
builder.not(builder.lessThan(root.get("period").get("end"), end));
^
method JpaCriteriaBuilder.<Y#1>lessThan(JpaExpression<? extends Y#1>,JpaExpression<? extends Y#1>) is not applicable
(cannot infer type-variable(s) Y#1,Y#2
(argument mismatch; LocalDate cannot be converted to JpaExpression<? extends Y#1>))
method JpaCriteriaBuilder.<Y#3>lessThan(JpaExpression<? extends Y#3>,Y#3) is not applicable
(inferred type does not conform to upper bound(s)
inferred: LocalDate
upper bound(s): LocalDate,Comparable<? super LocalDate>,Object,ChronoLocalDate,Comparable<? super Y#3>,Comparable<? super Y#3>,Comparable<? super Y#3
>,Comparable<? super Y#3>,Comparable<? super Y#3>,Comparable<? super Y#3>,Comparable<? super Y#3>)
where Y#1,Y#2,Y#3 are type-variables:
Y#1 extends Comparable<? super Y#1> declared in method <Y#1>lessThan(JpaExpression<? extends Y#1>,JpaExpression<? extends Y#1>)
Y#2 extends Object declared in method <Y#2>get(String)
Y#3 extends Comparable<? super Y#3> declared in method <Y#3>lessThan(JpaExpression<? extends Y#3>,Y#3)
1 error
1 warning
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.time.LocalDate;
public class Issue {
public void test(JpaCriteriaBuilder builder, JpaPath<Holidays> root, LocalDate end) {
builder.not(builder.lessThan(root.get("period").get("end"), end));
}
private static class Holidays {
private Period period;
}
private static class Period {
private LocalDate start;
private LocalDate end;
}
private static class JpaExpression<T> {
}
private static class JpaPredicate extends JpaExpression<Boolean> {
}
private static class JpaPath<T> extends JpaExpression<T> {
public <Y> JpaPath<Y> get(String attributeName) {
throw new UnsupportedOperationException();
}
}
private static class JpaCriteriaBuilder {
public JpaPredicate not(JpaExpression<Boolean> restriction) {
throw new UnsupportedOperationException();
}
public <Y extends Comparable<? super Y>> JpaPredicate lessThan(JpaExpression<? extends Y> x, JpaExpression<? extends Y> y) {
throw new UnsupportedOperationException();
}
public <Y extends Comparable<? super Y>> JpaPredicate lessThan(JpaExpression<? extends Y> x, Y y) {
throw new UnsupportedOperationException();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Compile with Java 8's javac
javac full version "9-ea+102-2016-01-21-002725.javare.4316.nc"
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
There is an apparent type inference regression in Java 9-ea, where a suitable method cannot be found. Please refer to the test case below on how to reproduce.
REGRESSION. Last worked in version 8u72
ADDITIONAL REGRESSION INFORMATION:
java full version "1.8.0_72-b15"
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Save the source code to a file named Issue.java and try to compile it
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compilation succeeds
ACTUAL -
Compilation fails
ERROR MESSAGES/STACK TRACES THAT OCCUR :
warning: [options] bootstrap class path not set in conjunction with -source 1.8
Issue.java:7: error: no suitable method found for lessThan(JpaPath<Object>,LocalDate)
builder.not(builder.lessThan(root.get("period").get("end"), end));
^
method JpaCriteriaBuilder.<Y#1>lessThan(JpaExpression<? extends Y#1>,JpaExpression<? extends Y#1>) is not applicable
(cannot infer type-variable(s) Y#1,Y#2
(argument mismatch; LocalDate cannot be converted to JpaExpression<? extends Y#1>))
method JpaCriteriaBuilder.<Y#3>lessThan(JpaExpression<? extends Y#3>,Y#3) is not applicable
(inferred type does not conform to upper bound(s)
inferred: LocalDate
upper bound(s): LocalDate,Comparable<? super LocalDate>,Object,ChronoLocalDate,Comparable<? super Y#3>,Comparable<? super Y#3>,Comparable<? super Y#3
>,Comparable<? super Y#3>,Comparable<? super Y#3>,Comparable<? super Y#3>,Comparable<? super Y#3>)
where Y#1,Y#2,Y#3 are type-variables:
Y#1 extends Comparable<? super Y#1> declared in method <Y#1>lessThan(JpaExpression<? extends Y#1>,JpaExpression<? extends Y#1>)
Y#2 extends Object declared in method <Y#2>get(String)
Y#3 extends Comparable<? super Y#3> declared in method <Y#3>lessThan(JpaExpression<? extends Y#3>,Y#3)
1 error
1 warning
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.time.LocalDate;
public class Issue {
public void test(JpaCriteriaBuilder builder, JpaPath<Holidays> root, LocalDate end) {
builder.not(builder.lessThan(root.get("period").get("end"), end));
}
private static class Holidays {
private Period period;
}
private static class Period {
private LocalDate start;
private LocalDate end;
}
private static class JpaExpression<T> {
}
private static class JpaPredicate extends JpaExpression<Boolean> {
}
private static class JpaPath<T> extends JpaExpression<T> {
public <Y> JpaPath<Y> get(String attributeName) {
throw new UnsupportedOperationException();
}
}
private static class JpaCriteriaBuilder {
public JpaPredicate not(JpaExpression<Boolean> restriction) {
throw new UnsupportedOperationException();
}
public <Y extends Comparable<? super Y>> JpaPredicate lessThan(JpaExpression<? extends Y> x, JpaExpression<? extends Y> y) {
throw new UnsupportedOperationException();
}
public <Y extends Comparable<? super Y>> JpaPredicate lessThan(JpaExpression<? extends Y> x, Y y) {
throw new UnsupportedOperationException();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Compile with Java 8's javac
- duplicates
-
JDK-8152832 Type inference regression in javac
-
- Closed
-