sshtools / maverick-synergy

Next Generation Java SSH API
https://jadaptive.com
GNU Lesser General Public License v3.0
96 stars 26 forks source link

Crash issue with GraalVM #93

Open stef-pellegrino opened 6 months ago

stef-pellegrino commented 6 months ago

The "Port forwarding" sample does not work with this configuration:

Works perfectly with fat .jar (JVM), but crashes badly when compiling against "native-image"

brett-smith commented 1 month ago

Synergy has a few features that are currently using reflection. This means those particular features will not work with native image without some extra meta-data.

You can either run the example once with the native image tracing agent enabled, or you can hand-craft a META-INF/native-image/synergy/reflect-config.json resource and bundle it inside your jar before native compilation.

I just gave the example a quick try, and can confirm this is needed in this case. Add the following to reflect-config.json.

[
{
  "name":"com.sshtools.common.events.EventCodes",
  "allPublicFields":true
},
{
  "name":"com.sshtools.common.forwarding.ForwardingPolicy",
  "methods":[{"name":"<init>","parameterTypes":[] }]
},
{
  "name":"com.sshtools.common.permissions.IPPolicy",
  "methods":[{"name":"<init>","parameterTypes":[] }]
},
{
  "name":"com.sshtools.common.policy.AuthenticationPolicy",
  "methods":[{"name":"<init>","parameterTypes":[] }]
},
{
  "name":"com.sshtools.common.policy.FileSystemPolicy",
  "methods":[{"name":"<init>","parameterTypes":[] }]
},
{
  "name":"com.sshtools.common.publickey.bc.OpenSSHPrivateKeyFileBC"
},
{
  "name":"com.sshtools.common.shell.ShellPolicy",
  "methods":[{"name":"<init>","parameterTypes":[] }]
}
]