Skip to content

Commit

Permalink
Merge pull request #15 from Over-Run/jdk23
Browse files Browse the repository at this point in the history
  • Loading branch information
squid233 authored Aug 20, 2024
2 parents 9c29aa0 + 2037f53 commit 05ab407
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 25 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
matrix:
java: [
22
23-ea
]
os: [ ubuntu-latest, windows-latest ]
runs-on: ${{ matrix.os }}
Expand All @@ -30,7 +30,6 @@ jobs:
with:
java-version: |
${{ matrix.java }}
21
distribution: 'temurin'
- name: Grant execute permission for gradlew
if: ${{ runner.os != 'Windows' }}
Expand All @@ -40,16 +39,14 @@ jobs:
- name: Execute Gradle build
run: ./gradlew build
- name: Upload build reports
if: ${{ runner.os == 'Linux' && matrix.java == '22' }}
uses: actions/upload-artifact@v4
with:
name: build-reports
name: build-reports-${{ runner.os }}-jdk${{ matrix.java }}
path: |
build/reports/
- name: Capture build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '22' }}
uses: actions/upload-artifact@v4
with:
name: Artifacts
name: artifacts-${{ runner.os }}-jdk${{ matrix.java }}
path: |
build/libs/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Marshal allows you to conveniently create native library bindings with [FFM API]

~~See [wiki](https://github.com/Over-Run/marshal/wiki) for more information.~~

This library requires JDK 22 or newer.
This library requires JDK 23 or newer.

## Overview

Expand Down Expand Up @@ -95,7 +95,7 @@ Import as a Gradle dependency:

```groovy
dependencies {
implementation("io.github.over-run:marshal:0.1.0-alpha.28-jdk22")
implementation("io.github.over-run:marshal:0.1.0-alpha.29-jdk23")
}
```

Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ projGroupId=io.github.over-run
projArtifactId=marshal
# The project name should only contain lowercase letters, numbers and hyphen.
projName=marshal
projVersion=0.1.0-alpha.28-jdk22
projVersion=0.1.0-alpha.29-jdk23
projDesc=Marshaler of native libraries
# Uncomment them if you want to publish to maven repository.
projUrl=https://github.com/Over-Run/marshal
Expand All @@ -27,9 +27,9 @@ orgName=Overrun Organization
orgUrl=https://over-run.github.io/

# JDK Options
jdkVersion=22
jdkVersion=23
jdkEnablePreview=true
# javadoc link of JDK early access build
# https://download.java.net/java/early_access/$jdkEarlyAccessDoc/docs/api/
# Uncomment it if you need to use EA build of JDK.
#jdkEarlyAccessDoc=jdk22
jdkEarlyAccessDoc=jdk23
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/overrun/marshal/Downcall.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private static void invokeSuperMethod(CodeBuilder codeBuilder, List<Parameter> p
codeBuilder.aload(codeBuilder.receiverSlot());
for (int i = 0, size = parameters.size(); i < size; i++) {
final var parameter = parameters.get(i);
codeBuilder.loadInstruction(
codeBuilder.loadLocal(
TypeKind.fromDescriptor(parameter.getType().descriptorString())
.asLoadable(),
codeBuilder.parameterSlot(i));
Expand Down Expand Up @@ -394,7 +394,7 @@ private static <T> T loadBytecode(MethodHandles.Lookup caller, SymbolLookup look
methodName,
mtd_method,
targetClass.isInterface()
).returnInstruction(returnTypeKind);
).return_(returnTypeKind);
} else {
//region body
final boolean hasAllocator =
Expand Down Expand Up @@ -520,7 +520,7 @@ private static <T> T loadBytecode(MethodHandles.Lookup caller, SymbolLookup look
} else {
final TypeKind typeKind = TypeKind.from(cd_returnTypeDowncall);
resultSlot = blockCodeBuilder.allocateLocal(typeKind);
blockCodeBuilder.storeInstruction(typeKind, resultSlot);
blockCodeBuilder.storeLocal(typeKind, resultSlot);
}

// copy ref result
Expand Down Expand Up @@ -566,7 +566,7 @@ private static <T> T loadBytecode(MethodHandles.Lookup caller, SymbolLookup look
} else {
unmarshalSlot = -1;
}
blockCodeBuilder.loadInstruction(TypeKind.from(cd_returnTypeDowncall), resultSlot);
blockCodeBuilder.loadLocal(TypeKind.from(cd_returnTypeDowncall), resultSlot);
}
final Convert convert = method.getDeclaredAnnotation(Convert.class);
if (convert != null && returnType == boolean.class) {
Expand Down Expand Up @@ -612,18 +612,18 @@ private static <T> T loadBytecode(MethodHandles.Lookup caller, SymbolLookup look
// reset stack
if (shouldAddStack) {
if (!returnVoid) {
blockCodeBuilder.storeInstruction(returnTypeKind, unmarshalSlot);
blockCodeBuilder.storeLocal(returnTypeKind, unmarshalSlot);
}
blockCodeBuilder.aload(stackSlot)
.lload(stackPointerSlot)
.invokevirtual(CD_MemoryStack, "setPointer", MTD_void_long);
if (!returnVoid) {
blockCodeBuilder.loadInstruction(returnTypeKind, unmarshalSlot);
blockCodeBuilder.loadLocal(returnTypeKind, unmarshalSlot);
}
}

// return
blockCodeBuilder.returnInstruction(returnTypeKind);
blockCodeBuilder.return_(returnTypeKind);
},
catchBuilder -> catchBuilder.catching(CD_Throwable, blockCodeBuilder -> {
final int slot = blockCodeBuilder.allocateLocal(TypeKind.ReferenceType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ public boolean process(CodeBuilder builder, ProcessorType type, ArgumentProcesso
if (value == ProcessorType.Value.BOOLEAN &&
context.convert() != null) {
final Type convertType = context.convert().value();
builder.loadInstruction(
builder.loadLocal(
value.typeKind(),
context.parameterSlot()
).invokestatic(CD_Marshal,
marshalFromBooleanMethod(convertType),
MethodTypeDesc.of(convertType.classDesc(), CD_boolean));
} else {
builder.loadInstruction(
builder.loadLocal(
value.typeKind().asLoadable(),
context.parameterSlot()
);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/overrun/marshal/struct/StructAllocator.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ private static byte[] buildBytecode(MethodHandles.Lookup lookup, StructLayout la
list.add(CD_long);
list.addAll(getterParams);
})))
.returnInstruction(returnKind);
.return_(returnKind);
});

// setter
Expand All @@ -302,7 +302,7 @@ private static byte[] buildBytecode(MethodHandles.Lookup lookup, StructLayout la
for (int i = 0; i < indexCount; i++) {
codeBuilder.lload(codeBuilder.parameterSlot(i));
}
codeBuilder.loadInstruction(returnKind, codeBuilder.parameterSlot(indexCount))
codeBuilder.loadLocal(returnKind, codeBuilder.parameterSlot(indexCount))
.invokevirtual(CD_VarHandle, "set", MethodTypeDesc.of(CD_void, makeClassDescriptors(list -> {
list.add(CD_MemorySegment);
list.add(CD_long);
Expand All @@ -329,15 +329,15 @@ private static byte[] buildBytecode(MethodHandles.Lookup lookup, StructLayout la
.getfield(cd_thisClass, "_segment", CD_MemorySegment)
.lconst_0()
.invokevirtual(CD_VarHandle, "get", MethodTypeDesc.of(returnDesc, CD_MemorySegment, CD_long))
.returnInstruction(returnKind));
.return_(returnKind));

// setter
classBuilder.withMethodBody(name, MethodTypeDesc.of(cd_caller, returnDesc), Modifier.PUBLIC, codeBuilder -> {
codeBuilder.getstatic(cd_thisClass, vhName, CD_VarHandle)
.aload(codeBuilder.receiverSlot())
.getfield(cd_thisClass, "_segment", CD_MemorySegment)
.lconst_0()
.loadInstruction(returnKind, codeBuilder.parameterSlot(0))
.loadLocal(returnKind, codeBuilder.parameterSlot(0))
.invokevirtual(CD_VarHandle, "set", MethodTypeDesc.of(CD_void, CD_MemorySegment, CD_long, returnDesc));
codeBuilder.aload(codeBuilder.receiverSlot())
.areturn();
Expand Down

0 comments on commit 05ab407

Please sign in to comment.