Default methods aren't skipped
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 1.7k
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Description
Interfaces can have default methods since Java 8. There was an attempted code fix to ignore them in the FactoryProvider: https://github.com/google/guice/commit/85f14e03ee00b20e20fd0f018a00ef52fcf909b1
However, the fix doesn't work because the condition needs to be `||` instead of `&&`. (Default methods aren't synthetic or bridge)
This makes it so that if you call any default method in an interface, you end up with the Guice-provided method instead of the default one.
public interface FooFactory {
Foo create();
default Foo createWithData(Data data){
Foo foo = create(); // This will never be called, even if you call `fooFactory.createWithData(data)`
foo.addData(data);
return foo;
}
}
Contributor guide
Assessment
This issue has not been assessed yet.