diff --git a/pom.xml b/pom.xml index 7e1417dca..9e21a2e64 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ org.springframework.boot spring-boot-dependencies - 2.3.1.RELEASE + 2.4.0-SNAPSHOT pom import diff --git a/spring-graalvm-native-configuration/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxHints.java b/spring-graalvm-native-configuration/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxHints.java index 98f878224..a4f4fadb4 100644 --- a/spring-graalvm-native-configuration/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxHints.java +++ b/spring-graalvm-native-configuration/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxHints.java @@ -42,8 +42,7 @@ "com.fasterxml.jackson.databind.ObjectMapper", "com.fasterxml.jackson.core.JsonGenerator", "com.fasterxml.jackson.dataformat.smile.SmileFactory", - "com.google.protobuf.Message", - "org.synchronoss.cloud.nio.multipart.NioMultipartParser" + "com.google.protobuf.Message" }, access=AccessBits.CLASS|AccessBits.DECLARED_CONSTRUCTORS ), diff --git a/spring-graalvm-native-configuration/src/main/java/org/springframework/boot/autoconfigure/web/reactive/netty/NettyHints.java b/spring-graalvm-native-configuration/src/main/java/org/springframework/boot/autoconfigure/web/reactive/netty/NettyHints.java index 18c99b5b5..10b3271c1 100644 --- a/spring-graalvm-native-configuration/src/main/java/org/springframework/boot/autoconfigure/web/reactive/netty/NettyHints.java +++ b/spring-graalvm-native-configuration/src/main/java/org/springframework/boot/autoconfigure/web/reactive/netty/NettyHints.java @@ -49,9 +49,7 @@ "io.netty.channel.ChannelHandler", "io.netty.util.concurrent.GenericFutureListener", "io.netty.bootstrap.ServerBootstrap$1", - "io.netty.bootstrap.ServerBootstrap$ServerBootstrapAcceptor", - "java.lang.management.ManagementFactory", - "java.lang.management.RuntimeMXBean"}, + "io.netty.bootstrap.ServerBootstrap$ServerBootstrapAcceptor"}, access=AccessBits.CLASS|AccessBits.DECLARED_CONSTRUCTORS|AccessBits.DECLARED_METHODS) }) public class NettyHints implements NativeImageConfiguration { diff --git a/spring-graalvm-native-configuration/src/main/resources/initialization.json b/spring-graalvm-native-configuration/src/main/resources/initialization.json index 7fc54cb06..72e00d382 100644 --- a/spring-graalvm-native-configuration/src/main/resources/initialization.json +++ b/spring-graalvm-native-configuration/src/main/resources/initialization.json @@ -62,7 +62,7 @@ {"class": "org.springframework.core.annotation.AnnotationFilter$1"}, {"class": "org.springframework.core.annotation.AnnotationFilter$2"}, {"class": "org.springframework.core.annotation.PackagesAnnotationFilter"}, - {"class": "org.springframework.core.GraalDetector"}, + {"class": "org.springframework.core.SerializableTypeWrapper"}, {"class": "org.springframework.core.SerializableTypeWrapper$SerializableTypeProxy"}, {"class": "org.springframework.format.annotation.DateTimeFormat$ISO"}, {"class": "org.springframework.http.HttpStatus"}, @@ -72,7 +72,25 @@ {"class": "org.springframework.util.unit.DataUnit"}, {"class": "org.springframework.util.unit.DataSize"}, {"class": "org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter"}, - // To avoid XML parsers to be included + {"class": "org.springframework.core.DefaultParameterNameDiscoverer"}, + {"class": "org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory"}, + {"class": "org.springframework.context.annotation.ConfigurationClassPostProcessor"}, + {"class": "org.springframework.context.annotation.ConfigurationClassEnhancer"}, + {"class": "org.springframework.aop.framework.DefaultAopProxyFactory"}, + + // For SPEL removal + {"class": "org.springframework.context.support.AbstractApplicationContext" }, + {"class": "org.springframework.core.SpringProperties" }, + {"class": "org.springframework.context.event.EventListenerMethodProcessor" }, + + // For XML removal + {"class": "org.springframework.util.DefaultPropertiesPersister" }, + {"class": "org.springframework.core.io.support.PropertiesLoaderUtils" }, + {"class": "org.springframework.web.servlet.function.support.RouterFunctionMapping" }, + {"class": "org.springframework.web.client.RestTemplate" }, + {"class": "org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver" }, + {"class": "org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport" }, + {"class": "org.springframework.web.socket.sockjs.transport.TransportHandlingSockJsService" }, {"class": "org.springframework.messaging.simp.config.AbstractMessageBrokerConfiguration" }, {"class": "org.springframework.http.MediaType" }, {"class": "org.springframework.http.codec.support.BaseDefaultCodecs" }, @@ -82,12 +100,11 @@ {"class": "org.springframework.util.CollectionUtils" }, {"class": "org.springframework.util.LinkedCaseInsensitiveMap" }, {"class": "org.springframework.util.MimeType" }, - {"class": "org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport" }, - {"class": "org.springframework.web.socket.sockjs.transport.TransportHandlingSockJsService" }, - {"class": "org.springframework.web.client.RestTemplate" }, - {"class": "org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter" }, {"class": "org.springframework.beans.factory.xml.XmlBeanDefinitionReader" }, {"class": "org.springframework.util.ReflectionUtils" }, + {"class": "org.springframework.beans.PropertyEditorRegistrySupport" }, + {"class": "org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter" }, + {"class": "org.springframework.core.io.support.ResourcePropertiesPersister" }, // Spring Boot {"class": "org.springframework.boot.CommandLineRunner"}, @@ -106,6 +123,9 @@ {"package": "org.jboss.logging"}, {"class": "org.slf4j.spi.LocationAwareLogger"}, {"class": "org.slf4j.Logger"}, + {"class": "org.apache.commons.logging.LogAdapter"}, + {"class": "org.apache.commons.logging.LogAdapter$1"}, + {"class": "org.apache.commons.logging.LogAdapter$Slf4jLocationAwareLog"}, {"class": "org.slf4j.event.SubstituteLoggingEvent"}, {"class": "org.slf4j.event.EventRecodingLogger"}, diff --git a/spring-graalvm-native-configuration/src/main/resources/resources.json b/spring-graalvm-native-configuration/src/main/resources/resources.json index c1bcbbb71..ee3b8c51e 100644 --- a/spring-graalvm-native-configuration/src/main/resources/resources.json +++ b/spring-graalvm-native-configuration/src/main/resources/resources.json @@ -9,7 +9,6 @@ // vvv r2dbc {"pattern": "\\QMETA-INF/services/io.r2dbc.spi.ConnectionFactoryProvider\\E"}, // vvv springmvc-tomcat - {"pattern": "org/springframework/web/servlet/DispatcherServlet.properties"}, {"pattern": "org/apache/catalina/startup/MimeTypeMappings.properties"}, // ^^^ springmvc-tomcat // vvv vanilla-tx diff --git a/spring-graalvm-native-docs/src/main/asciidoc/options.adoc b/spring-graalvm-native-docs/src/main/asciidoc/options.adoc index 4d2e71472..66d8163c7 100644 --- a/spring-graalvm-native-docs/src/main/asciidoc/options.adoc +++ b/spring-graalvm-native-docs/src/main/asciidoc/options.adoc @@ -42,6 +42,12 @@ You can find more details in GraalVM https://github.com/oracle/graal/blob/master * `-H:+RemoveSaturatedTypeFlows` reduces build time and decrease build memory consumption, especially for big projects. +=== Spring Framework/Boot options + +* `-Dspring.xml.ignore=true` removes XML support from Spring Boot, enabling faster compilation and smaller executables. + +* `-Dspring.spel.ignore=true` removes SpEL support from Spring Boot, enabling faster compilation and smaller executables. + === Feature options The current feature options are as follows: @@ -57,10 +63,6 @@ will provide initialization and resource configuration but nothing more. * `-Dspring.native.remove-yaml-support=true` removes Yaml support from Spring Boot, enabling faster compilation and smaller executables. -* `-Dspring.native.remove-xml-support=true` removes XML support from Spring Boot, enabling faster compilation and smaller executables. - -* `-Dspring.native.remove-spel-support=true` removes SpEL support from Spring Boot, enabling faster compilation and smaller executables. - * `-Dspring.native.remove-jmx-support=true` removes JMX support from Spring Boot, enabling faster compilation and smaller executables. * `-Dspring.native.dump-config=/tmp/dump.txt` dumps the configuration to the specified file. diff --git a/spring-graalvm-native-samples/actuator-webflux/pom.xml b/spring-graalvm-native-samples/actuator-webflux/pom.xml index d68c80cbc..94a9124e3 100644 --- a/spring-graalvm-native-samples/actuator-webflux/pom.xml +++ b/spring-graalvm-native-samples/actuator-webflux/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT com.example @@ -31,13 +31,6 @@ org.springframework.boot spring-boot-starter-webflux - - - io.netty - netty-codec-http2 - - - @@ -67,70 +60,70 @@ - - central - https://repo.maven.apache.org/maven2 - - false - - - - spring-release - Spring release - https://repo.spring.io/release - - false - - - - spring-snapshot - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestone - Spring Milestone - https://repo.spring.io/milestone - - false - - + + central + https://repo.maven.apache.org/maven2 + + false + + + + spring-release + Spring release + https://repo.spring.io/release + + false + + + + spring-snapshot + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestone + Spring Milestone + https://repo.spring.io/milestone + + false + + - central - https://repo.maven.apache.org/maven2 - - false - + central + https://repo.maven.apache.org/maven2 + + false + - spring-release - Spring release - https://repo.spring.io/release - - false - + spring-release + Spring release + https://repo.spring.io/release + + false + - spring-snapshot - Spring Snapshots - https://repo.spring.io/snapshot - - true - + spring-snapshot + Spring Snapshots + https://repo.spring.io/snapshot + + true + - spring-milestone - Spring Milestone - https://repo.spring.io/milestone - - false - + spring-milestone + Spring Milestone + https://repo.spring.io/milestone + + false + diff --git a/spring-graalvm-native-samples/actuator-webmvc/pom.xml b/spring-graalvm-native-samples/actuator-webmvc/pom.xml index 9c2be0ef6..b30a18cae 100644 --- a/spring-graalvm-native-samples/actuator-webmvc/pom.xml +++ b/spring-graalvm-native-samples/actuator-webmvc/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT com.example @@ -54,71 +54,71 @@ - - - central - https://repo.maven.apache.org/maven2 - - false - - - - spring-release - Spring release - https://repo.spring.io/release - - false - - - - spring-snapshot - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestone - Spring Milestone - https://repo.spring.io/milestone - - false - - - + + + central + https://repo.maven.apache.org/maven2 + + false + + + + spring-release + Spring release + https://repo.spring.io/release + + false + + + + spring-snapshot + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestone + Spring Milestone + https://repo.spring.io/milestone + + false + + + - - - central - https://repo.maven.apache.org/maven2 - - false - - - - spring-release - Spring release - https://repo.spring.io/release - - false - - - - spring-snapshot - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestone - Spring Milestone - https://repo.spring.io/milestone - - false - - - + + + central + https://repo.maven.apache.org/maven2 + + false + + + + spring-release + Spring release + https://repo.spring.io/release + + false + + + + spring-snapshot + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestone + Spring Milestone + https://repo.spring.io/milestone + + false + + + diff --git a/spring-graalvm-native-samples/commandlinerunner-agent/pom.xml b/spring-graalvm-native-samples/commandlinerunner-agent/pom.xml index 7ebab91fb..30c3ac818 100644 --- a/spring-graalvm-native-samples/commandlinerunner-agent/pom.xml +++ b/spring-graalvm-native-samples/commandlinerunner-agent/pom.xml @@ -7,7 +7,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT com.example @@ -70,7 +70,7 @@ 20.1.0 commandlinerunner-agent - --no-fallback -Dspring.native.mode=agent -Dspring.native.remove-spel-support=true -Dspring.native.remove-jmx-support=true + --no-fallback -Dspring.native.mode=agent -Dspring.spel.ignore=true -Dspring.native.remove-jmx-support=true diff --git a/spring-graalvm-native-samples/commandlinerunner/agent/4compile.sh b/spring-graalvm-native-samples/commandlinerunner/agent/4compile.sh index ccd19ad3a..1fff216e5 100755 --- a/spring-graalvm-native-samples/commandlinerunner/agent/4compile.sh +++ b/spring-graalvm-native-samples/commandlinerunner/agent/4compile.sh @@ -1,8 +1,8 @@ native-image \ -H:Name=commandlinerunner-agent \ -Dspring.native.mode=agent \ - -Dspring.native.remove-xml-support=true \ - -Dspring.native.remove-spel-support=true \ + -Dspring.xml.ignore=true \ + -Dspring.spel.ignore=true \ -Dspring.native.remove-jmx-support=true \ -cp .:$CP:graal \ com.example.commandlinerunner.CommandlinerunnerApplication 2>&1 | tee output.txt diff --git a/spring-graalvm-native-samples/commandlinerunner/compile.sh b/spring-graalvm-native-samples/commandlinerunner/compile.sh index 7c768831c..d4c756944 100755 --- a/spring-graalvm-native-samples/commandlinerunner/compile.sh +++ b/spring-graalvm-native-samples/commandlinerunner/compile.sh @@ -29,9 +29,9 @@ echo "Compiling $ARTIFACT with $GRAALVM_VERSION" { time native-image \ --verbose \ -H:Name=$ARTIFACT \ - -Dspring.native.remove-xml-support=true \ - -Dspring.native.remove-spel-support=true \ -Dspring.native.remove-jmx-support=true \ + -Dspring.xml.ignore=true \ + -Dspring.spel.ignore=true \ -cp $CP $MAINCLASS >> output.txt ; } 2>> output.txt if [[ -f $ARTIFACT ]] diff --git a/spring-graalvm-native-samples/commandlinerunner/pom.xml b/spring-graalvm-native-samples/commandlinerunner/pom.xml index a447bbb40..1ddd54408 100644 --- a/spring-graalvm-native-samples/commandlinerunner/pom.xml +++ b/spring-graalvm-native-samples/commandlinerunner/pom.xml @@ -7,7 +7,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT com.example diff --git a/spring-graalvm-native-samples/function-aws/pom.xml b/spring-graalvm-native-samples/function-aws/pom.xml index 5861108c5..e3fe3bbad 100644 --- a/spring-graalvm-native-samples/function-aws/pom.xml +++ b/spring-graalvm-native-samples/function-aws/pom.xml @@ -6,7 +6,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT com.example diff --git a/spring-graalvm-native-samples/function-netty-fun/pom.xml b/spring-graalvm-native-samples/function-netty-fun/pom.xml index 9ff1d07f0..a10d89222 100644 --- a/spring-graalvm-native-samples/function-netty-fun/pom.xml +++ b/spring-graalvm-native-samples/function-netty-fun/pom.xml @@ -6,7 +6,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT com.example diff --git a/spring-graalvm-native-samples/function-netty/pom.xml b/spring-graalvm-native-samples/function-netty/pom.xml index f76b9d8d3..d9eb2dc48 100644 --- a/spring-graalvm-native-samples/function-netty/pom.xml +++ b/spring-graalvm-native-samples/function-netty/pom.xml @@ -6,7 +6,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT com.example diff --git a/spring-graalvm-native-samples/gs-securing-web/pom.xml b/spring-graalvm-native-samples/gs-securing-web/pom.xml index 5e00e974d..8250f1871 100644 --- a/spring-graalvm-native-samples/gs-securing-web/pom.xml +++ b/spring-graalvm-native-samples/gs-securing-web/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT com.example diff --git a/spring-graalvm-native-samples/jafu-webmvc/compile.sh b/spring-graalvm-native-samples/jafu-webmvc/compile.sh index 1eb9d006e..928e24384 100755 --- a/spring-graalvm-native-samples/jafu-webmvc/compile.sh +++ b/spring-graalvm-native-samples/jafu-webmvc/compile.sh @@ -32,8 +32,8 @@ echo "Compiling $ARTIFACT with $GRAALVM_VERSION" -H:Name=$ARTIFACT \ -Dspring.native.mode=functional \ -Dspring.native.remove-yaml-support=true \ - -Dspring.native.remove-xml-support=true \ - -Dspring.native.remove-spel-support=true \ + -Dspring.xml.ignore=true \ + -Dspring.spel.ignore=true \ -cp $CP $MAINCLASS >> output.txt ; } 2>> output.txt if [[ -f $ARTIFACT ]] diff --git a/spring-graalvm-native-samples/jafu-webmvc/pom.xml b/spring-graalvm-native-samples/jafu-webmvc/pom.xml index 4bae48223..646859c66 100644 --- a/spring-graalvm-native-samples/jafu-webmvc/pom.xml +++ b/spring-graalvm-native-samples/jafu-webmvc/pom.xml @@ -7,7 +7,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT com.example @@ -17,6 +17,7 @@ Demo project for Spring Boot 1.8 + 5.3.0-SNAPSHOT @@ -31,7 +32,7 @@ org.springframework.fu spring-fu-jafu - 0.3.2 + 0.4.0-SNAPSHOT org.springframework diff --git a/spring-graalvm-native-samples/jafu-webmvc/src/main/resources/application.properties b/spring-graalvm-native-samples/jafu-webmvc/src/main/resources/application.properties new file mode 100644 index 000000000..62bb99f66 --- /dev/null +++ b/spring-graalvm-native-samples/jafu-webmvc/src/main/resources/application.properties @@ -0,0 +1 @@ +logging.level.org.springframework.web.servlet.DispatcherServlet=trace diff --git a/spring-graalvm-native-samples/jafu/compile.sh b/spring-graalvm-native-samples/jafu/compile.sh index 6b6e5e7e2..85e0a587d 100755 --- a/spring-graalvm-native-samples/jafu/compile.sh +++ b/spring-graalvm-native-samples/jafu/compile.sh @@ -31,8 +31,8 @@ echo "Compiling $ARTIFACT with $GRAALVM_VERSION" -H:Name=$ARTIFACT \ -Dspring.native.mode=functional \ -Dspring.native.remove-yaml-support=true \ - -Dspring.native.remove-xml-support=true \ - -Dspring.native.remove-spel-support=true \ + -Dspring.xml.ignore=true \ + -Dspring.spel.ignore=true \ -cp $CP $MAINCLASS >> output.txt ; } 2>> output.txt if [[ -f $ARTIFACT ]] diff --git a/spring-graalvm-native-samples/jafu/pom.xml b/spring-graalvm-native-samples/jafu/pom.xml index dc31c9823..06e24e190 100644 --- a/spring-graalvm-native-samples/jafu/pom.xml +++ b/spring-graalvm-native-samples/jafu/pom.xml @@ -7,7 +7,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT com.example @@ -31,7 +31,7 @@ org.springframework.fu spring-fu-jafu - 0.3.2 + 0.4.0-SNAPSHOT org.springframework.boot diff --git a/spring-graalvm-native-samples/kotlin-webmvc/compile.sh b/spring-graalvm-native-samples/kotlin-webmvc/compile.sh index 6b6ef6e92..4306c9fb8 100755 --- a/spring-graalvm-native-samples/kotlin-webmvc/compile.sh +++ b/spring-graalvm-native-samples/kotlin-webmvc/compile.sh @@ -30,8 +30,8 @@ echo "Compiling $ARTIFACT with $GRAALVM_VERSION" --verbose \ -H:EnableURLProtocols=http \ -H:Name=$ARTIFACT \ - -Dspring.native.remove-spel-support=true \ - -Dspring.native.remove-xml-support=true \ + -Dspring.spel.ignore=true \ + -Dspring.xml.ignore=true \ -Dspring.native.remove-yaml-support=true \ -Dspring.native.remove-jmx-support=true \ -cp $CP $MAINCLASS >> output.txt ; } 2>> output.txt diff --git a/spring-graalvm-native-samples/kotlin-webmvc/pom.xml b/spring-graalvm-native-samples/kotlin-webmvc/pom.xml index 192c58a34..6c28c3913 100644 --- a/spring-graalvm-native-samples/kotlin-webmvc/pom.xml +++ b/spring-graalvm-native-samples/kotlin-webmvc/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT com.example @@ -16,7 +16,7 @@ 1.8 - 1.3.61 + 1.3.72 diff --git a/spring-graalvm-native-samples/logger/pom.xml b/spring-graalvm-native-samples/logger/pom.xml index f8c198253..bcd318ce8 100644 --- a/spring-graalvm-native-samples/logger/pom.xml +++ b/spring-graalvm-native-samples/logger/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT com.example diff --git a/spring-graalvm-native-samples/messages/pom.xml b/spring-graalvm-native-samples/messages/pom.xml index ac2063c3b..653cdea81 100644 --- a/spring-graalvm-native-samples/messages/pom.xml +++ b/spring-graalvm-native-samples/messages/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT com.example diff --git a/spring-graalvm-native-samples/spring-batch-io/pom.xml b/spring-graalvm-native-samples/spring-batch-io/pom.xml index 600cac97b..e379af367 100644 --- a/spring-graalvm-native-samples/spring-batch-io/pom.xml +++ b/spring-graalvm-native-samples/spring-batch-io/pom.xml @@ -7,7 +7,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT com.example diff --git a/spring-graalvm-native-samples/spring-batch/pom.xml b/spring-graalvm-native-samples/spring-batch/pom.xml index 7d4193217..285e6ea28 100644 --- a/spring-graalvm-native-samples/spring-batch/pom.xml +++ b/spring-graalvm-native-samples/spring-batch/pom.xml @@ -7,7 +7,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT com.example diff --git a/spring-graalvm-native-samples/spring-data-mongodb/compile.sh b/spring-graalvm-native-samples/spring-data-mongodb/compile.sh index 07c73da2d..8e9e4d967 100755 --- a/spring-graalvm-native-samples/spring-data-mongodb/compile.sh +++ b/spring-graalvm-native-samples/spring-data-mongodb/compile.sh @@ -29,9 +29,9 @@ echo "Compiling $ARTIFACT with $GRAALVM_VERSION" { time native-image \ --verbose \ -H:Name=$ARTIFACT \ - -Dspring.native.remove-xml-support=true \ + -Dspring.xml.ignore=true \ -Dspring.native.remove-jmx-support=true \ - -Dspring.native.remove-spel-support=true \ + -Dspring.spel.ignore=true \ -Dspring.native.remove-yaml-support=true \ -cp $CP $MAINCLASS >> output.txt ; } 2>> output.txt diff --git a/spring-graalvm-native-samples/spring-data-mongodb/pom.xml b/spring-graalvm-native-samples/spring-data-mongodb/pom.xml index 8c4c02ef4..2d8bcad94 100644 --- a/spring-graalvm-native-samples/spring-data-mongodb/pom.xml +++ b/spring-graalvm-native-samples/spring-data-mongodb/pom.xml @@ -9,7 +9,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT spring-data-mongodb diff --git a/spring-graalvm-native-samples/spring-features/pom.xml b/spring-graalvm-native-samples/spring-features/pom.xml index e47bb39ba..e1d078ad0 100644 --- a/spring-graalvm-native-samples/spring-features/pom.xml +++ b/spring-graalvm-native-samples/spring-features/pom.xml @@ -7,7 +7,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT com.example @@ -17,7 +17,6 @@ Demo project for Spring Boot 1.8 - 5.2.6.RELEASE diff --git a/spring-graalvm-native-samples/spring-petclinic-jdbc/compile.sh b/spring-graalvm-native-samples/spring-petclinic-jdbc/compile.sh index e66997b64..0fa4ed6a0 100755 --- a/spring-graalvm-native-samples/spring-petclinic-jdbc/compile.sh +++ b/spring-graalvm-native-samples/spring-petclinic-jdbc/compile.sh @@ -2,7 +2,7 @@ ARTIFACT=spring-petclinic-jdbc MAINCLASS=org.springframework.samples.petclinic.PetClinicApplication -VERSION=2.3.0.BUILD-SNAPSHOT +VERSION=0.0.1-SNAPSHOT GREEN='\033[0;32m' RED='\033[0;31m' @@ -32,8 +32,8 @@ echo "Compiling $ARTIFACT with $GRAALVM_VERSION" -H:+RemoveSaturatedTypeFlows \ -Dspring.native.remove-yaml-support=true \ -Dspring.native.remove-jmx-support=true \ - -Dspring.native.remove-xml-support=true \ - -Dspring.native.remove-spel-support=true \ + -Dspring.xml.ignore=true \ + -Dspring.spel.ignore=true \ -cp $CP $MAINCLASS >> output.txt ; } 2>> output.txt if [[ -f $ARTIFACT ]] diff --git a/spring-graalvm-native-samples/spring-petclinic-jdbc/pom.xml b/spring-graalvm-native-samples/spring-petclinic-jdbc/pom.xml index da2cc8815..d9eeaedea 100644 --- a/spring-graalvm-native-samples/spring-petclinic-jdbc/pom.xml +++ b/spring-graalvm-native-samples/spring-petclinic-jdbc/pom.xml @@ -3,12 +3,12 @@ 4.0.0 org.springframework.samples spring-petclinic-jdbc - 2.3.0.BUILD-SNAPSHOT + 0.0.1-SNAPSHOT org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT spring-petclinic-jdbc diff --git a/spring-graalvm-native-samples/spring-petclinic-jdbc/src/main/java/org/springframework/samples/petclinic/system/BeanCountingApplicationListener.java b/spring-graalvm-native-samples/spring-petclinic-jdbc/src/main/java/org/springframework/samples/petclinic/system/BeanCountingApplicationListener.java deleted file mode 100644 index 75b100879..000000000 --- a/spring-graalvm-native-samples/spring-petclinic-jdbc/src/main/java/org/springframework/samples/petclinic/system/BeanCountingApplicationListener.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2016-2017 the original author or authors. - * - * 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 org.springframework.samples.petclinic.system; - -import java.lang.management.ManagementFactory; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.beans.BeansException; -import org.springframework.boot.context.event.ApplicationReadyEvent; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.context.ApplicationListener; -import org.springframework.context.ConfigurableApplicationContext; - -/** - * @author Dave Syer - * - */ -public class BeanCountingApplicationListener - implements ApplicationListener, ApplicationContextAware { - - private static Log logger = LogFactory.getLog(BeanCountingApplicationListener.class); - private ApplicationContext context; - - @Override - public void setApplicationContext(ApplicationContext context) throws BeansException { - this.context = context; - } - - @Override - public void onApplicationEvent(ApplicationReadyEvent event) { - if (!event.getApplicationContext().equals(this.context)) { - return; - } - ConfigurableApplicationContext context = event.getApplicationContext(); - log(context); - } - - public void log(ConfigurableApplicationContext context) { - int count = 0; - String id = context.getId(); - List names = new ArrayList<>(); - while (context != null) { - count += context.getBeanDefinitionCount(); - names.addAll(Arrays.asList(context.getBeanDefinitionNames())); - context = (ConfigurableApplicationContext) context.getParent(); - } - logger.info("Bean count: " + id + "=" + count); - logger.debug("Bean names: " + id + "=" + names); - try { - logger.info("Class count: " + id + "=" + ManagementFactory - .getClassLoadingMXBean().getTotalLoadedClassCount()); - } - catch (Exception e) { - } - } - -} diff --git a/spring-graalvm-native-samples/spring-petclinic-jdbc/src/main/java/org/springframework/samples/petclinic/system/ShutdownApplicationListener.java b/spring-graalvm-native-samples/spring-petclinic-jdbc/src/main/java/org/springframework/samples/petclinic/system/ShutdownApplicationListener.java deleted file mode 100644 index f7e4a666a..000000000 --- a/spring-graalvm-native-samples/spring-petclinic-jdbc/src/main/java/org/springframework/samples/petclinic/system/ShutdownApplicationListener.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2016-2017 the original author or authors. - * - * 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 org.springframework.samples.petclinic.system; - -import java.lang.reflect.Method; -import java.util.LinkedHashSet; -import java.util.Set; - -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.DisposableBean; -import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.SpringBootConfiguration; -import org.springframework.boot.context.event.ApplicationReadyEvent; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.context.ApplicationListener; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.AnnotatedElementUtils; -import org.springframework.core.annotation.Order; -import org.springframework.util.ClassUtils; -import org.springframework.util.ReflectionUtils; - -/** - * @author Dave Syer - * - */ -@Order(Ordered.HIGHEST_PRECEDENCE) -public class ShutdownApplicationListener - implements ApplicationListener, DisposableBean, - ApplicationContextAware { - - private static final String SHUTDOWN_LISTENER = "SHUTDOWN_LISTENER"; - public static final String MARKER = "Benchmark app stopped"; - - private ApplicationContext context; - - @Override - public void setApplicationContext(ApplicationContext context) throws BeansException { - this.context = context; - } - - @Override - public void onApplicationEvent(ApplicationReadyEvent event) { - if (!event.getApplicationContext().equals(this.context)) { - return; - } - if (isSpringBootApplication(sources(event))) { - ((DefaultListableBeanFactory) event.getApplicationContext().getBeanFactory()) - .registerDisposableBean(SHUTDOWN_LISTENER, this); - } - } - - @Override - public void destroy() throws Exception { - try { - System.out.println(MARKER); - } - catch (Exception e) { - } - } - - private boolean isSpringBootApplication(Set> sources) { - for (Class source : sources) { - if (AnnotatedElementUtils.hasAnnotation(source, - SpringBootConfiguration.class)) { - return true; - } - } - return false; - } - - private Set> sources(ApplicationReadyEvent event) { - Method method = ReflectionUtils.findMethod(SpringApplication.class, - "getAllSources"); - if (method == null) { - method = ReflectionUtils.findMethod(SpringApplication.class, "getSources"); - } - ReflectionUtils.makeAccessible(method); - @SuppressWarnings("unchecked") - Set objects = (Set) ReflectionUtils.invokeMethod(method, - event.getSpringApplication()); - Set> result = new LinkedHashSet<>(); - for (Object object : objects) { - if (object instanceof String) { - object = ClassUtils.resolveClassName((String) object, null); - } - result.add((Class) object); - } - return result; - } -} diff --git a/spring-graalvm-native-samples/spring-petclinic-jdbc/src/main/java/org/springframework/samples/petclinic/system/StartupApplicationListener.java b/spring-graalvm-native-samples/spring-petclinic-jdbc/src/main/java/org/springframework/samples/petclinic/system/StartupApplicationListener.java deleted file mode 100644 index 35d0314bc..000000000 --- a/spring-graalvm-native-samples/spring-petclinic-jdbc/src/main/java/org/springframework/samples/petclinic/system/StartupApplicationListener.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2016-2017 the original author or authors. - * - * 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 org.springframework.samples.petclinic.system; - -import java.lang.reflect.Method; -import java.util.LinkedHashSet; -import java.util.Set; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.beans.BeansException; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.SpringBootConfiguration; -import org.springframework.boot.context.event.ApplicationReadyEvent; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.context.ApplicationListener; -import org.springframework.core.annotation.AnnotatedElementUtils; -import org.springframework.util.ClassUtils; -import org.springframework.util.ReflectionUtils; - -/** - * @author Dave Syer - * - */ -public class StartupApplicationListener - implements ApplicationListener, ApplicationContextAware { - - public static final String MARKER = "Benchmark app started"; - private static Log logger = LogFactory.getLog(StartupApplicationListener.class); - private ApplicationContext context; - - @Override - public void setApplicationContext(ApplicationContext context) throws BeansException { - this.context = context; - } - - @Override - public void onApplicationEvent(ApplicationReadyEvent event) { - if (!event.getApplicationContext().equals(this.context)) { - return; - } - if (isSpringBootApplication(sources(event))) { - try { - logger.info(MARKER); - } - catch (Exception e) { - } - } - } - - private boolean isSpringBootApplication(Set> sources) { - for (Class source : sources) { - if (AnnotatedElementUtils.isAnnotated(source, - SpringBootConfiguration.class)) { - return true; - } - } - if (sources.contains(Object.class)) { - // TODO: find a better marker class for a @SpringInitApplication - return true; - } - return false; - } - - private Set> sources(ApplicationReadyEvent event) { - Method method = ReflectionUtils.findMethod(SpringApplication.class, - "getAllSources"); - if (method == null) { - method = ReflectionUtils.findMethod(SpringApplication.class, "getSources"); - } - ReflectionUtils.makeAccessible(method); - @SuppressWarnings("unchecked") - Set objects = (Set) ReflectionUtils.invokeMethod(method, - event.getSpringApplication()); - Set> result = new LinkedHashSet<>(); - for (Object object : objects) { - if (object instanceof String) { - object = ClassUtils.resolveClassName((String) object, null); - } - result.add((Class) object); - } - return result; - } - -} diff --git a/spring-graalvm-native-samples/spring-petclinic-jdbc/src/main/resources/META-INF/native-image/resource-config.json b/spring-graalvm-native-samples/spring-petclinic-jdbc/src/main/resources/META-INF/native-image/resource-config.json index 8dbf9cfbf..502e8764f 100644 --- a/spring-graalvm-native-samples/spring-petclinic-jdbc/src/main/resources/META-INF/native-image/resource-config.json +++ b/spring-graalvm-native-samples/spring-petclinic-jdbc/src/main/resources/META-INF/native-image/resource-config.json @@ -3,15 +3,6 @@ {"name":"messages/messages"} ], "resources": [ - {"pattern": "META-INF/resources/webjars/.*"}, - {"pattern": "banner.txt"}, - {"pattern": "db/.*"}, - {"pattern": "messages/.*"}, - {"pattern": "static/.*"}, - {"pattern": "templates/.*"}, - {"pattern": "org/springframework/web/util/HtmlCharacterEntityReferences.properties"}, - {"pattern": "org.springframework.web.servlet.DispatcherServlet.properties"}, - {"pattern": "templates/owners/ownersList.html"}, - {"pattern": "org/springframework/http/mime.types"} + {"pattern": "templates/owners/ownersList.html"} ] } diff --git a/spring-graalvm-native-samples/spring-petclinic-jdbc/src/main/resources/META-INF/spring.factories b/spring-graalvm-native-samples/spring-petclinic-jdbc/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 6cbbc1412..000000000 --- a/spring-graalvm-native-samples/spring-petclinic-jdbc/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,4 +0,0 @@ -org.springframework.context.ApplicationListener=\ -org.springframework.samples.petclinic.system.BeanCountingApplicationListener,\ -org.springframework.samples.petclinic.system.StartupApplicationListener,\ -org.springframework.samples.petclinic.system.ShutdownApplicationListener diff --git a/spring-graalvm-native-samples/spring-petclinic-jdbc/src/main/resources/logback.xml b/spring-graalvm-native-samples/spring-petclinic-jdbc/src/main/resources/logback.xml deleted file mode 100644 index afaebf8e1..000000000 --- a/spring-graalvm-native-samples/spring-petclinic-jdbc/src/main/resources/logback.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - \ No newline at end of file diff --git a/spring-graalvm-native-samples/spring-petclinic-jpa/compile.sh b/spring-graalvm-native-samples/spring-petclinic-jpa/compile.sh index 4f116b3dd..19fe9abc6 100755 --- a/spring-graalvm-native-samples/spring-petclinic-jpa/compile.sh +++ b/spring-graalvm-native-samples/spring-petclinic-jpa/compile.sh @@ -2,7 +2,7 @@ ARTIFACT=spring-petclinic-jpa MAINCLASS=org.springframework.samples.petclinic.PetClinicApplication -VERSION=2.3.0.BUILD-SNAPSHOT +VERSION=0.0.1-SNAPSHOT GREEN='\033[0;32m' RED='\033[0;31m' @@ -32,7 +32,7 @@ echo "Compiling $ARTIFACT with $GRAALVM_VERSION" -H:+RemoveSaturatedTypeFlows \ -Dspring.native.remove-yaml-support=true \ -Dspring.native.remove-jmx-support=true \ - -Dspring.native.remove-spel-support=true \ + -Dspring.spel.ignore=true \ -cp $CP $MAINCLASS >> output.txt ; } 2>> output.txt if [[ -f $ARTIFACT ]] diff --git a/spring-graalvm-native-samples/spring-petclinic-jpa/pom.xml b/spring-graalvm-native-samples/spring-petclinic-jpa/pom.xml index fa57588b5..77f75a06a 100644 --- a/spring-graalvm-native-samples/spring-petclinic-jpa/pom.xml +++ b/spring-graalvm-native-samples/spring-petclinic-jpa/pom.xml @@ -3,12 +3,12 @@ 4.0.0 org.springframework.samples spring-petclinic-jpa - 2.3.0.BUILD-SNAPSHOT + 0.0.1-SNAPSHOT org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT spring-petclinic-jpa diff --git a/spring-graalvm-native-samples/springmvc-tomcat/agent/build.sh b/spring-graalvm-native-samples/springmvc-tomcat/agent/build.sh index de8539e47..b16c29879 100755 --- a/spring-graalvm-native-samples/springmvc-tomcat/agent/build.sh +++ b/spring-graalvm-native-samples/springmvc-tomcat/agent/build.sh @@ -42,8 +42,8 @@ native-image \ -Dspring.native.mode=agent \ -H:Name=$APP-agent \ -Dspring.native.remove-yaml-support=true \ - -Dspring.native.remove-xml-support=true \ - -Dspring.native.remove-spel-support=true \ + -Dspring.xml.ignore=true \ + -Dspring.spel.ignore=true \ -Dspring.native.remove-jmx-support=true \ -H:IncludeResourceBundles=javax.servlet.LocalStrings \ -H:IncludeResourceBundles=javax.servlet.http.LocalStrings \ diff --git a/spring-graalvm-native-samples/springmvc-tomcat/compile.sh b/spring-graalvm-native-samples/springmvc-tomcat/compile.sh index 1053e52d8..ad4fbd717 100755 --- a/spring-graalvm-native-samples/springmvc-tomcat/compile.sh +++ b/spring-graalvm-native-samples/springmvc-tomcat/compile.sh @@ -31,9 +31,9 @@ echo "Compiling $ARTIFACT with $GRAALVM_VERSION" -H:EnableURLProtocols=http \ -H:Name=$ARTIFACT \ -Dspring.native.remove-yaml-support=true \ - -Dspring.native.remove-xml-support=true \ - -Dspring.native.remove-spel-support=true \ -Dspring.native.remove-jmx-support=true \ + -Dspring.xml.ignore=true \ + -Dspring.spel.ignore=true \ -cp $CP $MAINCLASS >> output.txt ; } 2>> output.txt if [[ -f $ARTIFACT ]] diff --git a/spring-graalvm-native-samples/springmvc-tomcat/pom.xml b/spring-graalvm-native-samples/springmvc-tomcat/pom.xml index 2f9919af2..6c91d73ee 100644 --- a/spring-graalvm-native-samples/springmvc-tomcat/pom.xml +++ b/spring-graalvm-native-samples/springmvc-tomcat/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT com.example diff --git a/spring-graalvm-native-samples/springmvc-tomcat/src/main/resources/application.properties b/spring-graalvm-native-samples/springmvc-tomcat/src/main/resources/application.properties index 8b1378917..3f99bf1bd 100644 --- a/spring-graalvm-native-samples/springmvc-tomcat/src/main/resources/application.properties +++ b/spring-graalvm-native-samples/springmvc-tomcat/src/main/resources/application.properties @@ -1 +1 @@ - +logging.level.org.springframework.web.servlet.DispatcherServlet=trace \ No newline at end of file diff --git a/spring-graalvm-native-samples/springmvc-tomcat/src/test/java/com/example/tomcat/TomcatApplicationTests.java b/spring-graalvm-native-samples/springmvc-tomcat/src/test/java/com/example/tomcat/TomcatApplicationTests.java index 8da0d42cf..c471d74b5 100644 --- a/spring-graalvm-native-samples/springmvc-tomcat/src/test/java/com/example/tomcat/TomcatApplicationTests.java +++ b/spring-graalvm-native-samples/springmvc-tomcat/src/test/java/com/example/tomcat/TomcatApplicationTests.java @@ -1,11 +1,9 @@ package com.example.tomcat; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; + import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; -@RunWith(SpringRunner.class) @SpringBootTest public class TomcatApplicationTests { diff --git a/spring-graalvm-native-samples/vanilla-grpc/pom.xml b/spring-graalvm-native-samples/vanilla-grpc/pom.xml index 084d18a45..2bb480769 100644 --- a/spring-graalvm-native-samples/vanilla-grpc/pom.xml +++ b/spring-graalvm-native-samples/vanilla-grpc/pom.xml @@ -15,7 +15,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT diff --git a/spring-graalvm-native-samples/vanilla-jpa/compile.sh b/spring-graalvm-native-samples/vanilla-jpa/compile.sh index 58df30019..f2bf380c3 100755 --- a/spring-graalvm-native-samples/vanilla-jpa/compile.sh +++ b/spring-graalvm-native-samples/vanilla-jpa/compile.sh @@ -31,7 +31,7 @@ echo "Compiling $ARTIFACT with $GRAALVM_VERSION" -H:+RemoveSaturatedTypeFlows \ -Dspring.native.remove-yaml-support=true \ -Dspring.native.remove-jmx-support=true \ - -Dspring.native.remove-spel-support=true \ + -Dspring.spel.ignore=true \ -H:Name=$ARTIFACT \ -cp $CP $MAINCLASS >> output.txt ; } 2>> output.txt diff --git a/spring-graalvm-native-samples/vanilla-jpa/pom.xml b/spring-graalvm-native-samples/vanilla-jpa/pom.xml index 023bf9319..2dc6c63ac 100644 --- a/spring-graalvm-native-samples/vanilla-jpa/pom.xml +++ b/spring-graalvm-native-samples/vanilla-jpa/pom.xml @@ -11,7 +11,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT diff --git a/spring-graalvm-native-samples/vanilla-orm/pom.xml b/spring-graalvm-native-samples/vanilla-orm/pom.xml index 56d24919c..cb7f93aa8 100644 --- a/spring-graalvm-native-samples/vanilla-orm/pom.xml +++ b/spring-graalvm-native-samples/vanilla-orm/pom.xml @@ -11,7 +11,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT @@ -110,10 +110,6 @@ - - jitpack.io - https://jitpack.io - spring-libs-snapshot https://repo.spring.io/libs-snapshot diff --git a/spring-graalvm-native-samples/vanilla-thymeleaf/compile.sh b/spring-graalvm-native-samples/vanilla-thymeleaf/compile.sh index c3723de09..598250776 100755 --- a/spring-graalvm-native-samples/vanilla-thymeleaf/compile.sh +++ b/spring-graalvm-native-samples/vanilla-thymeleaf/compile.sh @@ -30,8 +30,8 @@ echo "Compiling $ARTIFACT with $GRAALVM_VERSION" --verbose \ -H:Name=$ARTIFACT \ -Dspring.native.remove-yaml-support=true \ - -Dspring.native.remove-xml-support=true \ - -Dspring.native.remove-spel-support=true \ + -Dspring.xml.ignore=true \ + -Dspring.spel.ignore=true \ -Dspring.native.remove-jmx-support=true \ -cp $CP $MAINCLASS >> output.txt ; } 2>> output.txt diff --git a/spring-graalvm-native-samples/vanilla-thymeleaf/pom.xml b/spring-graalvm-native-samples/vanilla-thymeleaf/pom.xml index 2628d4c54..b85690944 100644 --- a/spring-graalvm-native-samples/vanilla-thymeleaf/pom.xml +++ b/spring-graalvm-native-samples/vanilla-thymeleaf/pom.xml @@ -10,7 +10,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT @@ -26,12 +26,6 @@ org.springframework.boot spring-boot-starter-webflux - - - io.netty - netty-codec-http2 - - org.springframework.boot diff --git a/spring-graalvm-native-samples/vanilla-thymeleaf/src/test/java/hello/ApplicationTests.java b/spring-graalvm-native-samples/vanilla-thymeleaf/src/test/java/hello/ApplicationTests.java index f69292552..82baca876 100644 --- a/spring-graalvm-native-samples/vanilla-thymeleaf/src/test/java/hello/ApplicationTests.java +++ b/spring-graalvm-native-samples/vanilla-thymeleaf/src/test/java/hello/ApplicationTests.java @@ -16,15 +16,12 @@ package hello; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.reactive.server.WebTestClient; -@RunWith(SpringRunner.class) @WebFluxTest(controllers = GreetingController.class) public class ApplicationTests { diff --git a/spring-graalvm-native-samples/vanilla-tx/compile.sh b/spring-graalvm-native-samples/vanilla-tx/compile.sh index bb9c85a7e..977eb9b79 100755 --- a/spring-graalvm-native-samples/vanilla-tx/compile.sh +++ b/spring-graalvm-native-samples/vanilla-tx/compile.sh @@ -30,7 +30,7 @@ echo "Compiling $ARTIFACT with $GRAALVM_VERSION" --verbose \ -H:Name=$ARTIFACT \ -Dspring.native.remove-yaml-support=true \ - -Dspring.native.remove-spel-support=true \ + -Dspring.spel.ignore=true \ -Dspring.native.remove-jmx-support=true \ -cp $CP $MAINCLASS >> output.txt ; } 2>> output.txt diff --git a/spring-graalvm-native-samples/vanilla-tx/pom.xml b/spring-graalvm-native-samples/vanilla-tx/pom.xml index 82448d5d4..68d23298d 100644 --- a/spring-graalvm-native-samples/vanilla-tx/pom.xml +++ b/spring-graalvm-native-samples/vanilla-tx/pom.xml @@ -11,7 +11,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT diff --git a/spring-graalvm-native-samples/web-issue122/build.gradle b/spring-graalvm-native-samples/web-issue122/build.gradle deleted file mode 100644 index 0e4508189..000000000 --- a/spring-graalvm-native-samples/web-issue122/build.gradle +++ /dev/null @@ -1,25 +0,0 @@ -plugins { - id 'org.springframework.boot' version '2.3.1.RELEASE' - id 'io.spring.dependency-management' version '1.0.9.RELEASE' - id 'java' - id 'eclipse' -} - -group = 'net.yisu.example' -version = '0.0.1-SNAPSHOT' -sourceCompatibility = '1.8' - -repositories { - mavenLocal() - mavenCentral() - maven { url 'https://repo.spring.io/milestone' } -} - -dependencies { - implementation 'org.springframework.experimental:spring-graalvm-native:0.8.0-SNAPSHOT' - implementation 'org.springframework.boot:spring-boot-starter-web' - implementation 'org.springframework.boot:spring-boot-starter-logging' - - compile group: 'org.json', name: 'json', version: '20171018' -} - diff --git a/spring-graalvm-native-samples/web-issue122/build.sh b/spring-graalvm-native-samples/web-issue122/build.sh deleted file mode 100755 index bab3c986e..000000000 --- a/spring-graalvm-native-samples/web-issue122/build.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -BLUE='\033[0;34m' -NC='\033[0m' - -printf "=== ${BLUE}Building %s sample${NC} ===\n" "${PWD##*/}" -./compile.sh && ${PWD%/*samples/*}/scripts/test.sh diff --git a/spring-graalvm-native-samples/web-issue122/compile.sh b/spring-graalvm-native-samples/web-issue122/compile.sh deleted file mode 100755 index 68596b93a..000000000 --- a/spring-graalvm-native-samples/web-issue122/compile.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env bash - -ARTIFACT=web-issue122 -MAINCLASS=net.yisu.example.demo.DemoApplication -VERSION=0.0.1-SNAPSHOT - -GREEN='\033[0;32m' -RED='\033[0;31m' -NC='\033[0m' - -rm -rf target -mkdir -p target/native-image - -rm -rf target/native-image -mkdir -p target/native-image -echo "Packaging $ARTIFACT with Gradle" -./gradlew build > target/native-image/output.txt - -JAR="$ARTIFACT-$VERSION.jar" -rm -f $ARTIFACT -echo "Unpacking $JAR" -cd target/native-image -jar -xvf ../../build/libs/$JAR >/dev/null 2>&1 -cp -R META-INF BOOT-INF/classes - -LIBPATH=`find BOOT-INF/lib | tr '\n' ':'` -CP=BOOT-INF/classes:$LIBPATH - -GRAALVM_VERSION=`native-image --version` -echo "Compiling $ARTIFACT with $GRAALVM_VERSION" -{ time native-image \ - -H:EnableURLProtocols=http \ - -H:Name=$ARTIFACT \ - -Dspring.native.remove-yaml-support=true \ - -cp $CP $MAINCLASS >> output.txt ; } 2>> output.txt - -if [[ -f $ARTIFACT ]] -then - printf "${GREEN}SUCCESS${NC}\n" - mv ./$ARTIFACT .. - exit 0 -else - cat output.txt - printf "${RED}FAILURE${NC}: an error occurred when compiling the native-image.\n" - exit 1 -fi diff --git a/spring-graalvm-native-samples/web-issue122/gradle/wrapper/gradle-wrapper.jar b/spring-graalvm-native-samples/web-issue122/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index f3d88b1c2..000000000 Binary files a/spring-graalvm-native-samples/web-issue122/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/spring-graalvm-native-samples/web-issue122/gradle/wrapper/gradle-wrapper.properties b/spring-graalvm-native-samples/web-issue122/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index a4b442974..000000000 --- a/spring-graalvm-native-samples/web-issue122/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/spring-graalvm-native-samples/web-issue122/gradlew b/spring-graalvm-native-samples/web-issue122/gradlew deleted file mode 100755 index 2fe81a7d9..000000000 --- a/spring-graalvm-native-samples/web-issue122/gradlew +++ /dev/null @@ -1,183 +0,0 @@ -#!/usr/bin/env sh - -# -# Copyright 2015 the original author or authors. -# -# 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 -# -# https://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. -# - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=`expr $i + 1` - done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -exec "$JAVACMD" "$@" diff --git a/spring-graalvm-native-samples/web-issue122/gradlew.bat b/spring-graalvm-native-samples/web-issue122/gradlew.bat deleted file mode 100644 index 9109989e3..000000000 --- a/spring-graalvm-native-samples/web-issue122/gradlew.bat +++ /dev/null @@ -1,103 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/spring-graalvm-native-samples/web-issue122/settings.gradle b/spring-graalvm-native-samples/web-issue122/settings.gradle deleted file mode 100644 index 4e20aeba8..000000000 --- a/spring-graalvm-native-samples/web-issue122/settings.gradle +++ /dev/null @@ -1,14 +0,0 @@ -pluginManagement { - repositories { - maven { url 'https://repo.spring.io/milestone' } - gradlePluginPortal() - } - resolutionStrategy { - eachPlugin { - if (requested.id.id == 'org.springframework.boot') { - useModule("org.springframework.boot:spring-boot-gradle-plugin:${requested.version}") - } - } - } -} -rootProject.name = 'web-issue122' diff --git a/spring-graalvm-native-samples/web-issue122/src/main/java/net/yisu/example/demo/Basic.java b/spring-graalvm-native-samples/web-issue122/src/main/java/net/yisu/example/demo/Basic.java deleted file mode 100644 index 8f2ecc8f4..000000000 --- a/spring-graalvm-native-samples/web-issue122/src/main/java/net/yisu/example/demo/Basic.java +++ /dev/null @@ -1,43 +0,0 @@ -package net.yisu.example.demo; - -import org.json.JSONObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -public class Basic { - - private static final Logger logger = LoggerFactory.getLogger(Basic.class); - - @RequestMapping(value = "${v1API}", method = RequestMethod.GET) - @ResponseBody - public ResponseEntity indexGetWithoutSlash() { - logger.info("the endpoint GET / without the slash was reached"); - - JSONObject output = new JSONObject(); - output.put("name", "hello there."); - return ResponseEntity.status(HttpStatus.OK).body( output.toString() ); - - } - - @RequestMapping(value = "${v1API}/", method = RequestMethod.GET) - @ResponseBody - public ResponseEntity indexGet() { - logger.info("the endpoint GET / was reached"); - - JSONObject output = new JSONObject(); - output.put("name", "hi there."); - return ResponseEntity.status(HttpStatus.OK).body( output.toString() ); - - } - -} diff --git a/spring-graalvm-native-samples/web-issue122/src/main/java/net/yisu/example/demo/DemoApplication.java b/spring-graalvm-native-samples/web-issue122/src/main/java/net/yisu/example/demo/DemoApplication.java deleted file mode 100644 index 46ca28084..000000000 --- a/spring-graalvm-native-samples/web-issue122/src/main/java/net/yisu/example/demo/DemoApplication.java +++ /dev/null @@ -1,22 +0,0 @@ -package net.yisu.example.demo; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication(proxyBeanMethods = false) -public class DemoApplication { - - private static final Logger logger = LoggerFactory.getLogger(DemoApplication.class); - - public static void main(String[] args) { - SpringApplication.run(DemoApplication.class, args); - - logger.info("-- Application Started (Spring Boot v2) --"); - - String javaVersion = System.getProperty("java.version"); - logger.info("-- Java Version: " + javaVersion + " --"); - } - -} diff --git a/spring-graalvm-native-samples/web-issue122/src/main/resources/application.properties b/spring-graalvm-native-samples/web-issue122/src/main/resources/application.properties deleted file mode 100644 index 6479727e8..000000000 --- a/spring-graalvm-native-samples/web-issue122/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -v1API=/API diff --git a/spring-graalvm-native-samples/web-issue122/verify.sh b/spring-graalvm-native-samples/web-issue122/verify.sh deleted file mode 100755 index fe5d772aa..000000000 --- a/spring-graalvm-native-samples/web-issue122/verify.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -RESPONSE=`curl localhost:8080/API` -if [[ "$RESPONSE" == '{"name":"hello there."}' ]]; then - RESPONSE2=`curl localhost:8080/API/` - if [[ "$RESPONSE2" == '{"name":"hi there."}' ]]; then - exit 0 - fi -fi -exit 1 diff --git a/spring-graalvm-native-samples/webclient/compile.sh b/spring-graalvm-native-samples/webclient/compile.sh index b8fb1767e..6fa6d2407 100755 --- a/spring-graalvm-native-samples/webclient/compile.sh +++ b/spring-graalvm-native-samples/webclient/compile.sh @@ -30,8 +30,8 @@ echo "Compiling $ARTIFACT with $GRAALVM_VERSION" --verbose \ -H:Name=$ARTIFACT \ --enable-all-security-services \ - -Dspring.native.remove-spel-support=true \ - -Dspring.native.remove-xml-support=true \ + -Dspring.spel.ignore=true \ + -Dspring.xml.ignore=true \ -Dspring.native.remove-jmx-support=true \ -cp $CP $MAINCLASS >> output.txt ; } 2>> output.txt diff --git a/spring-graalvm-native-samples/webclient/pom.xml b/spring-graalvm-native-samples/webclient/pom.xml index c0de1bb53..1f34c3d0e 100644 --- a/spring-graalvm-native-samples/webclient/pom.xml +++ b/spring-graalvm-native-samples/webclient/pom.xml @@ -7,7 +7,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT com.example diff --git a/spring-graalvm-native-samples/webflux-netty/agent/build.sh b/spring-graalvm-native-samples/webflux-netty/agent/build.sh index c1730ce7a..af3fbe8a1 100755 --- a/spring-graalvm-native-samples/webflux-netty/agent/build.sh +++ b/spring-graalvm-native-samples/webflux-netty/agent/build.sh @@ -42,8 +42,8 @@ native-image \ -Dspring.native.mode=agent \ -H:Name=$ARTIFACT-agent \ -Dspring.native.remove-yaml-support=true \ - -Dspring.native.remove-xml-support=true \ - -Dspring.native.remove-spel-support=true \ + -Dspring.xml.ignore=true \ + -Dspring.spel.ignore=true \ -Dspring.native.remove-jmx-support=true \ -cp .:$CP:graal \ $MAINCLASS 2>&1 | tee output.txt diff --git a/spring-graalvm-native-samples/webflux-netty/compile.sh b/spring-graalvm-native-samples/webflux-netty/compile.sh index 349440ad1..b10b60c35 100755 --- a/spring-graalvm-native-samples/webflux-netty/compile.sh +++ b/spring-graalvm-native-samples/webflux-netty/compile.sh @@ -30,8 +30,8 @@ echo "Compiling $ARTIFACT with $GRAALVM_VERSION" --verbose \ -H:Name=$ARTIFACT \ -Dspring.native.remove-yaml-support=true \ - -Dspring.native.remove-xml-support=true \ - -Dspring.native.remove-spel-support=true \ + -Dspring.xml.ignore=true \ + -Dspring.spel.ignore=true \ -Dspring.native.remove-jmx-support=true \ -cp $CP $MAINCLASS >> output.txt ; } 2>> output.txt diff --git a/spring-graalvm-native-samples/webflux-netty/pom.xml b/spring-graalvm-native-samples/webflux-netty/pom.xml index 633e529d2..83c6c7ccb 100644 --- a/spring-graalvm-native-samples/webflux-netty/pom.xml +++ b/spring-graalvm-native-samples/webflux-netty/pom.xml @@ -6,7 +6,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT com.example diff --git a/spring-graalvm-native-samples/webflux-r2dbc/pom.xml b/spring-graalvm-native-samples/webflux-r2dbc/pom.xml index d73388356..be42717c8 100644 --- a/spring-graalvm-native-samples/webflux-r2dbc/pom.xml +++ b/spring-graalvm-native-samples/webflux-r2dbc/pom.xml @@ -6,7 +6,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT com.example @@ -100,7 +100,7 @@ native-image-maven-plugin 20.1.0 - -Dspring.native.remove-xml-support=true -Dspring.native.remove-spel-support=true -Dspring.native.remove-yaml-support=true -Dspring.native.remove-jmx-support=true + -Dspring.xml.ignore=true -Dspring.spel.ignore=true -Dspring.native.remove-yaml-support=true -Dspring.native.remove-jmx-support=true webflux-r2dbc diff --git a/spring-graalvm-native-substitutions/src/main/java/io/micrometer/core/instrument/binder/tomcat/Target_TomcatMetrics.java b/spring-graalvm-native-substitutions/src/main/java/io/micrometer/core/instrument/binder/tomcat/Target_TomcatMetrics.java index b6d6d5645..dc009aaff 100644 --- a/spring-graalvm-native-substitutions/src/main/java/io/micrometer/core/instrument/binder/tomcat/Target_TomcatMetrics.java +++ b/spring-graalvm-native-substitutions/src/main/java/io/micrometer/core/instrument/binder/tomcat/Target_TomcatMetrics.java @@ -15,7 +15,8 @@ */ package io.micrometer.core.instrument.binder.tomcat; -import org.springframework.graalvm.substitutions.OnlyPresent; +import org.springframework.graalvm.substitutions.CatalinaManagerIsAround; +import org.springframework.graalvm.substitutions.OnlyIfPresent; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; @@ -28,7 +29,7 @@ * @author Andy Clement */ @TargetClass(className = "io.micrometer.core.instrument.binder.tomcat.TomcatMetrics", - onlyWith = {OnlyPresent.class,CatalinaManagerPresent.class}) + onlyWith = {OnlyIfPresent.class, CatalinaManagerIsAround.class}) public final class Target_TomcatMetrics { @Substitute diff --git a/spring-graalvm-native-substitutions/src/main/java/javax/xml/bind/Target_Binder.java b/spring-graalvm-native-substitutions/src/main/java/javax/xml/bind/Target_Binder.java index fe46571c0..0839b1710 100644 --- a/spring-graalvm-native-substitutions/src/main/java/javax/xml/bind/Target_Binder.java +++ b/spring-graalvm-native-substitutions/src/main/java/javax/xml/bind/Target_Binder.java @@ -3,10 +3,10 @@ import com.oracle.svm.core.annotate.Delete; import com.oracle.svm.core.annotate.TargetClass; -import org.springframework.graalvm.substitutions.OnlyPresent; +import org.springframework.graalvm.substitutions.OnlyIfPresent; import org.springframework.graalvm.substitutions.RemoveXmlSupport; -@TargetClass(className = "javax.xml.bind.Binder", onlyWith = { OnlyPresent.class, RemoveXmlSupport.class }) +@TargetClass(className = "javax.xml.bind.Binder", onlyWith = { OnlyIfPresent.class, RemoveXmlSupport.class }) @Delete final class Target_Binder { } diff --git a/spring-graalvm-native-substitutions/src/main/java/javax/xml/datatype/Target_DatatypeFactory.java b/spring-graalvm-native-substitutions/src/main/java/javax/xml/datatype/Target_DatatypeFactory.java index 47fdb435e..4c6686aaf 100644 --- a/spring-graalvm-native-substitutions/src/main/java/javax/xml/datatype/Target_DatatypeFactory.java +++ b/spring-graalvm-native-substitutions/src/main/java/javax/xml/datatype/Target_DatatypeFactory.java @@ -3,10 +3,10 @@ import com.oracle.svm.core.annotate.Delete; import com.oracle.svm.core.annotate.TargetClass; -import org.springframework.graalvm.substitutions.OnlyPresent; +import org.springframework.graalvm.substitutions.OnlyIfPresent; import org.springframework.graalvm.substitutions.RemoveXmlSupport; -@TargetClass(className = "javax.xml.datatype.DatatypeFactory", onlyWith = { OnlyPresent.class, RemoveXmlSupport.class }) +@TargetClass(className = "javax.xml.datatype.DatatypeFactory", onlyWith = { OnlyIfPresent.class, RemoveXmlSupport.class }) @Delete final class Target_DatatypeFactory { } diff --git a/spring-graalvm-native-substitutions/src/main/java/javax/xml/parsers/Target_DocumentBuilderFactory.java b/spring-graalvm-native-substitutions/src/main/java/javax/xml/parsers/Target_DocumentBuilderFactory.java index 02a7aaa3f..1e2492da5 100644 --- a/spring-graalvm-native-substitutions/src/main/java/javax/xml/parsers/Target_DocumentBuilderFactory.java +++ b/spring-graalvm-native-substitutions/src/main/java/javax/xml/parsers/Target_DocumentBuilderFactory.java @@ -3,10 +3,10 @@ import com.oracle.svm.core.annotate.Delete; import com.oracle.svm.core.annotate.TargetClass; -import org.springframework.graalvm.substitutions.OnlyPresent; +import org.springframework.graalvm.substitutions.OnlyIfPresent; import org.springframework.graalvm.substitutions.RemoveXmlSupport; -@TargetClass(className = "javax.xml.parsers.DocumentBuilderFactory", onlyWith = { OnlyPresent.class, RemoveXmlSupport.class }) +@TargetClass(className = "javax.xml.parsers.DocumentBuilderFactory", onlyWith = { OnlyIfPresent.class, RemoveXmlSupport.class }) @Delete final class Target_DocumentBuilderFactory { } diff --git a/spring-graalvm-native-substitutions/src/main/java/javax/xml/parsers/Target_SAXParserFactory.java b/spring-graalvm-native-substitutions/src/main/java/javax/xml/parsers/Target_SAXParserFactory.java index 0e74078b1..57b23a373 100644 --- a/spring-graalvm-native-substitutions/src/main/java/javax/xml/parsers/Target_SAXParserFactory.java +++ b/spring-graalvm-native-substitutions/src/main/java/javax/xml/parsers/Target_SAXParserFactory.java @@ -3,10 +3,10 @@ import com.oracle.svm.core.annotate.Delete; import com.oracle.svm.core.annotate.TargetClass; -import org.springframework.graalvm.substitutions.OnlyPresent; +import org.springframework.graalvm.substitutions.OnlyIfPresent; import org.springframework.graalvm.substitutions.RemoveXmlSupport; -@TargetClass(className = "javax.xml.parsers.SAXParserFactory", onlyWith = { OnlyPresent.class, RemoveXmlSupport.class }) +@TargetClass(className = "javax.xml.parsers.SAXParserFactory", onlyWith = { OnlyIfPresent.class, RemoveXmlSupport.class }) @Delete final class Target_SAXParserFactory { } diff --git a/spring-graalvm-native-substitutions/src/main/java/javax/xml/stream/Target_FactoryFinder.java b/spring-graalvm-native-substitutions/src/main/java/javax/xml/stream/Target_FactoryFinder.java index 2b358d047..b7839b352 100644 --- a/spring-graalvm-native-substitutions/src/main/java/javax/xml/stream/Target_FactoryFinder.java +++ b/spring-graalvm-native-substitutions/src/main/java/javax/xml/stream/Target_FactoryFinder.java @@ -3,10 +3,10 @@ import com.oracle.svm.core.annotate.Delete; import com.oracle.svm.core.annotate.TargetClass; -import org.springframework.graalvm.substitutions.OnlyPresent; +import org.springframework.graalvm.substitutions.OnlyIfPresent; import org.springframework.graalvm.substitutions.RemoveXmlSupport; -@TargetClass(className = "javax.xml.stream.FactoryFinder", onlyWith = { OnlyPresent.class, RemoveXmlSupport.class }) +@TargetClass(className = "javax.xml.stream.FactoryFinder", onlyWith = { OnlyIfPresent.class, RemoveXmlSupport.class }) @Delete final class Target_FactoryFinder { } diff --git a/spring-graalvm-native-substitutions/src/main/java/javax/xml/transform/Target_FactoryFinder.java b/spring-graalvm-native-substitutions/src/main/java/javax/xml/transform/Target_FactoryFinder.java index 1547cb854..a47e9071c 100644 --- a/spring-graalvm-native-substitutions/src/main/java/javax/xml/transform/Target_FactoryFinder.java +++ b/spring-graalvm-native-substitutions/src/main/java/javax/xml/transform/Target_FactoryFinder.java @@ -3,10 +3,10 @@ import com.oracle.svm.core.annotate.Delete; import com.oracle.svm.core.annotate.TargetClass; -import org.springframework.graalvm.substitutions.OnlyPresent; +import org.springframework.graalvm.substitutions.OnlyIfPresent; import org.springframework.graalvm.substitutions.RemoveXmlSupport; -@TargetClass(className = "javax.xml.transform.FactoryFinder", onlyWith = { OnlyPresent.class, RemoveXmlSupport.class }) +@TargetClass(className = "javax.xml.transform.FactoryFinder", onlyWith = { OnlyIfPresent.class, RemoveXmlSupport.class }) @Delete final class Target_FactoryFinder { } diff --git a/spring-graalvm-native-substitutions/src/main/java/org/apache/catalina/authenticator/Target_AuthenticatorBase.java b/spring-graalvm-native-substitutions/src/main/java/org/apache/catalina/authenticator/Target_AuthenticatorBase.java index c8feebd1a..db1818ab6 100644 --- a/spring-graalvm-native-substitutions/src/main/java/org/apache/catalina/authenticator/Target_AuthenticatorBase.java +++ b/spring-graalvm-native-substitutions/src/main/java/org/apache/catalina/authenticator/Target_AuthenticatorBase.java @@ -8,9 +8,9 @@ import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import org.springframework.graalvm.substitutions.OnlyPresent; +import org.springframework.graalvm.substitutions.OnlyIfPresent; -@TargetClass(className = "org.apache.catalina.authenticator.AuthenticatorBase", onlyWith = { OnlyPresent.class }) +@TargetClass(className = "org.apache.catalina.authenticator.AuthenticatorBase", onlyWith = { OnlyIfPresent.class }) final class Target_AuthenticatorBase { @Alias diff --git a/spring-graalvm-native-substitutions/src/main/java/org/apache/catalina/authenticator/jaspic/Target_AuthConfigFactoryImpl.java b/spring-graalvm-native-substitutions/src/main/java/org/apache/catalina/authenticator/jaspic/Target_AuthConfigFactoryImpl.java index afb3c4108..290d75608 100644 --- a/spring-graalvm-native-substitutions/src/main/java/org/apache/catalina/authenticator/jaspic/Target_AuthConfigFactoryImpl.java +++ b/spring-graalvm-native-substitutions/src/main/java/org/apache/catalina/authenticator/jaspic/Target_AuthConfigFactoryImpl.java @@ -3,9 +3,9 @@ import com.oracle.svm.core.annotate.Delete; import com.oracle.svm.core.annotate.TargetClass; -import org.springframework.graalvm.substitutions.OnlyPresent; +import org.springframework.graalvm.substitutions.OnlyIfPresent; @Delete -@TargetClass(className = "org.apache.catalina.authenticator.jaspic.AuthConfigFactoryImpl", onlyWith = { OnlyPresent.class }) +@TargetClass(className = "org.apache.catalina.authenticator.jaspic.AuthConfigFactoryImpl", onlyWith = { OnlyIfPresent.class }) final class Target_AuthConfigFactoryImpl { } diff --git a/spring-graalvm-native-substitutions/src/main/java/org/apache/catalina/servlets/Target_DefaultServlet.java b/spring-graalvm-native-substitutions/src/main/java/org/apache/catalina/servlets/Target_DefaultServlet.java index 9b972f99d..66f08ee78 100644 --- a/spring-graalvm-native-substitutions/src/main/java/org/apache/catalina/servlets/Target_DefaultServlet.java +++ b/spring-graalvm-native-substitutions/src/main/java/org/apache/catalina/servlets/Target_DefaultServlet.java @@ -3,10 +3,10 @@ import com.oracle.svm.core.annotate.Delete; import com.oracle.svm.core.annotate.TargetClass; -import org.springframework.graalvm.substitutions.OnlyPresent; +import org.springframework.graalvm.substitutions.OnlyIfPresent; @Delete -@TargetClass(className = "org.apache.catalina.servlets.DefaultServlet", onlyWith = { OnlyPresent.class }) +@TargetClass(className = "org.apache.catalina.servlets.DefaultServlet", onlyWith = { OnlyIfPresent.class }) final class Target_DefaultServlet { } diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/aop/framework/Target_DefaultAopProxyFactory.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/aop/framework/Target_DefaultAopProxyFactory.java deleted file mode 100644 index c6cf4e64b..000000000 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/aop/framework/Target_DefaultAopProxyFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.springframework.aop.framework; - -import java.lang.reflect.Proxy; - -import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; - -import org.springframework.aop.SpringProxy; -import org.springframework.graalvm.substitutions.OnlyPresent; -import org.springframework.graalvm.substitutions.RemoveCglibSupport; - -@TargetClass(className = "org.springframework.aop.framework.DefaultAopProxyFactory", onlyWith = { OnlyPresent.class, RemoveCglibSupport.class }) -public final class Target_DefaultAopProxyFactory { - - @Substitute - public AopProxy createAopProxy(AdvisedSupport config) throws AopConfigException { - if (config.isOptimize() || config.isProxyTargetClass() || hasNoUserSuppliedProxyInterfaces(config)) { - Class targetClass = config.getTargetClass(); - if (targetClass == null) { - throw new AopConfigException("TargetSource cannot determine target class: " + - "Either an interface or a target is required for proxy creation."); - } - if (targetClass.isInterface() || Proxy.isProxyClass(targetClass)) { - return new JdkDynamicAopProxy(config); - } - throw new AopConfigException("Can't create an ObjenesisCglibAopProxy since it is unsupported in native images"); - } - else { - return new JdkDynamicAopProxy(config); - } - } - - @Alias - private boolean hasNoUserSuppliedProxyInterfaces(AdvisedSupport config) { - Class[] ifcs = config.getProxiedInterfaces(); - return ifcs.length == 0 || ifcs.length == 1 && SpringProxy.class.isAssignableFrom(ifcs[0]); - } -} diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/beans/factory/support/Target_CglibSubclassingInstantiationStrategy.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/beans/factory/support/Target_CglibSubclassingInstantiationStrategy.java deleted file mode 100644 index fb5af1456..000000000 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/beans/factory/support/Target_CglibSubclassingInstantiationStrategy.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.springframework.beans.factory.support; - -import java.lang.reflect.Constructor; - -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; - -import org.springframework.beans.factory.BeanFactory; -import org.springframework.graalvm.substitutions.OnlyPresent; -import org.springframework.graalvm.substitutions.RemoveCglibSupport; -import org.springframework.lang.Nullable; - -@TargetClass(className = "org.springframework.beans.factory.support.CglibSubclassingInstantiationStrategy", onlyWith = { OnlyPresent.class, RemoveCglibSupport.class }) -public final class Target_CglibSubclassingInstantiationStrategy { - - @Substitute - protected Object instantiateWithMethodInjection(RootBeanDefinition bd, @Nullable String beanName, BeanFactory owner) { - throw new UnsupportedOperationException("Unsupported operation since CGLIB support has been removed"); - } - - @Substitute - protected Object instantiateWithMethodInjection(RootBeanDefinition bd, @Nullable String beanName, - BeanFactory owner, @Nullable Constructor ctor, Object... args) { - - throw new UnsupportedOperationException("Unsupported operation since CGLIB support has been removed"); - } - -} - diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/boot/Target_BeanDefinitionLoader.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/boot/Target_BeanDefinitionLoader.java index 6bec25529..64e6cbd89 100644 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/boot/Target_BeanDefinitionLoader.java +++ b/spring-graalvm-native-substitutions/src/main/java/org/springframework/boot/Target_BeanDefinitionLoader.java @@ -21,12 +21,12 @@ import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; import org.springframework.core.type.filter.AbstractTypeHierarchyTraversingFilter; -import org.springframework.graalvm.substitutions.OnlyPresent; +import org.springframework.graalvm.substitutions.OnlyIfPresent; import org.springframework.graalvm.substitutions.RemoveXmlSupport; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; -@TargetClass(className = "org.springframework.boot.BeanDefinitionLoader", onlyWith = { OnlyPresent.class, RemoveXmlSupport.class }) +@TargetClass(className = "org.springframework.boot.BeanDefinitionLoader", onlyWith = { OnlyIfPresent.class, RemoveXmlSupport.class }) final class Target_BeanDefinitionLoader { @Delete diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/boot/Target_SpringApplicationBannerPrinter.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/boot/Target_SpringApplicationBannerPrinter.java index 4eba89442..0d5d2239e 100644 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/boot/Target_SpringApplicationBannerPrinter.java +++ b/spring-graalvm-native-substitutions/src/main/java/org/springframework/boot/Target_SpringApplicationBannerPrinter.java @@ -5,9 +5,9 @@ import com.oracle.svm.core.annotate.TargetClass; import org.springframework.core.env.Environment; -import org.springframework.graalvm.substitutions.OnlyPresent; +import org.springframework.graalvm.substitutions.OnlyIfPresent; -@TargetClass(className = "org.springframework.boot.SpringApplicationBannerPrinter", onlyWith = OnlyPresent.class) +@TargetClass(className = "org.springframework.boot.SpringApplicationBannerPrinter", onlyWith = OnlyIfPresent.class) public final class Target_SpringApplicationBannerPrinter { @Alias diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/boot/autoconfigure/http/Target_HttpMessageConverters.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/boot/autoconfigure/http/Target_HttpMessageConverters.java index ea04d3b25..c3c9eceb0 100644 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/boot/autoconfigure/http/Target_HttpMessageConverters.java +++ b/spring-graalvm-native-substitutions/src/main/java/org/springframework/boot/autoconfigure/http/Target_HttpMessageConverters.java @@ -10,10 +10,10 @@ import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter; import org.springframework.graalvm.substitutions.MappingJackson2XmlHttpMessageConverterIsAround; -import org.springframework.graalvm.substitutions.OnlyPresent; +import org.springframework.graalvm.substitutions.OnlyIfPresent; import org.springframework.graalvm.substitutions.RemoveXmlSupport; -@TargetClass(className = "org.springframework.boot.autoconfigure.http.HttpMessageConverters", onlyWith = { OnlyPresent.class, MappingJackson2XmlHttpMessageConverterIsAround.class, RemoveXmlSupport.class }) +@TargetClass(className = "org.springframework.boot.autoconfigure.http.HttpMessageConverters", onlyWith = { OnlyIfPresent.class, MappingJackson2XmlHttpMessageConverterIsAround.class, RemoveXmlSupport.class }) final class Target_HttpMessageConverters { @Substitute diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/boot/json/Target_JsonParserFactory.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/boot/json/Target_JsonParserFactory.java index 4fa0fa0cd..2f464ba8a 100644 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/boot/json/Target_JsonParserFactory.java +++ b/spring-graalvm-native-substitutions/src/main/java/org/springframework/boot/json/Target_JsonParserFactory.java @@ -3,11 +3,11 @@ import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import org.springframework.graalvm.substitutions.OnlyPresent; +import org.springframework.graalvm.substitutions.OnlyIfPresent; import org.springframework.graalvm.substitutions.RemoveYamlSupport; import org.springframework.util.ClassUtils; -@TargetClass(className = "org.springframework.boot.json.JsonParserFactory", onlyWith = { RemoveYamlSupport.class, OnlyPresent.class }) +@TargetClass(className = "org.springframework.boot.json.JsonParserFactory", onlyWith = { RemoveYamlSupport.class, OnlyIfPresent.class }) public final class Target_JsonParserFactory { @Substitute diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/boot/logging/logback/Target_LogbackLoggingSystem.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/boot/logging/logback/Target_LogbackLoggingSystem.java index 6544e8ac0..c5eeaa3da 100644 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/boot/logging/logback/Target_LogbackLoggingSystem.java +++ b/spring-graalvm-native-substitutions/src/main/java/org/springframework/boot/logging/logback/Target_LogbackLoggingSystem.java @@ -9,10 +9,10 @@ import org.springframework.boot.logging.LoggingInitializationContext; import org.springframework.graalvm.substitutions.LogbackIsAround; -import org.springframework.graalvm.substitutions.OnlyPresent; +import org.springframework.graalvm.substitutions.OnlyIfPresent; import org.springframework.graalvm.substitutions.RemoveXmlSupport; -@TargetClass(className = "org.springframework.boot.logging.logback.LogbackLoggingSystem", onlyWith = { OnlyPresent.class, LogbackIsAround.class, RemoveXmlSupport.class }) +@TargetClass(className = "org.springframework.boot.logging.logback.LogbackLoggingSystem", onlyWith = { OnlyIfPresent.class, LogbackIsAround.class, RemoveXmlSupport.class }) final class Target_LogbackLoggingSystem { @Substitute diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/boot/validation/Target_MessageInterpolatorFactory.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/boot/validation/Target_MessageInterpolatorFactory.java index de4552ef0..0e60e10b0 100644 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/boot/validation/Target_MessageInterpolatorFactory.java +++ b/spring-graalvm-native-substitutions/src/main/java/org/springframework/boot/validation/Target_MessageInterpolatorFactory.java @@ -23,7 +23,7 @@ import org.springframework.beans.BeanUtils; import org.springframework.beans.BeansException; import org.springframework.graalvm.substitutions.MessageInterpolatorIsAround; -import org.springframework.graalvm.substitutions.OnlyPresent; +import org.springframework.graalvm.substitutions.OnlyIfPresent; import org.springframework.util.ClassUtils; /** @@ -31,7 +31,7 @@ * * @author Andy Clement */ -@TargetClass(className="org.springframework.boot.validation.MessageInterpolatorFactory", onlyWith = { MessageInterpolatorIsAround.class, OnlyPresent.class}) +@TargetClass(className="org.springframework.boot.validation.MessageInterpolatorFactory", onlyWith = { MessageInterpolatorIsAround.class, OnlyIfPresent.class}) public final class Target_MessageInterpolatorFactory { @Substitute diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/context/annotation/Target_ConfigurationClassEnhancer.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/context/annotation/Target_ConfigurationClassEnhancer.java index 6702d17e1..02503b87b 100644 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/context/annotation/Target_ConfigurationClassEnhancer.java +++ b/spring-graalvm-native-substitutions/src/main/java/org/springframework/context/annotation/Target_ConfigurationClassEnhancer.java @@ -3,11 +3,10 @@ import com.oracle.svm.core.annotate.Delete; import com.oracle.svm.core.annotate.TargetClass; -import org.springframework.graalvm.substitutions.OnlyPresent; -import org.springframework.graalvm.substitutions.RemoveCglibSupport; +import org.springframework.graalvm.substitutions.OnlyIfPresent; @Delete -@TargetClass(className = "org.springframework.context.annotation.ConfigurationClassEnhancer", onlyWith = { OnlyPresent.class, RemoveCglibSupport.class }) +@TargetClass(className = "org.springframework.context.annotation.ConfigurationClassEnhancer", onlyWith = { OnlyIfPresent.class }) final class Target_ConfigurationClassEnhancer { } diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/context/annotation/Target_ConfigurationClassPostProcessor.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/context/annotation/Target_ConfigurationClassPostProcessor.java deleted file mode 100644 index a1e4393be..000000000 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/context/annotation/Target_ConfigurationClassPostProcessor.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.springframework.context.annotation; - -import java.util.LinkedHashMap; -import java.util.Map; - -import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; -import org.apache.commons.logging.Log; - -import org.springframework.beans.factory.BeanDefinitionStoreException; -import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.beans.factory.support.AbstractBeanDefinition; -import org.springframework.core.type.MethodMetadata; -import org.springframework.graalvm.substitutions.OnlyPresent; -import org.springframework.graalvm.substitutions.RemoveCglibSupport; - -@TargetClass(className = "org.springframework.context.annotation.ConfigurationClassPostProcessor", onlyWith = { OnlyPresent.class, RemoveCglibSupport.class }) -public final class Target_ConfigurationClassPostProcessor { - - @Alias - private ClassLoader beanClassLoader; - - @Alias - private Log logger; - - @Substitute - public void enhanceConfigurationClasses(ConfigurableListableBeanFactory beanFactory) { - Map configBeanDefs = new LinkedHashMap<>(); - for (String beanName : beanFactory.getBeanDefinitionNames()) { - BeanDefinition beanDef = beanFactory.getBeanDefinition(beanName); - Object configClassAttr = beanDef.getAttribute(ConfigurationClassUtils.CONFIGURATION_CLASS_ATTRIBUTE); - MethodMetadata methodMetadata = null; - if (beanDef instanceof AnnotatedBeanDefinition) { - methodMetadata = ((AnnotatedBeanDefinition) beanDef).getFactoryMethodMetadata(); - } - if ((configClassAttr != null || methodMetadata != null) && beanDef instanceof AbstractBeanDefinition) { - // Configuration class (full or lite) or a configuration-derived @Bean method - // -> resolve bean class at this point... - AbstractBeanDefinition abd = (AbstractBeanDefinition) beanDef; - if (!abd.hasBeanClass()) { - try { - abd.resolveBeanClass(this.beanClassLoader); - } - catch (Throwable ex) { - throw new IllegalStateException( - "Cannot load configuration class: " + beanDef.getBeanClassName(), ex); - } - } - } - if (ConfigurationClassUtils.CONFIGURATION_CLASS_FULL.equals(configClassAttr)) { - if (!(beanDef instanceof AbstractBeanDefinition)) { - throw new BeanDefinitionStoreException("Cannot enhance @Configuration bean definition '" + - beanName + "' since it is not stored in an AbstractBeanDefinition subclass"); - } - else if (logger.isInfoEnabled() && beanFactory.containsSingleton(beanName)) { - logger.info("Cannot enhance @Configuration bean definition '" + beanName + - "' since its singleton instance has been created too early. The typical cause " + - "is a non-static @Bean method with a BeanDefinitionRegistryPostProcessor " + - "return type: Consider declaring such methods as 'static'."); - } - configBeanDefs.put(beanName, (AbstractBeanDefinition) beanDef); - } - } - if (configBeanDefs.isEmpty()) { - // nothing to enhance -> return immediately - return; - } - throw new BeanDefinitionStoreException("@Configuration classes need to be marked as proxyBeanMethods=false. Found: " + configBeanDefs.keySet()); - } -} diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/context/event/Target_ApplicationListenerMethodAdapter.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/context/event/Target_ApplicationListenerMethodAdapter.java deleted file mode 100644 index 4876ef474..000000000 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/context/event/Target_ApplicationListenerMethodAdapter.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.springframework.context.event; - -import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.Delete; -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; - -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationEvent; -import org.springframework.graalvm.substitutions.OnlyPresent; -import org.springframework.graalvm.substitutions.RemoveSpelSupport; -import org.springframework.graalvm.substitutions.RemoveXmlSupport; -import org.springframework.lang.Nullable; -import org.springframework.util.StringUtils; - -@TargetClass(className = "org.springframework.context.event.ApplicationListenerMethodAdapter", onlyWith = { OnlyPresent.class, RemoveSpelSupport.class }) -final class Target_ApplicationListenerMethodAdapter { - - @Delete - private EventExpressionEvaluator evaluator; - - @Delete - void init(ApplicationContext applicationContext, EventExpressionEvaluator evaluator) { - } - - @Substitute - private boolean shouldHandle(ApplicationEvent event, @Nullable Object[] args) { - if (args == null) { - return false; - } - String condition = getCondition(); - if (StringUtils.hasText(condition)) { - throw new UnsupportedOperationException("SpEL support disabled"); - } - return true; - } - - @Alias - protected String getCondition() { - return null; - } -} diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/context/event/Target_EventListenerMethodProcessor.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/context/event/Target_EventListenerMethodProcessor.java deleted file mode 100644 index 06db34e0f..000000000 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/context/event/Target_EventListenerMethodProcessor.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.springframework.context.event; - -import java.lang.reflect.Method; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.Delete; -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.aop.support.AopUtils; -import org.springframework.context.ApplicationListener; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.core.MethodIntrospector; -import org.springframework.core.annotation.AnnotatedElementUtils; -import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.graalvm.substitutions.OnlyPresent; -import org.springframework.graalvm.substitutions.RemoveSpelSupport; -import org.springframework.util.Assert; -import org.springframework.util.CollectionUtils; - -@TargetClass(className = "org.springframework.context.event.EventListenerMethodProcessor", onlyWith = { OnlyPresent.class, RemoveSpelSupport.class }) -final class Target_EventListenerMethodProcessor { - - @Alias - protected Log logger; - - @Alias - private Set> nonAnnotatedClasses; - - @Alias - private ConfigurableApplicationContext applicationContext; - - @Alias - private List eventListenerFactories; - - @Delete - private EventExpressionEvaluator evaluator; - - @Substitute - public Target_EventListenerMethodProcessor() { - this.logger = LogFactory.getLog(getClass()); - this.nonAnnotatedClasses = nonAnnotatedClasses = Collections.newSetFromMap(new ConcurrentHashMap<>(64)); - } - - @Substitute - private void processBean(final String beanName, final Class targetType) { - if (!this.nonAnnotatedClasses.contains(targetType) && - AnnotationUtils.isCandidateClass(targetType, EventListener.class) && - !isSpringContainerClass(targetType)) { - - Map annotatedMethods = null; - try { - annotatedMethods = MethodIntrospector.selectMethods(targetType, - new MethodIntrospector.MetadataLookup() { - @Override - public EventListener inspect(Method method) { - return AnnotatedElementUtils.findMergedAnnotation(method, EventListener.class); - } - }); - } - catch (Throwable ex) { - // An unresolvable type in a method signature, probably from a lazy bean - let's ignore it. - if (logger.isDebugEnabled()) { - logger.debug("Could not resolve methods for bean with name '" + beanName + "'", ex); - } - } - - if (CollectionUtils.isEmpty(annotatedMethods)) { - this.nonAnnotatedClasses.add(targetType); - if (logger.isTraceEnabled()) { - logger.trace("No @EventListener annotations found on bean class: " + targetType.getName()); - } - } - else { - // Non-empty set of methods - ConfigurableApplicationContext context = this.applicationContext; - Assert.state(context != null, "No ApplicationContext set"); - List factories = this.eventListenerFactories; - Assert.state(factories != null, "EventListenerFactory List not initialized"); - for (Method method : annotatedMethods.keySet()) { - for (EventListenerFactory factory : factories) { - if (factory.supportsMethod(method)) { - Method methodToUse = AopUtils.selectInvocableMethod(method, context.getType(beanName)); - ApplicationListener applicationListener = - factory.createApplicationListener(beanName, targetType, methodToUse); - context.addApplicationListener(applicationListener); - break; - } - } - } - if (logger.isDebugEnabled()) { - logger.debug(annotatedMethods.size() + " @EventListener methods processed on bean '" + - beanName + "': " + annotatedMethods); - } - } - } - } - - @Alias - private static boolean isSpringContainerClass(Class clazz) { - return false; - } -} diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/context/support/Target_AbstractApplicationContext.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/context/support/Target_AbstractApplicationContext.java deleted file mode 100644 index 3a7d44648..000000000 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/context/support/Target_AbstractApplicationContext.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.springframework.context.support; - -import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; - -import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.beans.support.ResourceEditorRegistrar; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.context.ApplicationEventPublisherAware; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.EmbeddedValueResolverAware; -import org.springframework.context.EnvironmentAware; -import org.springframework.context.MessageSourceAware; -import org.springframework.context.ResourceLoaderAware; -import org.springframework.core.env.ConfigurableEnvironment; -import org.springframework.core.io.ResourceLoader; -import org.springframework.graalvm.substitutions.OnlyPresent; -import org.springframework.graalvm.substitutions.RemoveSpelSupport; -import org.springframework.util.ClassUtils; - -@TargetClass(className = "org.springframework.context.support.AbstractApplicationContext", onlyWith = { OnlyPresent.class, RemoveSpelSupport.class }) -final class Target_AbstractApplicationContext { - - @Substitute - protected void prepareBeanFactory(ConfigurableListableBeanFactory beanFactory) { - // Tell the internal bean factory to use the context's class loader etc. - beanFactory.setBeanClassLoader(ClassUtils.getDefaultClassLoader()); // Should be beanFactory.setBeanClassLoader(getClassLoader()); but can't find a way to invoke inherited methods via @Alias - beanFactory.addPropertyEditorRegistrar(new ResourceEditorRegistrar((ResourceLoader)(Object)this, getEnvironment())); - - // Configure the bean factory with context callbacks. - beanFactory.addBeanPostProcessor(new ApplicationContextAwareProcessor((ConfigurableApplicationContext)(Object)this)); - beanFactory.ignoreDependencyInterface(EnvironmentAware.class); - beanFactory.ignoreDependencyInterface(EmbeddedValueResolverAware.class); - beanFactory.ignoreDependencyInterface(ResourceLoaderAware.class); - beanFactory.ignoreDependencyInterface(ApplicationEventPublisherAware.class); - beanFactory.ignoreDependencyInterface(MessageSourceAware.class); - beanFactory.ignoreDependencyInterface(ApplicationContextAware.class); - - // BeanFactory interface not registered as resolvable type in a plain factory. - // MessageSource registered (and found for autowiring) as a bean. - beanFactory.registerResolvableDependency(BeanFactory.class, beanFactory); - beanFactory.registerResolvableDependency(ResourceLoader.class, this); - beanFactory.registerResolvableDependency(ApplicationEventPublisher.class, this); - beanFactory.registerResolvableDependency(ApplicationContext.class, this); - - // Register early post-processor for detecting inner beans as ApplicationListeners. - beanFactory.addBeanPostProcessor(new ApplicationListenerDetector((AbstractApplicationContext)(Object)this)); - - // Register default environment beans. - if (!beanFactory.containsLocalBean("environment")) { - beanFactory.registerSingleton("environment", getEnvironment()); - } - if (!beanFactory.containsLocalBean("systemProperties")) { - beanFactory.registerSingleton("systemProperties", getEnvironment().getSystemProperties()); - } - if (!beanFactory.containsLocalBean("systemEnvironment")) { - beanFactory.registerSingleton("systemEnvironment", getEnvironment().getSystemEnvironment()); - } - } - - @Alias - public ConfigurableEnvironment getEnvironment() { - return null; - } - -} diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/core/io/support/Target_PropertiesLoaderUtils.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/core/io/support/Target_PropertiesLoaderUtils.java deleted file mode 100644 index 8460a96be..000000000 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/core/io/support/Target_PropertiesLoaderUtils.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.springframework.core.io.support; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.net.URLConnection; -import java.util.Enumeration; -import java.util.Properties; - -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; - -import org.springframework.core.io.Resource; -import org.springframework.graalvm.substitutions.OnlyPresent; -import org.springframework.graalvm.substitutions.RemoveXmlSupport; -import org.springframework.lang.Nullable; -import org.springframework.util.Assert; -import org.springframework.util.ClassUtils; -import org.springframework.util.ResourceUtils; - -/** - * Substitution for PropertiesLoaderUtils in order to avoid XML parsers which increase artificially the image size and and the memory consumption. - * - * @author Sebastien Deleuze - * @see oracle/graal#2327 - */ -@TargetClass(className="org.springframework.core.io.support.PropertiesLoaderUtils", onlyWith = { OnlyPresent.class, RemoveXmlSupport.class }) -public final class Target_PropertiesLoaderUtils { - - @Substitute - public static void fillProperties(Properties props, Resource resource) throws IOException { - try (InputStream is = resource.getInputStream()) { - props.load(is); - } - } - - @Substitute - public static Properties loadAllProperties(String resourceName, @Nullable ClassLoader classLoader) throws IOException { - Assert.notNull(resourceName, "Resource name must not be null"); - ClassLoader classLoaderToUse = classLoader; - if (classLoaderToUse == null) { - classLoaderToUse = ClassUtils.getDefaultClassLoader(); - } - Enumeration urls = (classLoaderToUse != null ? classLoaderToUse.getResources(resourceName) : - ClassLoader.getSystemResources(resourceName)); - Properties props = new Properties(); - while (urls.hasMoreElements()) { - URL url = urls.nextElement(); - URLConnection con = url.openConnection(); - ResourceUtils.useCachesIfNecessary(con); - try (InputStream is = con.getInputStream()) { - props.load(is); - } - } - return props; - } - -} diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/core/io/support/Target_SpringFactoriesLoader.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/core/io/support/Target_SpringFactoriesLoader.java index de4741164..b08ce8726 100644 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/core/io/support/Target_SpringFactoriesLoader.java +++ b/spring-graalvm-native-substitutions/src/main/java/org/springframework/core/io/support/Target_SpringFactoriesLoader.java @@ -9,11 +9,11 @@ import org.apache.commons.logging.Log; import org.springframework.core.annotation.AnnotationAwareOrderComparator; -import org.springframework.graalvm.substitutions.OnlyPresent; +import org.springframework.graalvm.substitutions.OnlyIfPresent; import org.springframework.lang.Nullable; import org.springframework.util.Assert; -@TargetClass(className="org.springframework.core.io.support.SpringFactoriesLoader", onlyWith = { OnlyPresent.class }) +@TargetClass(className="org.springframework.core.io.support.SpringFactoriesLoader", onlyWith = { OnlyIfPresent.class }) final class Target_SpringFactoriesLoader { @Alias diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/data/mapping/context/Target_AbstractMappingContext.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/data/mapping/context/Target_AbstractMappingContext.java index fe970916d..4c4040eff 100644 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/data/mapping/context/Target_AbstractMappingContext.java +++ b/spring-graalvm-native-substitutions/src/main/java/org/springframework/data/mapping/context/Target_AbstractMappingContext.java @@ -21,10 +21,9 @@ import org.springframework.data.mapping.model.Target_BeanWrapperPropertyAccessorFactory; import org.springframework.data.spel.EvaluationContextProvider; import org.springframework.data.util.TypeInformation; -import org.springframework.graalvm.substitutions.OnlyPresent; -import org.springframework.graalvm.substitutions.RemoveCglibSupport; +import org.springframework.graalvm.substitutions.OnlyIfPresent; -@TargetClass(className = "org.springframework.data.mapping.context.AbstractMappingContext", onlyWith = { OnlyPresent.class, RemoveCglibSupport.class }) +@TargetClass(className = "org.springframework.data.mapping.context.AbstractMappingContext", onlyWith = { OnlyIfPresent.class }) final class Target_AbstractMappingContext, P extends PersistentProperty

> { @Alias diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/data/mapping/model/Target_BeanWrapperPropertyAccessorFactory.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/data/mapping/model/Target_BeanWrapperPropertyAccessorFactory.java index dfde771aa..fe0fcfe5e 100644 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/data/mapping/model/Target_BeanWrapperPropertyAccessorFactory.java +++ b/spring-graalvm-native-substitutions/src/main/java/org/springframework/data/mapping/model/Target_BeanWrapperPropertyAccessorFactory.java @@ -5,10 +5,9 @@ import org.springframework.data.mapping.PersistentEntity; import org.springframework.data.mapping.PersistentPropertyAccessor; -import org.springframework.graalvm.substitutions.OnlyPresent; -import org.springframework.graalvm.substitutions.RemoveCglibSupport; +import org.springframework.graalvm.substitutions.OnlyIfPresent; -@TargetClass(className = "org.springframework.data.mapping.model.BeanWrapperPropertyAccessorFactory", onlyWith = { OnlyPresent.class, RemoveCglibSupport.class }) +@TargetClass(className = "org.springframework.data.mapping.model.BeanWrapperPropertyAccessorFactory", onlyWith = { OnlyIfPresent.class }) public final class Target_BeanWrapperPropertyAccessorFactory implements PersistentPropertyAccessorFactory { @Alias diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/data/mapping/model/Target_ClassGeneratingEntityInstantiator.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/data/mapping/model/Target_ClassGeneratingEntityInstantiator.java index 848a46ba3..276f9a882 100644 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/data/mapping/model/Target_ClassGeneratingEntityInstantiator.java +++ b/spring-graalvm-native-substitutions/src/main/java/org/springframework/data/mapping/model/Target_ClassGeneratingEntityInstantiator.java @@ -6,10 +6,9 @@ import com.oracle.svm.core.annotate.TargetClass; import org.springframework.data.mapping.PersistentEntity; -import org.springframework.graalvm.substitutions.OnlyPresent; -import org.springframework.graalvm.substitutions.RemoveCglibSupport; +import org.springframework.graalvm.substitutions.OnlyIfPresent; -@TargetClass(className = "org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator", onlyWith = { OnlyPresent.class, RemoveCglibSupport.class }) +@TargetClass(className = "org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator", onlyWith = { OnlyIfPresent.class }) final class Target_ClassGeneratingEntityInstantiator { @Substitute diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/data/mapping/model/Target_ClassGeneratingPropertyAccessorFactory.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/data/mapping/model/Target_ClassGeneratingPropertyAccessorFactory.java index 457d5c141..cf41bfdd0 100644 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/data/mapping/model/Target_ClassGeneratingPropertyAccessorFactory.java +++ b/spring-graalvm-native-substitutions/src/main/java/org/springframework/data/mapping/model/Target_ClassGeneratingPropertyAccessorFactory.java @@ -4,10 +4,9 @@ import com.oracle.svm.core.annotate.Delete; import com.oracle.svm.core.annotate.TargetClass; -import org.springframework.graalvm.substitutions.OnlyPresent; -import org.springframework.graalvm.substitutions.RemoveCglibSupport; +import org.springframework.graalvm.substitutions.OnlyIfPresent; @Delete -@TargetClass(className = "org.springframework.data.mapping.model.ClassGeneratingPropertyAccessorFactory", onlyWith = { OnlyPresent.class, RemoveCglibSupport.class }) +@TargetClass(className = "org.springframework.data.mapping.model.ClassGeneratingPropertyAccessorFactory", onlyWith = { OnlyIfPresent.class }) final class Target_ClassGeneratingPropertyAccessorFactory { } diff --git a/spring-graalvm-native-substitutions/src/main/java/io/micrometer/core/instrument/binder/tomcat/CatalinaManagerPresent.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/graalvm/substitutions/CatalinaManagerIsAround.java similarity index 88% rename from spring-graalvm-native-substitutions/src/main/java/io/micrometer/core/instrument/binder/tomcat/CatalinaManagerPresent.java rename to spring-graalvm-native-substitutions/src/main/java/org/springframework/graalvm/substitutions/CatalinaManagerIsAround.java index 23ee9d2c9..395c805df 100644 --- a/spring-graalvm-native-substitutions/src/main/java/io/micrometer/core/instrument/binder/tomcat/CatalinaManagerPresent.java +++ b/spring-graalvm-native-substitutions/src/main/java/org/springframework/graalvm/substitutions/CatalinaManagerIsAround.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.micrometer.core.instrument.binder.tomcat; +package org.springframework.graalvm.substitutions; import java.util.function.BooleanSupplier; -public class CatalinaManagerPresent implements BooleanSupplier { +public class CatalinaManagerIsAround implements BooleanSupplier { @Override public boolean getAsBoolean() { diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/graalvm/substitutions/OnlyPresent.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/graalvm/substitutions/OnlyIfPresent.java similarity index 94% rename from spring-graalvm-native-substitutions/src/main/java/org/springframework/graalvm/substitutions/OnlyPresent.java rename to spring-graalvm-native-substitutions/src/main/java/org/springframework/graalvm/substitutions/OnlyIfPresent.java index 59ca61d7d..edbb654c3 100644 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/graalvm/substitutions/OnlyPresent.java +++ b/spring-graalvm-native-substitutions/src/main/java/org/springframework/graalvm/substitutions/OnlyIfPresent.java @@ -18,7 +18,7 @@ import java.util.function.Predicate; -public class OnlyPresent implements Predicate { +public class OnlyIfPresent implements Predicate { @Override public boolean test(String type) { diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/graalvm/substitutions/RemoveCglibSupport.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/graalvm/substitutions/RemoveCglibSupport.java deleted file mode 100644 index fe920c902..000000000 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/graalvm/substitutions/RemoveCglibSupport.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.springframework.graalvm.substitutions; - -import java.util.function.BooleanSupplier; - -public class RemoveCglibSupport implements BooleanSupplier { - - @Override - public boolean getAsBoolean() { - return Boolean.valueOf(System.getProperty("spring.native.remove-cglib-support", "true")); - } - -} diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/graalvm/substitutions/RemoveSpelSupport.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/graalvm/substitutions/RemoveSpelSupport.java deleted file mode 100644 index ccda17d77..000000000 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/graalvm/substitutions/RemoveSpelSupport.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.springframework.graalvm.substitutions; - -import java.util.function.BooleanSupplier; - -public class RemoveSpelSupport implements BooleanSupplier { - - @Override - public boolean getAsBoolean() { - return Boolean.valueOf(System.getProperty("spring.native.remove-spel-support", "false")); - } - -} diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/graalvm/substitutions/RemoveXmlSupport.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/graalvm/substitutions/RemoveXmlSupport.java index 999fa4153..3b9e8e92c 100644 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/graalvm/substitutions/RemoveXmlSupport.java +++ b/spring-graalvm-native-substitutions/src/main/java/org/springframework/graalvm/substitutions/RemoveXmlSupport.java @@ -6,7 +6,7 @@ public class RemoveXmlSupport implements BooleanSupplier { @Override public boolean getAsBoolean() { - return Boolean.valueOf(System.getProperty("spring.native.remove-xml-support", "false")); + return Boolean.valueOf(System.getProperty("spring.xml.ignore", "false")); } } diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/http/codec/support/Target_BaseDefaultCodecs.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/http/codec/support/Target_BaseDefaultCodecs.java deleted file mode 100644 index 8529dad3d..000000000 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/http/codec/support/Target_BaseDefaultCodecs.java +++ /dev/null @@ -1,184 +0,0 @@ -package org.springframework.http.codec.support; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; - -import org.springframework.core.codec.AbstractDataBufferDecoder; -import org.springframework.core.codec.Decoder; -import org.springframework.core.codec.Encoder; -import org.springframework.http.codec.DecoderHttpMessageReader; -import org.springframework.http.codec.EncoderHttpMessageWriter; -import org.springframework.http.codec.FormHttpMessageReader; -import org.springframework.http.codec.FormHttpMessageWriter; -import org.springframework.http.codec.HttpMessageReader; -import org.springframework.http.codec.HttpMessageWriter; -import org.springframework.http.codec.ServerSentEventHttpMessageReader; -import org.springframework.http.codec.json.AbstractJackson2Decoder; -import org.springframework.http.codec.json.Jackson2SmileDecoder; -import org.springframework.http.codec.json.Jackson2SmileEncoder; -import org.springframework.http.codec.multipart.MultipartHttpMessageReader; -import org.springframework.http.codec.multipart.MultipartHttpMessageWriter; -import org.springframework.http.codec.multipart.SynchronossPartHttpMessageReader; -import org.springframework.http.codec.protobuf.ProtobufDecoder; -import org.springframework.graalvm.substitutions.OnlyPresent; -import org.springframework.graalvm.substitutions.RemoveXmlSupport; -import org.springframework.lang.Nullable; - -@TargetClass(className = "org.springframework.http.codec.support.BaseDefaultCodecs", onlyWith = { OnlyPresent.class, RemoveXmlSupport.class }) -final class Target_BaseDefaultCodecs { - - @Alias - static boolean jackson2Present; - - @Alias - private static boolean jackson2SmilePresent; - - @Alias - private static boolean jaxb2Present; - - @Alias - private static boolean protobufPresent; - - @Alias - static boolean synchronossMultipartPresent; - - @Alias - private Integer maxInMemorySize; - - @Alias - private Boolean enableLoggingRequestDetails; - - @Alias - private Encoder jackson2SmileEncoder; - - @Alias - private boolean registerDefaults; - - @Alias - private Decoder jackson2SmileDecoder; - - @Substitute - private void initCodec(@Nullable Object codec) { - - if (codec instanceof DecoderHttpMessageReader) { - codec = ((DecoderHttpMessageReader) codec).getDecoder(); - } - - if (codec == null) { - return; - } - - Integer size = this.maxInMemorySize; - if (size != null) { - if (codec instanceof AbstractDataBufferDecoder) { - ((AbstractDataBufferDecoder) codec).setMaxInMemorySize(size); - } - if (protobufPresent) { - if (codec instanceof ProtobufDecoder) { - ((ProtobufDecoder) codec).setMaxMessageSize(size); - } - } - if (jackson2Present) { - if (codec instanceof AbstractJackson2Decoder) { - ((AbstractJackson2Decoder) codec).setMaxInMemorySize(size); - } - } - if (codec instanceof FormHttpMessageReader) { - ((FormHttpMessageReader) codec).setMaxInMemorySize(size); - } - if (codec instanceof ServerSentEventHttpMessageReader) { - ((ServerSentEventHttpMessageReader) codec).setMaxInMemorySize(size); - initCodec(((ServerSentEventHttpMessageReader) codec).getDecoder()); - } - if (synchronossMultipartPresent) { - if (codec instanceof SynchronossPartHttpMessageReader) { - ((SynchronossPartHttpMessageReader) codec).setMaxInMemorySize(size); - } - } - } - - Boolean enable = this.enableLoggingRequestDetails; - if (enable != null) { - if (codec instanceof FormHttpMessageReader) { - ((FormHttpMessageReader) codec).setEnableLoggingRequestDetails(enable); - } - if (codec instanceof MultipartHttpMessageReader) { - ((MultipartHttpMessageReader) codec).setEnableLoggingRequestDetails(enable); - } - if (synchronossMultipartPresent) { - if (codec instanceof SynchronossPartHttpMessageReader) { - ((SynchronossPartHttpMessageReader) codec).setEnableLoggingRequestDetails(enable); - } - } - if (codec instanceof FormHttpMessageWriter) { - ((FormHttpMessageWriter) codec).setEnableLoggingRequestDetails(enable); - } - if (codec instanceof MultipartHttpMessageWriter) { - ((MultipartHttpMessageWriter) codec).setEnableLoggingRequestDetails(enable); - } - } - - if (codec instanceof MultipartHttpMessageReader) { - initCodec(((MultipartHttpMessageReader) codec).getPartReader()); - } - else if (codec instanceof MultipartHttpMessageWriter) { - initCodec(((MultipartHttpMessageWriter) codec).getFormWriter()); - } - } - - @Substitute - final List> getObjectReaders() { - if (!this.registerDefaults) { - return Collections.emptyList(); - } - List> readers = new ArrayList<>(); - if (jackson2Present) { - addCodec(readers, new DecoderHttpMessageReader<>(getJackson2JsonDecoder())); - } - if (jackson2SmilePresent) { - addCodec(readers, new DecoderHttpMessageReader<>(this.jackson2SmileDecoder != null ? - (Jackson2SmileDecoder) this.jackson2SmileDecoder : new Jackson2SmileDecoder())); - } - - // client vs server.. - extendObjectReaders(readers); - - return readers; - } - - @Alias - protected void addCodec(List codecs, T codec) { - } - - @Alias - protected void extendObjectReaders(List> objectReaders) { - } - - @Substitute - final List> getBaseObjectWriters() { - List> writers = new ArrayList<>(); - if (jackson2Present) { - writers.add(new EncoderHttpMessageWriter<>(getJackson2JsonEncoder())); - } - if (jackson2SmilePresent) { - writers.add(new EncoderHttpMessageWriter<>(this.jackson2SmileEncoder != null ? - (Jackson2SmileEncoder) this.jackson2SmileEncoder : new Jackson2SmileEncoder())); - } - return writers; - } - - @Alias - protected Decoder getJackson2JsonDecoder() { - return null; - } - - @Alias - protected Encoder getJackson2JsonEncoder() { - return null; - } -} diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/orm/jpa/persistenceunit/Target_DefaultPersistenceUnitManager.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/orm/jpa/persistenceunit/Target_DefaultPersistenceUnitManager.java index 45c098e94..3e23fe6a5 100644 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/orm/jpa/persistenceunit/Target_DefaultPersistenceUnitManager.java +++ b/spring-graalvm-native-substitutions/src/main/java/org/springframework/orm/jpa/persistenceunit/Target_DefaultPersistenceUnitManager.java @@ -20,7 +20,7 @@ import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import org.springframework.graalvm.substitutions.OnlyPresent; +import org.springframework.graalvm.substitutions.OnlyIfPresent; /** * Workaround for @@ -44,7 +44,7 @@ * org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.determineDefaultPersistenceUnitRootUrl(DefaultPersistenceUnitManager.java:636) * @author Andy Clement */ -@TargetClass(className = "org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager", onlyWith = OnlyPresent.class) +@TargetClass(className = "org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager", onlyWith = OnlyIfPresent.class) public final class Target_DefaultPersistenceUnitManager { @Substitute diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/util/Target_DefaultPropertiesPersister.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/util/Target_DefaultPropertiesPersister.java deleted file mode 100644 index 63ebf60d2..000000000 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/util/Target_DefaultPropertiesPersister.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.springframework.util; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Properties; - -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; - -import org.springframework.graalvm.substitutions.OnlyPresent; -import org.springframework.graalvm.substitutions.RemoveXmlSupport; - -@TargetClass(className = "org.springframework.util.DefaultPropertiesPersister", onlyWith = { OnlyPresent.class, RemoveXmlSupport.class }) -final class Target_DefaultPropertiesPersister { - - @Substitute - public void loadFromXml(Properties props, InputStream is) throws IOException { - throw new UnsupportedOperationException("XML support disabled"); - } - - @Substitute - public void storeToXml(Properties props, OutputStream os, String header) throws IOException { - throw new UnsupportedOperationException("XML support disabled"); - } - - @Substitute - public void storeToXml(Properties props, OutputStream os, String header, String encoding) throws IOException { - throw new UnsupportedOperationException("XML support disabled"); - } -} diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/web/client/Target_RestTemplate.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/web/client/Target_RestTemplate.java deleted file mode 100644 index f99ac87c6..000000000 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/web/client/Target_RestTemplate.java +++ /dev/null @@ -1,126 +0,0 @@ -package org.springframework.web.client; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; - -import org.springframework.http.HttpHeaders; -import org.springframework.http.client.ClientHttpResponse; -import org.springframework.http.converter.ByteArrayHttpMessageConverter; -import org.springframework.http.converter.FormHttpMessageConverter; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.ResourceHttpMessageConverter; -import org.springframework.http.converter.StringHttpMessageConverter; -import org.springframework.http.converter.cbor.MappingJackson2CborHttpMessageConverter; -import org.springframework.http.converter.feed.AtomFeedHttpMessageConverter; -import org.springframework.http.converter.feed.RssChannelHttpMessageConverter; -import org.springframework.http.converter.json.GsonHttpMessageConverter; -import org.springframework.http.converter.json.JsonbHttpMessageConverter; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; -import org.springframework.http.converter.smile.MappingJackson2SmileHttpMessageConverter; -import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter; -import org.springframework.graalvm.substitutions.FormHttpMessageConverterIsAround; -import org.springframework.graalvm.substitutions.OnlyPresent; -import org.springframework.graalvm.substitutions.RemoveXmlSupport; -import org.springframework.web.util.DefaultUriBuilderFactory; -import org.springframework.web.util.UriTemplateHandler; - -@TargetClass(className = "org.springframework.web.client.RestTemplate", onlyWith = { OnlyPresent.class, FormHttpMessageConverterIsAround.class, RemoveXmlSupport.class }) -final class Target_RestTemplate { - - @Alias - private List> messageConverters; - - @Alias - private UriTemplateHandler uriTemplateHandler; - - @Alias - private static boolean romePresent; - - @Alias - private static boolean jaxb2Present; - - @Alias - private static boolean jackson2Present; - - @Alias - private static boolean jackson2XmlPresent; - - @Alias - private static boolean jackson2SmilePresent; - - @Alias - private static boolean jackson2CborPresent; - - @Alias - private static boolean gsonPresent; - - @Alias - private static boolean jsonbPresent; - - @Alias - private ResponseErrorHandler errorHandler; - - @Alias - private ResponseExtractor headersExtractor; - - - @Substitute - public Target_RestTemplate() { - this.messageConverters = new ArrayList<>(); - this.errorHandler = new DefaultResponseErrorHandler(); - this.headersExtractor = new Target_RestTemplate_HeadersExtractor(); - - this.messageConverters.add(new ByteArrayHttpMessageConverter()); - this.messageConverters.add(new StringHttpMessageConverter()); - this.messageConverters.add(new ResourceHttpMessageConverter(false)); - this.messageConverters.add(new FormHttpMessageConverter()); // Impossible to create a substitution for AllEncompassingFormHttpMessageConverter for now so we use that one - - if (romePresent) { - this.messageConverters.add(new AtomFeedHttpMessageConverter()); - this.messageConverters.add(new RssChannelHttpMessageConverter()); - } - - if (jackson2XmlPresent) { - this.messageConverters.add(new MappingJackson2XmlHttpMessageConverter()); - } - - if (jackson2Present) { - this.messageConverters.add(new MappingJackson2HttpMessageConverter()); - } - else if (gsonPresent) { - this.messageConverters.add(new GsonHttpMessageConverter()); - } - else if (jsonbPresent) { - this.messageConverters.add(new JsonbHttpMessageConverter()); - } - - if (jackson2SmilePresent) { - this.messageConverters.add(new MappingJackson2SmileHttpMessageConverter()); - } - if (jackson2CborPresent) { - this.messageConverters.add(new MappingJackson2CborHttpMessageConverter()); - } - - this.uriTemplateHandler = initUriTemplateHandler(); - } - - @Alias - private static DefaultUriBuilderFactory initUriTemplateHandler() { - return null; - } - -} - -@TargetClass(className = "org.springframework.web.client.RestTemplate", innerClass ="HeadersExtractor", onlyWith = { OnlyPresent.class, FormHttpMessageConverterIsAround.class, RemoveXmlSupport.class }) -final class Target_RestTemplate_HeadersExtractor implements ResponseExtractor { - - @Alias - public HttpHeaders extractData(ClientHttpResponse response) throws IOException { - return null; - } -} diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/web/filter/Target_FormContentFilter.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/web/filter/Target_FormContentFilter.java deleted file mode 100644 index c9e68aa16..000000000 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/web/filter/Target_FormContentFilter.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.springframework.web.filter; - -import java.util.HashSet; -import java.util.Set; - -import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.RecomputeFieldValue; -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.http.converter.FormHttpMessageConverter; -import org.springframework.graalvm.substitutions.FormHttpMessageConverterIsAround; -import org.springframework.graalvm.substitutions.OnlyPresent; -import org.springframework.graalvm.substitutions.RemoveXmlSupport; - -@TargetClass(className = "org.springframework.web.filter.FormContentFilter", onlyWith = { OnlyPresent.class, FormHttpMessageConverterIsAround.class, RemoveXmlSupport.class }) -final class Target_FormContentFilter { - - @Alias - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClass = HashSet.class, isFinal = true) - private Set requiredProperties; - - @Alias - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClass = Log.class, isFinal = true) - protected Log logger; - - @Alias - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClass = FormHttpMessageConverter.class) - private FormHttpMessageConverter formConverter; - - @Substitute - public Target_FormContentFilter() { - this.formConverter = new FormHttpMessageConverter(); - this.logger = LogFactory.getLog(getClass()); - this.requiredProperties = new HashSet<>(4); - } -} diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/web/servlet/Target_DispatcherServlet.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/web/servlet/Target_DispatcherServlet.java deleted file mode 100644 index 6cc10aca0..000000000 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/web/servlet/Target_DispatcherServlet.java +++ /dev/null @@ -1,348 +0,0 @@ -package org.springframework.web.servlet; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.function.Supplier; - -import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.RecomputeFieldValue; -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; -import org.apache.commons.logging.Log; - -import org.springframework.beans.factory.BeanFactoryUtils; -import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.GenericApplicationContext; -import org.springframework.core.annotation.AnnotationAwareOrderComparator; -import org.springframework.graalvm.substitutions.OnlyPresent; -import org.springframework.web.multipart.MultipartResolver; -import org.springframework.web.servlet.function.support.HandlerFunctionAdapter; -import org.springframework.web.servlet.function.support.RouterFunctionMapping; -import org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping; -import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver; -import org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter; -import org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter; -import org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver; -import org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver; -import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; -import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; -import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver; -import org.springframework.web.servlet.support.SessionFlashMapManager; -import org.springframework.web.servlet.theme.FixedThemeResolver; -import org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator; -import org.springframework.web.servlet.view.InternalResourceViewResolver; - -@TargetClass(className = "org.springframework.web.servlet.DispatcherServlet", onlyWith = { OnlyPresent.class }) -final class Target_DispatcherServlet { - - @Alias - protected Log logger; - - @Alias - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset, isFinal = true) - private static Properties defaultStrategies; - - @Alias - private MultipartResolver multipartResolver; - - @Alias - private LocaleResolver localeResolver; - - @Alias - private ThemeResolver themeResolver; - - @Alias - private List handlerMappings; - - @Alias - private List handlerAdapters; - - @Alias - private List handlerExceptionResolvers; - - @Alias - private RequestToViewNameTranslator viewNameTranslator; - - @Alias - private FlashMapManager flashMapManager; - - @Alias - private List viewResolvers; - - @Alias - private boolean detectAllHandlerMappings; - - @Alias - private boolean detectAllHandlerAdapters; - - @Alias - private boolean detectAllHandlerExceptionResolvers; - - @Alias - private boolean detectAllViewResolvers; - - @Alias - private boolean throwExceptionIfNoHandlerFound; - - @Alias - private boolean cleanupAfterInclude; - - - @Substitute - private void initMultipartResolver(ApplicationContext context) { - try { - this.multipartResolver = context.getBean("multipartResolver", MultipartResolver.class); - if (logger.isTraceEnabled()) { - logger.trace("Detected " + this.multipartResolver); - } - else if (logger.isDebugEnabled()) { - logger.debug("Detected " + this.multipartResolver.getClass().getSimpleName()); - } - } - catch (NoSuchBeanDefinitionException ex) { - // Default is no multipart resolver. - this.multipartResolver = null; - if (logger.isTraceEnabled()) { - logger.trace("No MultipartResolver multipartResolver declared"); - } - } - } - - @Substitute - private void initLocaleResolver(ApplicationContext context) { - try { - this.localeResolver = context.getBean("localeResolver", LocaleResolver.class); - if (logger.isTraceEnabled()) { - logger.trace("Detected " + this.localeResolver); - } - else if (logger.isDebugEnabled()) { - logger.debug("Detected " + this.localeResolver.getClass().getSimpleName()); - } - } - catch (NoSuchBeanDefinitionException ex) { - // We need to use the default. - ((GenericApplicationContext)context).registerBean("localeResolver", LocaleResolver.class, AcceptHeaderLocaleResolver::new); - this.localeResolver = context.getBean("localeResolver", LocaleResolver.class); - if (logger.isTraceEnabled()) { - logger.trace("No LocaleResolver 'localeResolver': using default [" + this.localeResolver.getClass().getSimpleName() + "]"); - } - } - } - - @Substitute - private void initThemeResolver(ApplicationContext context) { - try { - this.themeResolver = context.getBean("themeResolver", ThemeResolver.class); - if (logger.isTraceEnabled()) { - logger.trace("Detected " + this.themeResolver); - } - else if (logger.isDebugEnabled()) { - logger.debug("Detected " + this.themeResolver.getClass().getSimpleName()); - } - } - catch (NoSuchBeanDefinitionException ex) { - // We need to use the default. - ((GenericApplicationContext)context).registerBean("themeResolver", ThemeResolver.class, FixedThemeResolver::new); - this.themeResolver = context.getBean("themeResolver", ThemeResolver.class); - if (logger.isTraceEnabled()) { - logger.trace("No ThemeResolver 'themeResolver': using default [" + this.themeResolver.getClass().getSimpleName() + "]"); - } - } - } - - @Substitute - private void initHandlerMappings(ApplicationContext context) { - this.handlerMappings = null; - - if (this.detectAllHandlerMappings) { - // Find all HandlerMappings in the ApplicationContext, including ancestor contexts. - Map matchingBeans = - BeanFactoryUtils.beansOfTypeIncludingAncestors(context, HandlerMapping.class, true, false); - if (!matchingBeans.isEmpty()) { - this.handlerMappings = new ArrayList<>(matchingBeans.values()); - // We keep HandlerMappings in sorted order. - AnnotationAwareOrderComparator.sort(this.handlerMappings); - } - } - else { - try { - HandlerMapping hm = context.getBean("handlerMapping", HandlerMapping.class); - this.handlerMappings = Collections.singletonList(hm); - } - catch (NoSuchBeanDefinitionException ex) { - // Ignore, we'll add a default HandlerMapping later. - } - } - - // Ensure we have at least one HandlerMapping, by registering - // a default HandlerMapping if no other mappings are found. - if (this.handlerMappings == null) { - ((GenericApplicationContext)context).registerBean(HandlerMapping.class, BeanNameUrlHandlerMapping::new); - ((GenericApplicationContext)context).registerBean(HandlerMapping.class, RequestMappingHandlerMapping::new); - ((GenericApplicationContext)context).registerBean(HandlerMapping.class, (Supplier) RouterFunctionMapping::new); - this.handlerMappings = (List) context.getBeansOfType(HandlerMapping.class).values(); - if (logger.isTraceEnabled()) { - logger.trace("No HandlerMappings declared, using default strategies from DispatcherServlet.properties"); - } - } - } - - @Substitute - private void initHandlerAdapters(ApplicationContext context) { - this.handlerAdapters = null; - - if (this.detectAllHandlerAdapters) { - // Find all HandlerAdapters in the ApplicationContext, including ancestor contexts. - Map matchingBeans = - BeanFactoryUtils.beansOfTypeIncludingAncestors(context, HandlerAdapter.class, true, false); - if (!matchingBeans.isEmpty()) { - this.handlerAdapters = new ArrayList<>(matchingBeans.values()); - // We keep HandlerAdapters in sorted order. - AnnotationAwareOrderComparator.sort(this.handlerAdapters); - } - } - else { - try { - HandlerAdapter ha = context.getBean("handlerAdapter", HandlerAdapter.class); - this.handlerAdapters = Collections.singletonList(ha); - } - catch (NoSuchBeanDefinitionException ex) { - // Ignore, we'll add a default HandlerAdapter later. - } - } - - // Ensure we have at least some HandlerAdapters, by registering - // default HandlerAdapters if no other adapters are found. - if (this.handlerAdapters == null) { - ((GenericApplicationContext)context).registerBean(HandlerAdapter.class, HttpRequestHandlerAdapter::new); - ((GenericApplicationContext)context).registerBean(HandlerAdapter.class, SimpleControllerHandlerAdapter::new); - ((GenericApplicationContext)context).registerBean(HandlerAdapter.class, RequestMappingHandlerAdapter::new); - ((GenericApplicationContext)context).registerBean(HandlerAdapter.class, HandlerFunctionAdapter::new); - this.handlerAdapters = (List) context.getBeansOfType(HandlerAdapter.class).values(); - if (logger.isTraceEnabled()) { - logger.trace("No HandlerAdapters declared using default strategies from DispatcherServlet.properties"); - } - } - } - - @Substitute - private void initHandlerExceptionResolvers(ApplicationContext context) { - this.handlerExceptionResolvers = null; - - if (this.detectAllHandlerExceptionResolvers) { - // Find all HandlerExceptionResolvers in the ApplicationContext, including ancestor contexts. - Map matchingBeans = BeanFactoryUtils - .beansOfTypeIncludingAncestors(context, HandlerExceptionResolver.class, true, false); - if (!matchingBeans.isEmpty()) { - this.handlerExceptionResolvers = new ArrayList<>(matchingBeans.values()); - // We keep HandlerExceptionResolvers in sorted order. - AnnotationAwareOrderComparator.sort(this.handlerExceptionResolvers); - } - } - else { - try { - HandlerExceptionResolver her = - context.getBean("handlerExceptionResolver", HandlerExceptionResolver.class); - this.handlerExceptionResolvers = Collections.singletonList(her); - } - catch (NoSuchBeanDefinitionException ex) { - // Ignore, no HandlerExceptionResolver is fine too. - } - } - - // Ensure we have at least some HandlerExceptionResolvers, by registering - // default HandlerExceptionResolvers if no other resolvers are found. - if (this.handlerExceptionResolvers == null) { - ((GenericApplicationContext)context).registerBean(HandlerExceptionResolver.class, ExceptionHandlerExceptionResolver::new); - ((GenericApplicationContext)context).registerBean(HandlerExceptionResolver.class, ResponseStatusExceptionResolver::new); - ((GenericApplicationContext)context).registerBean(HandlerExceptionResolver.class, DefaultHandlerExceptionResolver::new); - this.handlerExceptionResolvers = (List) context.getBeansOfType(HandlerExceptionResolver.class).values(); - if (logger.isTraceEnabled()) { - logger.trace("No HandlerExceptionResolvers declared using default strategies from DispatcherServlet.properties"); - } - } - } - - @Substitute - private void initRequestToViewNameTranslator(ApplicationContext context) { - try { - this.viewNameTranslator = - context.getBean("viewNameTranslator", RequestToViewNameTranslator.class); - if (logger.isTraceEnabled()) { - logger.trace("Detected " + this.viewNameTranslator.getClass().getSimpleName()); - } - else if (logger.isDebugEnabled()) { - logger.debug("Detected " + this.viewNameTranslator); - } - } - catch (NoSuchBeanDefinitionException ex) { - // We need to use the default. - ((GenericApplicationContext)context).registerBean("viewNameTranslator", RequestToViewNameTranslator.class, DefaultRequestToViewNameTranslator::new); - this.viewNameTranslator = context.getBean("viewNameTranslator", RequestToViewNameTranslator.class); - if (logger.isTraceEnabled()) { - logger.trace("No RequestToViewNameTranslator 'viewNameTranslator': using default [" + this.viewNameTranslator.getClass().getSimpleName() + "]"); - } - } - } - - @Substitute - private void initViewResolvers(ApplicationContext context) { - this.viewResolvers = null; - - if (this.detectAllViewResolvers) { - // Find all ViewResolvers in the ApplicationContext, including ancestor contexts. - Map matchingBeans = - BeanFactoryUtils.beansOfTypeIncludingAncestors(context, ViewResolver.class, true, false); - if (!matchingBeans.isEmpty()) { - this.viewResolvers = new ArrayList<>(matchingBeans.values()); - // We keep ViewResolvers in sorted order. - AnnotationAwareOrderComparator.sort(this.viewResolvers); - } - } - else { - try { - ViewResolver vr = context.getBean("viewResolver", ViewResolver.class); - this.viewResolvers = Collections.singletonList(vr); - } - catch (NoSuchBeanDefinitionException ex) { - // Ignore, we'll add a default ViewResolver later. - } - } - - // Ensure we have at least one ViewResolver, by registering - // a default ViewResolver if no other resolvers are found. - if (this.viewResolvers == null) { - ((GenericApplicationContext)context).registerBean("viewResolver", ViewResolver.class, InternalResourceViewResolver::new); - this.viewResolvers = (List) context.getBeansOfType(ViewResolver.class).values(); - if (logger.isTraceEnabled()) { - logger.trace("No ViewResolvers declared using default strategies from DispatcherServlet.properties"); - } - } - } - - @Substitute - private void initFlashMapManager(ApplicationContext context) { - try { - this.flashMapManager = context.getBean("flashMapManager", FlashMapManager.class); - if (logger.isTraceEnabled()) { - logger.trace("Detected " + this.flashMapManager.getClass().getSimpleName()); - } - else if (logger.isDebugEnabled()) { - logger.debug("Detected " + this.flashMapManager); - } - } - catch (NoSuchBeanDefinitionException ex) { - // We need to use the default. - ((GenericApplicationContext)context).registerBean("flashMapManager", FlashMapManager.class, SessionFlashMapManager::new); - this.flashMapManager = context.getBean("flashMapManager", FlashMapManager.class); - if (logger.isTraceEnabled()) { - logger.trace("No FlashMapManager 'flashMapManager': using default [" + this.flashMapManager.getClass().getSimpleName() + "]"); - } - } - } - -} diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/web/servlet/config/annotation/Target_WebMvcConfigurationSupport.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/web/servlet/config/annotation/Target_WebMvcConfigurationSupport.java deleted file mode 100644 index 1ee9dc2fb..000000000 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/web/servlet/config/annotation/Target_WebMvcConfigurationSupport.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.springframework.web.servlet.config.annotation; - -import java.util.List; - -import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; - -import org.springframework.context.ApplicationContext; -import org.springframework.http.converter.ByteArrayHttpMessageConverter; -import org.springframework.http.converter.FormHttpMessageConverter; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.ResourceHttpMessageConverter; -import org.springframework.http.converter.ResourceRegionHttpMessageConverter; -import org.springframework.http.converter.StringHttpMessageConverter; -import org.springframework.http.converter.cbor.MappingJackson2CborHttpMessageConverter; -import org.springframework.http.converter.feed.AtomFeedHttpMessageConverter; -import org.springframework.http.converter.feed.RssChannelHttpMessageConverter; -import org.springframework.http.converter.json.GsonHttpMessageConverter; -import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; -import org.springframework.http.converter.json.JsonbHttpMessageConverter; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; -import org.springframework.http.converter.smile.MappingJackson2SmileHttpMessageConverter; -import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter; -import org.springframework.graalvm.substitutions.FormHttpMessageConverterIsAround; -import org.springframework.graalvm.substitutions.OnlyPresent; -import org.springframework.graalvm.substitutions.RemoveXmlSupport; - -@TargetClass(className = "org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport", onlyWith = { OnlyPresent.class, FormHttpMessageConverterIsAround.class, RemoveXmlSupport.class }) -final class Target_WebMvcConfigurationSupport { - - @Alias - private static boolean romePresent; - - @Alias - private static boolean jaxb2Present; - - @Alias - private static boolean jackson2Present; - - @Alias - private static boolean jackson2XmlPresent; - - @Alias - private static boolean jackson2SmilePresent; - - @Alias - private static boolean jackson2CborPresent; - - @Alias - private static boolean gsonPresent; - - @Alias - private static boolean jsonbPresent; - - @Alias - private ApplicationContext applicationContext; - - @Substitute - protected final void addDefaultHttpMessageConverters(List> messageConverters) { - messageConverters.add(new ByteArrayHttpMessageConverter()); - messageConverters.add(new StringHttpMessageConverter()); - messageConverters.add(new ResourceHttpMessageConverter()); - messageConverters.add(new ResourceRegionHttpMessageConverter()); - messageConverters.add(new FormHttpMessageConverter()); // Impossible to create a substitution for AllEncompassingFormHttpMessageConverter for now so we use that one - - if (romePresent) { - messageConverters.add(new AtomFeedHttpMessageConverter()); - messageConverters.add(new RssChannelHttpMessageConverter()); - } - - if (jackson2XmlPresent) { - Jackson2ObjectMapperBuilder builder = Jackson2ObjectMapperBuilder.xml(); - if (this.applicationContext != null) { - builder.applicationContext(this.applicationContext); - } - messageConverters.add(new MappingJackson2XmlHttpMessageConverter(builder.build())); - } - - if (jackson2Present) { - Jackson2ObjectMapperBuilder builder = Jackson2ObjectMapperBuilder.json(); - if (this.applicationContext != null) { - builder.applicationContext(this.applicationContext); - } - messageConverters.add(new MappingJackson2HttpMessageConverter(builder.build())); - } - else if (gsonPresent) { - messageConverters.add(new GsonHttpMessageConverter()); - } - else if (jsonbPresent) { - messageConverters.add(new JsonbHttpMessageConverter()); - } - - if (jackson2SmilePresent) { - Jackson2ObjectMapperBuilder builder = Jackson2ObjectMapperBuilder.smile(); - if (this.applicationContext != null) { - builder.applicationContext(this.applicationContext); - } - messageConverters.add(new MappingJackson2SmileHttpMessageConverter(builder.build())); - } - if (jackson2CborPresent) { - Jackson2ObjectMapperBuilder builder = Jackson2ObjectMapperBuilder.cbor(); - if (this.applicationContext != null) { - builder.applicationContext(this.applicationContext); - } - messageConverters.add(new MappingJackson2CborHttpMessageConverter(builder.build())); - } - } - -} \ No newline at end of file diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/web/servlet/function/support/Target_RouterFunctionMapping.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/web/servlet/function/support/Target_RouterFunctionMapping.java deleted file mode 100644 index d53db7e66..000000000 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/web/servlet/function/support/Target_RouterFunctionMapping.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.springframework.web.servlet.function.support; - -import java.util.ArrayList; -import java.util.List; - -import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; - -import org.springframework.http.converter.ByteArrayHttpMessageConverter; -import org.springframework.http.converter.FormHttpMessageConverter; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.StringHttpMessageConverter; -import org.springframework.graalvm.substitutions.FormHttpMessageConverterIsAround; -import org.springframework.graalvm.substitutions.OnlyPresent; -import org.springframework.graalvm.substitutions.RemoveXmlSupport; - -@TargetClass(className = "org.springframework.web.servlet.function.support.RouterFunctionMapping", onlyWith = { OnlyPresent.class, FormHttpMessageConverterIsAround.class, RemoveXmlSupport.class }) -final class Target_RouterFunctionMapping { - - @Alias - private List> messageConverters; - - @Substitute - private void initMessageConverters() { - List> messageConverters = new ArrayList<>(4); - messageConverters.add(new ByteArrayHttpMessageConverter()); - messageConverters.add(new StringHttpMessageConverter()); - messageConverters.add(new FormHttpMessageConverter()); // Impossible to create a substitution for AllEncompassingFormHttpMessageConverter for now so we use that one - - this.messageConverters = messageConverters; - } - -} diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/web/servlet/mvc/method/annotation/Target_ExceptionHandlerExceptionResolver.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/web/servlet/mvc/method/annotation/Target_ExceptionHandlerExceptionResolver.java deleted file mode 100644 index 0ed3bd711..000000000 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/web/servlet/mvc/method/annotation/Target_ExceptionHandlerExceptionResolver.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.springframework.web.servlet.mvc.method.annotation; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.RecomputeFieldValue; -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.http.converter.ByteArrayHttpMessageConverter; -import org.springframework.http.converter.FormHttpMessageConverter; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.StringHttpMessageConverter; -import org.springframework.graalvm.substitutions.FormHttpMessageConverterIsAround; -import org.springframework.graalvm.substitutions.OnlyPresent; -import org.springframework.graalvm.substitutions.RemoveXmlSupport; -import org.springframework.web.accept.ContentNegotiationManager; -import org.springframework.web.method.ControllerAdviceBean; -import org.springframework.web.method.annotation.ExceptionHandlerMethodResolver; - -@TargetClass(className = "org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver", onlyWith = { OnlyPresent.class, FormHttpMessageConverterIsAround.class, RemoveXmlSupport.class }) -final class Target_ExceptionHandlerExceptionResolver { - - @Alias - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClass = ArrayList.class) - private ContentNegotiationManager contentNegotiationManager; - - @Alias - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClass = ArrayList.class) - private List responseBodyAdvice; - - @Alias - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClass = ConcurrentHashMap.class) - private Map, ExceptionHandlerMethodResolver> exceptionHandlerCache; - - @Alias - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClass = LinkedHashMap.class) - private Map exceptionHandlerAdviceCache; - - @Alias - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClass = Log.class) - protected Log logger; - - @Alias - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClass = ArrayList.class) - private List> messageConverters; - - @Substitute - public Target_ExceptionHandlerExceptionResolver() { - this.messageConverters = new ArrayList<>(); - this.messageConverters.add(new ByteArrayHttpMessageConverter()); - this.messageConverters.add(new StringHttpMessageConverter()); - this.messageConverters.add(new FormHttpMessageConverter()); // Impossible to create a substitution for AllEncompassingFormHttpMessageConverter for now so we use that one - this.contentNegotiationManager = new ContentNegotiationManager(); - this.responseBodyAdvice = new ArrayList<>(); - this.exceptionHandlerCache = new ConcurrentHashMap<>(64); - this.exceptionHandlerAdviceCache = new LinkedHashMap<>(); - this.logger = LogFactory.getLog(getClass()); - } -} diff --git a/spring-graalvm-native-substitutions/src/main/java/org/springframework/web/servlet/mvc/method/annotation/Target_RequestMappingHandlerAdapter.java b/spring-graalvm-native-substitutions/src/main/java/org/springframework/web/servlet/mvc/method/annotation/Target_RequestMappingHandlerAdapter.java deleted file mode 100644 index abc9ff4f8..000000000 --- a/spring-graalvm-native-substitutions/src/main/java/org/springframework/web/servlet/mvc/method/annotation/Target_RequestMappingHandlerAdapter.java +++ /dev/null @@ -1,124 +0,0 @@ -package org.springframework.web.servlet.mvc.method.annotation; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.RecomputeFieldValue; -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.core.DefaultParameterNameDiscoverer; -import org.springframework.core.ParameterNameDiscoverer; -import org.springframework.core.ReactiveAdapterRegistry; -import org.springframework.core.task.AsyncTaskExecutor; -import org.springframework.core.task.SimpleAsyncTaskExecutor; -import org.springframework.http.converter.ByteArrayHttpMessageConverter; -import org.springframework.http.converter.FormHttpMessageConverter; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.StringHttpMessageConverter; -import org.springframework.graalvm.substitutions.FormHttpMessageConverterIsAround; -import org.springframework.graalvm.substitutions.OnlyPresent; -import org.springframework.graalvm.substitutions.RemoveXmlSupport; -import org.springframework.web.accept.ContentNegotiationManager; -import org.springframework.web.bind.support.DefaultSessionAttributeStore; -import org.springframework.web.bind.support.SessionAttributeStore; -import org.springframework.web.context.request.async.CallableProcessingInterceptor; -import org.springframework.web.context.request.async.DeferredResultProcessingInterceptor; -import org.springframework.web.method.ControllerAdviceBean; -import org.springframework.web.method.annotation.SessionAttributesHandler; - -@TargetClass(className = "org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter", onlyWith = { OnlyPresent.class, FormHttpMessageConverterIsAround.class, RemoveXmlSupport.class }) -final class Target_RequestMappingHandlerAdapter { - - @Alias - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClass = ArrayList.class) - private List> messageConverters; - - @Alias - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClass = ArrayList.class) - private List requestResponseBodyAdvice; - - @Alias - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClass = Log.class) - protected Log logger; - - @Alias - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, declClass = ContentNegotiationManager.class) - private ContentNegotiationManager contentNegotiationManager; - - @Alias - private AsyncTaskExecutor taskExecutor; - - @Alias - private CallableProcessingInterceptor[] callableInterceptors; - - @Alias - private DeferredResultProcessingInterceptor[] deferredResultInterceptors; - - @Alias - private ReactiveAdapterRegistry reactiveAdapterRegistry; - - @Alias - private boolean ignoreDefaultModelOnRedirect; - - @Alias - private int cacheSecondsForSessionAttributeHandlers; - - @Alias - private boolean synchronizeOnSession; - - @Alias - private SessionAttributeStore sessionAttributeStore; - - @Alias - private ParameterNameDiscoverer parameterNameDiscoverer; - - @Alias - private Map, SessionAttributesHandler> sessionAttributesHandlerCache; - - @Alias - private Map, Set> initBinderCache; - - @Alias - private Map> initBinderAdviceCache; - - @Alias - private Map, Set> modelAttributeCache; - - @Alias - private Map> modelAttributeAdviceCache; - - @Substitute - public Target_RequestMappingHandlerAdapter() { - this.requestResponseBodyAdvice = new ArrayList<>(); - this.messageConverters = new ArrayList<>(2); - this.messageConverters.add(new ByteArrayHttpMessageConverter()); - this.messageConverters.add(new StringHttpMessageConverter()); - this.messageConverters.add(new FormHttpMessageConverter()); // Impossible to create a substitution for AllEncompassingFormHttpMessageConverter for now so we use that one - this.logger = LogFactory.getLog(getClass()); - this.contentNegotiationManager = new ContentNegotiationManager(); - this.taskExecutor = new SimpleAsyncTaskExecutor("MvcAsync"); - this.callableInterceptors = new CallableProcessingInterceptor[0]; - this.deferredResultInterceptors = new DeferredResultProcessingInterceptor[0]; - this.reactiveAdapterRegistry = ReactiveAdapterRegistry.getSharedInstance(); - this.sessionAttributeStore = new DefaultSessionAttributeStore(); - this.parameterNameDiscoverer = new DefaultParameterNameDiscoverer(); - this.sessionAttributesHandlerCache = new ConcurrentHashMap<>(64); - this.ignoreDefaultModelOnRedirect = false; - this.cacheSecondsForSessionAttributeHandlers = 0; - this.synchronizeOnSession = false; - this.initBinderCache = new ConcurrentHashMap<>(64); - this.initBinderAdviceCache = new LinkedHashMap<>(); - this.modelAttributeCache = new ConcurrentHashMap<>(64); - this.modelAttributeAdviceCache = new LinkedHashMap<>(); - } - -} diff --git a/spring-graalvm-native-substitutions/src/main/java/org/w3c/dom/bootstrap/Target_DOMImplementationRegistryClasses.java b/spring-graalvm-native-substitutions/src/main/java/org/w3c/dom/bootstrap/Target_DOMImplementationRegistryClasses.java index 05c453b1b..8dc67dfcf 100644 --- a/spring-graalvm-native-substitutions/src/main/java/org/w3c/dom/bootstrap/Target_DOMImplementationRegistryClasses.java +++ b/spring-graalvm-native-substitutions/src/main/java/org/w3c/dom/bootstrap/Target_DOMImplementationRegistryClasses.java @@ -3,10 +3,10 @@ import com.oracle.svm.core.annotate.Delete; import com.oracle.svm.core.annotate.TargetClass; -import org.springframework.graalvm.substitutions.OnlyPresent; +import org.springframework.graalvm.substitutions.OnlyIfPresent; import org.springframework.graalvm.substitutions.RemoveXmlSupport; -@TargetClass(className = "org.w3c.dom.bootstrap.DOMImplementationRegistryClasses", onlyWith = { OnlyPresent.class, RemoveXmlSupport.class }) +@TargetClass(className = "org.w3c.dom.bootstrap.DOMImplementationRegistryClasses", onlyWith = { OnlyIfPresent.class, RemoveXmlSupport.class }) @Delete final class Target_DOMImplementationRegistryClasses { } \ No newline at end of file