ballerina-platform / ballerina-lang

The Ballerina Programming Language
https://ballerina.io/
Apache License 2.0
3.67k stars 750 forks source link

[Bug]: Debugger evaluation tests are failing with Java 21 #43146

Closed warunalakshitha closed 2 weeks ago

warunalakshitha commented 3 months ago

Description

If we use Java 21 to run the ballerina debugger integration tests with minimum changes, tests are failing as below.

debugger-intg-test-suite > debugger-intg-tests > org.ballerinalang.debugger.test.adapter.evaluation.SingleFileEvaluationTest > literalEvaluationTest FAILED
    java.lang.AssertionError: expected [-20] but found [null]
        at org.testng.Assert.fail(Assert.java:110)
        at org.testng.Assert.failNotEquals(Assert.java:1413)
        at org.testng.Assert.assertEqualsImpl(Assert.java:149)
        at org.testng.Assert.assertEquals(Assert.java:131)
        at org.testng.Assert.assertEquals(Assert.java:655)
        at org.testng.Assert.assertEquals(Assert.java:665)
        at org.ballerinalang.debugger.test.utils.DebugTestRunner.assertExpression(DebugTestRunner.java:676)
        at org.ballerinalang.debugger.test.adapter.evaluation.ExpressionEvaluationTest.literalEvaluationTest(ExpressionEvaluationTest.java:45)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:139)
        at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:677)
        at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:221)
        at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50)
        at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:969)
        at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:194)
        at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:148)
        at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        at org.testng.TestRunner.privateRun(TestRunner.java:829)
        at org.testng.TestRunner.run(TestRunner.java:602)
        at org.testng.SuiteRunner.runTest(SuiteRunner.java:437)
        at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:431)
        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:391)
        at org.testng.SuiteRunner.run(SuiteRunner.java:330)
        at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
        at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95)
        at org.testng.TestNG.runSuitesSequentially(TestNG.java:1256)
        at org.testng.TestNG.runSuitesLocally(TestNG.java:1176)
        at org.testng.TestNG.runSuites(TestNG.java:1099)
        at org.testng.TestNG.run(TestNG.java:1067)
        at org.gradle.api.internal.tasks.testing.testng.TestNGTestClassProcessor.runTests(TestNGTestClassProcessor.java:153)
        at org.gradle.api.internal.tasks.testing.testng.TestNGTestClassProcessor.stop(TestNGTestClassProcessor.java:96)
        at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:62)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
        at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
        at jdk.proxy2/jdk.proxy2.$Proxy5.stop(Unknown Source)
        at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:193)
        at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
        at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
        at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
        at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
        at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113)
        at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65)
        at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
        at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)

debugger-intg-test-suite > debugger-intg-tests STANDARD_ERROR
    Jul 22, 2024 11:09:37 AM org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer fireStreamClosed
    INFO: Socket closed
    java.net.SocketException: Socket closed
        at java.base/sun.nio.ch.NioSocketImpl.endRead(NioSocketImpl.java:243)
        at java.base/sun.nio.ch.NioSocketImpl.implRead(NioSocketImpl.java:323)
        at java.base/sun.nio.ch.NioSocketImpl.read(NioSocketImpl.java:346)
        at java.base/sun.nio.ch.NioSocketImpl$1.read(NioSocketImpl.java:796)
        at java.base/java.net.Socket$SocketInputStream.read(Socket.java:1099)
        at java.base/java.net.Socket$SocketInputStream.read(Socket.java:1093)
        at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:79)
        at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)

debugger-intg-test-suite STANDARD_ERROR
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
        at java.base/java.lang.Thread.run(Thread.java:1583)

Steps to Reproduce

You can simply run the current main branch with Java 21 and skip checkstyle (-x check). Please use https://github.com/ballerina-platform/ballerina-lang/pull/43087 PR for all the changes done fixing checkstyle as well. Note: I have temporary disable debugger tests in workflow to check other test cases.

Affected Version(s)

No response

OS, DB, other environment details and versions

No response

Related area

-> Debugger

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

HindujaB commented 2 months ago

Happens due to the JDI method invokation picks a wrong method for Class.forName() method. With Java 21, a new method with 3 parameters is added in Class class.

private static Class<?> forName(Module module, String name, Class<?> caller);

Since we only consider parameter count to call the Class.forName() method, it fails with invalid JDI invocation.

HindujaB commented 2 weeks ago

Fixed with https://github.com/ballerina-platform/ballerina-lang/pull/43389

github-actions[bot] commented 2 weeks ago

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.