Skip to content

Instantly share code, notes, and snippets.

@odrotbohm
Created November 15, 2016 15:50
Show Gist options
  • Save odrotbohm/c644327bb89191f2b52e298427ebf201 to your computer and use it in GitHub Desktop.
Save odrotbohm/c644327bb89191f2b52e298427ebf201 to your computer and use it in GitHub Desktop.
Compiler ambiguity when compiling with target JDK 8
public class AmbiguitySample {
/**
* This compiles when using a JDK 8 with target JDK 6 but fails when the target is JDK 8.
*/
public static void main(String[] args) {
CriteriaBuilder builder;
Expression<Object> objectExpression;
Expression<Collection<Object>> collectionOfObjectExpression;
// Compiler error: AmbiguitySample.java:[35,24] reference to isNotMember is ambiguous
// [ERROR] both method
// <E,C>isNotMember(javax.persistence.criteria.Expression<E>,javax.persistence.criteria.Expression<C>) in
// javax.persistence.criteria.CriteriaBuilder and method
// <E,C>isNotMember(E,javax.persistence.criteria.Expression<C>) in javax.persistence.criteria.CriteriaBuilder match
builder.isNotMember(objectExpression, collectionOfObjectExpression);
// ^^^^^^^^^^^
}
}
@odrotbohm
Copy link
Author

@otrosien — once again, you made my day. Thanks for that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment