Google Guice - has the same erase error - compilation after updating java from v6 to v7

I am updating the java version from 6 to 7 for my project. It was used to compile 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 a snapshot from a decompiled class. Types have not been removed by the compiler, and code compilation is beautiful.

But after upgrading java to version 7, this code started to give a compilation error

error: name clash: provideVptchProv (NeVersion, Provider, Provider) and provideVptchProv (NeVersion, Provider, Provider) have the same erase

Has Java 7 changed anything that prevents Guice from working.

Note. Google Guice 2.0 Version

Do I need to update Guice or is there a workaround?

+5
source share
1 answer

The Java 5 and 6 compilers had an error that would accept your methods, since they believed that the signature included a return type in validation.

In Java 7, methods cannot have the same erased signature, 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.

+9
source

Source: https://habr.com/ru/post/1203291/


All Articles