From a80c643854f35e0a223d824eaa99a093909d7da7 Mon Sep 17 00:00:00 2001 From: Tomas Langer Date: Tue, 3 Oct 2023 12:27:04 +0200 Subject: [PATCH 1/9] Native image update - Java 21 - latest version - replace artifact id - remove initialize-at-build-time in SE --- .github/workflows/validate.yml | 13 +- applications/parent/pom.xml | 2 +- applications/se/pom.xml | 5 + .../common/files/Dockerfile.native.mustache | 5 +- .../helidon-common/native-image.properties | 18 - .../native-image.properties | 19 - .../resource-config.json | 10 + .../helidon-conifg-mp/resource-config.json | 10 + .../helidon-config/resource-config.json | 43 ++ .../native-image.properties | 4 +- .../native-image.properties | 17 - .../native-image.properties | 18 - .../helidon-config-yaml/resource-config.json | 12 + .../native-image.properties | 41 -- dependencies/pom.xml | 4 +- docs/includes/guides/graalnative.adoc | 14 +- docs/mp/aot.adoc | 16 +- etc/dependency-check-suppression.xml | 2 +- etc/scripts/test-packaging-native.sh | 11 +- .../helidon-quickstart-mp/Dockerfile.native | 5 +- .../helidon-quickstart-mp/README.md | 2 +- .../quickstarts/helidon-quickstart-mp/pom.xml | 4 +- .../native-image.properties | 2 +- .../helidon-quickstart-se/Dockerfile.native | 7 +- .../helidon-quickstart-se/README.md | 2 +- .../quickstarts/helidon-quickstart-se/pom.xml | 14 + .../Dockerfile.native | 5 +- .../Dockerfile.native | 5 +- .../README.md | 2 +- .../native-image.properties | 17 - .../native-image.properties | 18 + .../native-image.properties | 8 +- .../native-image.properties | 17 + .../native-image.properties | 20 - .../native-image.properties | 10 +- .../resource-config.json | 8 + .../native-image/reflection-config.json | 3 +- .../native-image.properties | 25 +- .../resource-config.json | 5 + integrations/db/h2/pom.xml | 2 +- .../mysql/native-image.properties | 5 +- integrations/db/pgsql/pom.xml | 2 +- .../graal/mp-native-image-extension/pom.xml | 6 +- .../extension/HelidonMpFeature.java | 572 ++++++++++++++++++ .../extension/JaxRsMethodAnalyzer.java | 10 +- .../mp/nativeimage/extension/WeldFeature.java | 18 +- .../src/main/java/module-info.java | 7 +- .../native-image.properties | 46 ++ .../graal/native-image-extension/pom.xml | 2 +- .../HelidonReflectionConfiguration.java | 66 +- .../extension/HelidonReflectionFeature.java | 136 +---- .../nativeimage/extension/NativeTrace.java | 42 +- .../nativeimage/extension/NativeUtil.java | 138 ++++- .../src/main/java/module-info.java | 3 +- .../native-image.properties | 23 +- .../resource-config.json | 3 + .../native-image.properties | 17 - .../io/helidon/logging/jul/JulProvider.java | 20 +- .../native-image/reflection-config.json | 3 +- .../helidon-logging-jul/resource-config.json | 3 + messaging/connectors/kafka/pom.xml | 2 +- .../kafka/src/main/java/module-info.java | 2 +- .../native-image.properties | 15 +- .../resource-config.json | 30 +- .../native-image.properties | 19 - .../helidon-metrics/native-image.properties | 17 - .../native-image/reflection-config.json | 9 + .../native-image.properties | 24 - .../native-image.properties | 10 +- .../native-image.properties | 4 +- .../native-image.properties | 19 + .../helidon-common}/native-image.properties | 4 +- .../native-image.properties | 4 +- .../helidon/native-image/proxy-config.json | 6 - .../native-image.properties | 26 + .../proxy-config.json | 11 + .../native-image/reflection-config.json | 44 +- .../native-image.properties | 28 + .../proxy-config.json | 20 + .../resource-config.json | 0 .../HelidonRestCdiExtension.java | 8 +- .../native-image.properties | 2 +- .../native-image.properties | 7 +- .../helidon-security/native-image.properties | 18 - .../helidon-security/resource-config.json | 7 + tests/integration/native-image/mp-1/README.md | 1 - tests/integration/native-image/mp-1/pom.xml | 25 +- .../native-image.properties | 17 + tests/integration/native-image/mp-2/README.md | 2 +- tests/integration/native-image/mp-2/pom.xml | 11 +- .../native-image.properties | 17 + .../native-image.properties | 17 + .../native-image/native-image.properties | 18 - .../native-image.properties | 7 +- .../native-image.properties | 3 +- .../reflect-config.json | 7 + 96 files changed, 1400 insertions(+), 628 deletions(-) delete mode 100644 common/common/src/main/resources/META-INF/native-image/io.helidon.common/helidon-common/native-image.properties delete mode 100644 common/media-type/src/main/resources/META-INF/native-image/io.helidon.common/helidon-common-media-type/native-image.properties create mode 100644 common/media-type/src/main/resources/META-INF/native-image/io.helidon.common/helidon-common-media-type/resource-config.json create mode 100644 config/config-mp/src/main/resources/META-INF/native-image/io.helidon.config/helidon-conifg-mp/resource-config.json delete mode 100644 config/yaml-mp/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config-yaml-mp/native-image.properties delete mode 100644 config/yaml/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config-yaml/native-image.properties delete mode 100644 dbclient/mongodb/src/main/resources/META-INF/native-image/io.helidon.dbclient/helidon-dbclient-mongo/native-image.properties rename {http/media/jsonp/src/main/resources/META-INF/native-image/io.helidon.nima.http.media/helidon-nima-http-mediate-jsonp => examples/quickstarts/helidon-quickstart-mp/src/main/resources/META-INF/io.helidon.examples.quickstarts/helidon-quickstart-mp}/native-image.properties (92%) delete mode 100644 http/media/jsonb/src/main/resources/META-INF/native-image/io.helidon.nima.http.media/helidon-nima-http-media-jsonb/native-image.properties create mode 100644 http/media/jsonp/src/main/resources/META-INF/native-image/io.helidon.http.media/helidon-http-media-jsonp/native-image.properties create mode 100644 integrations/cdi/datasource/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-datasource/native-image.properties delete mode 100644 integrations/cdi/hibernate-cdi/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-hibernate/native-image.properties create mode 100644 integrations/graal/mp-native-image-extension/src/main/java/io/helidon/integrations/graal/mp/nativeimage/extension/HelidonMpFeature.java rename integrations/graal/{native-image-extension/src/main/java/io/helidon/integrations/graal => mp-native-image-extension/src/main/java/io/helidon/integrations/graal/mp}/nativeimage/extension/JaxRsMethodAnalyzer.java (92%) create mode 100644 integrations/graal/mp-native-image-extension/src/main/resources/META-INF/native-image/io.helidon.integrations.graal/helidon-mp-graal-native-image-extension/native-image.properties delete mode 100644 jersey/jsonp/src/main/resources/META-INF/native-image/io.helidon.jersey/helidon-jersey-media-jsonp/native-image.properties rename {integrations/graal/native-image-extension => logging/jul}/src/main/resources/META-INF/helidon/native-image/reflection-config.json (59%) delete mode 100644 metrics/api/src/main/resources/META-INF/native-image/io.helidon.metrics/helidon-metrics-api/native-image.properties delete mode 100644 metrics/metrics/src/main/resources/META-INF/native-image/io.helidon.metrics/helidon-metrics/native-image.properties create mode 100644 metrics/providers/micrometer/src/main/resources/META-INF/helidon/native-image/reflection-config.json delete mode 100644 microprofile/cdi/src/main/resources/META-INF/native-image/io.helidon.microprofile.cdi/helidon-microprofile-cdi/native-image.properties rename {config/hocon-mp/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config-hocon-mp => microprofile/cors/src/main/resources/META-INF/native-image/io.helidon.microprofile/helidon-microprofile-cors}/native-image.properties (82%) create mode 100644 microprofile/jwt-auth/src/main/resources/META-INF/native-image/io.helidon.microprofile/helidon-microprofile-jwt-auth/native-image.properties rename {config/config/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config => microprofile/metrics/src/main/resources/META-INF/native-image/io.helidon/helidon-common}/native-image.properties (82%) rename {openapi/openapi/src/main/resources/META-INF/native-image/io.helidon.openapi/helidon-openapi => microprofile/openapi/src/main/resources/META-INF/native-image/io.helidon.microproflie/helidon-microprofile-openapi}/native-image.properties (81%) delete mode 100644 microprofile/security/src/main/resources/META-INF/helidon/native-image/proxy-config.json create mode 100644 microprofile/security/src/main/resources/META-INF/native-image/io.helidon.microprofile/helidon-microprofile-security/native-image.properties create mode 100644 microprofile/security/src/main/resources/META-INF/native-image/io.helidon.microprofile/helidon-microprofile-security/proxy-config.json create mode 100644 microprofile/server/src/main/resources/META-INF/native-image/io.helidon.microrpofile/helidon-microprofile-server/native-image.properties create mode 100644 microprofile/server/src/main/resources/META-INF/native-image/io.helidon.microrpofile/helidon-microprofile-server/proxy-config.json rename microprofile/server/src/main/resources/META-INF/native-image/{io.helidon.microprofile.jaxrs/helidon-microprofile-jaxrs => io.helidon.microrpofile/helidon-microprofile-server}/resource-config.json (100%) rename {http/media/jackson/src/main/resources/META-INF/native-image/io.helidon.nima.http.media/helidon-nima-http-media-jackson => microprofile/tracing/src/main/resources/META-INF/native-image/io.helidon.microprofile/helidon-microprofile-tracing}/native-image.properties (91%) delete mode 100644 security/security/src/main/resources/META-INF/native-image/io.helidon.security/helidon-security/native-image.properties create mode 100644 security/security/src/main/resources/META-INF/native-image/io.helidon.security/helidon-security/resource-config.json create mode 100644 tests/integration/native-image/mp-1/src/main/resources/META-INF/native-image/io.helidon.tests.integration.native-image/helidon-tests-native-image-mp1/native-image.properties create mode 100644 tests/integration/native-image/mp-2/src/main/resources/META-INF/native-image/io.helidon.tests.integration.native-image/helidon-tests-native-image-mp2/native-image.properties create mode 100644 tests/integration/native-image/mp-3/src/main/resources/META-INF/native-image/io.helidon.tests.integration.native-image/helidon-tests-native-image-mp3/native-image.properties delete mode 100644 tests/integration/native-image/se-1/src/main/resources/META-INF/native-image/native-image.properties create mode 100644 webserver/access-log/src/main/resources/META-INF/native-image/io.helidon.webserver/helidon-webserver-access-log/reflect-config.json diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index f30bad398e3..00b0915d1f6 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -140,13 +140,22 @@ jobs: - name: Test archetypes run: etc/scripts/test-archetypes.sh packaging: - timeout-minutes: 30 + timeout-minutes: 60 strategy: matrix: os: [ ubuntu-20.04, macos-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 + - uses: graalvm/setup-graalvm@v1 + with: + version: 23.1.0 + java-version: 21 + components: native-image + github-token: ${{ secrets.GITHUB_TOKEN }} + native-image-job-reports: true + set-java-home: false + cache: maven - name: Set up JDK ${{ env.JAVA_VERSION }} uses: actions/setup-java@v3.13.0 with: @@ -159,3 +168,5 @@ jobs: run: etc/scripts/test-packaging-jar.sh - name: JLink packaging run: etc/scripts/test-packaging-jlink.sh + - name: Native-Image packaging + run: etc/scripts/test-packaging-native.sh diff --git a/applications/parent/pom.xml b/applications/parent/pom.xml index 8b812876a1e..5c7852531e3 100644 --- a/applications/parent/pom.xml +++ b/applications/parent/pom.xml @@ -45,7 +45,7 @@ 4.0.0-M2 4.0.0-M2 3.0.2 - 0.9.16 + 0.9.27 1.5.0.Final 0.6.1 3.3.1 diff --git a/applications/se/pom.xml b/applications/se/pom.xml index ad7707c9aa2..55d54a804be 100644 --- a/applications/se/pom.xml +++ b/applications/se/pom.xml @@ -53,6 +53,11 @@ compile package + diff --git a/archetypes/helidon/src/main/archetype/common/files/Dockerfile.native.mustache b/archetypes/helidon/src/main/archetype/common/files/Dockerfile.native.mustache index 08ada4f85aa..4ff85c6391e 100644 --- a/archetypes/helidon/src/main/archetype/common/files/Dockerfile.native.mustache +++ b/archetypes/helidon/src/main/archetype/common/files/Dockerfile.native.mustache @@ -1,9 +1,6 @@ # 1st stage, build the app -FROM ghcr.io/graalvm/graalvm-ce:ol9-java21-22.3.1 as build - -# Install native-image -RUN gu install native-image +FROM ghcr.io/graalvm/graalvm-community:21.0.0-ol9 as build WORKDIR /usr/share diff --git a/common/common/src/main/resources/META-INF/native-image/io.helidon.common/helidon-common/native-image.properties b/common/common/src/main/resources/META-INF/native-image/io.helidon.common/helidon-common/native-image.properties deleted file mode 100644 index 059f9251bf4..00000000000 --- a/common/common/src/main/resources/META-INF/native-image/io.helidon.common/helidon-common/native-image.properties +++ /dev/null @@ -1,18 +0,0 @@ -# -# Copyright (c) 2022 Oracle and/or its affiliates. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# all Helidon classes should be designed for native image, exceptions configured in specific modules -Args=--initialize-at-build-time=io.helidon diff --git a/common/media-type/src/main/resources/META-INF/native-image/io.helidon.common/helidon-common-media-type/native-image.properties b/common/media-type/src/main/resources/META-INF/native-image/io.helidon.common/helidon-common-media-type/native-image.properties deleted file mode 100644 index d3c84a6c0b3..00000000000 --- a/common/media-type/src/main/resources/META-INF/native-image/io.helidon.common/helidon-common-media-type/native-image.properties +++ /dev/null @@ -1,19 +0,0 @@ -# -# Copyright (c) 2019, 2020 Oracle and/or its affiliates. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -Args=--initialize-at-build-time=io.helidon.common.media.type \ - -H:IncludeResources=io/helidon/common/media/type/default-media-types.properties \ - -H:IncludeResources=META-INF/helidon/media-types.properties diff --git a/common/media-type/src/main/resources/META-INF/native-image/io.helidon.common/helidon-common-media-type/resource-config.json b/common/media-type/src/main/resources/META-INF/native-image/io.helidon.common/helidon-common-media-type/resource-config.json new file mode 100644 index 00000000000..2bd231f9bbc --- /dev/null +++ b/common/media-type/src/main/resources/META-INF/native-image/io.helidon.common/helidon-common-media-type/resource-config.json @@ -0,0 +1,10 @@ +{ + "resources": [ + { + "pattern": "META-INF/helidon/media-types.properties" + }, + { + "pattern": "io/helidon/common/media/type/default-media-types.properties" + } + ] +} diff --git a/config/config-mp/src/main/resources/META-INF/native-image/io.helidon.config/helidon-conifg-mp/resource-config.json b/config/config-mp/src/main/resources/META-INF/native-image/io.helidon.config/helidon-conifg-mp/resource-config.json new file mode 100644 index 00000000000..f06d7c425ee --- /dev/null +++ b/config/config-mp/src/main/resources/META-INF/native-image/io.helidon.config/helidon-conifg-mp/resource-config.json @@ -0,0 +1,10 @@ +{ + "resources": [ + { + "pattern": "mp-meta-config.yaml" + }, + { + "pattern": "mp-meta-config.properties" + } + ] +} \ No newline at end of file diff --git a/config/config/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config/resource-config.json b/config/config/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config/resource-config.json index 985c1ada18c..e65c8bd1316 100644 --- a/config/config/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config/resource-config.json +++ b/config/config/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config/resource-config.json @@ -3,8 +3,51 @@ { "pattern": "application.properties" }, + { + "pattern": "application.yaml" + }, + { + "pattern": "application.json" + }, + { + "pattern": "application.conf" + }, + { + "pattern": "application.yml" + }, { "pattern": "meta-config.properties" + }, + { + "pattern": "meta-config.json" + }, + { + "pattern": "meta-config.yaml" + }, + { + "pattern": "meta-config.yml" + }, + { + "pattern": "meta-config.conf" + }, + { + "pattern": "config-profile.yaml" + }, + + { + "pattern": "config-profile.properties" + }, + + { + "pattern": "config-profile.json" + }, + + { + "pattern": "config-profile.conf" + }, + + { + "pattern": "config-profile.yml" } ] } \ No newline at end of file diff --git a/config/git/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config-git/native-image.properties b/config/git/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config-git/native-image.properties index 819cb6e5894..f6f08b9531d 100644 --- a/config/git/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config-git/native-image.properties +++ b/config/git/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config-git/native-image.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2020 Oracle and/or its affiliates. +# Copyright (c) 2020, 2023 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,4 +14,4 @@ # limitations under the License. # -Args=--initialize-at-build-time=org.slf4j -H:EnableURLProtocols=https +Args=--enable-https diff --git a/config/yaml-mp/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config-yaml-mp/native-image.properties b/config/yaml-mp/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config-yaml-mp/native-image.properties deleted file mode 100644 index f1fa1ebe9c3..00000000000 --- a/config/yaml-mp/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config-yaml-mp/native-image.properties +++ /dev/null @@ -1,17 +0,0 @@ -# -# Copyright (c) 2021 Oracle and/or its affiliates. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -Args=--initialize-at-build-time=io.helidon.config.yaml.mp diff --git a/config/yaml/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config-yaml/native-image.properties b/config/yaml/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config-yaml/native-image.properties deleted file mode 100644 index 30aecd85516..00000000000 --- a/config/yaml/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config-yaml/native-image.properties +++ /dev/null @@ -1,18 +0,0 @@ -# -# Copyright (c) 2019, 2022 Oracle and/or its affiliates. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -Args=--initialize-at-build-time=io.helidon.config.yaml \ - --initialize-at-build-time=org.yaml.snakeyaml diff --git a/config/yaml/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config-yaml/resource-config.json b/config/yaml/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config-yaml/resource-config.json index 6ff30a89d12..4c404da6621 100644 --- a/config/yaml/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config-yaml/resource-config.json +++ b/config/yaml/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config-yaml/resource-config.json @@ -11,6 +11,18 @@ }, { "pattern": "config-profile-.*\\.yaml$" + }, + { + "pattern": "application.yml" + }, + { + "pattern": "meta-config.yml" + }, + { + "pattern": "config-profile.yml" + }, + { + "pattern": "config-profile-.*\\.yml$" } ] } \ No newline at end of file diff --git a/dbclient/mongodb/src/main/resources/META-INF/native-image/io.helidon.dbclient/helidon-dbclient-mongo/native-image.properties b/dbclient/mongodb/src/main/resources/META-INF/native-image/io.helidon.dbclient/helidon-dbclient-mongo/native-image.properties deleted file mode 100644 index af2565acb9b..00000000000 --- a/dbclient/mongodb/src/main/resources/META-INF/native-image/io.helidon.dbclient/helidon-dbclient-mongo/native-image.properties +++ /dev/null @@ -1,41 +0,0 @@ -# -# Copyright (c) 2019, 2023 Oracle and/or its affiliates. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -Args= --initialize-at-run-time=org.bson.json.DateTimeFormatter$JaxbDateTimeFormatter \ - --initialize-at-build-time=org.bson.codecs \ - --initialize-at-build-time=org.bson.reader \ - --initialize-at-build-time=org.bson.internal.CodecCache \ - --initialize-at-build-time=org.bson.internal.Optional \ - --initialize-at-build-time=org.bson.UuidRepresentation \ - --initialize-at-build-time=org.bson.internal.LazyCodec \ - --initialize-at-build-time=org.bson.AbstractBsonReader \ - --initialize-at-build-time=org.bson.internal.ProvidersCodecRegistry \ - --initialize-at-build-time=org.bson.internal.ChildCodecRegistry \ - --initialize-at-build-time=org.bson.internal.Optional \ - --initialize-at-build-time=org.bson.internal.Optional$1 \ - --initialize-at-build-time=org.bson.internal.Optional$Some \ - --initialize-at-build-time=org.bson.AbstractBsonReader \ - --initialize-at-build-time=org.bson.AbstractBsonReader$1 \ - --initialize-at-build-time=org.bson.AbstractBsonReader$Context \ - --initialize-at-build-time=org.bson.Document \ - --initialize-at-build-time=org.bson.assertions.Assertions \ - --initialize-at-build-time=org.bson.json.JsonScanner \ - --initialize-at-build-time=org.bson.json.JsonReader \ - --initialize-at-build-time=org.bson.json.JsonReader$1 \ - --initialize-at-build-time=org.bson.json.JsonStringBuffer \ - --initialize-at-build-time=org.bson.json.JsonReader$Context \ - --initialize-at-build-time=org.bson.json.JsonToken \ - --initialize-at-build-time=org.bson.json.JsonBuffer diff --git a/dependencies/pom.xml b/dependencies/pom.xml index 72854d69c8c..4189c704516 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -54,7 +54,7 @@ 1.33.3 2.3.3 3.21.7 - 22.3.0 + 23.1.0 18.6 18.3 2.9.0 @@ -915,7 +915,7 @@ org.graalvm.sdk - graal-sdk + nativeimage ${version.lib.graalvm} diff --git a/docs/includes/guides/graalnative.adoc b/docs/includes/guides/graalnative.adoc index 80763152a68..2e5212aa5a0 100644 --- a/docs/includes/guides/graalnative.adoc +++ b/docs/includes/guides/graalnative.adoc @@ -37,7 +37,8 @@ include::{rootdir}/includes/prerequisites.adoc[tag=prerequisites-graal] == Install GraalVM and the Native Image Command After {graalvm-doc-url}/docs/getting-started/[downloading and installing] GraalVM, -set the `GRAALVM_HOME` environment variable to point at your GraalVM installation. +set the `GRAALVM_HOME` environment variable to point at your GraalVM installation, +or use the GraalVM installation as your Java home. [source,bash] ---- @@ -45,14 +46,7 @@ set the `GRAALVM_HOME` environment variable to point at your GraalVM installatio export GRAALVM_HOME=/usr/local/graalvm-jdk-21+35.1/Contents/Home/ ---- -Then install the optional `native-image` command: - -[source,bash] ----- -$GRAALVM_HOME/bin/gu install native-image ----- - -And verify: +Then verify: [source,bash] ---- @@ -130,7 +124,7 @@ mvn package -Pnative-image ---- [TIP] -This uses the `helidon-maven-plugin` to perform the native compilation using your installed +This uses the `org.graalvm.buildtools:native-maven-plugin` to perform the native compilation using your installed copy of GraalVM. It might take a while to complete. Once it completes start the application using the native executable (no JVM!): diff --git a/docs/mp/aot.adoc b/docs/mp/aot.adoc index 0f4f50ea545..a157bbd228a 100644 --- a/docs/mp/aot.adoc +++ b/docs/mp/aot.adoc @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// - Copyright (c) 2021, 2022 Oracle and/or its affiliates. + Copyright (c) 2021, 2023 Oracle and/or its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -31,10 +31,22 @@ application pom as a parent of your module, you can use the following steps to build a native image from your application: 1. Create an environment variable `GRAALVM_HOME` pointing to your installation of - GraalVM with `native-image` installed + GraalVM, or use a GraalVM JDK to build your project +2. Add configuration to initialize your packages at build time (see below) 2. Run Maven command `mvn clean package -Pnative-image` 3. Execute the native executable created in `target` directory of your project +== Initialize at build time +Due to restrictions of our current implementation of integration with native image for CDI, +we must initialize a subset of types at build time. +As a result, all beans created within CDI need to be also initialized at build time. +Easiest approach to support such compilation is to: +1. Create `src/main/resources/META-INF/native-image/groupId/artifactId/native-image.properties` file (`groupId` and `artifactId` of the module you are building should be used) +2. Add the following line to the file: +```properties +Args=--initialize-at-build-time=your.application.package +``` + == AOT supported modules Some Helidon components are not (yet) supported in native image, some have diff --git a/etc/dependency-check-suppression.xml b/etc/dependency-check-suppression.xml index 569eb489889..e4dfc3a0079 100644 --- a/etc/dependency-check-suppression.xml +++ b/etc/dependency-check-suppression.xml @@ -139,7 +139,7 @@ --> ^pkg:maven/org\.graalvm\.sdk/graal\-sdk@.*$ CVE-2023-22006 diff --git a/etc/scripts/test-packaging-native.sh b/etc/scripts/test-packaging-native.sh index b7311b891d4..507ec4b38d2 100755 --- a/etc/scripts/test-packaging-native.sh +++ b/etc/scripts/test-packaging-native.sh @@ -39,9 +39,6 @@ mvn ${MAVEN_ARGS} --version echo "GRAALVM_HOME=${GRAALVM_HOME}"; ${GRAALVM_HOME}/bin/native-image --version; -echo Skipping native image tests, until we have a Java 21 build -exit 0 - # Temporary workaround until job stages will share maven repository mvn ${MAVEN_ARGS} -f ${WS_DIR}/pom.xml \ install -e \ @@ -56,8 +53,7 @@ cd ${WS_DIR}/tests/integration/native-image mvn ${MAVEN_ARGS} -e clean install # Build native images -# TODO:java19 -readonly native_image_tests="se-1" +readonly native_image_tests="se-1 mp-1 mp-3" for native_test in ${native_image_tests}; do cd ${WS_DIR}/tests/integration/native-image/${native_test} mvn ${MAVEN_ARGS} -e clean package -Pnative-image @@ -65,9 +61,8 @@ done # Run this one because it has no pre-reqs and self-tests # Uses relative path to read configuration -# TODO:java19 -# cd ${WS_DIR}/tests/integration/native-image/mp-1 -# ${WS_DIR}/tests/integration/native-image/mp-1/target/helidon-tests-native-image-mp-1 || true +cd ${WS_DIR}/tests/integration/native-image/mp-1 +${WS_DIR}/tests/integration/native-image/mp-1/target/helidon-tests-native-image-mp-1 || true # Run se-1 exiting on started cd ${WS_DIR}/tests/integration/native-image/se-1 diff --git a/examples/quickstarts/helidon-quickstart-mp/Dockerfile.native b/examples/quickstarts/helidon-quickstart-mp/Dockerfile.native index 48098ab7055..d3e3eddc569 100644 --- a/examples/quickstarts/helidon-quickstart-mp/Dockerfile.native +++ b/examples/quickstarts/helidon-quickstart-mp/Dockerfile.native @@ -15,10 +15,7 @@ # # 1st stage, build the app -FROM ghcr.io/graalvm/graalvm-ce:ol9-java21-22.3.1 as build - -# Install native-image -RUN gu install native-image +FROM ghcr.io/graalvm/graalvm-community:21.0.0-ol9 as build WORKDIR /usr/share diff --git a/examples/quickstarts/helidon-quickstart-mp/README.md b/examples/quickstarts/helidon-quickstart-mp/README.md index 4a025bd51e0..294e1315cab 100644 --- a/examples/quickstarts/helidon-quickstart-mp/README.md +++ b/examples/quickstarts/helidon-quickstart-mp/README.md @@ -80,7 +80,7 @@ You can build a native executable in 2 different ways: ### Local build Download Graal VM at https://www.graalvm.org/downloads. We recommend -version `22.3.0` or later. +version `23.1.0` or later. ``` # Setup the environment diff --git a/examples/quickstarts/helidon-quickstart-mp/pom.xml b/examples/quickstarts/helidon-quickstart-mp/pom.xml index 7138557694a..aecf44808bc 100644 --- a/examples/quickstarts/helidon-quickstart-mp/pom.xml +++ b/examples/quickstarts/helidon-quickstart-mp/pom.xml @@ -18,8 +18,8 @@ --> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 io.helidon.applications diff --git a/http/media/jsonp/src/main/resources/META-INF/native-image/io.helidon.nima.http.media/helidon-nima-http-mediate-jsonp/native-image.properties b/examples/quickstarts/helidon-quickstart-mp/src/main/resources/META-INF/io.helidon.examples.quickstarts/helidon-quickstart-mp/native-image.properties similarity index 92% rename from http/media/jsonp/src/main/resources/META-INF/native-image/io.helidon.nima.http.media/helidon-nima-http-mediate-jsonp/native-image.properties rename to examples/quickstarts/helidon-quickstart-mp/src/main/resources/META-INF/io.helidon.examples.quickstarts/helidon-quickstart-mp/native-image.properties index 684c15bed9b..bac3f92ae57 100644 --- a/http/media/jsonp/src/main/resources/META-INF/native-image/io.helidon.nima.http.media/helidon-nima-http-mediate-jsonp/native-image.properties +++ b/examples/quickstarts/helidon-quickstart-mp/src/main/resources/META-INF/io.helidon.examples.quickstarts/helidon-quickstart-mp/native-image.properties @@ -14,4 +14,4 @@ # limitations under the License. # -Args=--initialize-at-build-time=org.eclipse.parsson +Args=--initialize-at-build-time=io.helidon.examples diff --git a/examples/quickstarts/helidon-quickstart-se/Dockerfile.native b/examples/quickstarts/helidon-quickstart-se/Dockerfile.native index 66e7b435bd3..d411da6f4a6 100644 --- a/examples/quickstarts/helidon-quickstart-se/Dockerfile.native +++ b/examples/quickstarts/helidon-quickstart-se/Dockerfile.native @@ -15,10 +15,7 @@ # # 1st stage, build the app -FROM ghcr.io/graalvm/graalvm-ce:ol9-java21-22.3.1 as build - -# Install native-image -RUN gu install native-image +FROM ghcr.io/graalvm/graalvm-community:21.0.0-ol9 as build WORKDIR /usr/share @@ -36,7 +33,7 @@ WORKDIR /helidon # Incremental docker builds will always resume after that, unless you update # the pom ADD pom.xml . -RUN mvn package -Pnative-image -Dnative.image.skip -Dmaven.test.skip -Declipselink.weave.skip +RUN mvn clean package -Pnative-image -Dnative.image.skip -Dmaven.test.skip -Declipselink.weave.skip # Do the Maven build! # Incremental docker builds will resume here when you change sources diff --git a/examples/quickstarts/helidon-quickstart-se/README.md b/examples/quickstarts/helidon-quickstart-se/README.md index 23701b5accf..ef45a423e8f 100644 --- a/examples/quickstarts/helidon-quickstart-se/README.md +++ b/examples/quickstarts/helidon-quickstart-se/README.md @@ -80,7 +80,7 @@ You can build a native executable in 2 different ways: ### Local build Download Graal VM at https://www.graalvm.org/downloads. We recommend -version `22.3.0` or later. +version `23.1.0` or later. ``` # Setup the environment diff --git a/examples/quickstarts/helidon-quickstart-se/pom.xml b/examples/quickstarts/helidon-quickstart-se/pom.xml index 6c8b46afc77..51dc8f25c0b 100644 --- a/examples/quickstarts/helidon-quickstart-se/pom.xml +++ b/examples/quickstarts/helidon-quickstart-se/pom.xml @@ -106,6 +106,20 @@ + + org.graalvm.buildtools + native-maven-plugin + + + build-native-image + + + + + + + + diff --git a/examples/quickstarts/helidon-standalone-quickstart-mp/Dockerfile.native b/examples/quickstarts/helidon-standalone-quickstart-mp/Dockerfile.native index 4dcc4791a69..ea9b8eb9fb6 100644 --- a/examples/quickstarts/helidon-standalone-quickstart-mp/Dockerfile.native +++ b/examples/quickstarts/helidon-standalone-quickstart-mp/Dockerfile.native @@ -15,10 +15,7 @@ # # 1st stage, build the app -FROM ghcr.io/graalvm/graalvm-ce:ol9-java21-22.3.1 as build - -# Install native-image -RUN gu install native-image +FROM ghcr.io/graalvm/graalvm-community:21.0.0-ol9 as build WORKDIR /usr/share diff --git a/examples/quickstarts/helidon-standalone-quickstart-se/Dockerfile.native b/examples/quickstarts/helidon-standalone-quickstart-se/Dockerfile.native index 3e575c0677d..7c4461c0d40 100644 --- a/examples/quickstarts/helidon-standalone-quickstart-se/Dockerfile.native +++ b/examples/quickstarts/helidon-standalone-quickstart-se/Dockerfile.native @@ -15,10 +15,7 @@ # # 1st stage, build the app -FROM ghcr.io/graalvm/graalvm-ce:ol9-java21-22.3.1 as build - -# Install native-image -RUN gu install native-image +FROM ghcr.io/graalvm/graalvm-community:21.0.0-ol9 as build WORKDIR /usr/share diff --git a/examples/quickstarts/helidon-standalone-quickstart-se/README.md b/examples/quickstarts/helidon-standalone-quickstart-se/README.md index 708fea5f8e4..73227cca7dd 100644 --- a/examples/quickstarts/helidon-standalone-quickstart-se/README.md +++ b/examples/quickstarts/helidon-standalone-quickstart-se/README.md @@ -81,7 +81,7 @@ You can build a native executable in 2 different ways: ### Local build Download Graal VM at https://www.graalvm.org/downloads. We recommend -version `22.3.0` or later. +version `23.1.0` or later. ``` # Setup the environment diff --git a/http/media/jsonb/src/main/resources/META-INF/native-image/io.helidon.nima.http.media/helidon-nima-http-media-jsonb/native-image.properties b/http/media/jsonb/src/main/resources/META-INF/native-image/io.helidon.nima.http.media/helidon-nima-http-media-jsonb/native-image.properties deleted file mode 100644 index fbdd1e45d6c..00000000000 --- a/http/media/jsonb/src/main/resources/META-INF/native-image/io.helidon.nima.http.media/helidon-nima-http-media-jsonb/native-image.properties +++ /dev/null @@ -1,17 +0,0 @@ -# -# Copyright (c) 2022, 2023 Oracle and/or its affiliates. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -Args=--initialize-at-build-time=org.eclipse.yasson diff --git a/http/media/jsonp/src/main/resources/META-INF/native-image/io.helidon.http.media/helidon-http-media-jsonp/native-image.properties b/http/media/jsonp/src/main/resources/META-INF/native-image/io.helidon.http.media/helidon-http-media-jsonp/native-image.properties new file mode 100644 index 00000000000..79289fd9292 --- /dev/null +++ b/http/media/jsonp/src/main/resources/META-INF/native-image/io.helidon.http.media/helidon-http-media-jsonp/native-image.properties @@ -0,0 +1,18 @@ +# +# Copyright (c) 2023 Oracle and/or its affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# As we use Parsson within our native image feature, we need to initialize it at build time +Args=--initialize-at-build-time=org.eclipse.parsson --initialize-at-build-time=jakarta.json diff --git a/integrations/cdi/datasource-hikaricp/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-datasource-hikaricp/native-image.properties b/integrations/cdi/datasource-hikaricp/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-datasource-hikaricp/native-image.properties index 5901aa4594b..bc8231dc995 100644 --- a/integrations/cdi/datasource-hikaricp/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-datasource-hikaricp/native-image.properties +++ b/integrations/cdi/datasource-hikaricp/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-datasource-hikaricp/native-image.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, 2022 Oracle and/or its affiliates. +# Copyright (c) 2023 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,6 +14,6 @@ # limitations under the License. # -Args=--initialize-at-build-time=com.zaxxer.hikari \ - --initialize-at-build-time=org.slf4j \ - --initialize-at-run-time=com.zaxxer.hikari.metrics.dropwizard.CodaHaleMetricsTracker +Args=--initialize-at-build-time=io.helidon.integrations.cdi \ + --initialize-at-build-time=com.zaxxer.hikari \ + --initialize-at-build-time=org.slf4j diff --git a/integrations/cdi/datasource/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-datasource/native-image.properties b/integrations/cdi/datasource/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-datasource/native-image.properties new file mode 100644 index 00000000000..3889033718b --- /dev/null +++ b/integrations/cdi/datasource/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-datasource/native-image.properties @@ -0,0 +1,17 @@ +# +# Copyright (c) 2023 Oracle and/or its affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +Args=--initialize-at-build-time=io.helidon.integrations.datasource diff --git a/integrations/cdi/hibernate-cdi/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-hibernate/native-image.properties b/integrations/cdi/hibernate-cdi/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-hibernate/native-image.properties deleted file mode 100644 index 8f9df8f56ce..00000000000 --- a/integrations/cdi/hibernate-cdi/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-hibernate/native-image.properties +++ /dev/null @@ -1,20 +0,0 @@ -# -# Copyright (c) 2020, 2022 Oracle and/or its affiliates. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -Args=--initialize-at-build-time=org.hibernate \ - --initialize-at-build-time=org.antlr \ - --initialize-at-run-time=org.hibernate.secure.internal.StandardJaccServiceImpl \ - --initialize-at-run-time=org.hibernate.dialect diff --git a/integrations/cdi/jpa-cdi/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-jpa/native-image.properties b/integrations/cdi/jpa-cdi/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-jpa/native-image.properties index d9eb58f5af5..40104f1e5e3 100644 --- a/integrations/cdi/jpa-cdi/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-jpa/native-image.properties +++ b/integrations/cdi/jpa-cdi/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-jpa/native-image.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, 2022 Oracle and/or its affiliates. +# Copyright (c) 2023 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,5 +14,9 @@ # limitations under the License. # -Args=-H:IncludeResourceBundles=com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages \ - -H:IncludeResourceBundles=io.helidon.integrations.cdi.jpa.Messages +Args=--initialize-at-build-time=io.helidon.integrations.cdi \ + --initialize-at-build-time=jakarta.xml.bind \ + --initialize-at-build-time=org.glassfish.jaxb \ + --initialize-at-build-time=org.hibernate \ + --initialize-at-build-time=jakarta.persistence \ + --initialize-at-run-time=org.hibernate.dialect diff --git a/integrations/cdi/jpa-cdi/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-jpa/resource-config.json b/integrations/cdi/jpa-cdi/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-jpa/resource-config.json index ca4c1813bd5..edbe383ab0b 100644 --- a/integrations/cdi/jpa-cdi/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-jpa/resource-config.json +++ b/integrations/cdi/jpa-cdi/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-jpa/resource-config.json @@ -1,4 +1,12 @@ { + "bundles": [ + { + "name": "com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages" + }, + { + "name": "io.helidon.integrations.cdi.jpa.Messages" + } + ], "resources": [ { "pattern": "META-INF/persistence.xml" diff --git a/integrations/cdi/jta-cdi/src/main/resources/META-INF/helidon/native-image/reflection-config.json b/integrations/cdi/jta-cdi/src/main/resources/META-INF/helidon/native-image/reflection-config.json index 1951c308d5b..e459870b4d7 100644 --- a/integrations/cdi/jta-cdi/src/main/resources/META-INF/helidon/native-image/reflection-config.json +++ b/integrations/cdi/jta-cdi/src/main/resources/META-INF/helidon/native-image/reflection-config.json @@ -1,7 +1,8 @@ { "annotated": [], "class-hierarchy": [ - "com.arjuna.ats.jta.cdi.transactional.TransactionalInterceptorBase" + "com.arjuna.ats.jta.cdi.transactional.TransactionalInterceptorBase", + "com.arjuna.ats.arjuna.coordinator.CheckedActionFactory" ], "classes": [ "org.jboss.tm.usertx.client.ServerVMClientUserTransactionOperationsProvider", diff --git a/integrations/cdi/jta-cdi/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-jta/native-image.properties b/integrations/cdi/jta-cdi/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-jta/native-image.properties index 9f03a961a9d..962a8d7a0fe 100644 --- a/integrations/cdi/jta-cdi/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-jta/native-image.properties +++ b/integrations/cdi/jta-cdi/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-jta/native-image.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, 2022 Oracle and/or its affiliates. +# Copyright (c) 2023 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,14 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # -Args=--initialize-at-run-time=com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinationManager \ - --initialize-at-run-time=com.arjuna.ats.arjuna.coordinator.TxControl \ - --initialize-at-run-time=com.arjuna.ats.internal.arjuna.recovery.RecoveryManagerImple \ - --initialize-at-run-time=com.arjuna.ats.internal.arjuna.recovery.ExpiredEntryMonitor \ - --initialize-at-run-time=com.arjuna.ats.internal.arjuna.coordinator.ReaperThread \ - --initialize-at-run-time=com.arjuna.ats.internal.arjuna.coordinator.ReaperWorkerThread \ - --initialize-at-run-time=com.arjuna.ats.arjuna.recovery.RecoveryManager \ - --initialize-at-run-time=com.arjuna.ats.internal.jta.resources.arjunacore.CommitMarkableResourceRecord \ - --initialize-at-run-time=com.arjuna.ats.jdbc.TransactionalDriver \ - -H:IncludeResourceBundles=io.helidon.integrations.jta.cdi.Messages \ - --initialize-at-build-time=com.arjuna + +Args=--initialize-at-build-time=io.helidon.integrations.jta \ + --initialize-at-build-time=com.arjuna \ + --initialize-at-run-time=com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinationManager \ + --initialize-at-run-time=com.arjuna.ats.arjuna.coordinator.TxControl \ + --initialize-at-run-time=com.arjuna.ats.internal.arjuna.recovery.RecoveryManagerImple \ + --initialize-at-run-time=com.arjuna.ats.internal.arjuna.recovery.ExpiredEntryMonitor \ + --initialize-at-run-time=com.arjuna.ats.internal.arjuna.coordinator.ReaperThread \ + --initialize-at-run-time=com.arjuna.ats.internal.arjuna.coordinator.ReaperWorkerThread \ + --initialize-at-run-time=com.arjuna.ats.arjuna.recovery.RecoveryManager \ + --initialize-at-run-time=com.arjuna.ats.internal.jta.resources.arjunacore.CommitMarkableResourceRecord \ + --initialize-at-run-time=com.arjuna.ats.jdbc.TransactionalDriver diff --git a/integrations/cdi/jta-cdi/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-jta/resource-config.json b/integrations/cdi/jta-cdi/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-jta/resource-config.json index 525a2de691e..64b96c189c9 100644 --- a/integrations/cdi/jta-cdi/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-jta/resource-config.json +++ b/integrations/cdi/jta-cdi/src/main/resources/META-INF/native-image/io.helidon.integrations.cdi/helidon-integrations-cdi-jta/resource-config.json @@ -1,4 +1,9 @@ { + "bundles": [ + { + "name": "io.helidon.integrations.jta.cdi.Messages" + } + ], "resources": [ { "pattern": "io/helidon/integrations/jta/cdi/Messages.properties" diff --git a/integrations/db/h2/pom.xml b/integrations/db/h2/pom.xml index b1f18402883..bf5d3f58fc7 100644 --- a/integrations/db/h2/pom.xml +++ b/integrations/db/h2/pom.xml @@ -49,7 +49,7 @@ org.graalvm.sdk - graal-sdk + nativeimage provided diff --git a/integrations/db/mysql/src/main/resources/META-INF/native-image/io.helidon.integrations.db/mysql/native-image.properties b/integrations/db/mysql/src/main/resources/META-INF/native-image/io.helidon.integrations.db/mysql/native-image.properties index 3963cc192b1..931f3e4c8a3 100644 --- a/integrations/db/mysql/src/main/resources/META-INF/native-image/io.helidon.integrations.db/mysql/native-image.properties +++ b/integrations/db/mysql/src/main/resources/META-INF/native-image/io.helidon.integrations.db/mysql/native-image.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2021 Oracle and/or its affiliates. +# Copyright (c) 2021, 2023 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,5 +14,4 @@ # limitations under the License. # -Args= -Dcom.mysql.cj.disableAbandonedConnectionCleanup=true \ - --initialize-at-build-time=com.mysql.cj.jdbc.AbandonedConnectionCleanupThread +Args= -Dcom.mysql.cj.disableAbandonedConnectionCleanup=true diff --git a/integrations/db/pgsql/pom.xml b/integrations/db/pgsql/pom.xml index e469c1bbf56..0f3ef9a0125 100644 --- a/integrations/db/pgsql/pom.xml +++ b/integrations/db/pgsql/pom.xml @@ -42,7 +42,7 @@ org.graalvm.sdk - graal-sdk + nativeimage provided diff --git a/integrations/graal/mp-native-image-extension/pom.xml b/integrations/graal/mp-native-image-extension/pom.xml index 9d30726f18b..ee4b1f1fce0 100644 --- a/integrations/graal/mp-native-image-extension/pom.xml +++ b/integrations/graal/mp-native-image-extension/pom.xml @@ -51,9 +51,13 @@ weld-se-core provided + + io.github.classgraph + classgraph + org.graalvm.sdk - graal-sdk + nativeimage provided diff --git a/integrations/graal/mp-native-image-extension/src/main/java/io/helidon/integrations/graal/mp/nativeimage/extension/HelidonMpFeature.java b/integrations/graal/mp-native-image-extension/src/main/java/io/helidon/integrations/graal/mp/nativeimage/extension/HelidonMpFeature.java new file mode 100644 index 00000000000..1bc1f3d283f --- /dev/null +++ b/integrations/graal/mp-native-image-extension/src/main/java/io/helidon/integrations/graal/mp/nativeimage/extension/HelidonMpFeature.java @@ -0,0 +1,572 @@ +/* + * Copyright (c) 2023 Oracle and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.helidon.integrations.graal.mp.nativeimage.extension; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.Type; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import io.helidon.config.mp.MpConfigProviderResolver; +import io.helidon.integrations.graal.nativeimage.extension.HelidonReflectionConfiguration; +import io.helidon.integrations.graal.nativeimage.extension.NativeTrace; +import io.helidon.integrations.graal.nativeimage.extension.NativeUtil; +import io.helidon.logging.common.LogConfig; + +import io.github.classgraph.ClassGraph; +import io.github.classgraph.ScanResult; +import org.graalvm.nativeimage.hosted.Feature; +import org.graalvm.nativeimage.hosted.RuntimeProxyCreation; +import org.graalvm.nativeimage.hosted.RuntimeReflection; + +/** + * Helidon MP feature for GraalVM native image. + */ +public class HelidonMpFeature implements Feature { + private static final String AT_REGISTER_REST_CLIENT = "org.eclipse.microprofile.rest.client.inject.RegisterRestClient"; + + private final NativeTrace tracer = new NativeTrace(); + private NativeUtil util; + + @Override + public void beforeAnalysis(BeforeAnalysisAccess access) { + // need the application classloader + Class logConfigClass = access.findClassByName(LogConfig.class.getName()); + ClassLoader classLoader = logConfigClass.getClassLoader(); + // load configuration + HelidonReflectionConfiguration config = HelidonReflectionConfiguration.load(access, classLoader, tracer); + + // classpath scanning using the correct classloader + ScanResult scan = new ClassGraph() + .overrideClasspath(access.getApplicationClassPath()) + .enableAllInfo() + .scan(); + + util = NativeUtil.create(tracer, + scan, + access::findClassByName, + config.excluded()::contains); + BeforeAnalysisContext context = new BeforeAnalysisContext(access, scan, config.excluded()); + + + /* + Now handle all MP specific tasks + */ + // rest client registration (proxy support) + processRegisterRestClient(context); + + // all classes used as return types and parameters in JAX-RS resources + processJaxRsTypes(context); + + // JAX-RS types required for headers, query params etc. + addJaxRsConversions(context); + + /* + * + * And finally register with native image + * + */ + registerForReflection(context); + } + + @Override + public void beforeCompilation(BeforeCompilationAccess access) { + MpConfigProviderResolver.buildTimeEnd(); + } + + @Override + public void duringSetup(DuringSetupAccess access) { + new WeldFeature().duringSetup(access); + } + + private void registerForReflection(BeforeAnalysisContext context) { + Collection toRegister = context.toRegister(); + + tracer.section(() -> "Registering " + toRegister.size() + " classes for reflection"); + + // register for reflection + for (Register register : toRegister) { + // first validate if all fields are on classpath + if (!register.validated) { + register.validate(); + } + // only register classes on the image classpath (not necessarily discovered by the scanning) + if (register.valid) { + register(register.clazz); + + if (!register.clazz.isInterface()) { + register.fields.forEach(this::register); + register.constructors.forEach(this::register); + } + + register.methods.forEach(this::register); + } else { + tracer.trace(() -> register.clazz.getName() + " is not registered, as it had failed fields or superclass."); + } + } + } + + private void register(Class clazz) { + tracer.trace(() -> "Registering " + clazz.getName() + " for reflection"); + + RuntimeReflection.register(clazz); + } + + private void register(Field field) { + tracer.trace(() -> " " + + Modifier.toString(field.getModifiers()) + + " " + typeToString(field.getGenericType()) + + " " + field.getName()); + + RuntimeReflection.register(field); + } + + private void register(Constructor constructor) { + tracer.trace(() -> " " + constructor.getDeclaringClass().getSimpleName() + + "(" + + params(constructor.getParameterTypes()) + + ")"); + + RuntimeReflection.register(constructor); + } + + private void register(Method method) { + tracer.trace(() -> " " + + Modifier.toString(method.getModifiers()) + + " " + typeToString(method.getGenericReturnType()) + + " " + method.getName() + + "(" + params(method.getGenericParameterTypes()) + ")"); + + RuntimeReflection.register(method); + } + + private String typeToString(Type type) { + if (type instanceof Class) { + return ((Class) type).getName(); + } else { + return type.toString(); + } + } + + private String params(Type[] parameterTypes) { + if (parameterTypes.length == 0) { + return ""; + } + return Arrays.stream(parameterTypes) + .map(this::typeToString) + .collect(Collectors.joining(", ")); + } + + private void addJaxRsConversions(BeforeAnalysisContext context) { + addJaxRsConversions(context, "jakarta.ws.rs.QueryParam"); + addJaxRsConversions(context, "jakarta.ws.rs.PathParam"); + addJaxRsConversions(context, "jakarta.ws.rs.HeaderParam"); + addJaxRsConversions(context, "jakarta.ws.rs.MatrixParam"); + addJaxRsConversions(context, "jakarta.ws.rs.BeanParam"); + } + + private void addJaxRsConversions(BeforeAnalysisContext context, String annotation) { + tracer.parsing(() -> "Looking up annotated by " + annotation); + + Set> allTypes = new HashSet<>(); + + // we need fields and method parameters + context.scan() + .getClassesWithFieldAnnotation(annotation) + .stream() + .flatMap(theClass -> theClass.getFieldInfo().stream()) + .filter(field -> field.hasAnnotation(annotation)) + .map(fieldInfo -> util.getSimpleType(context.access()::findClassByName, fieldInfo)) + .filter(Objects::nonNull) + .forEach(allTypes::add); + + // method annotations + context.scan() + .getClassesWithMethodParameterAnnotation(annotation) + .stream() + .flatMap(theClass -> theClass.getMethodInfo().stream()) + .flatMap(theMethod -> Stream.of(theMethod.getParameterInfo())) + .filter(param -> param.hasAnnotation(annotation)) + .map(param -> util.getSimpleType(context.access()::findClassByName, param)) + .filter(Objects::nonNull) + .forEach(allTypes::add); + + // now let's find all static methods `valueOf` and `fromString` + for (Class type : allTypes) { + try { + Method valueOf = type.getDeclaredMethod("valueOf", String.class); + RuntimeReflection.register(valueOf); + tracer.parsing(() -> "Registering " + valueOf); + } catch (NoSuchMethodException ignored) { + try { + Method fromString = type.getDeclaredMethod("fromString", String.class); + RuntimeReflection.register(fromString); + tracer.parsing(() -> "Registering " + fromString); + } catch (NoSuchMethodException ignored2) { + } + } + } + } + + private void processJaxRsTypes(BeforeAnalysisContext context) { + tracer.parsing(() -> "Looking up JAX-RS resource methods."); + + new JaxRsMethodAnalyzer(context, util) + .find() + .forEach(it -> { + tracer.parsing(() -> " class " + it); + context.register(it).addAll(); + }); + } + + @SuppressWarnings("unchecked") + private void processRegisterRestClient(BeforeAnalysisContext context) { + + Class restClientAnnotation = (Class) context.access() + .findClassByName(AT_REGISTER_REST_CLIENT); + + if (null == restClientAnnotation) { + return; + } + + tracer.parsing(() -> "Looking up annotated by " + AT_REGISTER_REST_CLIENT); + + Set> annotatedSet = util.findAnnotated(AT_REGISTER_REST_CLIENT); + Class autoCloseable = context.access().findClassByName("java.lang.AutoCloseable"); + Class closeable = context.access().findClassByName("java.io.Closeable"); + + annotatedSet.forEach(it -> { + if (context.isExcluded(it)) { + tracer.parsing(() -> "Class " + it.getName() + " annotated by " + AT_REGISTER_REST_CLIENT + " is excluded"); + } else { + // we need to add it for reflection + processClassHierarchy(context, it); + // and we also need to create a proxy + tracer.parsing(() -> "Registering a proxy for class " + it.getName()); + RuntimeProxyCreation.register(it, autoCloseable, closeable); + } + }); + } + + private void processClassHierarchy(BeforeAnalysisContext context, Class superclass) { + + // this class is always registered (interface or class) + context.register(superclass).addDefaults(); + + tracer.parsing(() -> "Looking up implementors of " + superclass.getName()); + + processSubClasses(context, superclass); + + util.findInterfaces(superclass) + .forEach(it -> addSingleClass(context, it)); + } + + private void addSingleClass(BeforeAnalysisContext context, + Class theClass) { + if (context.process(theClass)) { + tracer.parsing(theClass::getName); + tracer.parsing(() -> " Added for registration"); + superclasses(context, theClass); + context.register(theClass).addDefaults(); + } + } + + private void processClasses(BeforeAnalysisContext context, Set> classes) { + for (Class aClass : classes) { + if (context.process(aClass)) { + tracer.parsing(() -> " " + aClass.getName()); + tracer.parsing(() -> " Added for registration"); + + superclasses(context, aClass); + context.register(aClass).addDefaults(); + + int modifiers = aClass.getModifiers(); + if (!Modifier.isFinal(modifiers)) { + processSubClasses(context, aClass); + } + } + } + } + + private void superclasses(BeforeAnalysisContext context, Class aClass) { + Set> superclasses = util.findSuperclasses(aClass); + for (Class superclass : superclasses) { + if (context.process(superclass)) { + tracer.parsing(superclass::getName); + tracer.parsing(() -> " Added for registration"); + context.register(superclass).addDefaults(); + } + } + } + + private void processSubClasses(BeforeAnalysisContext context, Class aClass) { + Set> subclasses = util.findSubclasses(aClass.getName()); + + processClasses(context, subclasses); + } + + final class BeforeAnalysisContext { + private final BeforeAnalysisAccess access; + private final Set> processed = new HashSet<>(); + private final Set> excluded = new HashSet<>(); + private final Map, Register> registers = new HashMap<>(); + private final ScanResult scan; + + private BeforeAnalysisContext(BeforeAnalysisAccess access, ScanResult scan, Set> excluded) { + this.access = access; + this.scan = scan; + this.excluded.addAll(excluded); + } + + public boolean process(Class theClass) { + return processed.add(theClass); + } + + public Register register(Class theClass) { + return registers.computeIfAbsent(theClass, Register::new); + } + + public Collection toRegister() { + return registers.values(); + } + + BeforeAnalysisAccess access() { + return access; + } + + ScanResult scan() { + return scan; + } + + boolean isExcluded(Class theClass) { + return excluded.contains(theClass); + } + } + + private class Register { + private final Set methods = new HashSet<>(); + private final Set fields = new HashSet<>(); + private final Set> constructors = new HashSet<>(); + + private final Class clazz; + + private boolean validated; + private boolean valid = true; + + private Register(Class clazz) { + this.clazz = clazz; + } + + void validate() { + validated = true; + validateTypeParams(); + if (!valid) { + return; + } + addFields(true, true); + } + + boolean add(Method m) { + return methods.add(m); + } + + boolean add(Field f) { + return fields.add(f); + } + + boolean add(Constructor c) { + return constructors.add(c); + } + + void addAll() { + if (!validated) { + validated = true; + validateTypeParams(); + } + if (!valid) { + return; + } + addFields(true, false); + if (!valid) { + return; + } + addMethods(); + if (clazz.isInterface()) { + return; + } + addConstructors(); + } + + void addDefaults() { + validated = true; + validateTypeParams(); + if (!valid) { + return; + } + addFields(false, false); + if (!valid) { + return; + } + addMethods(); + if (clazz.isInterface()) { + return; + } + addConstructors(); + } + + void addFields(boolean all, boolean validateOnly) { + try { + Field[] fields = clazz.getFields(); + // add all public fields + for (Field field : fields) { + if (!validateOnly) { + add(field); + } + } + } catch (NoClassDefFoundError e) { + this.valid = false; + + if (validateOnly) { + tracer.trace(() -> "Validation of fields of " + + clazz.getName() + + " failed, as a type is not on classpath: " + + e.getMessage()); + } else { + tracer.trace(() -> "Public fields of " + + clazz.getName() + + " not added to reflection, as a type is not on classpath: " + + e.getMessage()); + } + + } + try { + for (Field declaredField : clazz.getDeclaredFields()) { + // there may be fields referencing classes not on the classpath + if (!Modifier.isPublic(declaredField.getModifiers())) { + // public already registered + if (all || declaredField.getAnnotations().length > 0) { + if (!validateOnly) { + add(declaredField); + } + } + } + } + } catch (NoClassDefFoundError e) { + this.valid = false; + + if (validateOnly) { + tracer.trace(() -> "Validation of fields of " + + clazz.getName() + + " failed, as a type is not on classpath: " + + e.getMessage()); + } else { + tracer.trace(() -> "Fields of " + + clazz.getName() + + " not added to reflection, as a type is not on classpath: " + + e.getMessage()); + } + } + } + + void addMethods() { + try { + Method[] methods = clazz.getMethods(); + for (Method method : methods) { + boolean register; + + // we do not want wait, notify etc + register = (method.getDeclaringClass() != Object.class); + + if (register) { + // we do not want toString(), hashCode(), equals(java.lang.Object) + switch (method.getName()) { + case "hashCode": + case "toString": + register = !util.hasParams(method); + break; + case "equals": + register = !util.hasParams(method, Object.class); + break; + default: + // do nothing + } + } + + if (register) { + tracer.trace(() -> " " + method.getName() + "(" + Arrays.toString(method.getParameterTypes()) + ")"); + + add(method); + } + } + } catch (Throwable e) { + tracer.trace(() -> " Cannot register methods of " + clazz.getName() + ": " + + e.getClass().getName() + ": " + e.getMessage()); + } + } + + @SuppressWarnings("ResultOfMethodCallIgnored") + private void validateTypeParams() { + try { + clazz.getGenericSuperclass(); + } catch (Exception e) { + // this is now reported with each build, because ProtobufEncoder is part of netty codec + tracer.parsing(() -> "Type parameter of superclass is not on classpath of " + + clazz.getName() + + " error: " + + e.getMessage()); + valid = false; + } + } + + private void addConstructors() { + try { + Constructor[] constructors = clazz.getConstructors(); + for (Constructor constructor : constructors) { + add(constructor); + } + } catch (NoClassDefFoundError e) { + tracer.trace(() -> "Public constructors of " + + clazz.getName() + + " not added to reflection, as a type is not on classpath: " + + e.getMessage()); + } + try { + // add all declared + Constructor[] constructors = clazz.getDeclaredConstructors(); + for (Constructor constructor : constructors) { + add(constructor); + } + } catch (NoClassDefFoundError e) { + tracer.trace(() -> "Constructors of " + + clazz.getName() + + " not added to reflection, as a type is not on classpath: " + + e.getMessage()); + } + } + } +} diff --git a/integrations/graal/native-image-extension/src/main/java/io/helidon/integrations/graal/nativeimage/extension/JaxRsMethodAnalyzer.java b/integrations/graal/mp-native-image-extension/src/main/java/io/helidon/integrations/graal/mp/nativeimage/extension/JaxRsMethodAnalyzer.java similarity index 92% rename from integrations/graal/native-image-extension/src/main/java/io/helidon/integrations/graal/nativeimage/extension/JaxRsMethodAnalyzer.java rename to integrations/graal/mp-native-image-extension/src/main/java/io/helidon/integrations/graal/mp/nativeimage/extension/JaxRsMethodAnalyzer.java index f98d05054c4..630e924bc0c 100644 --- a/integrations/graal/native-image-extension/src/main/java/io/helidon/integrations/graal/nativeimage/extension/JaxRsMethodAnalyzer.java +++ b/integrations/graal/mp-native-image-extension/src/main/java/io/helidon/integrations/graal/mp/nativeimage/extension/JaxRsMethodAnalyzer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. + * Copyright (c) 2021, 2023 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.helidon.integrations.graal.nativeimage.extension; +package io.helidon.integrations.graal.mp.nativeimage.extension; import java.util.HashSet; import java.util.List; @@ -23,6 +23,8 @@ import java.util.Set; import java.util.stream.Collectors; +import io.helidon.integrations.graal.nativeimage.extension.NativeUtil; + import io.github.classgraph.ClassInfo; import io.github.classgraph.ClassInfoList; import io.github.classgraph.ClassRefTypeSignature; @@ -54,10 +56,10 @@ class JaxRsMethodAnalyzer { private static final String HTTP_METHOD_ANNOTATION = "jakarta.ws.rs.HttpMethod"; private final Set classesToAdd = new HashSet<>(); - private final HelidonReflectionFeature.BeforeAnalysisContext context; + private final HelidonMpFeature.BeforeAnalysisContext context; private final NativeUtil nativeUtil; - JaxRsMethodAnalyzer(HelidonReflectionFeature.BeforeAnalysisContext context, + JaxRsMethodAnalyzer(HelidonMpFeature.BeforeAnalysisContext context, NativeUtil nativeUtil) { this.context = context; this.nativeUtil = nativeUtil; diff --git a/integrations/graal/mp-native-image-extension/src/main/java/io/helidon/integrations/graal/mp/nativeimage/extension/WeldFeature.java b/integrations/graal/mp-native-image-extension/src/main/java/io/helidon/integrations/graal/mp/nativeimage/extension/WeldFeature.java index 0a183a46d24..535ef85d83c 100644 --- a/integrations/graal/mp-native-image-extension/src/main/java/io/helidon/integrations/graal/mp/nativeimage/extension/WeldFeature.java +++ b/integrations/graal/mp-native-image-extension/src/main/java/io/helidon/integrations/graal/mp/nativeimage/extension/WeldFeature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022 Oracle and/or its affiliates. + * Copyright (c) 2019, 2023 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ import jakarta.json.JsonObject; import jakarta.json.JsonReaderFactory; import jakarta.json.stream.JsonParsingException; -import org.graalvm.nativeimage.hosted.Feature; +import org.graalvm.nativeimage.hosted.Feature.DuringSetupAccess; import org.graalvm.nativeimage.hosted.RuntimeReflection; import org.jboss.weld.bean.proxy.ClientProxyFactory; import org.jboss.weld.bean.proxy.ClientProxyProvider; @@ -50,18 +50,11 @@ * An automatic feature for native-image to * register Weld specific stuff. */ -public class WeldFeature implements Feature { - private static final boolean ENABLED = NativeConfig.option("weld.enable-feature", true); +class WeldFeature { private static final boolean TRACE = NativeConfig.option("weld.trace", false); private static final boolean WARN = NativeConfig.option("weld.warn", false); - @Override - public boolean isInConfiguration(IsInConfigurationAccess access) { - return ENABLED; - } - - @Override - public void duringSetup(DuringSetupAccess access) { + void duringSetup(DuringSetupAccess access) { Class beanManagerClass = access.findClassByName("org.jboss.weld.manager.BeanManagerImpl"); Set processed = new HashSet<>(); Set> processedExplicitProxy = new HashSet<>(); @@ -147,6 +140,7 @@ private void initializeProxy(DuringSetupAccess access, Class proxyClass = cpf.getProxyClass(); trace(() -> " Registering proxy class " + proxyClass.getName() + " with types " + types); + RuntimeReflection.register(proxyClass); RuntimeReflection.register(proxyClass.getConstructors()); RuntimeReflection.register(proxyClass.getDeclaredConstructors()); @@ -194,7 +188,7 @@ private void iterateBeans(BeanManagerImpl bm, static List weldProxyConfigurations(DuringSetupAccess access) { try { - ClassLoader classLoader = access.findClassByName("io.helidon.config.Config").getClassLoader(); + ClassLoader classLoader = access.getApplicationClassLoader(); Enumeration resources = classLoader .getResources("META-INF/helidon/native-image/weld-proxies.json"); diff --git a/integrations/graal/mp-native-image-extension/src/main/java/module-info.java b/integrations/graal/mp-native-image-extension/src/main/java/module-info.java index b309b80b439..fdc92b7b1a0 100644 --- a/integrations/graal/mp-native-image-extension/src/main/java/module-info.java +++ b/integrations/graal/mp-native-image-extension/src/main/java/module-info.java @@ -17,12 +17,15 @@ * Extension for Graal VM native image to correctly build Helidon MicroProfile applications. */ module io.helidon.graal.nativeimage.mp { - + requires io.github.classgraph; + requires io.helidon.config.mp; + requires io.helidon.logging.common; requires jakarta.cdi; requires jakarta.json; - requires org.graalvm.sdk; + requires org.graalvm.nativeimage; requires weld.core.impl; + requires transitive io.helidon.graal.nativeimage; exports io.helidon.integrations.graal.mp.nativeimage.extension; diff --git a/integrations/graal/mp-native-image-extension/src/main/resources/META-INF/native-image/io.helidon.integrations.graal/helidon-mp-graal-native-image-extension/native-image.properties b/integrations/graal/mp-native-image-extension/src/main/resources/META-INF/native-image/io.helidon.integrations.graal/helidon-mp-graal-native-image-extension/native-image.properties new file mode 100644 index 00000000000..e899a726713 --- /dev/null +++ b/integrations/graal/mp-native-image-extension/src/main/resources/META-INF/native-image/io.helidon.integrations.graal/helidon-mp-graal-native-image-extension/native-image.properties @@ -0,0 +1,46 @@ +# +# Copyright (c) 2019, 2023 Oracle and/or its affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# At build time +# - MP config, initialized first at build time, second time at runtime +# - CDI itself - we need to do beginning of bootstrap at build time, to get all the bytecode generated +# - and all the required options are here (not in microprofile-cdi) +Args=--features=io.helidon.integrations.graal.mp.nativeimage.extension.HelidonMpFeature \ + --initialize-at-build-time=io.helidon.integrations.graal.mp.nativeimage.extension.ProxyBean \ + --initialize-at-build-time=io.helidon.config.mp.MpConfigProviderResolver \ + --initialize-at-build-time=io.helidon.microprofile \ + --initialize-at-build-time=io.helidon.common.GenericType \ + --initialize-at-build-time=io.helidon.common.LazyValueImpl \ + --initialize-at-build-time=io.helidon.common.context \ + --initialize-at-build-time=io.helidon.common.features.FeatureDescriptor \ + --initialize-at-build-time=io.helidon.common.features.HelidonFeatures$Node \ + --initialize-at-build-time=io.helidon.common.features.api.HelidonFlavor \ + --initialize-at-build-time=io.helidon.common.Errors \ + --initialize-at-build-time=io.helidon.common.Errors$Collector \ + --initialize-at-build-time=io.helidon.common.media.type \ + --initialize-at-build-time=org.jboss.jandex \ + --initialize-at-build-time=org.jboss.weld \ + --initialize-at-build-time=org.jboss.logging \ + --initialize-at-build-time=jakarta.enterprise \ + --initialize-at-build-time=jakarta.decorator \ + --initialize-at-build-time=jakarta.inject \ + --initialize-at-build-time=jakarta.interceptor \ + --initialize-at-build-time=jakarta.annotation \ + --initialize-at-build-time=com.sun.beans.TypeResolver \ + --initialize-at-build-time=java.beans.PropertyDescriptor \ + --initialize-at-build-time=java.beans.MethodRef \ + --initialize-at-build-time=org.yaml.snakeyaml \ + --report-unsupported-elements-at-runtime diff --git a/integrations/graal/native-image-extension/pom.xml b/integrations/graal/native-image-extension/pom.xml index 8d083354883..3f29852f0ed 100644 --- a/integrations/graal/native-image-extension/pom.xml +++ b/integrations/graal/native-image-extension/pom.xml @@ -55,7 +55,7 @@ org.graalvm.sdk - graal-sdk + nativeimage provided diff --git a/integrations/graal/native-image-extension/src/main/java/io/helidon/integrations/graal/nativeimage/extension/HelidonReflectionConfiguration.java b/integrations/graal/native-image-extension/src/main/java/io/helidon/integrations/graal/nativeimage/extension/HelidonReflectionConfiguration.java index 33650613f54..efcd05cfb27 100644 --- a/integrations/graal/native-image-extension/src/main/java/io/helidon/integrations/graal/nativeimage/extension/HelidonReflectionConfiguration.java +++ b/integrations/graal/native-image-extension/src/main/java/io/helidon/integrations/graal/nativeimage/extension/HelidonReflectionConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. + * Copyright (c) 2021, 2023 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,16 +32,27 @@ import jakarta.json.stream.JsonParsingException; import org.graalvm.nativeimage.hosted.Feature; -final class HelidonReflectionConfiguration { +/** + * Loads Helidon native image configuration. + */ +public final class HelidonReflectionConfiguration { private final Set> annotations = new LinkedHashSet<>(); private final Set> hierarchy = new LinkedHashSet<>(); private final Set> fullHierarchy = new LinkedHashSet<>(); private final Set> classes = new LinkedHashSet<>(); private final Set> excluded = new HashSet<>(); - static HelidonReflectionConfiguration load(Feature.BeforeAnalysisAccess access, - ClassLoader cl, - NativeTrace tracer) { + /** + * Load configuration json files from classpath. + * + * @param access native image event + * @param cl class loader + * @param tracer tracer to use + * @return a new configuration + */ + public static HelidonReflectionConfiguration load(Feature.BeforeAnalysisAccess access, + ClassLoader cl, + NativeTrace tracer) { try { Enumeration resources = cl.getResources("META-INF/helidon/native-image/reflection-config.json"); HelidonReflectionConfiguration config = new HelidonReflectionConfiguration(); @@ -74,6 +85,31 @@ static HelidonReflectionConfiguration load(Feature.BeforeAnalysisAccess access, } } + Set> annotations() { + return annotations; + } + + Set> hierarchy() { + return hierarchy; + } + + Set> fullHierarchy() { + return fullHierarchy; + } + + Set> classes() { + return classes; + } + + /** + * Set of excluded classes. + * + * @return set of classes to exclude from registration + */ + public Set> excluded() { + return excluded; + } + private static void jsonArray(NativeTrace tracer, Feature.BeforeAnalysisAccess access, Collection> classList, @@ -105,24 +141,4 @@ private static void jsonArray(NativeTrace tracer, } } } - - Set> annotations() { - return annotations; - } - - Set> hierarchy() { - return hierarchy; - } - - Set> fullHierarchy() { - return fullHierarchy; - } - - Set> classes() { - return classes; - } - - Set> excluded() { - return excluded; - } } diff --git a/integrations/graal/native-image-extension/src/main/java/io/helidon/integrations/graal/nativeimage/extension/HelidonReflectionFeature.java b/integrations/graal/native-image-extension/src/main/java/io/helidon/integrations/graal/nativeimage/extension/HelidonReflectionFeature.java index 8193332d548..74309f99ffb 100644 --- a/integrations/graal/native-image-extension/src/main/java/io/helidon/integrations/graal/nativeimage/extension/HelidonReflectionFeature.java +++ b/integrations/graal/native-image-extension/src/main/java/io/helidon/integrations/graal/nativeimage/extension/HelidonReflectionFeature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022 Oracle and/or its affiliates. + * Copyright (c) 2019, 2023 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,20 +28,17 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; -import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; -import java.util.stream.Stream; import io.helidon.common.Reflected; import io.helidon.common.features.HelidonFeatures; -import io.helidon.config.mp.MpConfigProviderResolver; import io.helidon.logging.common.LogConfig; import io.github.classgraph.ClassGraph; import io.github.classgraph.ScanResult; import org.graalvm.nativeimage.hosted.Feature; -import org.graalvm.nativeimage.hosted.RuntimeProxyCreation; +import org.graalvm.nativeimage.hosted.RuntimeClassInitialization; import org.graalvm.nativeimage.hosted.RuntimeReflection; import org.graalvm.nativeimage.hosted.RuntimeResourceAccess; @@ -54,7 +51,6 @@ public class HelidonReflectionFeature implements Feature { private static final String AT_ENTITY = "jakarta.persistence.Entity"; private static final String AT_MAPPED_SUPERCLASS = "jakarta.persistence.MappedSuperclass"; - private static final String AT_REGISTER_REST_CLIENT = "org.eclipse.microprofile.rest.client.inject.RegisterRestClient"; private final NativeTrace tracer = new NativeTrace(); private NativeUtil util; @@ -68,7 +64,10 @@ public boolean isInConfiguration(IsInConfigurationAccess access) { public void beforeAnalysis(BeforeAnalysisAccess access) { // need the application classloader Class logConfigClass = access.findClassByName(LogConfig.class.getName()); - ClassLoader classLoader = logConfigClass.getClassLoader(); + ClassLoader classLoader = access.getApplicationClassLoader(); + + tracer.parsing(() -> "Classpath as provided by the access: " + access.getApplicationClassPath()); + tracer.parsing(() -> "Modulepath as provided by the access: " + access.getApplicationModulePath()); // initialize logging (if on classpath) try { @@ -81,12 +80,15 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { // make sure we print all the warnings for native image HelidonFeatures.nativeBuildTime(classLoader); + // we need to initialize open-api type (as it fails at runtime, uses class files from classpath) + initLogging(access); + // load configuration HelidonReflectionConfiguration config = HelidonReflectionConfiguration.load(access, classLoader, tracer); // classpath scanning using the correct classloader ScanResult scan = new ClassGraph() - .overrideClassLoaders(classLoader) + .overrideClasspath(access.getApplicationClassPath()) .enableAllInfo() .scan(); @@ -107,20 +109,12 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { // process each configured class config.classes().forEach(it -> addSingleClass(context, it)); - // rest client registration (proxy support) - processRegisterRestClient(context); - // JPA Entity registration processEntity(context); // all classes, fields and methods annotated with @Reflected addAnnotatedWithReflected(context); - // all classes used as return types and parameters in JAX-RS resources - processJaxRsTypes(context); - - // JAX-RS types required for headers, query params etc. - addJaxRsConversions(context); /* * @@ -130,9 +124,24 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { registerForReflection(context); } - @Override - public void beforeCompilation(BeforeCompilationAccess access) { - MpConfigProviderResolver.buildTimeEnd(); + private void initLogging(BeforeAnalysisAccess access) { + String jul = "io.helidon.logging.jul.JulProvider"; + Class classByName = access.findClassByName(jul); + if (classByName != null) { + addBuildTime(access, "java.util.logging.StreamHandler"); + addBuildTime(access, "java.util.logging.Handler"); + addBuildTime(access, "io.helidon.logging.jul.HelidonConsoleHandler"); + addBuildTime(access, jul); + } + } + + private void addBuildTime(BeforeAnalysisAccess access, String className) { + Class classByName = access.findClassByName(className); + if (classByName == null) { + return; + } + // only register it if on classpath + RuntimeClassInitialization.initializeAtBuildTime(classByName); } private void processAnnotated(BeforeAnalysisContext context, Class annotationClass) { @@ -174,68 +183,6 @@ private void addSingleClass(BeforeAnalysisContext context, } } - private void addJaxRsConversions(BeforeAnalysisContext context) { - addJaxRsConversions(context, "jakarta.ws.rs.QueryParam"); - addJaxRsConversions(context, "jakarta.ws.rs.PathParam"); - addJaxRsConversions(context, "jakarta.ws.rs.HeaderParam"); - addJaxRsConversions(context, "jakarta.ws.rs.MatrixParam"); - addJaxRsConversions(context, "jakarta.ws.rs.BeanParam"); - } - - private void addJaxRsConversions(BeforeAnalysisContext context, String annotation) { - tracer.parsing(() -> "Looking up annotated by " + annotation); - - Set> allTypes = new HashSet<>(); - - // we need fields and method parameters - context.scan() - .getClassesWithFieldAnnotation(annotation) - .stream() - .flatMap(theClass -> theClass.getFieldInfo().stream()) - .filter(field -> field.hasAnnotation(annotation)) - .map(fieldInfo -> util.getSimpleType(context.access()::findClassByName, fieldInfo)) - .filter(Objects::nonNull) - .forEach(allTypes::add); - - // method annotations - context.scan() - .getClassesWithMethodParameterAnnotation(annotation) - .stream() - .flatMap(theClass -> theClass.getMethodInfo().stream()) - .flatMap(theMethod -> Stream.of(theMethod.getParameterInfo())) - .filter(param -> param.hasAnnotation(annotation)) - .map(param -> util.getSimpleType(context.access()::findClassByName, param)) - .filter(Objects::nonNull) - .forEach(allTypes::add); - - // now let's find all static methods `valueOf` and `fromString` - for (Class type : allTypes) { - try { - Method valueOf = type.getDeclaredMethod("valueOf", String.class); - RuntimeReflection.register(valueOf); - tracer.parsing(() -> "Registering " + valueOf); - } catch (NoSuchMethodException ignored) { - try { - Method fromString = type.getDeclaredMethod("fromString", String.class); - RuntimeReflection.register(fromString); - tracer.parsing(() -> "Registering " + fromString); - } catch (NoSuchMethodException ignored2) { - } - } - } - } - - private void processJaxRsTypes(BeforeAnalysisContext context) { - tracer.parsing(() -> "Looking up JAX-RS resource methods."); - - new JaxRsMethodAnalyzer(context, util) - .find() - .forEach(it -> { - tracer.parsing(() -> " class " + it); - context.register(it).addAll(); - }); - } - private void addAnnotatedWithReflected(BeforeAnalysisContext context) { // want to make sure we use the correct classloader String annotation = Reflected.class.getName(); @@ -294,34 +241,7 @@ private void processEntity(BeforeAnalysisContext context) { }); } - @SuppressWarnings("unchecked") - private void processRegisterRestClient(BeforeAnalysisContext context) { - - Class restClientAnnotation = (Class) context.access() - .findClassByName(AT_REGISTER_REST_CLIENT); - if (null == restClientAnnotation) { - return; - } - - tracer.parsing(() -> "Looking up annotated by " + AT_REGISTER_REST_CLIENT); - - Set> annotatedSet = util.findAnnotated(AT_REGISTER_REST_CLIENT); - Class autoCloseable = context.access().findClassByName("java.lang.AutoCloseable"); - Class closeable = context.access().findClassByName("java.io.Closeable"); - - annotatedSet.forEach(it -> { - if (context.isExcluded(it)) { - tracer.parsing(() -> "Class " + it.getName() + " annotated by " + AT_REGISTER_REST_CLIENT + " is excluded"); - } else { - // we need to add it for reflection - processClassHierarchy(context, it); - // and we also need to create a proxy - tracer.parsing(() -> "Registering a proxy for class " + it.getName()); - RuntimeProxyCreation.register(it, autoCloseable, closeable); - } - }); - } private void registerForReflection(BeforeAnalysisContext context) { Collection toRegister = context.toRegister(); diff --git a/integrations/graal/native-image-extension/src/main/java/io/helidon/integrations/graal/nativeimage/extension/NativeTrace.java b/integrations/graal/native-image-extension/src/main/java/io/helidon/integrations/graal/nativeimage/extension/NativeTrace.java index 2fbfff9908e..6a7b35c07ca 100644 --- a/integrations/graal/native-image-extension/src/main/java/io/helidon/integrations/graal/nativeimage/extension/NativeTrace.java +++ b/integrations/graal/native-image-extension/src/main/java/io/helidon/integrations/graal/nativeimage/extension/NativeTrace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. + * Copyright (c) 2021, 2023 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,34 +18,52 @@ import java.util.function.Supplier; -class NativeTrace { +/** + * Tracing tool for native image analysis and registration of reflection. + */ +public class NativeTrace { private static final boolean TRACE_PARSING = NativeConfig.option("reflection.trace-parsing", false); private static final boolean TRACE = NativeConfig.option("reflection.trace", false); - void parsing(Supplier message) { - if (TRACE_PARSING) { - System.out.println(message.get()); - } - } - - void parsing(Supplier message, Throwable e) { + /** + * Trace parsing message. + * + * @param message message + */ + public void parsing(Supplier message) { if (TRACE_PARSING) { System.out.println(message.get()); - e.printStackTrace(); } } - void trace(Supplier message) { + /** + * Trace the message. + * + * @param message message + */ + public void trace(Supplier message) { if (TRACE) { System.out.println(message.get()); } } - void section(Supplier message) { + /** + * Start a new section. + * + * @param message section name + */ + public void section(Supplier message) { if (TRACE) { System.out.println("***********************************"); System.out.println("** " + message.get()); System.out.println("***********************************"); } } + + void parsing(Supplier message, Throwable e) { + if (TRACE_PARSING) { + System.out.println(message.get()); + e.printStackTrace(); + } + } } diff --git a/integrations/graal/native-image-extension/src/main/java/io/helidon/integrations/graal/nativeimage/extension/NativeUtil.java b/integrations/graal/native-image-extension/src/main/java/io/helidon/integrations/graal/nativeimage/extension/NativeUtil.java index a9d254ab336..0028429b640 100644 --- a/integrations/graal/native-image-extension/src/main/java/io/helidon/integrations/graal/nativeimage/extension/NativeUtil.java +++ b/integrations/graal/native-image-extension/src/main/java/io/helidon/integrations/graal/nativeimage/extension/NativeUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. + * Copyright (c) 2021, 2023 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,10 @@ import io.github.classgraph.TypeArgument; import io.github.classgraph.TypeSignature; -final class NativeUtil { +/** + * Utilities to help with discovery and analysis of the image. + */ +public final class NativeUtil { private static final Map, Class> PRIMITIVES_TO_OBJECT = new HashMap<>(); static { @@ -73,6 +76,71 @@ final class NativeUtil { this.exclusion = exclusion; } + /** + * Create a new instance. + * + * @param tracer tracer to log messages + * @param scan classpath scan result + * @param classResolver resolver of class names to classes + * @param exclusion excluded classes + * @return a new utility + */ + public static NativeUtil create(NativeTrace tracer, + ScanResult scan, + Function> classResolver, + Function, Boolean> exclusion) { + return new NativeUtil(tracer, scan, classResolver, exclusion); + } + + /** + * Get the type of the field. + * + * @param classResolver resolver of names to classes + * @param fieldInfo field info to get type from + * @return class of the field + */ + public Class getSimpleType(Function> classResolver, FieldInfo fieldInfo) { + return getSimpleType(classResolver, fieldInfo::getTypeSignature, fieldInfo::getTypeDescriptor); + } + + /** + * Find all classes annotated with the provided annotation. + * + * @param annotation annotation to look for + * @return set of annotated types + */ + public Set> findAnnotated(String annotation) { + InclusionFilter inclusionFilter = new InclusionFilter(tracer, exclusion, "annotated by " + annotation); + ClassResolverMapper mapper = new ClassResolverMapper(tracer, classResolver, "annotated by " + annotation); + + return scan.getClassesWithAnnotation(annotation) + .stream() + .map(mapper) + .filter(Objects::nonNull) + .filter(inclusionFilter) + .collect(Collectors.toSet()); + } + + /** + * Filter to exclude types that are marked as excluded. + * + * @param description filter description + * @return a new predicate + */ + public Predicate> inclusionFilter(String description) { + return new InclusionFilter(tracer, exclusion, description); + } + + /** + * Class mapper. + * + * @param description description of this instance + * @return a new mapper from class names to classes + */ + public Function> classMapper(String description) { + return new StringClassResolverMapper(tracer, classResolver, description); + } + Class box(Class primitiveClass) { Class type = PRIMITIVES_TO_OBJECT.get(primitiveClass); @@ -83,14 +151,17 @@ Class box(Class primitiveClass) { return type; } - Class getSimpleType(Function> classResolver, MethodParameterInfo paramInfo) { + /** + * Get the type of the parameter. + * + * @param classResolver resolver of names to classes + * @param paramInfo parameter info to get type from + * @return class of the parameter + */ + public Class getSimpleType(Function> classResolver, MethodParameterInfo paramInfo) { return getSimpleType(classResolver, paramInfo::getTypeSignature, paramInfo::getTypeDescriptor); } - Class getSimpleType(Function> classResolver, FieldInfo fieldInfo) { - return getSimpleType(classResolver, fieldInfo::getTypeSignature, fieldInfo::getTypeDescriptor); - } - Class getSimpleType(Function> classResolver, Supplier typeSignatureSupplier, Supplier typeDescriptorSupplier) { @@ -138,12 +209,25 @@ Class cast(Class clazz, Class expected) { } } - boolean hasParams(Method method, Class... params) { + /** + * Check if method has the required parameters. + * + * @param method method to check + * @param params parameters to expect + * @return {@code true} if parameters of the method match the expected parameters + */ + public boolean hasParams(Method method, Class... params) { Class[] parameterTypes = method.getParameterTypes(); return Arrays.equals(params, parameterTypes); } - Set> findSuperclasses(Class aClass) { + /** + * Find all superclasses of this type. + * + * @param aClass type + * @return all super types + */ + public Set> findSuperclasses(Class aClass) { Set> result = new LinkedHashSet<>(); Class nextSuper = aClass.getSuperclass(); @@ -160,7 +244,13 @@ Set> findSuperclasses(Class aClass) { return result; } - Set> findInterfaces(Class aClass) { + /** + * Get all interfaces of the type. + * + * @param aClass class to get interfaces for + * @return set of interfaces with proper exclusions + */ + public Set> findInterfaces(Class aClass) { Set> result = new LinkedHashSet<>(); for (Class anInterface : aClass.getInterfaces()) { @@ -229,19 +319,13 @@ void processAnnotatedExecutables(String annotation, }); } - Set> findAnnotated(String annotation) { - InclusionFilter inclusionFilter = new InclusionFilter(tracer, exclusion, "annotated by " + annotation); - ClassResolverMapper mapper = new ClassResolverMapper(tracer, classResolver, "annotated by " + annotation); - - return scan.getClassesWithAnnotation(annotation) - .stream() - .map(mapper) - .filter(Objects::nonNull) - .filter(inclusionFilter) - .collect(Collectors.toSet()); - } - - Set> findSubclasses(String superclassName) { + /** + * Find all direct subclasses of the provided type. + * + * @param superclassName type + * @return subclasses + */ + public Set> findSubclasses(String superclassName) { ClassInfo superclass = scan.getClassInfo(superclassName); if (null == superclass) { @@ -277,14 +361,6 @@ Set> findSubclasses(String superclassName) { } } - Predicate> inclusionFilter(String description) { - return new InclusionFilter(tracer, exclusion, description); - } - - Function> classMapper(String description) { - return new StringClassResolverMapper(tracer, classResolver, description); - } - private static class InclusionFilter implements Predicate> { private final NativeTrace tracer; private final Function, Boolean> exclusion; diff --git a/integrations/graal/native-image-extension/src/main/java/module-info.java b/integrations/graal/native-image-extension/src/main/java/module-info.java index 2f5c4069df9..dbf5ffa647d 100644 --- a/integrations/graal/native-image-extension/src/main/java/module-info.java +++ b/integrations/graal/native-image-extension/src/main/java/module-info.java @@ -21,13 +21,12 @@ requires io.github.classgraph; requires io.helidon.common.features.api; requires io.helidon.common.features; - requires io.helidon.config.mp; requires io.helidon.config; requires io.helidon.logging.common; requires io.helidon.logging.jul; requires jakarta.json; - requires transitive org.graalvm.sdk; + requires transitive org.graalvm.nativeimage; exports io.helidon.integrations.graal.nativeimage.extension; diff --git a/integrations/graal/native-image-extension/src/main/resources/META-INF/native-image/io.helidon.integrations.graal/helidon-graal-native-image-extension/native-image.properties b/integrations/graal/native-image-extension/src/main/resources/META-INF/native-image/io.helidon.integrations.graal/helidon-graal-native-image-extension/native-image.properties index fc13fba03fd..6dbfda8e9ea 100644 --- a/integrations/graal/native-image-extension/src/main/resources/META-INF/native-image/io.helidon.integrations.graal/helidon-graal-native-image-extension/native-image.properties +++ b/integrations/graal/native-image-extension/src/main/resources/META-INF/native-image/io.helidon.integrations.graal/helidon-graal-native-image-extension/native-image.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2019, 2022 Oracle and/or its affiliates. +# Copyright (c) 2019, 2023 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,18 +14,13 @@ # limitations under the License. # +# Init at build time +# - log initialization during build of native image +# - feature validation that features are ok in native Args=--no-fallback \ --features=io.helidon.integrations.graal.nativeimage.extension.HelidonReflectionFeature \ - --initialize-at-run-time=io.netty.util.internal.logging.Log4JLogger \ - --initialize-at-build-time=io.helidon \ - --initialize-at-build-time=io.netty \ - --initialize-at-build-time=org.yaml.snakeyaml \ - --initialize-at-build-time=org.reactivestreams \ - --initialize-at-build-time=org.glassfish.json \ - --initialize-at-build-time=org.eclipse.microprofile \ - --initialize-at-build-time=io.opentracing \ - --initialize-at-build-time=jakarta.json \ - --initialize-at-build-time=org.glassfish.jersey \ - --initialize-at-build-time=jakarta.ws.rs \ - --initialize-at-build-time=org.glassfish.hk2 \ - --initialize-at-build-time=org.jvnet.hk2 + --initialize-at-build-time=io.helidon.logging.common.LogConfig \ + --initialize-at-build-time=io.helidon.common.features.FeatureCatalog \ + --initialize-at-build-time=io.helidon.logging.jul.HelidonFormatter \ + --initialize-at-build-time=io.helidon.common.HelidonServiceLoader \ + --initialize-at-build-time=io.helidon.common.features.HelidonFeatures diff --git a/integrations/graal/native-image-extension/src/main/resources/META-INF/native-image/io.helidon.integrations.graal/helidon-graal-native-image-extension/resource-config.json b/integrations/graal/native-image-extension/src/main/resources/META-INF/native-image/io.helidon.integrations.graal/helidon-graal-native-image-extension/resource-config.json index f86d5a86265..2f62aecd9e0 100644 --- a/integrations/graal/native-image-extension/src/main/resources/META-INF/native-image/io.helidon.integrations.graal/helidon-graal-native-image-extension/resource-config.json +++ b/integrations/graal/native-image-extension/src/main/resources/META-INF/native-image/io.helidon.integrations.graal/helidon-graal-native-image-extension/resource-config.json @@ -2,6 +2,9 @@ "resources": [ { "pattern": "logging.properties" + }, + { + "pattern": "META-INF/services/.*" } ] } \ No newline at end of file diff --git a/jersey/jsonp/src/main/resources/META-INF/native-image/io.helidon.jersey/helidon-jersey-media-jsonp/native-image.properties b/jersey/jsonp/src/main/resources/META-INF/native-image/io.helidon.jersey/helidon-jersey-media-jsonp/native-image.properties deleted file mode 100644 index 7f3a3e2cfeb..00000000000 --- a/jersey/jsonp/src/main/resources/META-INF/native-image/io.helidon.jersey/helidon-jersey-media-jsonp/native-image.properties +++ /dev/null @@ -1,17 +0,0 @@ -# -# Copyright (c) 2022 Oracle and/or its affiliates. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -Args=--initialize-at-build-time=org.eclipse.parsson diff --git a/logging/jul/src/main/java/io/helidon/logging/jul/JulProvider.java b/logging/jul/src/main/java/io/helidon/logging/jul/JulProvider.java index 44564290fb7..a9327bd5da3 100644 --- a/logging/jul/src/main/java/io/helidon/logging/jul/JulProvider.java +++ b/logging/jul/src/main/java/io/helidon/logging/jul/JulProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022 Oracle and/or its affiliates. + * Copyright (c) 2019, 2023 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import java.util.logging.LogManager; import java.util.logging.Logger; +import io.helidon.common.NativeImageHelper; import io.helidon.common.Weight; import io.helidon.logging.common.spi.LoggingProvider; @@ -44,6 +45,8 @@ public class JulProvider implements LoggingProvider { private static final String SYS_PROP_DISABLE_CONFIG = "io.helidon.logging.config.disabled"; private static final String SYS_PROP_LOGGING_CLASS = "java.util.logging.config.class"; private static final String SYS_PROP_LOGGING_FILE = "java.util.logging.config.file"; + private static final String WHEN_INIT = "initialization"; + private static final String WHEN_RUNTIME = "runtime"; /** * Default constructor required by {@link java.util.ServiceLoader}. @@ -53,28 +56,28 @@ public JulProvider() { @Override public void initialization() { - configureLogging("initialization"); + configureLogging(false); } @Override public void runTime() { - configureLogging("runtime"); + configureLogging(true); } // when is either `initialization` or `runtime` // when building native image, the `initialization` is called // when running it, the `runtime` is called // when outside of native-image, only `initialization` is called - private static void configureLogging(String when) { + private static void configureLogging(boolean runtime) { try { - doConfigureLogging(when); + doConfigureLogging(runtime); } catch (IOException e) { System.err.println("Failed to configure logging"); e.printStackTrace(); } } - private static void doConfigureLogging(String when) throws IOException { + private static void doConfigureLogging(boolean runtime) throws IOException { String disableConfigProperty = System.getProperty(SYS_PROP_DISABLE_CONFIG); if (Boolean.parseBoolean(disableConfigProperty)) { // we are explicitly request to disable this feature @@ -94,7 +97,10 @@ private static void doConfigureLogging(String when) throws IOException { source = findAndConfigureLogging(); } - Logger.getLogger(JulProvider.class.getName()).info("Logging at " + when + " configured using " + source); + if (runtime || NativeImageHelper.isBuildTime()) { + String when = runtime ? WHEN_RUNTIME : WHEN_INIT; + Logger.getLogger(JulProvider.class.getName()).info("Logging at " + when + " configured using " + source); + } } private static String findAndConfigureLogging() throws IOException { diff --git a/integrations/graal/native-image-extension/src/main/resources/META-INF/helidon/native-image/reflection-config.json b/logging/jul/src/main/resources/META-INF/helidon/native-image/reflection-config.json similarity index 59% rename from integrations/graal/native-image-extension/src/main/resources/META-INF/helidon/native-image/reflection-config.json rename to logging/jul/src/main/resources/META-INF/helidon/native-image/reflection-config.json index 9c0254c6c1e..ae8d0fc6420 100644 --- a/integrations/graal/native-image-extension/src/main/resources/META-INF/helidon/native-image/reflection-config.json +++ b/logging/jul/src/main/resources/META-INF/helidon/native-image/reflection-config.json @@ -2,7 +2,8 @@ "annotated":[ ], "class-hierarchy": [ - "java.util.logging.Formatter" + "java.util.logging.Formatter", + "java.util.logging.Handler" ], "classes": [ ], diff --git a/logging/jul/src/main/resources/META-INF/native-image/io.helidon.logging/helidon-logging-jul/resource-config.json b/logging/jul/src/main/resources/META-INF/native-image/io.helidon.logging/helidon-logging-jul/resource-config.json index f86d5a86265..acef796d4f0 100644 --- a/logging/jul/src/main/resources/META-INF/native-image/io.helidon.logging/helidon-logging-jul/resource-config.json +++ b/logging/jul/src/main/resources/META-INF/native-image/io.helidon.logging/helidon-logging-jul/resource-config.json @@ -2,6 +2,9 @@ "resources": [ { "pattern": "logging.properties" + }, + { + "pattern": "logging-test.properties" } ] } \ No newline at end of file diff --git a/messaging/connectors/kafka/pom.xml b/messaging/connectors/kafka/pom.xml index 1d1fd79de3e..6e5ab87826c 100644 --- a/messaging/connectors/kafka/pom.xml +++ b/messaging/connectors/kafka/pom.xml @@ -70,7 +70,7 @@ org.graalvm.sdk - graal-sdk + nativeimage provided diff --git a/messaging/connectors/kafka/src/main/java/module-info.java b/messaging/connectors/kafka/src/main/java/module-info.java index e933c4a7db9..1f79aa43e9b 100644 --- a/messaging/connectors/kafka/src/main/java/module-info.java +++ b/messaging/connectors/kafka/src/main/java/module-info.java @@ -42,7 +42,7 @@ requires static jakarta.cdi; requires static jakarta.inject; requires static kafka.clients; - requires static org.graalvm.sdk; + requires static org.graalvm.nativeimage; requires transitive io.helidon.config; requires transitive microprofile.reactive.messaging.api; diff --git a/messaging/connectors/kafka/src/main/resources/META-INF/native-image/io.helidon.messaging.connectors.kafka/native-image.properties b/messaging/connectors/kafka/src/main/resources/META-INF/native-image/io.helidon.messaging.connectors.kafka/native-image.properties index 302e9d8e239..c56586661ca 100644 --- a/messaging/connectors/kafka/src/main/resources/META-INF/native-image/io.helidon.messaging.connectors.kafka/native-image.properties +++ b/messaging/connectors/kafka/src/main/resources/META-INF/native-image/io.helidon.messaging.connectors.kafka/native-image.properties @@ -15,16 +15,5 @@ # # Manual registration of Sun Sasl as workaround for https://github.com/oracle/graal/issues/3664 -Args=--initialize-at-build-time=org.slf4j \ - --initialize-at-build-time=org.xerial.snappy.SnappyInputStream \ - --initialize-at-build-time=org.xerial.snappy.SnappyOutputStream \ - --initialize-at-build-time=com.github.luben.zstd.ZstdInputStream \ - --initialize-at-build-time=com.github.luben.zstd.ZstdOutputStream \ - --initialize-at-build-time=com.github.luben.zstd.util.Native \ - --initialize-at-run-time=io.netty.handler.codec.compression.Lz4XXHash32 \ - --initialize-at-run-time=org.apache.kafka.common.security.authenticator.SaslClientAuthenticator \ - --initialize-at-run-time=org.apache.kafka.common.security.oauthbearer.internals.expiring.ExpiringCredentialRefreshingLogin \ - --initialize-at-run-time=org.apache.kafka.common.security.kerberos.KerberosLogin \ - -H:AdditionalSecurityProviders=com.sun.security.sasl.Provider \ - -H:+JNI \ - -H:IncludeResources=.*\\.so$|.*\\.h$|.*\\.dll$|.*\\.dylib$ +Args=-H:AdditionalSecurityProviders=com.sun.security.sasl.Provider \ + -H:+JNI diff --git a/messaging/connectors/kafka/src/main/resources/META-INF/native-image/io.helidon.messaging.connectors.kafka/resource-config.json b/messaging/connectors/kafka/src/main/resources/META-INF/native-image/io.helidon.messaging.connectors.kafka/resource-config.json index 23e1cce16a8..ce3aa28901e 100644 --- a/messaging/connectors/kafka/src/main/resources/META-INF/native-image/io.helidon.messaging.connectors.kafka/resource-config.json +++ b/messaging/connectors/kafka/src/main/resources/META-INF/native-image/io.helidon.messaging.connectors.kafka/resource-config.json @@ -1,10 +1,24 @@ { - "bundles": [ - { - "name": "sun.security.util.Resources" - }, - { - "name": "sun.security.util.AuthResources" - } - ] + "bundles": [ + { + "name": "sun.security.util.Resources" + }, + { + "name": "sun.security.util.AuthResources" + } + ], + "resources": [ + { + "pattern": ".*\\.so$" + }, + { + "pattern": ".*\\.h$" + }, + { + "pattern": ".*\\.dll$" + }, + { + "pattern": ".*\\.dylib$" + } + ] } diff --git a/metrics/api/src/main/resources/META-INF/native-image/io.helidon.metrics/helidon-metrics-api/native-image.properties b/metrics/api/src/main/resources/META-INF/native-image/io.helidon.metrics/helidon-metrics-api/native-image.properties deleted file mode 100644 index 625ce1877fc..00000000000 --- a/metrics/api/src/main/resources/META-INF/native-image/io.helidon.metrics/helidon-metrics-api/native-image.properties +++ /dev/null @@ -1,19 +0,0 @@ -# -# Copyright (c) 2022 Oracle and/or its affiliates. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# All Helidon modules are designed to be initialized at build time -# (specific classes may be delayed to runtime) -Args=--initialize-at-build-time=org.eclipse.microprofile.metrics diff --git a/metrics/metrics/src/main/resources/META-INF/native-image/io.helidon.metrics/helidon-metrics/native-image.properties b/metrics/metrics/src/main/resources/META-INF/native-image/io.helidon.metrics/helidon-metrics/native-image.properties deleted file mode 100644 index 4a39f5603d9..00000000000 --- a/metrics/metrics/src/main/resources/META-INF/native-image/io.helidon.metrics/helidon-metrics/native-image.properties +++ /dev/null @@ -1,17 +0,0 @@ -# -# Copyright (c) 2021, 2022 Oracle and/or its affiliates. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -Args=--initialize-at-build-time=io.helidon.metrics diff --git a/metrics/providers/micrometer/src/main/resources/META-INF/helidon/native-image/reflection-config.json b/metrics/providers/micrometer/src/main/resources/META-INF/helidon/native-image/reflection-config.json new file mode 100644 index 00000000000..e7fdd78e77b --- /dev/null +++ b/metrics/providers/micrometer/src/main/resources/META-INF/helidon/native-image/reflection-config.json @@ -0,0 +1,9 @@ +{ + "annotated": [], + "class-hierarchy": [ + "org.HdrHistogram.EncodableHistogram" + ], + "classes": [], + "exclude": [ + ] +} diff --git a/microprofile/cdi/src/main/resources/META-INF/native-image/io.helidon.microprofile.cdi/helidon-microprofile-cdi/native-image.properties b/microprofile/cdi/src/main/resources/META-INF/native-image/io.helidon.microprofile.cdi/helidon-microprofile-cdi/native-image.properties deleted file mode 100644 index 37f73e723ec..00000000000 --- a/microprofile/cdi/src/main/resources/META-INF/native-image/io.helidon.microprofile.cdi/helidon-microprofile-cdi/native-image.properties +++ /dev/null @@ -1,24 +0,0 @@ -# -# Copyright (c) 2019, 2022 Oracle and/or its affiliates. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -Args=--initialize-at-build-time=io.helidon.microprofile \ - --initialize-at-build-time=org.eclipse.microprofile \ - --initialize-at-build-time=jakarta \ - --initialize-at-build-time=org.jboss \ - --initialize-at-build-time=org.glassfish \ - --initialize-at-run-time=org.jboss.weld.probe.Resource \ - --initialize-at-run-time=org.jboss.weld.probe.Resource$14 - diff --git a/microprofile/config/src/main/resources/META-INF/native-image/io.helidon.microprofile.config/helidon-microprofile-config/native-image.properties b/microprofile/config/src/main/resources/META-INF/native-image/io.helidon.microprofile.config/helidon-microprofile-config/native-image.properties index 64595ba636e..16a26dac9bb 100644 --- a/microprofile/config/src/main/resources/META-INF/native-image/io.helidon.microprofile.config/helidon-microprofile-config/native-image.properties +++ b/microprofile/config/src/main/resources/META-INF/native-image/io.helidon.microprofile.config/helidon-microprofile-config/native-image.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2019, 2023 Oracle and/or its affiliates. +# Copyright (c) 2022, 2023 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,6 +14,8 @@ # limitations under the License. # -Args=--initialize-at-build-time=io.helidon.microprofile.config \ - --initialize-at-build-time=org.eclipse.microprofile.config - +Args=--initialize-at-build-time=io.helidon.common.config \ + --initialize-at-build-time=io.helidon.config \ + --initialize-at-build-time=io.helidon.config.mp \ + --initialize-at-build-time=org.eclipse.microprofile.config \ + --initialize-at-build-time=io.helidon.microprofile.config diff --git a/config/hocon-mp/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config-hocon-mp/native-image.properties b/microprofile/cors/src/main/resources/META-INF/native-image/io.helidon.microprofile/helidon-microprofile-cors/native-image.properties similarity index 82% rename from config/hocon-mp/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config-hocon-mp/native-image.properties rename to microprofile/cors/src/main/resources/META-INF/native-image/io.helidon.microprofile/helidon-microprofile-cors/native-image.properties index 5347fb8a838..db1d41c3895 100644 --- a/config/hocon-mp/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config-hocon-mp/native-image.properties +++ b/microprofile/cors/src/main/resources/META-INF/native-image/io.helidon.microprofile/helidon-microprofile-cors/native-image.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 Oracle and/or its affiliates. +# Copyright (c) 2023 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,4 +14,4 @@ # limitations under the License. # -Args=--initialize-at-build-time=io.helidon.config.hocon.mp +Args=--initialize-at-build-time=io.helidon.cors.CrossOriginConfig diff --git a/microprofile/jwt-auth/src/main/resources/META-INF/native-image/io.helidon.microprofile/helidon-microprofile-jwt-auth/native-image.properties b/microprofile/jwt-auth/src/main/resources/META-INF/native-image/io.helidon.microprofile/helidon-microprofile-jwt-auth/native-image.properties new file mode 100644 index 00000000000..4f08e4c5de0 --- /dev/null +++ b/microprofile/jwt-auth/src/main/resources/META-INF/native-image/io.helidon.microprofile/helidon-microprofile-jwt-auth/native-image.properties @@ -0,0 +1,19 @@ +# +# Copyright (c) 2023 Oracle and/or its affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +Args=--initialize-at-build-time=io.helidon.microprofile.jwt.auth.JsonWebTokenImpl \ + --initialize-at-build-time=org.eclipse.microprofile.jwt.JsonWebToken \ + --initialize-at-build-time=org.eclipse.microprofile.jwt diff --git a/config/config/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config/native-image.properties b/microprofile/metrics/src/main/resources/META-INF/native-image/io.helidon/helidon-common/native-image.properties similarity index 82% rename from config/config/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config/native-image.properties rename to microprofile/metrics/src/main/resources/META-INF/native-image/io.helidon/helidon-common/native-image.properties index dd433ce8da9..dce2783187c 100644 --- a/config/config/src/main/resources/META-INF/native-image/io.helidon.config/helidon-config/native-image.properties +++ b/microprofile/metrics/src/main/resources/META-INF/native-image/io.helidon/helidon-common/native-image.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2019, 2021 Oracle and/or its affiliates. +# Copyright (c) 2023 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,4 +14,4 @@ # limitations under the License. # -Args=--initialize-at-build-time=io.helidon.config.spi +Args=--initialize-at-build-time=org.eclipse.microprofile.metrics diff --git a/openapi/openapi/src/main/resources/META-INF/native-image/io.helidon.openapi/helidon-openapi/native-image.properties b/microprofile/openapi/src/main/resources/META-INF/native-image/io.helidon.microproflie/helidon-microprofile-openapi/native-image.properties similarity index 81% rename from openapi/openapi/src/main/resources/META-INF/native-image/io.helidon.openapi/helidon-openapi/native-image.properties rename to microprofile/openapi/src/main/resources/META-INF/native-image/io.helidon.microproflie/helidon-microprofile-openapi/native-image.properties index c247eb32a4f..d948c9c9fcc 100644 --- a/openapi/openapi/src/main/resources/META-INF/native-image/io.helidon.openapi/helidon-openapi/native-image.properties +++ b/microprofile/openapi/src/main/resources/META-INF/native-image/io.helidon.microproflie/helidon-microprofile-openapi/native-image.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, 2023 Oracle and/or its affiliates. +# Copyright (c) 2023 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,5 +14,5 @@ # limitations under the License. # -Args=--initialize-at-run-time=io.smallrye.openapi.runtime.io.OpenApiSerializer \ +Args=--initialize-at-build-time=org.eclipse.microprofile.openapi \ --initialize-at-build-time=io.smallrye.openapi diff --git a/microprofile/security/src/main/resources/META-INF/helidon/native-image/proxy-config.json b/microprofile/security/src/main/resources/META-INF/helidon/native-image/proxy-config.json deleted file mode 100644 index 0cb8d3a3e15..00000000000 --- a/microprofile/security/src/main/resources/META-INF/helidon/native-image/proxy-config.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - [ - "io.helidon.security.SecurityContext", - "org.glassfish.hk2.api.ProxyCtl" - ] -] \ No newline at end of file diff --git a/microprofile/security/src/main/resources/META-INF/native-image/io.helidon.microprofile/helidon-microprofile-security/native-image.properties b/microprofile/security/src/main/resources/META-INF/native-image/io.helidon.microprofile/helidon-microprofile-security/native-image.properties new file mode 100644 index 00000000000..9e9e763fdba --- /dev/null +++ b/microprofile/security/src/main/resources/META-INF/native-image/io.helidon.microprofile/helidon-microprofile-security/native-image.properties @@ -0,0 +1,26 @@ +# +# Copyright (c) 2023 Oracle and/or its affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +Args=--initialize-at-build-time=io.helidon.security.Principal \ + --initialize-at-build-time=io.helidon.security.Subject \ + --initialize-at-build-time=io.helidon.security.SecurityContext \ + --initialize-at-build-time=io.helidon.common.security.SecurityContext \ + --initialize-at-build-time=java.security.Principal \ + --initialize-at-build-time=io.helidon.security.HelidonPrincipal \ + --initialize-at-build-time=io.helidon.security.ClassToInstanceStore \ + --initialize-at-build-time=io.helidon.security.Security$Builder \ + --initialize-at-build-time=io.helidon.security.util \ + --initialize-at-build-time=io.helidon.security.SecurityTime diff --git a/microprofile/security/src/main/resources/META-INF/native-image/io.helidon.microprofile/helidon-microprofile-security/proxy-config.json b/microprofile/security/src/main/resources/META-INF/native-image/io.helidon.microprofile/helidon-microprofile-security/proxy-config.json new file mode 100644 index 00000000000..f700f4edf9a --- /dev/null +++ b/microprofile/security/src/main/resources/META-INF/native-image/io.helidon.microprofile/helidon-microprofile-security/proxy-config.json @@ -0,0 +1,11 @@ +[ + { + "condition": { + "typeReachable": "io.helidon.security.SecurityContext" + }, + "interfaces": [ + "io.helidon.security.SecurityContext", + "org.glassfish.hk2.api.ProxyCtl" + ] + } +] diff --git a/microprofile/server/src/main/resources/META-INF/helidon/native-image/reflection-config.json b/microprofile/server/src/main/resources/META-INF/helidon/native-image/reflection-config.json index e510b8415ca..8239173acc7 100644 --- a/microprofile/server/src/main/resources/META-INF/helidon/native-image/reflection-config.json +++ b/microprofile/server/src/main/resources/META-INF/helidon/native-image/reflection-config.json @@ -1,14 +1,56 @@ { "annotated":[ + "org.jvnet.hk2.annotations.Service", + "org.jvnet.hk2.annotations.Contract", + "org.glassfish.hk2.api.PerLookup", + "org.glassfish.jersey.process.internal.RequestScoped", + "org.glassfish.jersey.spi.Contract", + "org.glassfish.jersey.internal.inject.PerLookup", + "jakarta.ws.rs.Path", + "jakarta.ws.rs.ext.Provider", + "org.jboss.logging.annotations.MessageLogger" ], "class-hierarchy": [ "jakarta.ws.rs.client.ClientBuilder", "jakarta.ws.rs.client.ClientRequestFilter", "jakarta.ws.rs.client.ClientResponseFilter", - "jakarta.ws.rs.client.RxInvokerProvider" + "jakarta.ws.rs.client.RxInvokerProvider", + "jakarta.ws.rs.container.ContainerRequestFilter", + "jakarta.ws.rs.container.ContainerResponseFilter", + "jakarta.ws.rs.core.Application", + "jakarta.ws.rs.core.Feature", + "jakarta.ws.rs.core.SecurityContext", + "jakarta.ws.rs.ext.ContextResolver", + "jakarta.ws.rs.ext.ExceptionMapper", + "jakarta.ws.rs.ext.MessageBodyReader", + "jakarta.ws.rs.ext.MessageBodyWriter", + "jakarta.ws.rs.ext.Providers", + "jakarta.ws.rs.ext.ReaderInterceptor", + "jakarta.ws.rs.ext.WriterInterceptor", + "jakarta.ws.rs.ext.ParamConverterProvider", + "jakarta.ws.rs.container.DynamicFeature", + "jakarta.ws.rs.sse.Sse", + "org.glassfish.jersey.internal.inject.Providers", + "org.glassfish.jersey.process.Inflector", + "org.glassfish.jersey.process.internal.Inflecting", + "org.glassfish.jersey.process.internal.RequestScope", + "org.glassfish.jersey.server.ResourceConfig", + "org.glassfish.jersey.server.ServerConfig", + "org.glassfish.jersey.internal.inject.InjectionResolver", + "org.glassfish.jersey.internal.inject.ReferencingFactory", + "org.glassfish.hk2.api.ErrorService", + "org.jboss.logging.BasicLogger" ], "classes": [ + "org.glassfish.jersey.server.internal.process.RequestProcessingConfigurator$AsyncContextFactory", + "org.glassfish.jersey.server.internal.process.RequestProcessingConfigurator$CloseableServiceFactory", + "org.glassfish.jersey.server.internal.process.RequestProcessingConfigurator$ContainerRequestFactory", + "org.glassfish.jersey.server.internal.process.RequestProcessingConfigurator$UriRoutingContextFactory", + "javassist.util.proxy.MethodHandler", + "java.lang.Boolean", + "java.net.URI" ], "exclude": [ + "org.glassfish.jersey.message.internal.RenderedImageProvider" ] } diff --git a/microprofile/server/src/main/resources/META-INF/native-image/io.helidon.microrpofile/helidon-microprofile-server/native-image.properties b/microprofile/server/src/main/resources/META-INF/native-image/io.helidon.microrpofile/helidon-microprofile-server/native-image.properties new file mode 100644 index 00000000000..12a77349bab --- /dev/null +++ b/microprofile/server/src/main/resources/META-INF/native-image/io.helidon.microrpofile/helidon-microprofile-server/native-image.properties @@ -0,0 +1,28 @@ +# +# Copyright (c) 2023 Oracle and/or its affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +Args=--initialize-at-build-time=io.helidon.http \ + --initialize-at-build-time=io.helidon.webserver.WebServerConfig$Builder \ + --initialize-at-build-time=io.helidon.webserver.http \ + --initialize-at-build-time=io.helidon.webserver.observe.ObserveConfig$Builder \ + --initialize-at-build-time=io.helidon.common.security.SecurityContext \ + --initialize-at-build-time=io.helidon.cors.CrossOriginConfig \ + --initialize-at-build-time=jakarta.ws.rs \ + --initialize-at-build-time=org.glassfish.hk2 \ + --initialize-at-build-time=org.glassfish.jersey \ + --initialize-at-run-time=org.glassfish.hk2.utilities.CleanerFactory \ + --initialize-at-build-time=org.eclipse.yasson \ + --initialize-at-build-time=io.helidon.common.pki diff --git a/microprofile/server/src/main/resources/META-INF/native-image/io.helidon.microrpofile/helidon-microprofile-server/proxy-config.json b/microprofile/server/src/main/resources/META-INF/native-image/io.helidon.microrpofile/helidon-microprofile-server/proxy-config.json new file mode 100644 index 00000000000..5dd300a1fee --- /dev/null +++ b/microprofile/server/src/main/resources/META-INF/native-image/io.helidon.microrpofile/helidon-microprofile-server/proxy-config.json @@ -0,0 +1,20 @@ +[ + { + "condition": { + "typeReachable": "jakarta.ws.rs.core.UriInfo" + }, + "interfaces": [ + "jakarta.ws.rs.core.UriInfo", + "org.glassfish.hk2.api.ProxyCtl" + ] + }, + { + "condition": { + "typeReachable": "io.helidon.webserver.http.ServerRequest" + }, + "interfaces": [ + "io.helidon.webserver.http.ServerRequest", + "org.glassfish.hk2.api.ProxyCtl" + ] + } +] diff --git a/microprofile/server/src/main/resources/META-INF/native-image/io.helidon.microprofile.jaxrs/helidon-microprofile-jaxrs/resource-config.json b/microprofile/server/src/main/resources/META-INF/native-image/io.helidon.microrpofile/helidon-microprofile-server/resource-config.json similarity index 100% rename from microprofile/server/src/main/resources/META-INF/native-image/io.helidon.microprofile.jaxrs/helidon-microprofile-jaxrs/resource-config.json rename to microprofile/server/src/main/resources/META-INF/native-image/io.helidon.microrpofile/helidon-microprofile-server/resource-config.json diff --git a/microprofile/service-common/src/main/java/io/helidon/microprofile/servicecommon/HelidonRestCdiExtension.java b/microprofile/service-common/src/main/java/io/helidon/microprofile/servicecommon/HelidonRestCdiExtension.java index 4125acadae7..09617b30d53 100644 --- a/microprofile/service-common/src/main/java/io/helidon/microprofile/servicecommon/HelidonRestCdiExtension.java +++ b/microprofile/service-common/src/main/java/io/helidon/microprofile/servicecommon/HelidonRestCdiExtension.java @@ -254,7 +254,13 @@ protected HttpRouting.Builder routingBuilder(ServerCdiExtension server) { : server.serverNamedRoutingBuilder(routingName); } - void prepareRuntime(@Observes @RuntimeStart Config config) { + /** + * Configure with runtime config. + * + * @param config config to use + */ + public void prepareRuntime(@Observes @RuntimeStart Config config) { + // this method must be public, so it is registered for reflection by Helidon GraalVM feature this.rootConfig = config; } diff --git a/http/media/jackson/src/main/resources/META-INF/native-image/io.helidon.nima.http.media/helidon-nima-http-media-jackson/native-image.properties b/microprofile/tracing/src/main/resources/META-INF/native-image/io.helidon.microprofile/helidon-microprofile-tracing/native-image.properties similarity index 91% rename from http/media/jackson/src/main/resources/META-INF/native-image/io.helidon.nima.http.media/helidon-nima-http-media-jackson/native-image.properties rename to microprofile/tracing/src/main/resources/META-INF/native-image/io.helidon.microprofile/helidon-microprofile-tracing/native-image.properties index 1fb3ad9e697..ef4cdca252a 100644 --- a/http/media/jackson/src/main/resources/META-INF/native-image/io.helidon.nima.http.media/helidon-nima-http-media-jackson/native-image.properties +++ b/microprofile/tracing/src/main/resources/META-INF/native-image/io.helidon.microprofile/helidon-microprofile-tracing/native-image.properties @@ -14,4 +14,4 @@ # limitations under the License. # -Args=--initialize-at-build-time=com.fasterxml.jackson +Args=--initialize-at-build-time=io.helidon.tracing diff --git a/security/providers/oidc-common/src/main/resources/META-INF/native-image/io.helidon.security.providers/helidon-security-providers-oidc-common/native-image.properties b/security/providers/oidc-common/src/main/resources/META-INF/native-image/io.helidon.security.providers/helidon-security-providers-oidc-common/native-image.properties index 14dc9dc2da9..b27e5380410 100644 --- a/security/providers/oidc-common/src/main/resources/META-INF/native-image/io.helidon.security.providers/helidon-security-providers-oidc-common/native-image.properties +++ b/security/providers/oidc-common/src/main/resources/META-INF/native-image/io.helidon.security.providers/helidon-security-providers-oidc-common/native-image.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2019, 2022 Oracle and/or its affiliates. +# Copyright (c) 2019, 2023 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,6 +14,5 @@ # limitations under the License. # -Args=-H:EnableURLProtocols=http \ - -H:EnableURLProtocols=https \ - --initialize-at-build-time=io.helidon.security.providers.oidc.common +Args=--enable-http \ + --enable-https diff --git a/security/security/src/main/resources/META-INF/native-image/io.helidon.security/helidon-security/native-image.properties b/security/security/src/main/resources/META-INF/native-image/io.helidon.security/helidon-security/native-image.properties deleted file mode 100644 index 9f1f44505e7..00000000000 --- a/security/security/src/main/resources/META-INF/native-image/io.helidon.security/helidon-security/native-image.properties +++ /dev/null @@ -1,18 +0,0 @@ -# -# Copyright (c) 2019, 2022 Oracle and/or its affiliates. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# Security Subject requires this to work -Args=-H:IncludeResourceBundles=sun.security.util.Resources diff --git a/security/security/src/main/resources/META-INF/native-image/io.helidon.security/helidon-security/resource-config.json b/security/security/src/main/resources/META-INF/native-image/io.helidon.security/helidon-security/resource-config.json new file mode 100644 index 00000000000..e688dd5de05 --- /dev/null +++ b/security/security/src/main/resources/META-INF/native-image/io.helidon.security/helidon-security/resource-config.json @@ -0,0 +1,7 @@ +{ + "bundles": [ + { + "name": "sun.security.util.Resources" + } + ] +} diff --git a/tests/integration/native-image/mp-1/README.md b/tests/integration/native-image/mp-1/README.md index 932a81d8b9e..88293667f3d 100644 --- a/tests/integration/native-image/mp-1/README.md +++ b/tests/integration/native-image/mp-1/README.md @@ -33,7 +33,6 @@ ${GRAALVM_HOME}/bin/native-image -Dhelidon.native.reflection.trace-parsing=true -Dhelidon.native.reflection.trace=true \ -H:Path=./target \ -H:Name=helidon-tests-native-image-mp-1 \ - "-H:IncludeResources=logging.properties|meta-config.yaml|web/resource.txt|web/welcome.txt|verify-jwk.json|META-INF/native-image/tests/mp-1/resource-config.json|META-INF/beans.xml|META-INF/microprofile-config.properties|sign-jwk.json" \ -H:+ReportExceptionStackTraces \ -jar ./target/helidon-tests-native-image-mp-1.jar ``` diff --git a/tests/integration/native-image/mp-1/pom.xml b/tests/integration/native-image/mp-1/pom.xml index 8533c411cc3..87700e15de0 100644 --- a/tests/integration/native-image/mp-1/pom.xml +++ b/tests/integration/native-image/mp-1/pom.xml @@ -30,12 +30,10 @@ Helidon Tests Integration GraalVM Native image MP1 - This test makes sure the following helidon modules can be compiled into native image: - - Microprofile CDI - - Microprofile Server - - Microprofile Tracing - Jaeger Tracer - Microprofile Access Log - Microprofile Fault Tolerance - Microprofile Metrics - - Microprofile Health Check - Microprofile Rest Client - Microprofile Config - YAML configuration - JSON-P - JSON-B - - Microprofile JWT-Auth + This test makes sure the following helidon modules can be compiled into native image: - Microprofile CDI - Microprofile + Server - Microprofile Tracing - Jaeger Tracer - Microprofile Access Log - Microprofile Fault Tolerance - Microprofile + Metrics - Microprofile Health Check - Microprofile Rest Client - Microprofile Config - YAML configuration - JSON-P - + JSON-B - Microprofile JWT-Auth @@ -47,6 +45,10 @@ io.helidon.microprofile.bundles helidon-microprofile + + helidon-microprofile-tracing + io.helidon.microprofile.tracing + io.helidon.security.providers helidon-security-providers-oidc @@ -106,9 +108,14 @@ org.graalvm.buildtools native-maven-plugin - - true - + + + build-native-image + + true + + + diff --git a/tests/integration/native-image/mp-1/src/main/resources/META-INF/native-image/io.helidon.tests.integration.native-image/helidon-tests-native-image-mp1/native-image.properties b/tests/integration/native-image/mp-1/src/main/resources/META-INF/native-image/io.helidon.tests.integration.native-image/helidon-tests-native-image-mp1/native-image.properties new file mode 100644 index 00000000000..8b0df87467f --- /dev/null +++ b/tests/integration/native-image/mp-1/src/main/resources/META-INF/native-image/io.helidon.tests.integration.native-image/helidon-tests-native-image-mp1/native-image.properties @@ -0,0 +1,17 @@ +# +# Copyright (c) 2023 Oracle and/or its affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +Args=--initialize-at-build-time=io.helidon.tests.integration.nativeimage.mp1 diff --git a/tests/integration/native-image/mp-2/README.md b/tests/integration/native-image/mp-2/README.md index 787287661e4..cae0e88fb07 100644 --- a/tests/integration/native-image/mp-2/README.md +++ b/tests/integration/native-image/mp-2/README.md @@ -11,7 +11,7 @@ mvn clean package -Pnative-image ./target/helidon-tests-native-image-mp-2 ``` -Requires at least GraalVM 22.3.0 +Requires at least GraalVM 23.1.0 This test validates that JPA integration (using Hibernate) and JTA integration work in native image. diff --git a/tests/integration/native-image/mp-2/pom.xml b/tests/integration/native-image/mp-2/pom.xml index 67f627a35f5..503b2e2a69e 100644 --- a/tests/integration/native-image/mp-2/pom.xml +++ b/tests/integration/native-image/mp-2/pom.xml @@ -128,9 +128,14 @@ org.graalvm.buildtools native-maven-plugin - - true - + + + build-native-image + + true + + + io.smallrye diff --git a/tests/integration/native-image/mp-2/src/main/resources/META-INF/native-image/io.helidon.tests.integration.native-image/helidon-tests-native-image-mp2/native-image.properties b/tests/integration/native-image/mp-2/src/main/resources/META-INF/native-image/io.helidon.tests.integration.native-image/helidon-tests-native-image-mp2/native-image.properties new file mode 100644 index 00000000000..2ec31934688 --- /dev/null +++ b/tests/integration/native-image/mp-2/src/main/resources/META-INF/native-image/io.helidon.tests.integration.native-image/helidon-tests-native-image-mp2/native-image.properties @@ -0,0 +1,17 @@ +# +# Copyright (c) 2023 Oracle and/or its affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +Args=--initialize-at-build-time=io.helidon.tests.integration.nativeimage.mp2 diff --git a/tests/integration/native-image/mp-3/src/main/resources/META-INF/native-image/io.helidon.tests.integration.native-image/helidon-tests-native-image-mp3/native-image.properties b/tests/integration/native-image/mp-3/src/main/resources/META-INF/native-image/io.helidon.tests.integration.native-image/helidon-tests-native-image-mp3/native-image.properties new file mode 100644 index 00000000000..6d6ffe86a3e --- /dev/null +++ b/tests/integration/native-image/mp-3/src/main/resources/META-INF/native-image/io.helidon.tests.integration.native-image/helidon-tests-native-image-mp3/native-image.properties @@ -0,0 +1,17 @@ +# +# Copyright (c) 2023 Oracle and/or its affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +Args=--initialize-at-build-time=io.helidon.tests.integration.nativeimage.mp3 diff --git a/tests/integration/native-image/se-1/src/main/resources/META-INF/native-image/native-image.properties b/tests/integration/native-image/se-1/src/main/resources/META-INF/native-image/native-image.properties deleted file mode 100644 index 49106660db1..00000000000 --- a/tests/integration/native-image/se-1/src/main/resources/META-INF/native-image/native-image.properties +++ /dev/null @@ -1,18 +0,0 @@ -# -# Copyright (c) 2022, 2023 Oracle and/or its affiliates. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# We must explicitly include resources from other modules -Args=-H:IncludeResources=web-jar/.* -H:IncludeResources=web/.* diff --git a/tracing/providers/jaeger/src/main/resources/META-INF/native-image/io.helidon.tracing/helidon-tracing-jaeger/native-image.properties b/tracing/providers/jaeger/src/main/resources/META-INF/native-image/io.helidon.tracing/helidon-tracing-jaeger/native-image.properties index 65ed88bfab7..c82e50b43c1 100644 --- a/tracing/providers/jaeger/src/main/resources/META-INF/native-image/io.helidon.tracing/helidon-tracing-jaeger/native-image.properties +++ b/tracing/providers/jaeger/src/main/resources/META-INF/native-image/io.helidon.tracing/helidon-tracing-jaeger/native-image.properties @@ -14,7 +14,6 @@ # limitations under the License. # -Args=--initialize-at-build-time=org.slf4j,io.helidon.tracing.providers.jaeger \ - -H:+AddAllCharsets \ - -H:EnableURLProtocols=http \ - -H:EnableURLProtocols=https +Args=-H:+AddAllCharsets \ + --enable-http \ + --enable-https diff --git a/tracing/providers/zipkin/src/main/resources/META-INF/native-image/io.helidon.tracing/helidon-tracing-zipkin/native-image.properties b/tracing/providers/zipkin/src/main/resources/META-INF/native-image/io.helidon.tracing/helidon-tracing-zipkin/native-image.properties index 9ae92f67e9e..0b5b28649e5 100644 --- a/tracing/providers/zipkin/src/main/resources/META-INF/native-image/io.helidon.tracing/helidon-tracing-zipkin/native-image.properties +++ b/tracing/providers/zipkin/src/main/resources/META-INF/native-image/io.helidon.tracing/helidon-tracing-zipkin/native-image.properties @@ -18,6 +18,5 @@ # Graal native image supports additional configuration from this property file. # Zipkin requires http support over URL connection # -Args=--enable-url-protocols=http \ - --initialize-at-build-time=io.helidon.tracing.providers.zipkin,zipkin2 +Args=--enable-url-protocols=http diff --git a/webserver/access-log/src/main/resources/META-INF/native-image/io.helidon.webserver/helidon-webserver-access-log/reflect-config.json b/webserver/access-log/src/main/resources/META-INF/native-image/io.helidon.webserver/helidon-webserver-access-log/reflect-config.json new file mode 100644 index 00000000000..b4e7ed70f63 --- /dev/null +++ b/webserver/access-log/src/main/resources/META-INF/native-image/io.helidon.webserver/helidon-webserver-access-log/reflect-config.json @@ -0,0 +1,7 @@ +[ + { + "name": "io.helidon.webserver.accesslog.AccessLogHandler", + "allDeclaredConstructors": true, + "allPublicMethods": true + } +] From c10a2f1607d8800a721bbff751ffb7d2ce01ce70 Mon Sep 17 00:00:00 2001 From: Tomas Langer Date: Tue, 3 Oct 2023 23:37:44 +0200 Subject: [PATCH 2/9] Review fixes. --- applications/se/pom.xml | 5 ----- docs/mp/aot.adoc | 9 ++++----- examples/quickstarts/helidon-quickstart-se/pom.xml | 14 -------------- 3 files changed, 4 insertions(+), 24 deletions(-) diff --git a/applications/se/pom.xml b/applications/se/pom.xml index 55d54a804be..ad7707c9aa2 100644 --- a/applications/se/pom.xml +++ b/applications/se/pom.xml @@ -53,11 +53,6 @@ compile package - diff --git a/docs/mp/aot.adoc b/docs/mp/aot.adoc index a157bbd228a..2843d1985b2 100644 --- a/docs/mp/aot.adoc +++ b/docs/mp/aot.adoc @@ -37,11 +37,10 @@ build a native image from your application: 3. Execute the native executable created in `target` directory of your project == Initialize at build time -Due to restrictions of our current implementation of integration with native image for CDI, -we must initialize a subset of types at build time. -As a result, all beans created within CDI need to be also initialized at build time. -Easiest approach to support such compilation is to: -1. Create `src/main/resources/META-INF/native-image/groupId/artifactId/native-image.properties` file (`groupId` and `artifactId` of the module you are building should be used) +Helidon MP requires the types of all beans created within CDI to be initialized at builder time, to achieve that: + +1. Create `src/main/resources/META-INF/native-image/groupId/artifactId/native-image.properties` file (`groupId` and `artifactId` + of the module you are building should be used) 2. Add the following line to the file: ```properties Args=--initialize-at-build-time=your.application.package diff --git a/examples/quickstarts/helidon-quickstart-se/pom.xml b/examples/quickstarts/helidon-quickstart-se/pom.xml index 51dc8f25c0b..6c8b46afc77 100644 --- a/examples/quickstarts/helidon-quickstart-se/pom.xml +++ b/examples/quickstarts/helidon-quickstart-se/pom.xml @@ -106,20 +106,6 @@ - - org.graalvm.buildtools - native-maven-plugin - - - build-native-image - - - - - - - - From be69904d7d8487cee85b834c0e25f179642f2a35 Mon Sep 17 00:00:00 2001 From: Tomas Langer Date: Tue, 3 Oct 2023 23:42:47 +0200 Subject: [PATCH 3/9] Doc fix --- docs/mp/aot.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/mp/aot.adoc b/docs/mp/aot.adoc index 2843d1985b2..fe9c1307899 100644 --- a/docs/mp/aot.adoc +++ b/docs/mp/aot.adoc @@ -33,8 +33,8 @@ build a native image from your application: 1. Create an environment variable `GRAALVM_HOME` pointing to your installation of GraalVM, or use a GraalVM JDK to build your project 2. Add configuration to initialize your packages at build time (see below) -2. Run Maven command `mvn clean package -Pnative-image` -3. Execute the native executable created in `target` directory of your project +3. Run Maven command `mvn clean package -Pnative-image` +4. Execute the native executable created in `target` directory of your project == Initialize at build time Helidon MP requires the types of all beans created within CDI to be initialized at builder time, to achieve that: From 189a95c9b9344a124881035f8684e923efac82d9 Mon Sep 17 00:00:00 2001 From: Tomas Langer Date: Tue, 3 Oct 2023 23:51:35 +0200 Subject: [PATCH 4/9] Update to graalvm github action --- .github/workflows/validate.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 00b0915d1f6..5994821ac21 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -149,18 +149,10 @@ jobs: - uses: actions/checkout@v3 - uses: graalvm/setup-graalvm@v1 with: - version: 23.1.0 java-version: 21 - components: native-image + distribution: graalvm-community github-token: ${{ secrets.GITHUB_TOKEN }} native-image-job-reports: true - set-java-home: false - cache: maven - - name: Set up JDK ${{ env.JAVA_VERSION }} - uses: actions/setup-java@v3.13.0 - with: - distribution: ${{ env.JAVA_DISTRO }} - java-version: ${{ env.JAVA_VERSION }} cache: maven - name: Build Helidon run: etc/scripts/github-compile.sh From 5a8657e2a172d4b56c5ae87e1c44d568b45f024c Mon Sep 17 00:00:00 2001 From: Tomas Langer Date: Wed, 4 Oct 2023 10:01:21 +0200 Subject: [PATCH 5/9] Upgrade jar plugin to honor main class attribute for modules --- applications/parent/pom.xml | 2 +- etc/scripts/test-packaging-jar.sh | 2 +- etc/scripts/test-packaging-jlink.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/applications/parent/pom.xml b/applications/parent/pom.xml index 5c7852531e3..3b752eb9a62 100644 --- a/applications/parent/pom.xml +++ b/applications/parent/pom.xml @@ -44,7 +44,7 @@ 3.1.2 4.0.0-M2 4.0.0-M2 - 3.0.2 + 3.3.0 0.9.27 1.5.0.Final 0.6.1 diff --git a/etc/scripts/test-packaging-jar.sh b/etc/scripts/test-packaging-jar.sh index 4fcddfec327..c648b3bf180 100755 --- a/etc/scripts/test-packaging-jar.sh +++ b/etc/scripts/test-packaging-jar.sh @@ -41,7 +41,7 @@ java -jar target/helidon-tests-native-image-mp-1.jar # Module Path java --module-path target/helidon-tests-native-image-mp-1.jar:target/libs \ - --module helidon.tests.nimage.mp/io.helidon.tests.integration.nativeimage.mp1.Mp1Main + --module helidon.tests.nimage.mp # # Run MP-3 (just start and stop) diff --git a/etc/scripts/test-packaging-jlink.sh b/etc/scripts/test-packaging-jlink.sh index ad192bbf62f..7557ca49375 100755 --- a/etc/scripts/test-packaging-jlink.sh +++ b/etc/scripts/test-packaging-jlink.sh @@ -50,7 +50,7 @@ ${jri_dir}/bin/start # Module Path ${jri_dir}/bin/java \ --module-path ${jri_dir}/app/helidon-tests-native-image-mp-1.jar:${jri_dir}/app/libs \ - --module helidon.tests.nimage.mp/io.helidon.tests.integration.nativeimage.mp1.Mp1Main + --module helidon.tests.nimage.mp # Run MP-3 (just start and stop) cd ${WS_DIR}/tests/integration/native-image/mp-3 From 50eb635c8b78029be3c234b03447bd36a1396235 Mon Sep 17 00:00:00 2001 From: Tomas Langer Date: Wed, 4 Oct 2023 10:39:03 +0200 Subject: [PATCH 6/9] Add main class to modularized test Add kotlin dependency to resolve modularized failure --- dependencies/pom.xml | 7 ++++ pom.xml | 2 +- tests/integration/native-image/mp-3/pom.xml | 4 +++ .../integration/nativeimage/mp3/Mp3Main.java | 34 +++++++++++++++++++ tracing/providers/jaeger/pom.xml | 5 +++ .../jaeger/src/main/java/module-info.java | 3 ++ 6 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 tests/integration/native-image/mp-3/src/main/java/io/helidon/tests/integration/nativeimage/mp3/Mp3Main.java diff --git a/dependencies/pom.xml b/dependencies/pom.xml index 4189c704516..0e63e4d086c 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -95,6 +95,7 @@ 6.7.0.202309050840-r 5.9.3 3.4.0 + 1.8.0 2.18.0 1.4.0 2.6.2 @@ -953,6 +954,12 @@ + + + kotlin-stdlib + org.jetbrains.kotlin + ${version.lib.kotlin} + org.glassfish.jersey.media jersey-media-json-binding diff --git a/pom.xml b/pom.xml index 530c11cf9ab..7e73d8f5736 100644 --- a/pom.xml +++ b/pom.xml @@ -112,7 +112,7 @@ ${version.lib.hibernate} 0.8.5 3.1.2 - 3.1.1 + 3.3.0 3.5.0 2.5.0 1.16 diff --git a/tests/integration/native-image/mp-3/pom.xml b/tests/integration/native-image/mp-3/pom.xml index 7bce153384a..4c9042906a1 100644 --- a/tests/integration/native-image/mp-3/pom.xml +++ b/tests/integration/native-image/mp-3/pom.xml @@ -33,6 +33,10 @@ This test uses quickstart application with minimal number of changes + + io.helidon.tests.integration.nativeimage.mp3.Mp3Main + + io.helidon.microprofile.bundles diff --git a/tests/integration/native-image/mp-3/src/main/java/io/helidon/tests/integration/nativeimage/mp3/Mp3Main.java b/tests/integration/native-image/mp-3/src/main/java/io/helidon/tests/integration/nativeimage/mp3/Mp3Main.java new file mode 100644 index 00000000000..83d5da9e999 --- /dev/null +++ b/tests/integration/native-image/mp-3/src/main/java/io/helidon/tests/integration/nativeimage/mp3/Mp3Main.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Oracle and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.helidon.tests.integration.nativeimage.mp3; + +import io.helidon.Main; + +/** + * When using module-info, we must have a main class in the same module, as we cannot + * have a module main class in a package that does not belong to this module. + */ +public class Mp3Main { + /** + * Main method. + * + * @param args ignored + */ + public static void main(String[] args) { + Main.main(args); + } +} diff --git a/tracing/providers/jaeger/pom.xml b/tracing/providers/jaeger/pom.xml index 6cdb56a2931..3d4fd930ebd 100644 --- a/tracing/providers/jaeger/pom.xml +++ b/tracing/providers/jaeger/pom.xml @@ -65,6 +65,11 @@ io.helidon.tracing helidon-tracing + + + kotlin-stdlib + org.jetbrains.kotlin + org.slf4j diff --git a/tracing/providers/jaeger/src/main/java/module-info.java b/tracing/providers/jaeger/src/main/java/module-info.java index 9dc3ef2e038..7a21fb9e627 100644 --- a/tracing/providers/jaeger/src/main/java/module-info.java +++ b/tracing/providers/jaeger/src/main/java/module-info.java @@ -34,6 +34,9 @@ requires io.opentelemetry.sdk.common; requires io.opentelemetry.sdk.trace; requires io.opentelemetry.sdk; + // this was missing from module path, need an explicit requires + // as kotlin is modularized + requires kotlin.stdlib; requires static io.helidon.common.features.api; requires static io.helidon.config.metadata; From e02fdb4a7041cac15b38b831644efc688869c069 Mon Sep 17 00:00:00 2001 From: Tomas Langer Date: Wed, 4 Oct 2023 11:03:31 +0200 Subject: [PATCH 7/9] Native packaging test fixed. --- etc/scripts/includes/pipeline-env.sh | 3 ++- etc/scripts/test-packaging-native.sh | 7 ------- tests/integration/native-image/se-1/pom.xml | 4 ++++ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/etc/scripts/includes/pipeline-env.sh b/etc/scripts/includes/pipeline-env.sh index b556ae8a926..8c4029002d4 100644 --- a/etc/scripts/includes/pipeline-env.sh +++ b/etc/scripts/includes/pipeline-env.sh @@ -47,7 +47,8 @@ if [ -z "${__PIPELINE_ENV_INCLUDED__}" ]; then . ${WS_DIR}/etc/scripts/includes/error_handlers.sh if [ -z "${GRAALVM_HOME}" ]; then - export GRAALVM_HOME="/tools/graalvm-ce-java20-22.3.1" + # we must expect the current JDK is graal + export GRAALVM_HOME=$JAVA_HOME fi require_env() { diff --git a/etc/scripts/test-packaging-native.sh b/etc/scripts/test-packaging-native.sh index 507ec4b38d2..067edb143e7 100755 --- a/etc/scripts/test-packaging-native.sh +++ b/etc/scripts/test-packaging-native.sh @@ -39,13 +39,6 @@ mvn ${MAVEN_ARGS} --version echo "GRAALVM_HOME=${GRAALVM_HOME}"; ${GRAALVM_HOME}/bin/native-image --version; -# Temporary workaround until job stages will share maven repository -mvn ${MAVEN_ARGS} -f ${WS_DIR}/pom.xml \ - install -e \ - -Dmaven.test.skip=true \ - -DskipTests \ - -Ppipeline - # Run native image tests cd ${WS_DIR}/tests/integration/native-image diff --git a/tests/integration/native-image/se-1/pom.xml b/tests/integration/native-image/se-1/pom.xml index d0fbce6a507..65cf0ceb7d2 100644 --- a/tests/integration/native-image/se-1/pom.xml +++ b/tests/integration/native-image/se-1/pom.xml @@ -74,6 +74,10 @@ io.helidon.webclient helidon-webclient + + helidon-webclient-tracing + io.helidon.webclient + io.helidon.common helidon-common-reactive From 717ccd41c95e18aebd3c02564dd32bd11c1104fa Mon Sep 17 00:00:00 2001 From: Tomas Langer Date: Wed, 4 Oct 2023 13:10:21 +0200 Subject: [PATCH 8/9] Fix archetypes to work with new jar plugin --- .../src/main/archetype/mp/common/common-mp.xml | 1 + .../src/main/java/__pkg__/Main.java.mustache | 17 +++++++++++++++++ .../src/main/archetype/mp/custom/custom-mp.xml | 2 ++ .../resource-config.json | 7 +++++++ 4 files changed, 27 insertions(+) create mode 100644 archetypes/helidon/src/main/archetype/mp/common/files/src/main/java/__pkg__/Main.java.mustache create mode 100644 tests/integration/native-image/se-1/src/main/resources/META-INF/native-image/io.helidon.tests.integration.native-image/helidon-tests-native-image-se-1/resource-config.json diff --git a/archetypes/helidon/src/main/archetype/mp/common/common-mp.xml b/archetypes/helidon/src/main/archetype/mp/common/common-mp.xml index 8114be39fb6..3ecb707ee28 100644 --- a/archetypes/helidon/src/main/archetype/mp/common/common-mp.xml +++ b/archetypes/helidon/src/main/archetype/mp/common/common-mp.xml @@ -25,6 +25,7 @@ + ${package}.Main helidon-mp diff --git a/archetypes/helidon/src/main/archetype/mp/common/files/src/main/java/__pkg__/Main.java.mustache b/archetypes/helidon/src/main/archetype/mp/common/files/src/main/java/__pkg__/Main.java.mustache new file mode 100644 index 00000000000..5042d20dcbc --- /dev/null +++ b/archetypes/helidon/src/main/archetype/mp/common/files/src/main/java/__pkg__/Main.java.mustache @@ -0,0 +1,17 @@ + +package {{package}}; + +/** + * Main entry point of the application. + * This class is registered as the main class in the jar manifest, as well as the main class of the module. + */ +public class Main { + /** + * Main method. Starts CDI (and the application). + * + * @param args ignored + */ + public static void main(String[] args) { + io.helidon.Main.main(args); + } +} diff --git a/archetypes/helidon/src/main/archetype/mp/custom/custom-mp.xml b/archetypes/helidon/src/main/archetype/mp/custom/custom-mp.xml index 350886fa1f5..057eef4428f 100644 --- a/archetypes/helidon/src/main/archetype/mp/custom/custom-mp.xml +++ b/archetypes/helidon/src/main/archetype/mp/custom/custom-mp.xml @@ -82,7 +82,9 @@ jakarta.cdi jakarta.inject jakarta.ws.rs + io.helidon io.helidon.microprofile.config + io.helidon.microprofile.server diff --git a/tests/integration/native-image/se-1/src/main/resources/META-INF/native-image/io.helidon.tests.integration.native-image/helidon-tests-native-image-se-1/resource-config.json b/tests/integration/native-image/se-1/src/main/resources/META-INF/native-image/io.helidon.tests.integration.native-image/helidon-tests-native-image-se-1/resource-config.json new file mode 100644 index 00000000000..5507cdf2955 --- /dev/null +++ b/tests/integration/native-image/se-1/src/main/resources/META-INF/native-image/io.helidon.tests.integration.native-image/helidon-tests-native-image-se-1/resource-config.json @@ -0,0 +1,7 @@ +{ + "resources": [ + { + "pattern": "application-test.yaml" + } + ] +} \ No newline at end of file From f2f4b13f883a174bf7c2611e4bdf81f95ca533a4 Mon Sep 17 00:00:00 2001 From: Daniel Kec Date: Wed, 4 Oct 2023 11:56:26 +0200 Subject: [PATCH 9/9] Kafka connector native image updates --- dependencies/pom.xml | 11 +- .../messaging/docker/kafka/Dockerfile.kafka | 6 +- .../messaging/docker/kafka/init_topics.sh | 34 +++- .../examples/messaging/se/SendingService.java | 2 + .../messaging/se/WebSocketEndpoint.java | 4 +- .../src/main/resources/application.yaml | 8 +- .../kafka/AppInfoParserSubstitution.java | 38 ----- .../kafka/CompressionTypeSubstitution.java | 155 ------------------ .../connectors/kafka/Crc32CSubstitution.java | 57 ------- .../kafka/JmxReporterSubstitution.java | 39 ----- ...SaslClientCallbackHandlerSubstitution.java | 154 ----------------- .../native-image/reflection-config.json | 12 +- .../native-image.properties | 19 --- .../messaging/src/main/java/module-info.java | 2 +- 14 files changed, 58 insertions(+), 483 deletions(-) delete mode 100644 messaging/connectors/kafka/src/main/java/io/helidon/messaging/connectors/kafka/AppInfoParserSubstitution.java delete mode 100644 messaging/connectors/kafka/src/main/java/io/helidon/messaging/connectors/kafka/CompressionTypeSubstitution.java delete mode 100644 messaging/connectors/kafka/src/main/java/io/helidon/messaging/connectors/kafka/Crc32CSubstitution.java delete mode 100644 messaging/connectors/kafka/src/main/java/io/helidon/messaging/connectors/kafka/JmxReporterSubstitution.java delete mode 100644 messaging/connectors/kafka/src/main/java/io/helidon/messaging/connectors/kafka/SaslClientCallbackHandlerSubstitution.java delete mode 100644 messaging/connectors/kafka/src/main/resources/META-INF/native-image/io.helidon.messaging.connectors.kafka/native-image.properties diff --git a/dependencies/pom.xml b/dependencies/pom.xml index 0e63e4d086c..00321407574 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -94,7 +94,7 @@ 3.1.3 6.7.0.202309050840-r 5.9.3 - 3.4.0 + 3.5.1 1.8.0 2.18.0 1.4.0 @@ -944,15 +944,6 @@ org.apache.kafka kafka-clients ${version.lib.kafka} - - - - - - org.xerial.snappy - snappy-java - - diff --git a/examples/messaging/docker/kafka/Dockerfile.kafka b/examples/messaging/docker/kafka/Dockerfile.kafka index f78d62addc0..cae5ad7368d 100644 --- a/examples/messaging/docker/kafka/Dockerfile.kafka +++ b/examples/messaging/docker/kafka/Dockerfile.kafka @@ -1,5 +1,5 @@ # -# Copyright (c) 2019, 2021 Oracle and/or its affiliates. +# Copyright (c) 2019, 2023 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,12 +14,12 @@ # limitations under the License. # -FROM openjdk:17-jdk-slim-buster +FROM container-registry.oracle.com/java/openjdk:21 ENV VERSION=2.7.0 ENV SCALA_VERSION=2.13 -RUN apt-get -qq update && apt-get -qq -y install bash curl wget netcat jq +RUN dnf update && dnf -y install wget jq nc RUN REL_PATH=kafka/${VERSION}/kafka_${SCALA_VERSION}-${VERSION}.tgz \ && BACKUP_ARCHIVE=https://archive.apache.org/dist/ \ diff --git a/examples/messaging/docker/kafka/init_topics.sh b/examples/messaging/docker/kafka/init_topics.sh index bee6716faad..4957126f588 100644 --- a/examples/messaging/docker/kafka/init_topics.sh +++ b/examples/messaging/docker/kafka/init_topics.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 2020, 2021 Oracle and/or its affiliates. +# Copyright (c) 2020, 2023 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -40,9 +40,39 @@ while sleep 2; do --replication-factor 1 \ --partitions 10 \ --topic messaging-test-topic-2 + bash $KAFKA_TOPICS \ + --create \ + --replication-factor 1 \ + --partitions 10 \ + --config compression.type=snappy \ + --topic messaging-test-topic-snappy-compressed + bash $KAFKA_TOPICS \ + --create \ + --replication-factor 1 \ + --partitions 10 \ + --config compression.type=lz4 \ + --topic messaging-test-topic-lz4-compressed + bash $KAFKA_TOPICS \ + --create \ + --replication-factor 1 \ + --partitions 10 \ + --config compression.type=zstd \ + --topic messaging-test-topic-zstd-compressed + bash $KAFKA_TOPICS \ + --create \ + --replication-factor 1 \ + --partitions 10 \ + --config compression.type=gzip \ + --topic messaging-test-topic-gzip-compressed echo - echo "Example topics messaging-test-topic-1 and messaging-test-topic-2 created" + echo "Example topics created:" + echo " messaging-test-topic-1" + echo " messaging-test-topic-2" + echo " messaging-test-topic-snappy-compressed" + echo " messaging-test-topic-lz4-compressed" + echo " messaging-test-topic-zstd-compressed" + echo " messaging-test-topic-gzip-compressed" echo echo "================== Kafka is ready, stop it with Ctrl+C ==================" exit 0 diff --git a/examples/messaging/kafka-websocket-se/src/main/java/io/helidon/examples/messaging/se/SendingService.java b/examples/messaging/kafka-websocket-se/src/main/java/io/helidon/examples/messaging/se/SendingService.java index 8d8ef73a7a9..355c2ac33bb 100644 --- a/examples/messaging/kafka-websocket-se/src/main/java/io/helidon/examples/messaging/se/SendingService.java +++ b/examples/messaging/kafka-websocket-se/src/main/java/io/helidon/examples/messaging/se/SendingService.java @@ -35,6 +35,7 @@ class SendingService implements HttpService { String kafkaServer = config.get("app.kafka.bootstrap.servers").asString().get(); String topic = config.get("app.kafka.topic").asString().get(); + String compression = config.get("app.kafka.compression").asString().orElse("none"); // Prepare channel for connecting processor -> kafka connector with specific subscriber configuration, // channel -> connector mapping is automatic when using KafkaConnector.configBuilder() @@ -42,6 +43,7 @@ class SendingService implements HttpService { .subscriberConfig(KafkaConnector.configBuilder() .bootstrapServers(kafkaServer) .topic(topic) + .compressionType(compression) .keySerializer(StringSerializer.class) .valueSerializer(StringSerializer.class) .build()) diff --git a/examples/messaging/kafka-websocket-se/src/main/java/io/helidon/examples/messaging/se/WebSocketEndpoint.java b/examples/messaging/kafka-websocket-se/src/main/java/io/helidon/examples/messaging/se/WebSocketEndpoint.java index 3c62028ef9c..edf15419c88 100644 --- a/examples/messaging/kafka-websocket-se/src/main/java/io/helidon/examples/messaging/se/WebSocketEndpoint.java +++ b/examples/messaging/kafka-websocket-se/src/main/java/io/helidon/examples/messaging/se/WebSocketEndpoint.java @@ -47,6 +47,7 @@ public void onOpen(WsSession session) { String kafkaServer = config.get("app.kafka.bootstrap.servers").asString().get(); String topic = config.get("app.kafka.topic").asString().get(); + String compression = config.get("app.kafka.compression").asString().orElse("none"); // Prepare channel for connecting kafka connector with specific publisher configuration -> listener, // channel -> connector mapping is automatic when using KafkaConnector.configBuilder() @@ -60,6 +61,7 @@ public void onOpen(WsSession session) { .enableAutoCommit(true) .keyDeserializer(StringDeserializer.class) .valueDeserializer(StringDeserializer.class) + .compressionType(compression) .build() ) .build(); @@ -72,7 +74,7 @@ public void onOpen(WsSession session) { .listener(fromKafka, payload -> { System.out.println("Kafka says: " + payload); // Send message received from Kafka over websocket - session.send(payload, false); + session.send(payload, true); }) .build() .start(); diff --git a/examples/messaging/kafka-websocket-se/src/main/resources/application.yaml b/examples/messaging/kafka-websocket-se/src/main/resources/application.yaml index e5e6f96c0f7..949b803df73 100644 --- a/examples/messaging/kafka-websocket-se/src/main/resources/application.yaml +++ b/examples/messaging/kafka-websocket-se/src/main/resources/application.yaml @@ -1,5 +1,5 @@ # -# Copyright (c) 2020 Oracle and/or its affiliates. +# Copyright (c) 2020, 2023 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,11 @@ app: kafka: bootstrap.servers: localhost:9092 - topic: messaging-test-topic-1 + compression: snappy +# compression: lz4 +# compression: zstd +# compression: gzip + topic: messaging-test-topic-${app.kafka.compression}-compressed server: port: 7001 diff --git a/messaging/connectors/kafka/src/main/java/io/helidon/messaging/connectors/kafka/AppInfoParserSubstitution.java b/messaging/connectors/kafka/src/main/java/io/helidon/messaging/connectors/kafka/AppInfoParserSubstitution.java deleted file mode 100644 index d6bb2c570ea..00000000000 --- a/messaging/connectors/kafka/src/main/java/io/helidon/messaging/connectors/kafka/AppInfoParserSubstitution.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2020, 2022 Oracle and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.helidon.messaging.connectors.kafka; - -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; -import org.apache.kafka.common.metrics.Metrics; -import org.apache.kafka.common.utils.AppInfoParser; - -/** - * JMX not supported in native-image. - */ -@TargetClass(AppInfoParser.class) -@SuppressWarnings("checkstyle:HideUtilityClassConstructor") -final class AppInfoParserSubstitution { - - @Substitute - public static void registerAppInfo(String p, String i, Metrics m, long n) { - } - - @Substitute - public static void unregisterAppInfo(String p, String i, Metrics m) { - } -} diff --git a/messaging/connectors/kafka/src/main/java/io/helidon/messaging/connectors/kafka/CompressionTypeSubstitution.java b/messaging/connectors/kafka/src/main/java/io/helidon/messaging/connectors/kafka/CompressionTypeSubstitution.java deleted file mode 100644 index 89977c98157..00000000000 --- a/messaging/connectors/kafka/src/main/java/io/helidon/messaging/connectors/kafka/CompressionTypeSubstitution.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2020, 2022 Oracle and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.helidon.messaging.connectors.kafka; - -import java.io.InputStream; -import java.io.OutputStream; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.nio.ByteBuffer; - -import io.helidon.common.LazyValue; - -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; -import org.apache.kafka.common.KafkaException; -import org.apache.kafka.common.utils.BufferSupplier; -import org.apache.kafka.common.utils.ByteBufferInputStream; -import org.apache.kafka.common.utils.ByteBufferOutputStream; - -/** - * Helper for creating ZSTD or SNAPPY compression stream wrappers without method handles. - */ -@SuppressWarnings("checkstyle:OuterTypeFilename") -final class CompressionTypeHelper { - - private CompressionTypeHelper() { - } - - private static boolean zstdNativeLibLoaded = false; - - static final LazyValue> LAZY_INPUT_ZSTD = - LazyValue.create(() -> findConstructor("com.github.luben.zstd.ZstdInputStream", InputStream.class)); - static final LazyValue> LAZY_OUTPUT_ZSTD = - LazyValue.create(() -> findConstructor("com.github.luben.zstd.ZstdOutputStream", OutputStream.class)); - static final LazyValue> LAZY_INPUT_SNAPPY = - LazyValue.create(() -> findConstructor("org.xerial.snappy.SnappyInputStream", InputStream.class)); - static final LazyValue> LAZY_OUTPUT_SNAPPY = - LazyValue.create(() -> findConstructor("org.xerial.snappy.SnappyOutputStream", OutputStream.class)); - - static OutputStream snappyOutputStream(OutputStream orig) { - try { - return (OutputStream) LAZY_OUTPUT_SNAPPY.get().newInstance(orig); - } catch (KafkaException e) { - throw e; - } catch (Exception e) { - throw new KafkaException(e); - } - } - - static InputStream snappyInputStream(ByteBuffer orig) { - try { - return (InputStream) LAZY_INPUT_SNAPPY.get().newInstance(new ByteBufferInputStream(orig)); - } catch (KafkaException e) { - throw e; - } catch (Exception e) { - throw new KafkaException(e); - } - } - - static void zstdLoadNativeLibs() throws ReflectiveOperationException { - // loading jni libs in static blocks is not supported - // see https://github.com/oracle/graal/issues/439#issuecomment-394341725 - if (!zstdNativeLibLoaded) { - Class clazz = Class.forName("com.github.luben.zstd.util.Native"); - Field loadedField = clazz.getDeclaredField("loaded"); - loadedField.setAccessible(true); - loadedField.setBoolean(null, false); - Method loadMethod = clazz.getDeclaredMethod("load"); - loadMethod.invoke(null); - zstdNativeLibLoaded = true; - } - } - - static OutputStream zstdOutputStream(OutputStream orig) { - try { - zstdLoadNativeLibs(); - return (OutputStream) LAZY_OUTPUT_ZSTD.get().newInstance(orig); - } catch (KafkaException e) { - throw e; - } catch (Exception e) { - throw new KafkaException(e); - } - } - - static InputStream zstdInputStream(ByteBuffer orig) { - try { - zstdLoadNativeLibs(); - return (InputStream) LAZY_INPUT_ZSTD.get().newInstance(new ByteBufferInputStream(orig)); - } catch (KafkaException e) { - throw e; - } catch (Exception e) { - throw new KafkaException(e); - } - } - - static Constructor findConstructor(String className, Class... paramTypes) { - try { - return Class.forName(className) - .getDeclaredConstructor(paramTypes); - } catch (NoSuchMethodException | ClassNotFoundException e) { - throw new KafkaException(e); - } - } -} - -/** - * Substitution for {@link org.apache.kafka.common.record.CompressionType#SNAPPY CompressionType.SNAPPY}. - */ -@TargetClass(className = "org.apache.kafka.common.record.CompressionType$3") -@SuppressWarnings("checkstyle:OneTopLevelClass") -final class SnappySubstitution { - - @Substitute - public OutputStream wrapForOutput(ByteBufferOutputStream buffer, byte messageVersion) { - return CompressionTypeHelper.snappyOutputStream(buffer); - } - - @Substitute - public InputStream wrapForInput(ByteBuffer buffer, byte messageVersion, BufferSupplier decompressionBufferSupplier) { - return CompressionTypeHelper.snappyInputStream(buffer); - } -} - -/** - * Substitution for {@link org.apache.kafka.common.record.CompressionType#ZSTD CompressionType.ZSTD}. - */ -@TargetClass(className = "org.apache.kafka.common.record.CompressionType$5") -@SuppressWarnings("checkstyle:OneTopLevelClass") -final class ZstdSubstitution { - - @Substitute - public OutputStream wrapForOutput(ByteBufferOutputStream buffer, byte messageVersion) { - return CompressionTypeHelper.zstdOutputStream(buffer); - } - - @Substitute - public InputStream wrapForInput(ByteBuffer buffer, byte messageVersion, BufferSupplier decompressionBufferSupplier) { - return CompressionTypeHelper.zstdInputStream(buffer); - } -} diff --git a/messaging/connectors/kafka/src/main/java/io/helidon/messaging/connectors/kafka/Crc32CSubstitution.java b/messaging/connectors/kafka/src/main/java/io/helidon/messaging/connectors/kafka/Crc32CSubstitution.java deleted file mode 100644 index ce5214c0990..00000000000 --- a/messaging/connectors/kafka/src/main/java/io/helidon/messaging/connectors/kafka/Crc32CSubstitution.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2020, 2023 Oracle and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.helidon.messaging.connectors.kafka; - -import java.nio.ByteBuffer; -import java.util.zip.Checksum; - -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; -import org.apache.kafka.common.utils.Checksums; - - -/** - * Method handles are not supported by native-image, - * invoke {@link java.util.zip.CRC32C CRC32C} directly. - *

- * Helidon (since version 2) runs only on Java 11 and newer, {@link java.util.zip.CRC32C CRC32C} - * doesn't have to be instantiated by method handles. - */ -@TargetClass(org.apache.kafka.common.utils.Crc32C.class) -@Substitute -@SuppressWarnings("checkstyle:HideUtilityClassConstructor") -final class Crc32CSubstitution { - - @Substitute - public static long compute(byte[] bytes, int offset, int size) { - Checksum crc = create(); - crc.update(bytes, offset, size); - return crc.getValue(); - } - - @Substitute - public static long compute(ByteBuffer buffer, int offset, int size) { - Checksum crc = create(); - Checksums.update(crc, buffer, offset, size); - return crc.getValue(); - } - - @Substitute - public static Checksum create() { - return new java.util.zip.CRC32C(); - } -} diff --git a/messaging/connectors/kafka/src/main/java/io/helidon/messaging/connectors/kafka/JmxReporterSubstitution.java b/messaging/connectors/kafka/src/main/java/io/helidon/messaging/connectors/kafka/JmxReporterSubstitution.java deleted file mode 100644 index bb483d8084c..00000000000 --- a/messaging/connectors/kafka/src/main/java/io/helidon/messaging/connectors/kafka/JmxReporterSubstitution.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2020, 2022 Oracle and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.helidon.messaging.connectors.kafka; - -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; -import org.apache.kafka.common.metrics.KafkaMetric; - -/** - * JMX not supported in native-image. - */ -@TargetClass(org.apache.kafka.common.metrics.JmxReporter.class) -final class JmxReporterSubstitution { - - @Substitute - private Object addAttribute(KafkaMetric metric) { - return null; - } - - @Substitute - public void metricChange(KafkaMetric metric) { - } - -} - diff --git a/messaging/connectors/kafka/src/main/java/io/helidon/messaging/connectors/kafka/SaslClientCallbackHandlerSubstitution.java b/messaging/connectors/kafka/src/main/java/io/helidon/messaging/connectors/kafka/SaslClientCallbackHandlerSubstitution.java deleted file mode 100644 index a38e494e05c..00000000000 --- a/messaging/connectors/kafka/src/main/java/io/helidon/messaging/connectors/kafka/SaslClientCallbackHandlerSubstitution.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2021, 2022 Oracle and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.helidon.messaging.connectors.kafka; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.security.auth.Subject; -import javax.security.auth.callback.Callback; -import javax.security.auth.callback.NameCallback; -import javax.security.auth.callback.PasswordCallback; -import javax.security.auth.callback.UnsupportedCallbackException; -import javax.security.auth.login.AppConfigurationEntry; -import javax.security.auth.spi.LoginModule; -import javax.security.sasl.AuthorizeCallback; -import javax.security.sasl.RealmCallback; - -import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.Inject; -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; -import org.apache.kafka.common.KafkaException; -import org.apache.kafka.common.config.SaslConfigs; -import org.apache.kafka.common.security.auth.AuthenticateCallbackHandler; -import org.apache.kafka.common.security.auth.SaslExtensions; -import org.apache.kafka.common.security.auth.SaslExtensionsCallback; -import org.apache.kafka.common.security.authenticator.LoginManager; -import org.apache.kafka.common.security.scram.ScramExtensionsCallback; -import org.apache.kafka.common.security.scram.internals.ScramMechanism; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@TargetClass(org.apache.kafka.common.security.authenticator.SaslClientCallbackHandler.class) -@SuppressWarnings("checkstyle:RedundantModifier") -final class SaslClientCallbackHandlerSubstitution implements AuthenticateCallbackHandler { - - @Alias - private String mechanism; - - @Inject - private Logger logger; - - @Inject - private Subject subject; - - @Substitute - public SaslClientCallbackHandlerSubstitution() { - logger = LoggerFactory.getLogger(LoginManager.class); - } - - @Override - @Substitute - public void configure(Map configs, String saslMechanism, List jaasConfigEntries) { - this.mechanism = saslMechanism; - this.subject = null; - - int entrySize = jaasConfigEntries.size(); - if (entrySize == 0) { - logger.warn("Missing JAAS config entry, missing or malformed sasl.jaas.config property."); - return; - } else if (entrySize > 1) { - logger.warn("Multiple JAAS config entries, Kafka client's sasl.jaas.config can have only one JAAS config entry."); - return; - } - - AppConfigurationEntry jaasConfigEntry = jaasConfigEntries.get(0); - String jaasLoginModuleName = jaasConfigEntry.getLoginModuleName(); - subject = new Subject(); - - try { - Class.forName(jaasLoginModuleName) - .asSubclass(LoginModule.class) - .getDeclaredConstructor() - .newInstance() - .initialize(subject, this, new HashMap<>(), jaasConfigEntry.getOptions()); - } catch (ReflectiveOperationException e) { - throw new KafkaException("Can't instantiate JAAS login module" + jaasLoginModuleName, e); - } - } - - @Override - @Substitute - public void handle(Callback[] callbacks) throws UnsupportedCallbackException { - // Subject.getSubject doesn't return proper subject in native image - // Remove substitution when https://github.com/oracle/graal/issues/2745 is fixed - // Subject subject = Subject.getSubject(AccessController.getContext()); - - for (Callback callback : callbacks) { - if (callback instanceof NameCallback) { - NameCallback nc = (NameCallback) callback; - if (subject != null && !subject.getPublicCredentials(String.class).isEmpty()) { - nc.setName(subject.getPublicCredentials(String.class).iterator().next()); - } else { - nc.setName(nc.getDefaultName()); - } - } else if (callback instanceof PasswordCallback) { - if (subject != null && !subject.getPrivateCredentials(String.class).isEmpty()) { - char[] password = subject.getPrivateCredentials(String.class).iterator().next().toCharArray(); - ((PasswordCallback) callback).setPassword(password); - } else { - String errorMessage = "Could not login: the client is being asked for a password, but the Kafka" - + " client code does not currently support obtaining a password from the user."; - throw new UnsupportedCallbackException(callback, errorMessage); - } - } else if (callback instanceof RealmCallback) { - RealmCallback rc = (RealmCallback) callback; - rc.setText(rc.getDefaultText()); - } else if (callback instanceof AuthorizeCallback) { - AuthorizeCallback ac = (AuthorizeCallback) callback; - String authId = ac.getAuthenticationID(); - String authzId = ac.getAuthorizationID(); - ac.setAuthorized(authId.equals(authzId)); - if (ac.isAuthorized()) { - ac.setAuthorizedID(authzId); - } - } else if (callback instanceof ScramExtensionsCallback) { - if (ScramMechanism.isScram(mechanism) && subject != null && !subject.getPublicCredentials(Map.class).isEmpty()) { - @SuppressWarnings("unchecked") - Map extensions = - (Map) subject.getPublicCredentials(Map.class).iterator().next(); - ((ScramExtensionsCallback) callback).extensions(extensions); - } - } else if (callback instanceof SaslExtensionsCallback) { - if (!SaslConfigs.GSSAPI_MECHANISM.equals(mechanism) - && subject != null && !subject.getPublicCredentials(SaslExtensions.class).isEmpty()) { - SaslExtensions extensions = subject.getPublicCredentials(SaslExtensions.class).iterator().next(); - ((SaslExtensionsCallback) callback).extensions(extensions); - } - } else { - throw new UnsupportedCallbackException(callback, "Unrecognized SASL ClientCallback"); - } - } - } - - @Override - @Substitute - public void close() { - } -} diff --git a/messaging/connectors/kafka/src/main/resources/META-INF/helidon/native-image/reflection-config.json b/messaging/connectors/kafka/src/main/resources/META-INF/helidon/native-image/reflection-config.json index 9d8a492e06d..a96c8b57def 100644 --- a/messaging/connectors/kafka/src/main/resources/META-INF/helidon/native-image/reflection-config.json +++ b/messaging/connectors/kafka/src/main/resources/META-INF/helidon/native-image/reflection-config.json @@ -8,13 +8,21 @@ "org.apache.kafka.clients.producer.Partitioner", "org.apache.kafka.common.security.auth.AuthenticateCallbackHandler", "org.apache.kafka.common.security.auth.Login", - "javax.security.auth.spi.LoginModule" + "javax.security.auth.spi.LoginModule", + "net.jpountz.xxhash.StreamingXXHash32", + "net.jpountz.xxhash.StreamingXXHash32$Factory", + "net.jpountz.xxhash.StreamingXXHash64JavaSafe$Factory", + "net.jpountz.xxhash.XXHash32", + "net.jpountz.lz4.LZ4UnknownSizeDecompressor", + "net.jpountz.lz4.LZ4Compressor", + "net.jpountz.lz4.LZ4Decompressor" ], "classes": [ "org.xerial.snappy.SnappyInputStream", "org.xerial.snappy.SnappyOutputStream", "com.github.luben.zstd.ZstdInputStream", "com.github.luben.zstd.ZstdOutputStream", - "com.github.luben.zstd.util.Native" + "com.github.luben.zstd.util.Native", + "net.jpountz.xxhash.XXHash64JavaSafe" ] } diff --git a/messaging/connectors/kafka/src/main/resources/META-INF/native-image/io.helidon.messaging.connectors.kafka/native-image.properties b/messaging/connectors/kafka/src/main/resources/META-INF/native-image/io.helidon.messaging.connectors.kafka/native-image.properties deleted file mode 100644 index c56586661ca..00000000000 --- a/messaging/connectors/kafka/src/main/resources/META-INF/native-image/io.helidon.messaging.connectors.kafka/native-image.properties +++ /dev/null @@ -1,19 +0,0 @@ -# -# Copyright (c) 2020, 2023 Oracle and/or its affiliates. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# Manual registration of Sun Sasl as workaround for https://github.com/oracle/graal/issues/3664 -Args=-H:AdditionalSecurityProviders=com.sun.security.sasl.Provider \ - -H:+JNI diff --git a/messaging/messaging/src/main/java/module-info.java b/messaging/messaging/src/main/java/module-info.java index 3c88d7ff326..855b6180d11 100644 --- a/messaging/messaging/src/main/java/module-info.java +++ b/messaging/messaging/src/main/java/module-info.java @@ -26,7 +26,7 @@ in = HelidonFlavor.SE, path = "Messaging" ) -@Aot(description = "Experimental support in native image") +@Aot @SuppressWarnings({ "requires-automatic", "requires-transitive-automatic" }) module io.helidon.messaging {