[ 
https://issues.apache.org/jira/browse/FLINK-13451?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Stephan Ewen updated FLINK-13451:
---------------------------------
    Description: 
The method {{Unsafe.defineClass()}} is removed in Java 11.
To support Java 11, we need to rework the method 
{{CommonTestUtils.createClassNotInClassPath()}} to use a different mechanism.

Java 11 introduces a new way to define a class from byte code via 
{{MethodHandles}}. However, because these do not exist in Java 8, we cannot use 
them if we want to keep supporting Java 8, which we most likely want to do for 
quite a while.

A method that works across both versions is to write the class byte code out to 
a temporary file and create a new URLClassLoader that loads the class from that 
file.

That solution is not a complete drop-in replacement, because it cannot add the 
class to an existing class loader, but can only create a new pair of 
(classloader & new-class-in-that-classloader). But it is seems straightforward 
to adjust the existing tests to work with that.

  was:
The method {{Unsafe.defineClass()}} is removed in Java 11.
To support Java 11, we need to rework the method {{ 
CommonTestUtils.createClassNotInClassPath()}} to use a different mechanism.

Java 11 introduces a new way to define a class from byte code via 
{{MethodHandles}}. However, because these do not exist in Java 8, we cannot use 
them if we want to keep supporting Java 8, which we most likely want to do for 
quite a while.

A method that works across both versions is to write the class byte code out to 
a temporary file and create a new URLClassLoader that loads the class from that 
file.

That solution is not a complete drop-in replacement, because it cannot add the 
class to an existing class loader, but can only create a new pair of 
(classloader & new-class-in-that-classloader). But it is seems straightforward 
to adjust the existing tests to work with that.


> Rework CommonTestUtils.createClassNotInClassPath() to not use 
> Unsafe.defineClass()
> ----------------------------------------------------------------------------------
>
>                 Key: FLINK-13451
>                 URL: https://issues.apache.org/jira/browse/FLINK-13451
>             Project: Flink
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.9.0
>            Reporter: Stephan Ewen
>            Priority: Critical
>             Fix For: 1.10.0
>
>
> The method {{Unsafe.defineClass()}} is removed in Java 11.
> To support Java 11, we need to rework the method 
> {{CommonTestUtils.createClassNotInClassPath()}} to use a different mechanism.
> Java 11 introduces a new way to define a class from byte code via 
> {{MethodHandles}}. However, because these do not exist in Java 8, we cannot 
> use them if we want to keep supporting Java 8, which we most likely want to 
> do for quite a while.
> A method that works across both versions is to write the class byte code out 
> to a temporary file and create a new URLClassLoader that loads the class from 
> that file.
> That solution is not a complete drop-in replacement, because it cannot add 
> the class to an existing class loader, but can only create a new pair of 
> (classloader & new-class-in-that-classloader). But it is seems 
> straightforward to adjust the existing tests to work with that.



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Reply via email to