netbeans: Profiler does not work on Apple Silicon
Apache NetBeans version
Apache NetBeans 14
What happened
Profiler cannot start on Apple Silicon. The first time it tries to start, it needs to run a calibration. For this, the console displays that Netbeans is running the following command:
/Library/Java/JavaVirtualMachines/jdk-18.0.2.1.jdk/Contents/Home/bin/java -agentpath:/Applications/NetBeans/Apache NetBeans 14.app/Contents/Resources/NetBeans/netbeans/profiler/lib/deployed/jdk16/mac/libprofilerinterface.jnilib -Xbootclasspath/a:/Applications/NetBeans/Apache NetBeans 14.app/Contents/Resources/NetBeans/netbeans/profiler/lib/jfluid-server.jar:/Applications/NetBeans/Apache NetBeans 14.app/Contents/Resources/NetBeans/netbeans/profiler/lib/jfluid-server-15.jar org.netbeans.lib.profiler.server.ProfilerServer /Applications/NetBeans/Apache NetBeans 14.app/Contents/Resources/NetBeans/netbeans/profiler/lib/deployed/jdk16/mac 5141 10 ____Profiler+Calibration+Run____
And hungs there forever.
Trying to run that command manually on the command line reveals that the command fails with the following error:
Error occurred during initialization of VM Could not find agent library /Applications/NetBeans/Apache NetBeans 14.app/Contents/Resources/NetBeans/netbeans/profiler/lib/deployed/jdk16/mac/libprofilerinterface.jnilib in absolute path, with error: dlopen(/Applications/NetBeans/Apache NetBeans 14.app/Contents/Resources/NetBeans/netbeans/profiler/lib/deployed/jdk16/mac/libprofilerinterface.jnilib, 0x0001): tried: '/Applications/NetBeans/Apache NetBeans 14.app/Contents/Resources/NetBeans/netbeans/profiler/lib/deployed/jdk16/mac/libprofilerinterface.jnilib' (fat file, but missing compatible architecture (have 'unknown,i386,unknown,x86_64', need 'arm64e')), '/usr/lib/libprofilerinterface.jnilib' (no such file)
So, it seems that the “libprofilerinterface.jnilib” file is only provided for intel processors, but not for Arm, and hence it cannot be run on Apple Silicon. I wonder if there is any way to generate an Apple Silicon version of this file.
How to reproduce
Just try to profile any Java project, and this will occur.
Did this work correctly in an earlier version?
No / Don’t know
Operating System
MacOS 12.2 Monterey on Apple Silicon
JDK
java 18.0.2.1 2022-08-18
Apache NetBeans packaging
Apache NetBeans provided installer
Anything else
This problem occurs every time.
Are you willing to submit a pull request?
Yes
Code of Conduct
Yes
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 7
- Comments: 18 (8 by maintainers)
Should be fixed in NB20. A release candidate should be available next week. Please help testing that.
Ok, may be it’s time to give something back. Fixing the profiler is pretty easy, but I have no clue how to make a push request.
So here it comes: The profiler lib is build by a shell script: netbeans/profiler/lib.profiler/native/scripts/buildnative-mac.sh
This file seems to be a little bit too old. The author didn’t know at that time how to build a universal library for arm64 and x86_64. The build produces a library with support for i386, ppc, ppc64 and x86_64. Because Apple drop the support for ppc and i386 we should not longer support them (no chance to update the code).
As a result we can focus on building a library for x86_64 and arm64. This is what I have done. I tested the library with NB19 with success (even if I am not totally clear why there is a jdk16 dependency…).
New build file is attached. If someone would be so kind to integrate that into the right repository it would be fixed for the next build. Even better would be of course if someone with more knowledge checks if the jdk15/jdk16 thing is still ok.
Here is the build file: buildnative-mac.sh.zip