spring-boot
spring-boot copied to clipboard
Take MethodType into account to deduce main application class
The change in https://github.com/spring-projects/spring-boot/pull/31828 is breaking a native image deployment as follows:
Exception in thread "main" java.lang.UnsupportedOperationException
at java.lang.StackWalker$StackFrame.getMethodType(StackWalker.java:148)
at org.springframework.boot.SpringApplication.lambda$findMainClass$1(SpringApplication.java:290)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
at com.oracle.svm.core.jdk.Target_java_lang_StackWalker$AbstractStackFrameSpliterator.tryAdvance(Target_java_lang_StackWalker.java:220)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:647)
at org.springframework.boot.SpringApplication.findMainClass(SpringApplication.java:290)
at java.lang.StackWalker.walk(StackWalker.java:167)
at org.springframework.boot.SpringApplication.deduceMainApplicationClass(SpringApplication.java:283)
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:279)
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:256)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1307)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1296)
at com.example.commandlinerunner.CommandlinerunnerApplication.main(CommandlinerunnerApplication.java:10)
This looks like that the getMethodType
method is not implemented in GraalVM native-image or its configuration differs from the JVM. The JavaDoc on the method says:
@throws UnsupportedOperationException if this StackWalker is not configured with Option#RETAIN_CLASS_REFERENCE.
I've opened an issue on GraalVM side: https://github.com/oracle/graal/issues/4755
Once the issue is fixed, we can reconsider reinstantiating https://github.com/spring-projects/spring-boot/pull/31828
I'm going to move this out into 3.x. We need a fix in Graal which may not be available in time for 3.0.x and, even if it is, it may then have an impact on our minimum supported version of Graal. I think we'd be better tackling this once the fix is available and we know what effect that will have on our version requirements.