Skip to content

Commit

Permalink
Example for registration via feature
Browse files Browse the repository at this point in the history
  • Loading branch information
maschnetwork committed Jun 1, 2024
1 parent 2f81a01 commit 094af5e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@
</profiles>

<dependencies>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -370,6 +371,11 @@
<version>1.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>graal-sdk</artifactId>
<version>23.1.1</version>
</dependency>
</dependencies>
<build>
<resources>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package software.amazon.awssdk.crt.graalvm;


import org.graalvm.nativeimage.hosted.Feature;
import org.graalvm.nativeimage.hosted.RuntimeJNIAccess;
import software.amazon.awssdk.crt.http.HttpRequestBase;


class JNIRegistrationFeature implements Feature {
public void beforeAnalysis(BeforeAnalysisAccess access) {
try {
RuntimeJNIAccess.register(HttpRequestBase.class);
RuntimeJNIAccess.register(HttpRequestBase.class.getDeclaredField("bodyStream"));
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,6 @@
"name":"software.amazon.awssdk.crt.http.HttpRequest",
"methods":[{"name":"<init>","parameterTypes":["java.nio.ByteBuffer","software.amazon.awssdk.crt.http.HttpRequestBodyStream"] }]
},
{
"name":"software.amazon.awssdk.crt.http.HttpRequestBase",
"fields":[{"name":"bodyStream"}]
},
{
"name":"software.amazon.awssdk.crt.http.HttpRequestBodyStream",
"methods":[{"name":"getLength","parameterTypes":[] }, {"name":"resetPosition","parameterTypes":[] }, {"name":"sendRequestBody","parameterTypes":["java.nio.ByteBuffer"] }]
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Args=-H:ClassInitialization=org.slf4j:build_time
Args=-H:ClassInitialization=org.slf4j:build_time --features=software.amazon.awssdk.crt.graalvm.JNIRegistrationFeature

0 comments on commit 094af5e

Please sign in to comment.