-
Enhancement
-
Resolution: Fixed
-
P4
-
9
-
b122
-
Verified
A service implementation type must be a subtype of the corresponding service interface type.
javac checks for this, and while the error message is not wrong, it is not as helpful as it could be.
$ cat play/service/src/m/module-info.java
module m {
uses java.lang.String;
provides java.lang.String with java.io.File;
}
$ ./build/linux-x86_64-normal-server-release/images/jdk/bin/javac -d play/service/modules !$
./build/linux-x86_64-normal-server-release/images/jdk/bin/javac -d play/service/modules play/service/src/m/module-info.java
play/service/src/m/module-info.java:3: error: incompatible types: File cannot be converted to String
provides java.lang.String with java.io.File;
^
1 error
A more obvious message would be to say the the service implementation type must be a subtype of the service interface type.
javac checks for this, and while the error message is not wrong, it is not as helpful as it could be.
$ cat play/service/src/m/module-info.java
module m {
uses java.lang.String;
provides java.lang.String with java.io.File;
}
$ ./build/linux-x86_64-normal-server-release/images/jdk/bin/javac -d play/service/modules !$
./build/linux-x86_64-normal-server-release/images/jdk/bin/javac -d play/service/modules play/service/src/m/module-info.java
play/service/src/m/module-info.java:3: error: incompatible types: File cannot be converted to String
provides java.lang.String with java.io.File;
^
1 error
A more obvious message would be to say the the service implementation type must be a subtype of the service interface type.
- duplicates
-
JDK-8151052 compilation of broken provides statement produces incorrect error
-
- Closed
-