Open credmond opened 3 months ago
Thank you for reaching out about this, we'll take a look into it shortly
Hey -- any thoughts / insights on this?
Is it intentional for some reason, or a bug, do we think?
We have assigned it to @pejovica last week and waiting for his analysis.
We have had problems like this before, and thought we had fixed them - so I assume this is a bug, but let's wait for Alex' analysis. The curious difference in this case is that it is a non-M1 Mac, maybe we missed that case?
Hi -- any updates on this?
Can you reproduce or do you want any additional info from me / my setup?
Describe the issue As per title, on MacOs, calling System.getProperty("os.arch") returns x86_64 when running the application in the JVM, and then returns "amd64" from the native image.
Why does this matter?
Because many JAR libraries ship with their own .dylib/.dll/.so native libraries (for win, linux, darwin, etc...), etc. These libraries, in determining which native library to load, will consult System.getProperty("os.arch") and use its return value to form part of the path.
E.g., /darwin/x86_64/something.dylib vs. /darwin/amd64/something.dylib (i.e., the latter does not exist in any library).
For macOs, the correct arch should be x86_64 for non-M1, which this is.
At the very least, the native image should surely behave the same, not differently, as running the .class in the same GraalVM JVM.
This causes unusual and unexpected errors or behaviour. Many libraries will have less-efficient fallback classes if the library fails to load, and won't even tell you about it. In that case, it's impossible to use the tracing agent to trace the code paths, when the code paths are different because os.arch drives different choices for a tracing agent run versus native image run. This leads you to believe you have bad reflection config (unless you dive in and find out the real root cause).
Other libraries without such fallbacks fail immediately.
Two examples of such libraries with this loading behaviour:
Steps to reproduce the issue
On macOs, run this as a .class, then as a native image, and observe the difference.
Describe GraalVM and your environment: