[ 
https://issues.apache.org/jira/browse/FLINK-36350?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17883947#comment-17883947
 ] 

xuhuang commented on FLINK-36350:
---------------------------------

Hi [~mapohl],

I've identified the cause of the "Illegal Access Error" in JDK 17+.

You are right, it is related to FLINK-29741 and the pull request 
[25324|https://github.com/apache/flink/pull/25324].

I have submitted a fix in pull request 
[25379|https://github.com/apache/flink/pull/25379].

 

Here are the details:

According to the [Kryo Object Creation 
documentation|https://github.com/EsotericSoftware/kryo?tab=readme-ov-file#instantiatorstrategy],
 there are two types of object creation strategies: the 
{_}DefaultInstantiatorStrategy{_}, which creates objects using a no-argument 
constructor, and the {_}StdInstantiatorStrategy{_}, which utilizes JVM-specific 
APIs to create instances without invoking any constructors.

In JDK 17+ [Strong 
Encapsulation|https://docs.oracle.com/en/java/javase/17/migrate/migrating-jdk-8-later-jdk-releases.html#GUID-7BB28E4D-99B3-4078-BDC4-FC24180CE82B],
 some class reflection issues arise, such as with 
{_}org.apache.flink.test.checkpointing.UnalignedCheckpointRescaleITCase$VerifyingSink$State{_}.
 In these cases, the {_}DefaultInstantiatorStrategy{_}, which relies on class 
constructors, can lead to an IllegalAccessError, while the 
_StdInstantiatorStrategy_ does not encounter this issue.

Before pull request [25324|https://github.com/apache/flink/pull/25324], Flink 
always used the _StdInstantiatorStrategy_ in both the test and installed 
environments, as the _FlinkScalaKryoInstantiator_ was present in the classpath 
and utilized the {_}StdInstantiatorStrategy{_}. The detailed logic can be found 
in 
{_}org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer#getKryoInstance{_}.

However, pull request [25324|https://github.com/apache/flink/pull/25324] 
removed the _FlinkScalaKryoInstantiator_ class dependency from the flink-test 
pom.xml, causing Flink to use the DefaultInstantiatorStrategy in the test 
environment, which results in the IllegalAccessError.

Given that the _FlinkScalaKryoInstantiator_ is related to deprecated Scala 
APIs, I think it should be removed ultimatly, and we should use the 
{_}StdInstantiatorStrategy{_}, as was done previously in Flink.

WDYT?

> IllegalAccessError detected in JDK17+ runs
> ------------------------------------------
>
>                 Key: FLINK-36350
>                 URL: https://issues.apache.org/jira/browse/FLINK-36350
>             Project: Flink
>          Issue Type: Bug
>          Components: Tests
>    Affects Versions: 2.0-preview
>            Reporter: Matthias Pohl
>            Priority: Blocker
>              Labels: pull-request-available, test-stability
>
> UnalignedCheckpointRescaleITCase and GroupReduceITCase are affected in JDK17 
> and JDK21 test profiles.
> https://dev.azure.com/apache-flink/apache-flink/_build/results?buildId=62359&view=logs&j=a596f69e-60d2-5a4b-7d39-dc69e4cdaed3&t=712ade8c-ca16-5b76-3acd-14df33bc1cb1



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to