Skip to content

Runtime errors when implementing non-sealed java interface #25271

@PhoenixmitX

Description

@PhoenixmitX

Relates to

This is a reopen of #23479 which was supposed to be fixed with #23482.
The bug still appears in 3.8.1 and the current nightly version.

The hierarchy of the interfaces is a bit more complex than what the minified version in the issue was.

Compiler version

  • 3.7.1
  • 3.8.1
  • 3.nightly (3.8.3-RC1-bin-20260214-f10f20d-NIGHTLY)

Minimized code

#!/usr/bin/env scala
//> using scala "3.8.1"
// //> using scala 3.nightly // also tried with nightly
//> using repository "https://repo.papermc.io/repository/maven-public/"
//> using dep "com.velocitypowered:velocity-api:3.4.0-SNAPSHOT"

import com.velocitypowered.api.command.RawCommand
import com.velocitypowered.api.command.RawCommand.Invocation

class CrashCommand() extends RawCommand:
	override def execute(invocation: Invocation): Unit =
		()

object Main:
	def main(args: Array[String]): Unit =
		val command = CrashCommand()

Output

When RUNNING this code the jvm throws an error

Details
Downloading Scala 3.8.3-RC1-bin-20260214-f10f20d-NIGHTLY compiler
Downloading Scala 3.8.3-RC1-bin-20260214-f10f20d-NIGHTLY bridgela-lang/scala3-compiler_3/3.8.3-RC1-bin-20260214-f10f20d-NIGHTLY/scala3-compiler_3-3.8.3-RC1-bin-20260214-f10f20d-NIGHTLY.jar
Compiling project (Scala 3.8.3-RC1-bin-20260214-f10f20d-NIGHTLY, JVM (25))
Compiled project (Scala 3.8.3-RC1-bin-20260214-f10f20d-NIGHTLY, JVM (25))
[hint] ./test.sc:5:16
[hint] "velocity-api is outdated, update to 3.4.0"
[hint]      velocity-api 3.4.0-SNAPSHOT -> com.velocitypowered:velocity-api:3.4.0
[hint] //> using dep "com.velocitypowered:velocity-api:3.4.0-SNAPSHOT"
[hint]                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Exception in thread "main" java.lang.IncompatibleClassChangeError: Failed listed permitted subclass check: class test$_$CrashCommand is not a permitted subclass of com.velocitypowered.api.command.InvocableCommand
        at java.base/java.lang.ClassLoader.defineClass1(Native Method)
        at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:962)
        at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:144)
        at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:776)
        at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:691)
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:620)
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:578)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:490)
        at test$_$Main$.main(test.sc:16)
        at test_sc$.main(test.sc:35)
        at test_sc.main(test.sc)

Expectation

no error is thrown

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions