Code changes required after JDK-8291473
Filip Krakowski
filip.krakowski at hhu.de
Thu Aug 4 13:47:02 UTC 2022
Hi,
since jextract does not work with the latest changes introduced in
https://git.openjdk.org/panama-foreign/pull/694, I started to work on
adjusting the sources in [1]. I took the following steps so far:
1. Find & replace all occurrences and imports of "Addressable" and
"MemoryAddress" and replace it with "MemorySegment"
2. Change all occurences of "Linker.downcallType" and
"Linker.upcallType" with "Linker.methodType"
3. Remove duplicate if-statements resulting from Step 1
4. Make C_POINTER$LAYOUT unbounded (in
org.openjdk.jextract.impl.ToplevelBuilder#primitiveLayoutString)
5. Use MemorySegment#equals instead of reference comparison inside
org.openjdk.jextract.clang.org.openjdk.jextract.clang#getLocation
6. Tweak build.gradle so that the user does not have to specify the
jdk home directory. Gradle will automatically search for the specified
JDK version. It can also be instructed to search inside custom locations
using the org.gradle.java.installations.paths property, which can be set
inside ${HOME}/.gradle/gradle.properties.
Since my approach is relatively naive ("find & replace" + fixing
compiler and runtime errors), important parts of the code may be
incorrect at the moment. I tested it with my Gradle plugin's demo
project [2], which works. But again, this is only a simple program just
calling printf and doing nothing fancy. In the next step I will try to
rewrite some jtreg tests and see if they pass. Hopefully, this should
point out all incorrect parts.
If you want to try it out, you need to compile [1] and add the resulting
"bin"-Folder ("$PROJECT_DIR/build/jextract/bin") to your PATH.
Afterwards [2] should just work by executing "./gradlew run". If
successful, the program should print "Hello World" (using the native
printf function).
I would greatly appreciate feedback regarding my general approach to
code changes. In particular, I am unsure about changing the C_POINTER
layout to be unbounded.
Best regards,
Filip
[1] - https://github.com/krakowski/jextract/tree/jdk20
[2] - https://github.com/krakowski/jextract-demo
More information about the jextract-dev
mailing list