[OpenJDK 2D-Dev] RFR: 8254024: Enhance native libs for AWT and Swing to work with GraalVM Native Image

Andrii Rodionov github.com+1538227+arodionov at openjdk.java.net
Wed Nov 4 23:11:58 UTC 2020


On Fri, 16 Oct 2020 04:49:37 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

>>> > > How it is possible to test the current changes?
>>> > 
>>> > 
>>> > For GraalVM native image, we run JCK tests `api/java_awt` and `api/javax_swing`. Those tests built as a native image.
>>> 
>>> I meant some "steps to reproduce" the current bug, and which can be used to verify the current fix.
>> 
>> Actually, we have found this issue during JCK tests execution that was built as a native image. The fix criteria are the successful tests run.
>
>> Actually, we have found this issue during JCK tests execution that was built as a native image. The fix criteria are the successful tests run.
> 
> But what exact steps should be done to reproduce this bug w/o using jck or any external tools? Something like:
>  - Clone JDK
>  - Build JDK using some specific options.
>  - Create some small test case
>  - Somehow create the native image
>  - Run the app -> boom -> bug is reproduced

@mrserb With the last dev build of GraalVM based on JDK 11.09, the bug can be reproduced by the approach that I've mentioned above.
The general steps: 
- download the [last dev build](https://github.com/graalvm/graalvm-ce-dev-builds/releases) of GraalVM + Native image 
- build the native image for AWTFixExample class (ziped configs for reflection and JNI is attached): 
`$ ~/graalvm-ce-java11-21.0.0-dev/bin/native-image -H:ConfigurationFileDirectories=./configs -Djava.awt.headless=true --native-image-info AWTFixExample`
- run built image - it should be executed successfully
- clone any version of the OpenJDK (11.09 - 16)
- build static libraries by executing `make static-libs-image` target 
- replace `libawt.a` in GraalVM on built static library from OpenJDK
- try to build example again and run it - it should be failed
- clone OpenJDK with the proposed fix
- build static libraries
- replace `libawt.a` in GraalVM on built static library with the fix
- build example and run it - it should be executed successfully

public class AWTFixExample {
    public static void main(String[] args) {
        float[] data = new float[]{0.0f, 1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f};
        Kernel kernel = new Kernel(3, 3, data);
        ConvolveOp op = new ConvolveOp(kernel);

        BufferedImage src = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
        BufferedImage dest = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);

        BufferedImage image = op.filter(src, dest);
        System.out.println(image);
    }
}

[configs.zip](https://github.com/openjdk/jdk/files/5490906/configs.zip)

-------------

PR: https://git.openjdk.java.net/jdk/pull/562


More information about the 2d-dev mailing list