cannot override guice 2.0 provider method
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 1.7k
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Description
_From [ferncam1](https://code.google.com/u/102290260414172705059/) on March 12, 2009 19:17:00_
See the code below. Eventhough you can successfully override a provider
method with no args, overriding provider methods with more then one arg
will fail.
package net.meat;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import org.testng.annotations.Test;
import java.net.InetSocketAddress;
/**
*
* `@`author Adrian Cole
*/
public class TestImNotCrazy {
`@`Inject
InetSocketAddress me;
`@`Test
void testCannotOverrideProvides() {
Injector i = Guice.createInjector(new Module2());
TestImNotCrazy crazy = i.getInstance(TestImNotCrazy.class);
}
static class Module1 extends AbstractModule {
protected void configure() {
// lala
}
`@`Provides
`@`Singleton
InetSocketAddress provideMeASocket(String meat) {
return new InetSocketAddress("localhost", 80);
}
}
static class Module2 extends Module1 {
protected void configure() {
// lala
}
`@`Provides
`@`Singleton
`@`Override
InetSocketAddress provideMeASocket(String meat) {
return new InetSocketAddress("localhost", 80);
}
}
}
_Original issue: http://code.google.com/p/google-guice/issues/detail?id=347_
Contributor guide
Assessment
This issue has not been assessed yet.