Jenkins error on static method interface invocation after upgrade

Hi everyone.

we are trying to upgrade our Jenkins server from version 2.330 to version 2.473, however we are getting an error that we can’t resolve.
Our Jenkins Server is installed on an EKS cluster and use an EFS (Elastic File System) to persist the storage needed by Jenkins.
We have both a old version (2.330) of the Jenkins server and the new version (2.473) running so we can test on both.
For our new Jenkins server we had to upgrade the Java version from the version 11.0.13 to the 21.0.4.
The groovy version, printed at runtime from the code, is the 2.4 for both Jenkins servers.
For our Jenkins pipelines, we make use of some groovy Shared Libraries where we the AWS SDK Java to operate with some private ECR.
After the upgrade of the Jenkins Server to the version 2.473 we are getting this error, which I write down only the initial part:

May be JENKINS-73031: calling static interface methods from Groovy is not currently supported by Jenkins
[Pipeline] End of Pipeline
17:11:59  Also:   org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: a8bd684b-967b-49c6-937a-1671998634f5
17:11:59  java.lang.VerifyError: (class: software/amazon/awssdk/services/ecr/EcrClient$builder, method: call signature: (Ljava/lang/Object;)Ljava/lang/Object;) Illegal type in constant pool
17:11:59    at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
17:11:59    at java.base/java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
17:11:59    at java.base/java.lang.Class.getConstructor0(Unknown Source)
17:11:59    at java.base/java.lang.Class.getConstructor(Unknown Source)
17:11:59    at org.codehaus.groovy.reflection.ClassLoaderForClassArtifacts.defineClassAndGetConstructor(ClassLoaderForClassArtifacts.java:82)
17:11:59    at org.codehaus.groovy.runtime.callsite.CallSiteGenerator.compileStaticMethod(CallSiteGenerator.java:262)
17:11:59    at org.codehaus.groovy.reflection.CachedMethod.createStaticMetaMethodSite(CachedMethod.java:295)
17:11:59    at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.createStaticMetaMethodSite(StaticMetaMethodSite.java:114)
17:11:59    at groovy.lang.MetaClassImpl.createStaticSite(MetaClassImpl.java:3421)
17:11:59    at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallStaticSite(CallSiteArray.java:76)
17:11:59    at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallSite(CallSiteArray.java:161)
17:11:59    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
17:11:59    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
17:11:59    at PluginClassLoader for workflow-cps//com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
17:11:59    at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.LoggingInvoker.methodCall(LoggingInvoker.java:105)
17:11:59    at it.application.shared.core.aws.Ecr.getEcrClient(Ecr.groovy:38)
17:11:59    at it.application.shared.core.aws.Ecr.getEcrClient(Ecr.groovy)

.
I’m attaching the complete error log in the file called ecr-jenkins-error-application.txt.
The AWS SDK Java for ECR is version 2.13.75, we have tried to upgrade this AWS SDK version even to the latest (2.29.30), but we keep getting the same error.

The line of code of the Shared Library which are returning this error is:
EcrClientBuilder varBuilder = EcrClient.builder()
I’m attaching the complete Shared Library code in the file called ECR.groovy.

Looking on internet this error “Illegal type in constant pool” seems related to the fact the in groovy we are trying to invoke a static method ffrom an interface,
and it seems that in groovy this type of invocation is not supported.
As shown even from the code of this plugin:

In fact EcrClient is an interface and the method .builder() is a static method.
Java AWS SDK Documentation of the interface EcrCLient:
https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/ecr/EcrClient.html

The weird thing is that this Shared library work correctly on the old version of Jenkins (2.330), where we make us of the same version of groovy.
Some of the differences between this two Jenkins server are some plugins version and plugin deprecated,
for example the plugin workflow-cps-global-lib has been deprecated and so we had to remove it in the new version in favor of the new plugin pipeline-groovy-lib.

https://plugins.jenkins.io/workflow-cps-global-lib/
https://plugins.jenkins.io/pipeline-groovy-lib/

Has anyone had the same kind of problem?

Can you help me understand how to resolve this kind of issue?
Because it seems weird that a Shared library which use the AWS SDK ECR like AWS show with their example is not working.