-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
area:reportingError reporting including formatting, implicit suggestions, etcError reporting including formatting, implicit suggestions, etcbetter-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesIssues concerned with improving confusing/unhelpful diagnostic messagescompat:javaitype:enhancement
Description
Latest release of JDK 21 might be a time when more and more people might want to migrate to latest Java version. However, if we'd try to do so, we might get a very nasty error.
Compiler version
3.3.0 (fixed in 3.3.1 for JDK 21, however the issue would still be present in future JDK's if more assumptions of classfile format are violated)
Minimized code
import java.nio.file.StandardOpenOption
@main def Test = {
val x = StandardOpenOption.CREATE
}Output
>scalac main.scala
error while loading StandardOpenOption,
class file /modules/java.base/java/nio/file/StandardOpenOption.class is broken, reading aborted with class java.lang.RuntimeException
bad constant pool index: 0 at pos: 1200
-- [E008] Not Found Error: main.scala:4:30 -------------------------------------
4 | val x = StandardOpenOption.CREATE
| ^^^^^^^^^^^^^^^^^^^^^^^^^
| value CREATE is not a member of object java.nio.file.StandardOpenOption
2 errors foundExpectation
Compiler should provide better error messages when using unsupported JDK version, eg. what is the latest supported version and which version was found in the classfile along with a possible way to mitigate this issue, eg. please try to use the latest version the Scala compiler
He-Pin, Kordyjan and SethTisue
Metadata
Metadata
Assignees
Labels
area:reportingError reporting including formatting, implicit suggestions, etcError reporting including formatting, implicit suggestions, etcbetter-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesIssues concerned with improving confusing/unhelpful diagnostic messagescompat:javaitype:enhancement