Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GraalVM native-image configuration #1959

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions native/access-filter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"rules": [
{
"includeClasses": "**"
},
{
"excludeClasses": "org.apache.logging.log4j.**"
}
]
}
10 changes: 10 additions & 0 deletions native/caller-filter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"rules": [
{
"excludeClasses": "**"
},
{
"includeClasses": "com.zaxxer.hikari.**"
}
]
}
10 changes: 10 additions & 0 deletions native/user-code-filter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"rules": [
{
"excludeClasses": "**"
},
{
"includeClasses": "com.zaxxer.hikari.**"
}
]
}
28 changes: 28 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@
<resource>
<directory>target/classes</directory>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>

<plugins>
Expand Down Expand Up @@ -654,5 +657,30 @@
</dependency>
</dependencies>
</profile>

<profile>
<id>native</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.9.13</version>
<extensions>true</extensions>
<configuration>
<agent>
<options>
<option>experimental-conditional-config-part</option>
</options>
<options name="test">
<option>access-filter-file=${project.basedir}/native/access-filter.json</option>
<option>caller-filter-file=${project.basedir}/native/caller-filter.json</option>
</options>
</agent>
Comment on lines +671 to +679
Copy link

@linghengqian linghengqian Nov 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • As a reminder, you have not configured native/user-code-filter.json

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Sorry, I noticed it in the shell script

</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
12 changes: 12 additions & 0 deletions run-tests-with-agent.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -euo pipefail

echo "Running tests..."
mvn clean test -Pnative -Dagent=true -Dmaven.test.failure.ignore=true -Djacoco.skip=true

echo "Post-processing native-image files"
INPUT_DIR=(target/native/agent-output/test/session-*)
OUTPUT_DIR="src/main/resources/META-INF/native-image/com.zaxxer/HikariCP"
mkdir -p "$OUTPUT_DIR"
native-image-configure generate-conditional --user-code-filter=native/user-code-filter.json --input-dir="$INPUT_DIR" --output-dir="$OUTPUT_DIR"
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"name": "java.lang.ClassLoader",
"methods": [
{
"name": "getPlatformClassLoader",
"parameterTypes": []
},
{
"name": "loadClass",
"parameterTypes": [
"java.lang.String"
]
}
]
},
{
"name": "jdk.internal.loader.ClassLoaders$PlatformClassLoader"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"type":"agent-extracted",
"classes":[
]
}
]

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"condition": {
"typeReachable": "com.zaxxer.hikari.pool.ProxyConnection$ClosedConnection"
},
"interfaces": [
"java.sql.Connection"
]
}
]
Loading