Skip to content

Instantly share code, notes, and snippets.

@tnymlr
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tnymlr/eb28e44dcadb9f8e9de3 to your computer and use it in GitHub Desktop.
Save tnymlr/eb28e44dcadb9f8e9de3 to your computer and use it in GitHub Desktop.
Javac (1.8.0_25) bug
package com.ermys;
/**
* Hello world!
*
*/
public class App
{
@FunctionalInterface
public interface FunctionalInterfaceFoo<X, Y> {
public boolean apply(X x, Y y);
public default FunctionalInterfaceFoo<X, Y> or(FunctionalInterfaceFoo<X, Y> condition) {
return (x, y) -> this.apply(x, y) || condition.apply(x, y);
}
public default FunctionalInterfaceFoo<X, Y> and(FunctionalInterfaceFoo<X, Y> condition) {
return (x, y) -> this.apply(x, y) || condition.apply(x, y);
}
}
public interface SpecificFunctionalInterfaceFoo<Z> extends FunctionalInterfaceFoo<Integer, Z> {
@Override
public boolean apply(Integer integer, Z z);
}
public enum EnumWithFunctionalInterface implements SpecificFunctionalInterfaceFoo<Object> {
ANY((x, y) -> true),
EQUALS ((x, y) -> x.equals(y));
private final SpecificFunctionalInterfaceFoo action;
private EnumWithFunctionalInterface(SpecificFunctionalInterfaceFoo action) {
this.action = action;
}
@Override
public boolean apply(Integer integer, Object o) {
return action.apply(integer, o);
}
}
public static void main( String[] args )
{
System.out.println(EnumWithFunctionalInterface.ANY);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment