Skip to content

Commit 094af5e

Browse files
committed
Example for registration via feature
1 parent 2f81a01 commit 094af5e

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@
345345
</profiles>
346346

347347
<dependencies>
348+
348349
<dependency>
349350
<groupId>junit</groupId>
350351
<artifactId>junit</artifactId>
@@ -370,6 +371,11 @@
370371
<version>1.4</version>
371372
<scope>test</scope>
372373
</dependency>
374+
<dependency>
375+
<groupId>org.graalvm.sdk</groupId>
376+
<artifactId>graal-sdk</artifactId>
377+
<version>23.1.1</version>
378+
</dependency>
373379
</dependencies>
374380
<build>
375381
<resources>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package software.amazon.awssdk.crt.graalvm;
2+
3+
4+
import org.graalvm.nativeimage.hosted.Feature;
5+
import org.graalvm.nativeimage.hosted.RuntimeJNIAccess;
6+
import software.amazon.awssdk.crt.http.HttpRequestBase;
7+
8+
9+
class JNIRegistrationFeature implements Feature {
10+
public void beforeAnalysis(BeforeAnalysisAccess access) {
11+
try {
12+
RuntimeJNIAccess.register(HttpRequestBase.class);
13+
RuntimeJNIAccess.register(HttpRequestBase.class.getDeclaredField("bodyStream"));
14+
} catch (NoSuchFieldException e) {
15+
throw new RuntimeException(e);
16+
}
17+
}
18+
}
19+

src/main/resources/META-INF/native-image/software.amazon.awssdk/crt/aws-crt/jni-config.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,6 @@
174174
"name":"software.amazon.awssdk.crt.http.HttpRequest",
175175
"methods":[{"name":"<init>","parameterTypes":["java.nio.ByteBuffer","software.amazon.awssdk.crt.http.HttpRequestBodyStream"] }]
176176
},
177-
{
178-
"name":"software.amazon.awssdk.crt.http.HttpRequestBase",
179-
"fields":[{"name":"bodyStream"}]
180-
},
181177
{
182178
"name":"software.amazon.awssdk.crt.http.HttpRequestBodyStream",
183179
"methods":[{"name":"getLength","parameterTypes":[] }, {"name":"resetPosition","parameterTypes":[] }, {"name":"sendRequestBody","parameterTypes":["java.nio.ByteBuffer"] }]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Args=-H:ClassInitialization=org.slf4j:build_time
1+
Args=-H:ClassInitialization=org.slf4j:build_time --features=software.amazon.awssdk.crt.graalvm.JNIRegistrationFeature

0 commit comments

Comments
 (0)