From ed9ccbbcd7f1e1d4867ded76572bd67e4db367f4 Mon Sep 17 00:00:00 2001 From: Maxim Nesen Date: Sat, 13 Feb 2021 12:58:16 +0100 Subject: [PATCH 1/4] GraalVM native-image Signed-off-by: Maxim Nesen --- .gitignore | 1 + .../jersey-common/reflect-config.json | 153 ++++++++++++++++++ .../jersey-common/resource-config.json | 5 + .../jersey-server/reflect-config.json | 91 +++++++++++ .../jersey-server/resource-config.json | 5 + .../examples/helloworld/cdi2se/App.java | 4 +- examples/helloworld/pom.xml | 56 ++++++- .../helloworld/jni-config.json | 9 ++ .../helloworld/native-image.properties | 16 ++ .../helloworld/reflect-config.json | 85 ++++++++++ .../helloworld/resource-config.json | 8 + .../jersey-hk2/reflect-config.json | 34 ++++ .../jersey-hk2/resource-config.json | 5 + pom.xml | 4 +- 14 files changed, 471 insertions(+), 5 deletions(-) create mode 100644 core-common/src/main/resources/META-INF/native-image/org.glassfish.jersey.core/jersey-common/reflect-config.json create mode 100644 core-common/src/main/resources/META-INF/native-image/org.glassfish.jersey.core/jersey-common/resource-config.json create mode 100644 core-server/src/main/resources/META-INF/native-image/org.glassfish.jersey.core/jersey-server/reflect-config.json create mode 100644 core-server/src/main/resources/META-INF/native-image/org.glassfish.jersey.core/jersey-server/resource-config.json create mode 100644 examples/helloworld/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld/jni-config.json create mode 100644 examples/helloworld/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld/native-image.properties create mode 100644 examples/helloworld/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld/reflect-config.json create mode 100644 examples/helloworld/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld/resource-config.json create mode 100644 inject/hk2/src/main/resources/META-INF/native-image/org.glassfish.jersey.inject/jersey-hk2/reflect-config.json create mode 100644 inject/hk2/src/main/resources/META-INF/native-image/org.glassfish.jersey.inject/jersey-hk2/resource-config.json diff --git a/.gitignore b/.gitignore index 9f7d5b947e..9d011f0bfb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # maven noise target/ target-*/ +target*/ # gradle noise .gradle diff --git a/core-common/src/main/resources/META-INF/native-image/org.glassfish.jersey.core/jersey-common/reflect-config.json b/core-common/src/main/resources/META-INF/native-image/org.glassfish.jersey.core/jersey-common/reflect-config.json new file mode 100644 index 0000000000..9ea23c8d07 --- /dev/null +++ b/core-common/src/main/resources/META-INF/native-image/org.glassfish.jersey.core/jersey-common/reflect-config.json @@ -0,0 +1,153 @@ +[ + { + "name":"org.glassfish.jersey.internal.config.ExternalPropertiesAutoDiscoverable", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.internal.inject.Custom", + "allDeclaredMethods":true + }, + { + "name":"org.glassfish.jersey.internal.ServiceFinder", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.logging.LoggingFeatureAutoDiscoverable", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.message.internal.AbstractFormProvider", + "allDeclaredFields":true, + "allDeclaredMethods":true + }, + { + "name":"org.glassfish.jersey.message.internal.AbstractMessageReaderWriterProvider", + "allDeclaredFields":true, + "allDeclaredMethods":true + }, + { + "name":"org.glassfish.jersey.message.internal.BasicTypesMessageProvider", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.message.internal.ByteArrayProvider", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.message.internal.DataSourceProvider", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.message.internal.EnumMessageProvider", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allPublicMethods":true, + "allDeclaredConstructors":true, + "allPublicConstructors":true + }, + { + "name":"org.glassfish.jersey.message.internal.FileProvider", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.message.internal.FormMultivaluedMapProvider", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.message.internal.FormProvider", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.message.internal.InputStreamProvider", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.message.internal.ReaderProvider", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.message.internal.RenderedImageProvider", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.message.internal.SourceProvider$DomSourceReader", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.message.internal.SourceProvider$SaxSourceReader", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.message.internal.SourceProvider$SourceWriter", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.message.internal.SourceProvider$StreamSourceReader", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.message.internal.StreamingOutputProvider", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.message.internal.StringMessageProvider", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.process.Inflector", + "methods":[{"name":"apply","parameterTypes":["java.lang.Object"] }] + }, + { + "name":"org.glassfish.jersey.process.internal.RequestScope", + "allDeclaredFields":true, + "allDeclaredMethods":true + }, + { + "name":"org.glassfish.jersey.spi.AbstractThreadPoolProvider", + "allDeclaredMethods":true + }, + { + "name":"org.glassfish.jersey.spi.ScheduledThreadPoolExecutorProvider", + "allDeclaredMethods":true + }, + { + "name":"org.glassfish.jersey.spi.ThreadPoolExecutorProvider", + "allDeclaredMethods":true + } +] \ No newline at end of file diff --git a/core-common/src/main/resources/META-INF/native-image/org.glassfish.jersey.core/jersey-common/resource-config.json b/core-common/src/main/resources/META-INF/native-image/org.glassfish.jersey.core/jersey-common/resource-config.json new file mode 100644 index 0000000000..462f993b7b --- /dev/null +++ b/core-common/src/main/resources/META-INF/native-image/org.glassfish.jersey.core/jersey-common/resource-config.json @@ -0,0 +1,5 @@ +{ + "bundles": [ + {"name": "org.glassfish.jersey.internal.localization"} + ] +} \ No newline at end of file diff --git a/core-server/src/main/resources/META-INF/native-image/org.glassfish.jersey.core/jersey-server/reflect-config.json b/core-server/src/main/resources/META-INF/native-image/org.glassfish.jersey.core/jersey-server/reflect-config.json new file mode 100644 index 0000000000..f013c3699d --- /dev/null +++ b/core-server/src/main/resources/META-INF/native-image/org.glassfish.jersey.core/jersey-server/reflect-config.json @@ -0,0 +1,91 @@ +[ + { + "name":"org.glassfish.jersey.server.BackgroundScheduler", + "allDeclaredMethods":true + }, + { + "name":"org.glassfish.jersey.server.ChunkedResponseWriter", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.server.ManagedAsyncExecutor", + "allDeclaredMethods":true + }, + { + "name":"org.glassfish.jersey.server.ResourceConfig", + "allDeclaredMethods":true + }, + { + "name":"org.glassfish.jersey.server.ServerExecutorProvidersConfigurator$DefaultBackgroundSchedulerProvider", + "allDeclaredMethods":true + }, + { + "name":"org.glassfish.jersey.server.ServerExecutorProvidersConfigurator$DefaultManagedAsyncExecutorProvider", + "allDeclaredMethods":true + }, + { + "name":"org.glassfish.jersey.server.filter.internal.ServerFiltersAutoDiscoverable", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.server.internal.monitoring.MonitoringAutodiscoverable", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.server.internal.monitoring.MonitoringContainerListener", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.server.internal.process.RequestProcessingContextReference", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.server.model.Parameter$ServerParameterService", + "methods":[{"name":"","parameterTypes":[] }] + }, + { + "name":"org.glassfish.jersey.server.wadl.WadlFeature", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allPublicMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.server.wadl.internal.WadlAutoDiscoverable", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.server.wadl.processor.OptionsMethodProcessor$GenericOptionsInflector", + "allPublicMethods":true, + "allPublicConstructors":true + }, + { + "name":"org.glassfish.jersey.server.wadl.processor.OptionsMethodProcessor$PlainTextOptionsInflector", + "allPublicMethods":true, + "allPublicConstructors":true + } +] \ No newline at end of file diff --git a/core-server/src/main/resources/META-INF/native-image/org.glassfish.jersey.core/jersey-server/resource-config.json b/core-server/src/main/resources/META-INF/native-image/org.glassfish.jersey.core/jersey-server/resource-config.json new file mode 100644 index 0000000000..6615ca336b --- /dev/null +++ b/core-server/src/main/resources/META-INF/native-image/org.glassfish.jersey.core/jersey-server/resource-config.json @@ -0,0 +1,5 @@ +{ + "bundles": [ + {"name":"org.glassfish.jersey.server.internal.localization"} + ] +} \ No newline at end of file diff --git a/examples/helloworld-cdi2-se/src/main/java/org/glassfish/jersey/examples/helloworld/cdi2se/App.java b/examples/helloworld-cdi2-se/src/main/java/org/glassfish/jersey/examples/helloworld/cdi2se/App.java index 5608a6de8e..3ad314e4af 100644 --- a/examples/helloworld-cdi2-se/src/main/java/org/glassfish/jersey/examples/helloworld/cdi2se/App.java +++ b/examples/helloworld-cdi2-se/src/main/java/org/glassfish/jersey/examples/helloworld/cdi2se/App.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -40,7 +40,7 @@ public static void main(String[] args) { server.start(); System.out.println("Application started.\nTry out"); - System.out.println(String.format("%s%s%s", BASE_URI, ROOT_HELLO_PATH, "/Some%Name")); + System.out.println(String.format("%s%s%s", BASE_URI, ROOT_HELLO_PATH, "/Some%20Name")); System.out.println(String.format("%s%s%s", BASE_URI, ROOT_COUNTER_PATH, "/request")); System.out.println(String.format("%s%s%s", BASE_URI, ROOT_COUNTER_PATH, "/application")); System.out.println("Stop the application using CTRL+C"); diff --git a/examples/helloworld/pom.xml b/examples/helloworld/pom.xml index d3e729b415..bdb5c8550c 100644 --- a/examples/helloworld/pom.xml +++ b/examples/helloworld/pom.xml @@ -26,6 +26,11 @@ Jersey annotated resource class "Hello world" example. + + + 20.3.2 + + org.glassfish.jersey.containers @@ -76,6 +81,55 @@ + + native-image + + + + org.graalvm.nativeimage + native-image-maven-plugin + ${graalvm.version} + + + + native-image + + package + + + + ${project.artifactId}-native + org.glassfish.jersey.examples.helloworld.App + + + + + + + org.graalvm.sdk + graal-sdk + ${graalvm.version} + provided + + + jakarta.activation + jakarta.activation-api + ${jakarta.activation.version} + + + jakarta.xml.bind + jakarta.xml.bind-api + + + org.osgi + org.osgi.framework + 1.10.0 + + + org.glassfish.hk2 + hk2-locator + + + - diff --git a/examples/helloworld/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld/jni-config.json b/examples/helloworld/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld/jni-config.json new file mode 100644 index 0000000000..9127dd449d --- /dev/null +++ b/examples/helloworld/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld/jni-config.json @@ -0,0 +1,9 @@ +[ + { + "name":"java.lang.ClassLoader", + "methods":[{"name":"getPlatformClassLoader","parameterTypes":[] }] + }, + { + "name":"java.lang.NoSuchMethodError" + } +] diff --git a/examples/helloworld/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld/native-image.properties b/examples/helloworld/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld/native-image.properties new file mode 100644 index 0000000000..6d2c053639 --- /dev/null +++ b/examples/helloworld/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld/native-image.properties @@ -0,0 +1,16 @@ +# +# Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Distribution License v. 1.0, which is available at +# http://www.eclipse.org/org/documents/edl-v10.php. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +Args=-H:EnableURLProtocols=http,https \ + --initialize-at-build-time=org.glassfish.jersey.client.internal.HttpUrlConnector \ + -H:+ReportExceptionStackTraces \ + --verbose \ + --no-fallback \ + --report-unsupported-elements-at-runtime \ No newline at end of file diff --git a/examples/helloworld/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld/reflect-config.json b/examples/helloworld/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld/reflect-config.json new file mode 100644 index 0000000000..98d7642a1b --- /dev/null +++ b/examples/helloworld/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld/reflect-config.json @@ -0,0 +1,85 @@ +[ + { + "name":"java.awt.image.RenderedImage" + }, + { + "name":"javax.activation.DataSource" + }, + { + "name":"javax.inject.Named", + "allDeclaredMethods":true + }, + { + "name":"javax.activation.DataSource" + }, + { + "name":"javax.inject.Singleton", + "allDeclaredMethods":true + }, + { + "name":"javax.ws.rs.core.Application", + "allDeclaredMethods":true + }, + { + "name":"javax.ws.rs.core.Feature", + "methods":[{"name":"configure","parameterTypes":["javax.ws.rs.core.FeatureContext"] }] + }, + { + "name":"javax.xml.transform.Source" + }, + { + "name":"javax.xml.transform.dom.DOMSource" + }, + { + "name":"javax.xml.transform.sax.SAXSource" + }, + { + "name":"javax.xml.transform.stream.StreamSource" + }, + { + "name":"org.glassfish.grizzly.http.server.TagLocaleParser", + "methods":[{"name":"","parameterTypes":[] }] + }, + { + "name":"org.glassfish.hk2.internal.PerThreadContext", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.hk2.osgiresourcelocator.ServiceLoader", + "methods":[{"name":"lookupProviderClasses","parameterTypes":["java.lang.Class"] }] + }, + { + "name":"org.glassfish.jersey.examples.helloworld.HelloWorldResource", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allPublicMethods":true, + "allDeclaredConstructors":true, + "allPublicConstructors":true + }, + { + "name":"org.jvnet.hk2.internal.ProxyUtilities$4", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.jvnet.hk2.internal.ProxyUtilities", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.jvnet.hk2.internal.DynamicConfigurationServiceImpl", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.jvnet.hk2.internal.ServiceLocatorRuntimeImpl", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + } +] \ No newline at end of file diff --git a/examples/helloworld/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld/resource-config.json b/examples/helloworld/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld/resource-config.json new file mode 100644 index 0000000000..b247af1679 --- /dev/null +++ b/examples/helloworld/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld/resource-config.json @@ -0,0 +1,8 @@ +{ + "resources": [ + {"pattern": "org/glassfish/grizzly/version.properties"} + ], + "bundles": [ + {"name":"javax.xml.bind.Messages"} + ] +} \ No newline at end of file diff --git a/inject/hk2/src/main/resources/META-INF/native-image/org.glassfish.jersey.inject/jersey-hk2/reflect-config.json b/inject/hk2/src/main/resources/META-INF/native-image/org.glassfish.jersey.inject/jersey-hk2/reflect-config.json new file mode 100644 index 0000000000..c8c31691cf --- /dev/null +++ b/inject/hk2/src/main/resources/META-INF/native-image/org.glassfish.jersey.inject/jersey-hk2/reflect-config.json @@ -0,0 +1,34 @@ +[ + { + "name":"org.glassfish.jersey.inject.hk2.ContextInjectionResolverImpl", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.inject.hk2.Hk2InjectionManagerFactory", + "methods":[{"name":"","parameterTypes":[] }] + }, + { + "name":"org.glassfish.jersey.inject.hk2.Hk2RequestScope", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.inject.hk2.InstanceSupplierFactoryBridge", + "methods":[{"name":"provide","parameterTypes":[] }] + }, + { + "name":"org.glassfish.jersey.inject.hk2.JerseyErrorService", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.glassfish.jersey.inject.hk2.RequestContext", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + } +] \ No newline at end of file diff --git a/inject/hk2/src/main/resources/META-INF/native-image/org.glassfish.jersey.inject/jersey-hk2/resource-config.json b/inject/hk2/src/main/resources/META-INF/native-image/org.glassfish.jersey.inject/jersey-hk2/resource-config.json new file mode 100644 index 0000000000..1845c39361 --- /dev/null +++ b/inject/hk2/src/main/resources/META-INF/native-image/org.glassfish.jersey.inject/jersey-hk2/resource-config.json @@ -0,0 +1,5 @@ +{ + "bundles": [ + {"name":"org.glassfish.jersey.inject.hk2.localization"} + ] +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index a74d7facf0..98f0cb2690 100644 --- a/pom.xml +++ b/pom.xml @@ -329,7 +329,7 @@ org.apache.maven.plugins maven-jar-plugin - 2.4 + 3.2.0 org.apache.maven.plugins @@ -446,7 +446,7 @@ org.apache.maven.plugins maven-dependency-plugin - 2.8 + 3.1.2 org.apache.maven.plugins From 6da07690a54de9c61910866639d32341573e3d4f Mon Sep 17 00:00:00 2001 From: Maxim Nesen Date: Wed, 16 Jun 2021 15:31:10 +0200 Subject: [PATCH 2/4] GraalVM helloworld programmatic native-image Signed-off-by: Maxim Nesen --- .../reflect-config.json | 39 +++++++++++ examples/helloworld-programmatic/pom.xml | 67 +++++++++++++++++++ .../helloworld-programmatic/jni-config.json | 9 +++ .../native-image.properties | 16 +++++ .../reflect-config.json | 51 ++++++++++++++ .../resource-config.json | 8 +++ examples/helloworld/pom.xml | 9 +-- .../helloworld/reflect-config.json | 38 ----------- .../jersey-hk2/reflect-config.json | 34 ++++++++++ pom.xml | 4 ++ 10 files changed, 229 insertions(+), 46 deletions(-) create mode 100644 containers/grizzly2-http/src/main/resources/META-INF/native-image/org.glassfish.jersey.containers/jersey-container-grizzly2-http/reflect-config.json create mode 100644 examples/helloworld-programmatic/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-programmatic/jni-config.json create mode 100644 examples/helloworld-programmatic/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-programmatic/native-image.properties create mode 100644 examples/helloworld-programmatic/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-programmatic/reflect-config.json create mode 100644 examples/helloworld-programmatic/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-programmatic/resource-config.json diff --git a/containers/grizzly2-http/src/main/resources/META-INF/native-image/org.glassfish.jersey.containers/jersey-container-grizzly2-http/reflect-config.json b/containers/grizzly2-http/src/main/resources/META-INF/native-image/org.glassfish.jersey.containers/jersey-container-grizzly2-http/reflect-config.json new file mode 100644 index 0000000000..6ababc479c --- /dev/null +++ b/containers/grizzly2-http/src/main/resources/META-INF/native-image/org.glassfish.jersey.containers/jersey-container-grizzly2-http/reflect-config.json @@ -0,0 +1,39 @@ +[ +{ + "name":"org.glassfish.grizzly.Buffer[]" +}, +{ +"name":"org.glassfish.grizzly.ConnectionProbe[]" +}, +{ +"name":"org.glassfish.grizzly.IOEventLifeCycleListener[]" +}, +{ +"name":"org.glassfish.grizzly.TransportProbe[]" +}, +{ +"name":"org.glassfish.grizzly.http.HttpProbe[]" +}, +{ +"name":"org.glassfish.grizzly.http.TransferEncoding[]" +}, +{ +"name":"org.glassfish.grizzly.http.server.HttpServerProbe[]" +}, +{ +"name":"org.glassfish.grizzly.http.server.TagLocaleParser", +"methods":[{"name":"","parameterTypes":[] }] +}, +{ +"name":"org.glassfish.grizzly.http.server.filecache.FileCacheProbe[]" +}, +{ +"name":"org.glassfish.grizzly.memory.MemoryProbe[]" +}, +{ +"name":"org.glassfish.grizzly.threadpool.ThreadPoolProbe[]" +}, +{ +"name":"org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainerProvider" +} +] \ No newline at end of file diff --git a/examples/helloworld-programmatic/pom.xml b/examples/helloworld-programmatic/pom.xml index 6e49ed39ad..afa3434bc2 100644 --- a/examples/helloworld-programmatic/pom.xml +++ b/examples/helloworld-programmatic/pom.xml @@ -67,6 +67,73 @@ + + native-image + + + + maven-assembly-plugin + + + + org.glassfish.jersey.examples.helloworld.App + + + + jar-with-dependencies + + + + + make-assembly + package + + single + + + + + + org.graalvm.nativeimage + native-image-maven-plugin + ${graalvm.version} + + + + native-image + + package + + + + ${project.artifactId}-native + org.glassfish.jersey.examples.helloworld.App + + + + + + + + jakarta.activation + jakarta.activation-api + ${jakarta.activation.version} + + + jakarta.xml.bind + jakarta.xml.bind-api + + + org.glassfish.hk2 + hk2-locator + + + org.osgi + org.osgi.framework + ${osgi.framework.version} + + + diff --git a/examples/helloworld-programmatic/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-programmatic/jni-config.json b/examples/helloworld-programmatic/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-programmatic/jni-config.json new file mode 100644 index 0000000000..9127dd449d --- /dev/null +++ b/examples/helloworld-programmatic/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-programmatic/jni-config.json @@ -0,0 +1,9 @@ +[ + { + "name":"java.lang.ClassLoader", + "methods":[{"name":"getPlatformClassLoader","parameterTypes":[] }] + }, + { + "name":"java.lang.NoSuchMethodError" + } +] diff --git a/examples/helloworld-programmatic/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-programmatic/native-image.properties b/examples/helloworld-programmatic/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-programmatic/native-image.properties new file mode 100644 index 0000000000..6d2c053639 --- /dev/null +++ b/examples/helloworld-programmatic/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-programmatic/native-image.properties @@ -0,0 +1,16 @@ +# +# Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Distribution License v. 1.0, which is available at +# http://www.eclipse.org/org/documents/edl-v10.php. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +Args=-H:EnableURLProtocols=http,https \ + --initialize-at-build-time=org.glassfish.jersey.client.internal.HttpUrlConnector \ + -H:+ReportExceptionStackTraces \ + --verbose \ + --no-fallback \ + --report-unsupported-elements-at-runtime \ No newline at end of file diff --git a/examples/helloworld-programmatic/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-programmatic/reflect-config.json b/examples/helloworld-programmatic/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-programmatic/reflect-config.json new file mode 100644 index 0000000000..75af870592 --- /dev/null +++ b/examples/helloworld-programmatic/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-programmatic/reflect-config.json @@ -0,0 +1,51 @@ +[ + { + "name":"java.awt.image.RenderedImage" + }, + { + "name":"javax.activation.DataSource" + }, + { + "name":"javax.inject.Named", + "allDeclaredMethods":true + }, + { + "name":"javax.activation.DataSource" + }, + { + "name":"javax.inject.Singleton", + "allDeclaredMethods":true + }, + { + "name":"javax.ws.rs.core.Application", + "allDeclaredMethods":true + }, + { + "name":"javax.ws.rs.core.Feature", + "methods":[{"name":"configure","parameterTypes":["javax.ws.rs.core.FeatureContext"] }] + }, + { + "name":"javax.xml.transform.Source" + }, + { + "name":"javax.xml.transform.dom.DOMSource" + }, + { + "name":"javax.xml.transform.sax.SAXSource" + }, + { + "name":"javax.xml.transform.stream.StreamSource" + }, + { + "name":"org.glassfish.jersey.examples.helloworld.App$2", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allPublicMethods":true + }, + { + "name":"org.glassfish.jersey.examples.helloworld.App$3", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allPublicMethods":true + } +] \ No newline at end of file diff --git a/examples/helloworld-programmatic/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-programmatic/resource-config.json b/examples/helloworld-programmatic/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-programmatic/resource-config.json new file mode 100644 index 0000000000..b247af1679 --- /dev/null +++ b/examples/helloworld-programmatic/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-programmatic/resource-config.json @@ -0,0 +1,8 @@ +{ + "resources": [ + {"pattern": "org/glassfish/grizzly/version.properties"} + ], + "bundles": [ + {"name":"javax.xml.bind.Messages"} + ] +} \ No newline at end of file diff --git a/examples/helloworld/pom.xml b/examples/helloworld/pom.xml index bdb5c8550c..a75a07d446 100644 --- a/examples/helloworld/pom.xml +++ b/examples/helloworld/pom.xml @@ -28,7 +28,6 @@ - 20.3.2 @@ -105,12 +104,6 @@ - - org.graalvm.sdk - graal-sdk - ${graalvm.version} - provided - jakarta.activation jakarta.activation-api @@ -123,7 +116,7 @@ org.osgi org.osgi.framework - 1.10.0 + ${osgi.framework.version} org.glassfish.hk2 diff --git a/examples/helloworld/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld/reflect-config.json b/examples/helloworld/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld/reflect-config.json index 98d7642a1b..86e499ff97 100644 --- a/examples/helloworld/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld/reflect-config.json +++ b/examples/helloworld/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld/reflect-config.json @@ -36,20 +36,6 @@ { "name":"javax.xml.transform.stream.StreamSource" }, - { - "name":"org.glassfish.grizzly.http.server.TagLocaleParser", - "methods":[{"name":"","parameterTypes":[] }] - }, - { - "name":"org.glassfish.hk2.internal.PerThreadContext", - "allDeclaredFields":true, - "allDeclaredMethods":true, - "allDeclaredConstructors":true - }, - { - "name":"org.glassfish.hk2.osgiresourcelocator.ServiceLoader", - "methods":[{"name":"lookupProviderClasses","parameterTypes":["java.lang.Class"] }] - }, { "name":"org.glassfish.jersey.examples.helloworld.HelloWorldResource", "allDeclaredFields":true, @@ -57,29 +43,5 @@ "allPublicMethods":true, "allDeclaredConstructors":true, "allPublicConstructors":true - }, - { - "name":"org.jvnet.hk2.internal.ProxyUtilities$4", - "allDeclaredFields":true, - "allDeclaredMethods":true, - "allDeclaredConstructors":true - }, - { - "name":"org.jvnet.hk2.internal.ProxyUtilities", - "allDeclaredFields":true, - "allDeclaredMethods":true, - "allDeclaredConstructors":true - }, - { - "name":"org.jvnet.hk2.internal.DynamicConfigurationServiceImpl", - "allDeclaredFields":true, - "allDeclaredMethods":true, - "allDeclaredConstructors":true - }, - { - "name":"org.jvnet.hk2.internal.ServiceLocatorRuntimeImpl", - "allDeclaredFields":true, - "allDeclaredMethods":true, - "allDeclaredConstructors":true } ] \ No newline at end of file diff --git a/inject/hk2/src/main/resources/META-INF/native-image/org.glassfish.jersey.inject/jersey-hk2/reflect-config.json b/inject/hk2/src/main/resources/META-INF/native-image/org.glassfish.jersey.inject/jersey-hk2/reflect-config.json index c8c31691cf..cb8c35b9f2 100644 --- a/inject/hk2/src/main/resources/META-INF/native-image/org.glassfish.jersey.inject/jersey-hk2/reflect-config.json +++ b/inject/hk2/src/main/resources/META-INF/native-image/org.glassfish.jersey.inject/jersey-hk2/reflect-config.json @@ -1,4 +1,14 @@ [ + { + "name": "org.glassfish.hk2.internal.PerThreadContext", + "allDeclaredFields": true, + "allDeclaredMethods": true, + "allDeclaredConstructors": true + }, + { + "name": "org.glassfish.hk2.osgiresourcelocator.ServiceLoader", + "methods": [{ "name":"lookupProviderClasses", "parameterTypes":["java.lang.Class"] }] + }, { "name":"org.glassfish.jersey.inject.hk2.ContextInjectionResolverImpl", "allDeclaredFields":true, @@ -30,5 +40,29 @@ "allDeclaredFields":true, "allDeclaredMethods":true, "allDeclaredConstructors":true + }, + { + "name":"org.jvnet.hk2.internal.ProxyUtilities$4", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.jvnet.hk2.internal.ProxyUtilities", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.jvnet.hk2.internal.DynamicConfigurationServiceImpl", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true + }, + { + "name":"org.jvnet.hk2.internal.ServiceLocatorRuntimeImpl", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allDeclaredConstructors":true } ] \ No newline at end of file diff --git a/pom.xml b/pom.xml index 98f0cb2690..50a6cedc6b 100644 --- a/pom.xml +++ b/pom.xml @@ -2132,6 +2132,7 @@ 1.6.7 0.30.0 6.0.0 + 1.10.0 5.0.0 4.13.1 0.7.4 @@ -2152,6 +2153,9 @@ 3.1.7.SP1 2.11.0 + + 20.3.2 + 5.1.0 3.0.8 From 5fd7cec545c41a605835c9e8489dd499d22d751d Mon Sep 17 00:00:00 2001 From: Maxim Nesen Date: Wed, 16 Jun 2021 15:43:52 +0200 Subject: [PATCH 3/4] GraalVM helloworld pure jax-rs native-image Signed-off-by: Maxim Nesen --- examples/helloworld-programmatic/pom.xml | 22 --------- examples/helloworld-pure-jax-rs/pom.xml | 45 ++++++++++++++++++ .../helloworld-pure-jax-rs/jni-config.json | 9 ++++ .../native-image.properties | 16 +++++++ .../reflect-config.json | 47 +++++++++++++++++++ .../resource-config.json | 8 ++++ 6 files changed, 125 insertions(+), 22 deletions(-) create mode 100644 examples/helloworld-pure-jax-rs/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-pure-jax-rs/jni-config.json create mode 100644 examples/helloworld-pure-jax-rs/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-pure-jax-rs/native-image.properties create mode 100644 examples/helloworld-pure-jax-rs/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-pure-jax-rs/reflect-config.json create mode 100644 examples/helloworld-pure-jax-rs/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-pure-jax-rs/resource-config.json diff --git a/examples/helloworld-programmatic/pom.xml b/examples/helloworld-programmatic/pom.xml index afa3434bc2..91b03d2c3e 100644 --- a/examples/helloworld-programmatic/pom.xml +++ b/examples/helloworld-programmatic/pom.xml @@ -71,28 +71,6 @@ native-image - - maven-assembly-plugin - - - - org.glassfish.jersey.examples.helloworld.App - - - - jar-with-dependencies - - - - - make-assembly - package - - single - - - - org.graalvm.nativeimage native-image-maven-plugin diff --git a/examples/helloworld-pure-jax-rs/pom.xml b/examples/helloworld-pure-jax-rs/pom.xml index c83d3cec58..cc10ce55e0 100644 --- a/examples/helloworld-pure-jax-rs/pom.xml +++ b/examples/helloworld-pure-jax-rs/pom.xml @@ -70,6 +70,51 @@ + + native-image + + + + org.graalvm.nativeimage + native-image-maven-plugin + ${graalvm.version} + + + + native-image + + package + + + + ${project.artifactId}-native + org.glassfish.jersey.examples.helloworld.jaxrs.App + + + + + + + + jakarta.activation + jakarta.activation-api + ${jakarta.activation.version} + + + jakarta.xml.bind + jakarta.xml.bind-api + + + org.glassfish.hk2 + hk2-locator + + + org.osgi + org.osgi.framework + ${osgi.framework.version} + + + diff --git a/examples/helloworld-pure-jax-rs/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-pure-jax-rs/jni-config.json b/examples/helloworld-pure-jax-rs/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-pure-jax-rs/jni-config.json new file mode 100644 index 0000000000..9127dd449d --- /dev/null +++ b/examples/helloworld-pure-jax-rs/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-pure-jax-rs/jni-config.json @@ -0,0 +1,9 @@ +[ + { + "name":"java.lang.ClassLoader", + "methods":[{"name":"getPlatformClassLoader","parameterTypes":[] }] + }, + { + "name":"java.lang.NoSuchMethodError" + } +] diff --git a/examples/helloworld-pure-jax-rs/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-pure-jax-rs/native-image.properties b/examples/helloworld-pure-jax-rs/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-pure-jax-rs/native-image.properties new file mode 100644 index 0000000000..6d2c053639 --- /dev/null +++ b/examples/helloworld-pure-jax-rs/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-pure-jax-rs/native-image.properties @@ -0,0 +1,16 @@ +# +# Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Distribution License v. 1.0, which is available at +# http://www.eclipse.org/org/documents/edl-v10.php. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +Args=-H:EnableURLProtocols=http,https \ + --initialize-at-build-time=org.glassfish.jersey.client.internal.HttpUrlConnector \ + -H:+ReportExceptionStackTraces \ + --verbose \ + --no-fallback \ + --report-unsupported-elements-at-runtime \ No newline at end of file diff --git a/examples/helloworld-pure-jax-rs/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-pure-jax-rs/reflect-config.json b/examples/helloworld-pure-jax-rs/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-pure-jax-rs/reflect-config.json new file mode 100644 index 0000000000..064eb06043 --- /dev/null +++ b/examples/helloworld-pure-jax-rs/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-pure-jax-rs/reflect-config.json @@ -0,0 +1,47 @@ +[ + { + "name":"java.awt.image.RenderedImage" + }, + { + "name":"javax.activation.DataSource" + }, + { + "name":"javax.inject.Named", + "allDeclaredMethods":true + }, + { + "name":"javax.activation.DataSource" + }, + { + "name":"javax.inject.Singleton", + "allDeclaredMethods":true + }, + { + "name":"javax.ws.rs.core.Application", + "allDeclaredMethods":true + }, + { + "name":"javax.ws.rs.core.Feature", + "methods":[{"name":"configure","parameterTypes":["javax.ws.rs.core.FeatureContext"] }] + }, + { + "name":"javax.xml.transform.Source" + }, + { + "name":"javax.xml.transform.dom.DOMSource" + }, + { + "name":"javax.xml.transform.sax.SAXSource" + }, + { + "name":"javax.xml.transform.stream.StreamSource" + }, + { + "name":"org.glassfish.jersey.examples.helloworld.jaxrs.HelloWorldResource", + "allDeclaredFields":true, + "allDeclaredMethods":true, + "allPublicMethods":true, + "allDeclaredConstructors":true, + "allPublicConstructors":true + } +] \ No newline at end of file diff --git a/examples/helloworld-pure-jax-rs/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-pure-jax-rs/resource-config.json b/examples/helloworld-pure-jax-rs/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-pure-jax-rs/resource-config.json new file mode 100644 index 0000000000..b247af1679 --- /dev/null +++ b/examples/helloworld-pure-jax-rs/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-pure-jax-rs/resource-config.json @@ -0,0 +1,8 @@ +{ + "resources": [ + {"pattern": "org/glassfish/grizzly/version.properties"} + ], + "bundles": [ + {"name":"javax.xml.bind.Messages"} + ] +} \ No newline at end of file From cd190ed013056da0bd3e2d5857fadad4f0ede858 Mon Sep 17 00:00:00 2001 From: Maxim Nesen Date: Thu, 17 Jun 2021 12:53:02 +0200 Subject: [PATCH 4/4] reflect-config adjustments Signed-off-by: Maxim Nesen --- .../helloworld-programmatic/reflect-config.json | 7 ------- .../helloworld-pure-jax-rs/reflect-config.json | 7 ------- .../helloworld/reflect-config.json | 7 ------- 3 files changed, 21 deletions(-) diff --git a/examples/helloworld-programmatic/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-programmatic/reflect-config.json b/examples/helloworld-programmatic/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-programmatic/reflect-config.json index 75af870592..90f407d841 100644 --- a/examples/helloworld-programmatic/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-programmatic/reflect-config.json +++ b/examples/helloworld-programmatic/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-programmatic/reflect-config.json @@ -5,13 +5,6 @@ { "name":"javax.activation.DataSource" }, - { - "name":"javax.inject.Named", - "allDeclaredMethods":true - }, - { - "name":"javax.activation.DataSource" - }, { "name":"javax.inject.Singleton", "allDeclaredMethods":true diff --git a/examples/helloworld-pure-jax-rs/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-pure-jax-rs/reflect-config.json b/examples/helloworld-pure-jax-rs/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-pure-jax-rs/reflect-config.json index 064eb06043..ccde28c93c 100644 --- a/examples/helloworld-pure-jax-rs/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-pure-jax-rs/reflect-config.json +++ b/examples/helloworld-pure-jax-rs/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld-pure-jax-rs/reflect-config.json @@ -5,13 +5,6 @@ { "name":"javax.activation.DataSource" }, - { - "name":"javax.inject.Named", - "allDeclaredMethods":true - }, - { - "name":"javax.activation.DataSource" - }, { "name":"javax.inject.Singleton", "allDeclaredMethods":true diff --git a/examples/helloworld/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld/reflect-config.json b/examples/helloworld/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld/reflect-config.json index 86e499ff97..ce14b8e87f 100644 --- a/examples/helloworld/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld/reflect-config.json +++ b/examples/helloworld/src/main/resources/META-INF/native-image/org.glassfish.jersey.examples/helloworld/reflect-config.json @@ -5,13 +5,6 @@ { "name":"javax.activation.DataSource" }, - { - "name":"javax.inject.Named", - "allDeclaredMethods":true - }, - { - "name":"javax.activation.DataSource" - }, { "name":"javax.inject.Singleton", "allDeclaredMethods":true