Reputation: 85
I am trying to recompile a JAVA8 code in JAVA11. Getting below compilation errors.
error: reference to Module is ambiguous
private Module module;
both interface com.module.Module in com.module and class java.lang.Module in java.lang match
Being new to the Java not able to fully understand the root cause. Any information will be of great help.
Upvotes: 6
Views: 5182
Reputation: 31868
both interface
com.module.Module
incom.module
and classjava.lang.Module
injava.lang
match
The error is mostly because of the new class java.lang.Module
introduced in Java-9.
Just use the fully qualified name while referencing the interface/class that you've defined as:
private com.module.Module module;
Alternatively, as pointed out by Alan and Holger in comments and from the release notes of Java-9, you can explicitly specify the import
for your Module
class as :
import com.module.Module;
Upvotes: 8