Code changes required after JDK-8291473
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Thu Aug 4 17:06:40 UTC 2022
Hi Filip,
thanks for jumping into this. We have some internal version of jextract
that works against the latest panama changes, but we need to find a
place for it in the jextract repo. The main branch is not it, as we use
that branch to generate the binaries for the current release (at this
time Java 19).
The main idea we've been discussing (but would be nice to have feedback
on it) would be to have two branches:
* main: this is where changes for JDK N live
* next: this is where changes for JDK N+1 live
When JDK N is GA'ed, we do two things:
* we "freeze" the contents of the "main" branch into a branch called jdkN-1
* we move "next" into "main" (so we'll start generating binary snapshot
that refer to the latest GA'ed JDK release).
Right now we are a bit in an inconsistent state because (a) main points
to JDK 19 bits even though JDK 19 is not GA'ed yet and (b) we have no
place where to put the JDK 20 bits. But I think that, if we structure
the repo as described above, we'll get in a saner place (once JDK 19 is
GA'ed, that is :-) ).
Thoughts?
Maurizio
On 04/08/2022 14:47, Filip Krakowski wrote:
> 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