Skip to content

Commit

Permalink
Support non-preview Panama - JDK 22+
Browse files Browse the repository at this point in the history
  • Loading branch information
danielperano committed Jun 21, 2024
1 parent 3afc4c5 commit 37e8b5d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 6 additions & 5 deletions lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,30 @@ dependencies {

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
languageVersion = JavaLanguageVersion.of(22)
}
}

tasks.withType(JavaCompile).configureEach {
options.compilerArgs.add('--enable-preview')
//options.compilerArgs.add('--enable-preview')
}

tasks.withType(Test).configureEach {
jvmArgs += '--enable-preview'
//jvmArgs += '--enable-preview'
jvmArgs += '--enable-native-access=ALL-UNNAMED'
}

compileTestGroovy {
options.compilerArgs.add('--enable-preview')
//options.compilerArgs.add('--enable-preview')
options.compilerArgs.add('--enable-native-access=ALL-UNNAMED')
}

test {
useJUnitPlatform()
// TODO - support non-Linux lib names
systemProperty "buoy.test.lib.path", new File(parent.projectDir.absoluteFile, "native/build/lib/main/debug/").toPath().toString()
jvmArgs(['--enable-preview', '--enable-native-access=ALL-UNNAMED'])
jvmArgs(['--enable-native-access=ALL-UNNAMED'])
//jvmArgs(['--enable-preview', '--enable-native-access=ALL-UNNAMED'])
}

publishing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.lang.foreign.MemorySegment;
import java.lang.foreign.ValueLayout;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.lang.reflect.Field;

Expand All @@ -43,7 +44,8 @@ public FieldHandler(FieldDef model, Field field){
// TODO - this doesn't work if this field references a struct value, since structs
// are not value layouts in Panama and the VarHandle can only access a value layout.
public VarHandle getHandle(MemoryLayout layout){
return layout.varHandle(MemoryLayout.PathElement.groupElement(model.name()));
var handle = layout.varHandle(MemoryLayout.PathElement.groupElement(model.name()));
return MethodHandles.insertCoordinates(handle, 1, 0L);
}

public MethodHandle getAccessor(MemoryLayout layout, VarHandle.AccessMode mode){
Expand Down

0 comments on commit 37e8b5d

Please sign in to comment.