Add scripted test for #6175 (#8598)

This PR adds a scripted test to prevent regression of issue #6175, where `MethodHandle.invokeExact` failed to compile on JDK 15+ when using `-release 11`.

Changes:
- Added `sbt-app/src/sbt-test/java/method-handle-release/` scripted test
- Test uses Scala 2.13.16 with `-release:11` to reproduce the original issue scenario
- Verifies that polymorphic signature methods compile correctly under cross-version targeting
This commit is contained in:
calm 2026-01-20 23:31:07 -08:00 committed by GitHub
parent d2cd284e5e
commit 642be58d44
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,2 @@
ThisBuild / scalaVersion := "2.13.16"
scalacOptions += "-release:11"

View File

@ -0,0 +1,19 @@
import java.lang.invoke.{ MethodHandle, MethodHandles }
object Main {
case class TestClass(number: Int)
def testMethod(): TestClass = {
TestClass(10)
}
def wrappedMethod(handle: MethodHandle): TestClass = {
handle.invokeExact()
}
def main(args: Array[String]): Unit = {
val method = classOf[Main.type].getDeclaredMethod("testMethod")
method.setAccessible(true)
val handle = MethodHandles.lookup.unreflect(method)
println(wrappedMethod(handle))
}
}

View File

@ -0,0 +1,3 @@
# https://github.com/sbt/sbt/issues/6175
# MethodHandle.invokeExact fails to compile on JDK 15+ when targeting Java 11
> compile