osx-cross / homebrew-stm32

STM32 Casks & Formulae (not official)
BSD 2-Clause "Simplified" License
15 stars 3 forks source link

Latest OpenJDK 16 doesn't appear to work with STM32CubeMX #3

Closed tuna-f1sh closed 3 years ago

tuna-f1sh commented 3 years ago

Homebrew updated adoptopenjdk to version 16 recently and STM32CubeMX failed to launch for me after this:

Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError
    at com.thoughtworks.xstream.XStream.setupConverters(XStream.java:990)
    at com.thoughtworks.xstream.XStream.<init>(XStream.java:593)
    at com.thoughtworks.xstream.XStream.<init>(XStream.java:515)
    at com.thoughtworks.xstream.XStream.<init>(XStream.java:484)
    at com.thoughtworks.xstream.XStream.<init>(XStream.java:430)
    at com.thoughtworks.xstream.XStream.<init>(XStream.java:397)
    at com.st.library.rawvaluescontainer.FilesUtils.<clinit>(FilesUtils.java:41)
    at com.st.library.analyticscore.AnalyticsContext.<init>(AnalyticsContext.java:167)
    at com.st.library.dynamicproxy.AnalyticsInvocationHandler.<init>(AnalyticsInvocationHandler.java:36)
    at com.st.library.builder.AnalyticsBuilder.getAnalytics(AnalyticsBuilder.java:33)
    at com.st.library.analyticscore.AnalyticsAPI.initialize(AnalyticsAPI.java:142)
    at com.st.microxplorer.plugins.analytics.AnalyticsPlugin.<init>(AnalyticsPlugin.java:187)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:78)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
    at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128)
    at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:350)
    at java.base/java.lang.Class.newInstance(Class.java:642)
    at com.st.microxplorer.plugin.PluginManage.loadPluginJar(PluginManage.java:335)
    at com.st.microxplorer.plugin.PluginManage.PluginSearch(PluginManage.java:206)
    at com.st.microxplorer.plugin.PluginManage.PluginDiscovery(PluginManage.java:49)
    at com.st.microxplorer.maingui.MainPanel.initialization(MainPanel.java:237)
    at com.st.microxplorer.maingui.MainFrame.initialization(MainFrame.java:149)
    at com.st.microxplorer.maingui.MicroXplorer.run(MicroXplorer.java:227)
    at com.st.microxplorer.maingui.STM32CubeMX.run(STM32CubeMX.java:25)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:316)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not "opens java.util" to unnamed module @7c5e9755
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
    at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:177)
    at java.base/java.lang.reflect.Field.setAccessible(Field.java:171)
    at com.thoughtworks.xstream.core.util.Fields.locate(Fields.java:40)
    at com.thoughtworks.xstream.converters.collections.TreeMapConverter.<clinit>(TreeMapConverter.java:50)

Rolling back to OpenJDK 15 fixed this for me:

brew tap AdoptOpenJDK/openjdk
brew uninstall --cask adoptopenjdk
brew install --cask adoptopenjdk15

Not sure if the STM32CubeMX cask is out of date or if OpenJDK15 needs to be specified moving forwards.

ladislas commented 3 years ago

Thanks for reporting. I'll fix that asap

ladislas commented 3 years ago

@tuna-f1sh can you test https://github.com/osx-cross/homebrew-stm32/pull/4 and let me know if it works for you?

it seems to be working on mine with OpenJDK 16 but I'd love to have confirmation :)

tuna-f1sh commented 3 years ago

Trying to test it but keep getting error on uninstall:

Error: osx-cross/stm32/stm32cubemx: Failure while executing; `java -jar \#\{Utils.cubemx_final_app_path\}/Contents/Resources/Uninstaller/uninstaller.jar` exited with 1. Here's the output:
Error: Unable to access jarfile #{Utils.cubemx_final_app_path}/Contents/Resources/Uninstaller/uninstaller.jar

Running that script (with '/Applications/STMicroelectronics/STM32CubeMX.app') works but I can't get brew to ignore it? Even editing the 6.2.0 cask doesn't work, it seems to call that line from a cached cask? Sorry, I'm not that familiar with the inner workings of Homebrew.

ladislas commented 3 years ago

I've updated the cask with cubemx 6.2.0. I've also added caveats information about the need to have openjdk15 and not 16.

The cask depends on openjdk15 but if people have both installed, it will use 16 and won't work.

Also, the STM32CubeMX.app doesn't want to open on my mac, but using stm32cubemx from the command line works, I don't know why 🙄

tuna-f1sh commented 3 years ago

Thanks. Just a further note on this. I don't think OpenJDK 16 has to uninstalled. I have both installed and the updated version works. Launching from Finder doesn't work for me either now though...

If you look at the shell script in the App package contents, this is because it is now calling OpenJDK 15 not the system installed one.

stm32cubemx.sh


#!/usr/bin/env bash
/Library/Java/JavaVirtualMachines/adoptopenjdk-15.jdk/Contents/Home/bin/java -jar /Applications/STMicroelectronics/STM32CubeMX.app/Contents/MacOS/STM32CubeMX $@
ladislas commented 3 years ago

ah yes you're right, I changed that script! I'll change the caveat to reflect that.

tuna-f1sh commented 3 years ago

Will you're at it, I fixed launching in finder. The jre symbolic link in the App package points to the wrong place. If I do this:

ln -s /usr/local/Caskroom/stm32cubemx/6.2.0/jre /Applications/STMicroelectronics/STM32CubeMX.app/Contents/MacOs/jre

It now launches

ladislas commented 3 years ago

I've added the fix to the formula, see 92fb1aa

ladislas commented 3 years ago

Thanks again for your help and for testing! :)