spring-shell
spring-shell copied to clipboard
Shell Table does not work in Native Compilation
trafficstars
Software:
- Spring Boot: 3.4.0
- Spring Shell: 3.4.0
- GraalVM: graalvm-jdk-23.0.1+11.1
- Java: 21
What I’m doing:
Creating a Spring Shell application and compiling it in native mode. The commands must print a Shell Table with a DTO.
package com.reproducer.shell.model;
import java.util.Objects;
public class SampleDTO {
private String name;
private String surname;
/**
* @return the name
*/
public String getName() {
return this.name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the surname
*/
public String getSurname() {
return this.surname;
}
/**
* @param surname the surname to set
*/
public void setSurname(String surname) {
this.surname = surname;
}
/**
* @param name
* @param surname
*/
public SampleDTO(String name, String surname) {
this.name = name;
this.surname = surname;
}
/**
*
*/
public SampleDTO() {}
@Override
public int hashCode() {
return Objects.hash(this.name, this.surname);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!(obj instanceof SampleDTO other))
return false;
return Objects.equals(this.name, other.name) && Objects.equals(this.surname, other.surname);
}
@Override
public String toString() {
return "SampleDTO [name=" + this.name + ", surname=" + this.surname + "]";
}
}
Behavior:
- JVM Scenario:
When compiling the Java application into a jar and running it, the framework correctly prints the table.
- Native Scenario:
When compiling the Java application into an executable (I’m using macOS Sonoma Version 14.7.1), running the command to print the Shell Table causes the application to throw an exception.