I am upgrading java version from 6 to 7 for my project. It used to compile fine with java 6.
@Provides
VptchProvIntf provideVptchProv(NeVersion neVersion, Provider<ClVptchProv> classicProvider, Provider<RsVptchProv> rsProvider)
{
return (VptchProvIntf)provideForPlatform(neVersion, classicProvider, rsProvider);
}
@Provides
StsnVcnProvIntf provideVptchProv(NeVersion neVersion, Provider<ClStsnVcnProv> classicProvider, Provider<RsStsnVcnProv> rsProvider)
{
return (StsnVcnProvIntf)provideForPlatform(neVersion, classicProvider, rsProvider);
}
This is snapshot from a de-compiled class. Types were not erased by compiler and code compiles fine.
But after java upgrade to version 7, this code has started giving compilation error
error: name clash: provideVptchProv(NeVersion,Provider,Provider) and provideVptchProv(NeVersion,Provider,Provider) have the same erasure
Has Java 7 changed anything that is not allowing Guice to work.
Note : Google Guice version is 2.0
Do I need to update Guice or is there any workaround?
The Java 5 and 6 compilers had a bug that would accept your methods, because they considered the signature to include the return type in the check.
In Java 7, methods cannot have the same erased signatures, regardless of their return types. See this blog post and this bug report.
In your case, the answer is to rename one of your methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With