mgarin / weblaf

WebLaF is a fully open-source Look & Feel and component library written in pure Java for cross-platform desktop Swing applications.
http://weblookandfeel.com
GNU General Public License v3.0
1.15k stars 235 forks source link

JDK 12 support #525

Open mgarin opened 5 years ago

mgarin commented 5 years ago

WebLaF uses Reflection to access fields & methods to configure components and setup styles which is not fully allowed on JDK 12 anymore, at least by default. So there needs to be some sort of a solution for JDK 12+ that would allow running WebLaF.

mgarin commented 5 years ago

@macstrace investigated the Java 12 issues and found a decent solution, but we are still thinking about how we should proceed with implementing it and versioning overall because the solution involves some JDK9+ specific code and doesn't seem to correctly work through Reflection, so we can't inject it in a way similar to other proprietary utilities are used within WebLaF.

mgarin commented 5 years ago

Temporary fix for Java 12+ have been added into core module and will be available in v1.2.11 update. I'll keep this issue open until proper support is added.

mokun commented 4 years ago

When I run weblaf under Java 12 in win 10, I have the following stacktrace :

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.alee.utils.ReflectUtils (file:/D:/eclipse/eclipse-jee-2019-12-R-win32-x86_64/Git/mars-sim/mars-sim-main/target/m.jar) to method sun.font.FontUtilities.fontSupportsDefaultEncoding(java.awt.Font)
WARNING: Please consider reporting this to the maintainers of com.alee.utils.ReflectUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
00-Adir-01:000.799 (Warning) MainWindow : Could not load system look&feel
com.alee.managers.style.StyleException: Unable to setup component UI: com.alee.managers.glasspane.WebGlassPane[,0,0,0x0,invalid,layout=com.alee.extended.layout.MultiLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]
        at com.alee.managers.style.AbstractComponentDescriptor.updateUI(AbstractComponentDescriptor.java:308)
        at com.alee.laf.panel.WebPanel.updateUI(WebPanel.java:1045)
        at java.desktop/javax.swing.JPanel.<init>(JPanel.java:86)
        at java.desktop/javax.swing.JPanel.<init>(JPanel.java:95)
        at com.alee.laf.panel.WebPanel.<init>(WebPanel.java:121)
        at com.alee.managers.glasspane.WebGlassPane.<init>(WebGlassPane.java:98)
        at com.alee.laf.rootpane.WebRootPane.createGlassPane(WebRootPane.java:91)
        at java.desktop/javax.swing.JRootPane.<init>(JRootPane.java:348)
        at com.alee.laf.rootpane.WebRootPane.<init>(WebRootPane.java:75)
        at com.alee.laf.window.WebFrame$WebFrameRootPane.<init>(WebFrame.java:807)
        at com.alee.laf.window.WebFrame.createRootPane(WebFrame.java:227)
        at com.alee.laf.window.WebFrame.initialize(WebFrame.java:185)
        at com.alee.laf.window.WebFrame.<init>(WebFrame.java:165)
        at com.alee.laf.window.WebFrame.<init>(WebFrame.java:150)
        at com.alee.laf.window.WebFrame.<init>(WebFrame.java:125)
        at com.alee.laf.window.WebFrame.<init>(WebFrame.java:78)

Is the method sun.font.FontUtilities.fontSupportsDefaultEncoding called internally by java.awt.Font or com.alee.utils.ReflectUtils ?

mgarin commented 4 years ago

That and a dozen of other proprietary stuff gets called by WebLaF. Unfortunately it's not possible to workaround that (in WebLaF at least) unless Oracle opens up some private stuff or makes a decent API for things like fonts, UIs, windows, etc, which most probably isn't happening.

I recommend reading this section on the README.md: https://github.com/mgarin/weblaf#java-9 It lists all the settings you need to provide for JVM to avoid these issues.

mgarin commented 4 years ago

Although normally it shouldn't fail with an exception - only display a warning. Unless your JVM is explicitly setup to block unauthorized reflective access.

mokun commented 4 years ago

--EDITED--

I just added the following JVM options :

--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.text=ALL-UNNAMED
--add-opens java.base/java.lang.reflect=ALL-UNNAMED
--add-opens java.base/java.net=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/jdk.internal.loader=ALL-UNNAMED
--add-opens java.desktop/javax.swing=ALL-UNNAMED
--add-opens java.desktop/javax.swing.text=ALL-UNNAMED
--add-opens java.desktop/java.awt.font=ALL-UNNAMED
--add-opens java.desktop/java.awt.geom=ALL-UNNAMED
--add-opens java.desktop/java.awt=ALL-UNNAMED
--add-opens java.desktop/java.beans=ALL-UNNAMED
--add-opens java.desktop/javax.swing.table=ALL-UNNAMED
--add-opens java.desktop/com.sun.awt=ALL-UNNAMED
--add-opens java.desktop/sun.awt=ALL-UNNAMED
--add-opens java.desktop/sun.swing=ALL-UNNAMED
--add-opens java.desktop/sun.font=ALL-UNNAMED
--add-opens java.desktop/javax.swing.plaf.basic=ALL-UNNAMED
--add-opens java.desktop/javax.swing.plaf.synth=ALL-UNNAMED
--add-opens java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED
--add-opens java.desktop/com.sun.java.swing.plaf.gtk=ALL-UNNAMED
--add-opens java.desktop/com.apple.laf=ALL-UNNAMED

I still cannot load the JFrame in my SimulationConfigEditor as follows :

2020-01-22T12:24:05.6 (Warning) SimulationConfigEditor : Could not load system look&feel
Exception in thread "AWT-EventQueue-0" com.alee.managers.style.StyleException: StyleManager wasn't able to initialize default skin
        at com.alee.managers.style.StyleManager.getSkin(StyleManager.java:950)
        at com.alee.managers.style.StyleData.install(StyleData.java:124)
        at com.alee.managers.style.StyleManager.installSkin(StyleManager.java:1198)
        at com.alee.laf.panel.WebPanelUI.installUI(WebPanelUI.java:57)
        at java.desktop/javax.swing.JComponent.setUI(JComponent.java:685)
        at java.desktop/javax.swing.JPanel.setUI(JPanel.java:150)
        at java.desktop/javax.swing.JPanel.updateUI(JPanel.java:126)
        at java.desktop/javax.swing.JPanel.<init>(JPanel.java:86)
        at java.desktop/javax.swing.JPanel.<init>(JPanel.java:109)
        at java.desktop/javax.swing.JPanel.<init>(JPanel.java:117)
        at java.desktop/javax.swing.JRootPane.createGlassPane(JRootPane.java:521)
        at java.desktop/javax.swing.JRootPane.<init>(JRootPane.java:348)
        at java.desktop/javax.swing.JFrame.createRootPane(JFrame.java:279)
        at java.desktop/javax.swing.JFrame.frameInit(JFrame.java:258)
        at java.desktop/javax.swing.JFrame.<init>(JFrame.java:181)
        at org.mars_sim.msp.ui.swing.configeditor.SimulationConfigEditor.<init>(SimulationConfigEditor.java:140)
        at org.mars_sim.main.MarsProject.lambda$handleNewSimulation$0(MarsProject.java:466)
        at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
        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:389)
        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)

And I cannot load the WebFrame in MainWindow below :

00-Adir-01:000.153 (Config) MainWindow : width : 1366    height : 768
00-Adir-01:000.697 (Warning) MainWindow : Could not load system look&feel
com.alee.managers.style.StyleException: Unable to setup component UI: com.alee.managers.glasspane.WebGlassPane[,0,0,0x0,invalid,layout=com.alee.extended.layout.MultiLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]
        at com.alee.managers.style.AbstractComponentDescriptor.updateUI(AbstractComponentDescriptor.java:308)
        at com.alee.laf.panel.WebPanel.updateUI(WebPanel.java:1045)
        at java.desktop/javax.swing.JPanel.<init>(JPanel.java:86)
        at java.desktop/javax.swing.JPanel.<init>(JPanel.java:95)
        at com.alee.laf.panel.WebPanel.<init>(WebPanel.java:121)
        at com.alee.managers.glasspane.WebGlassPane.<init>(WebGlassPane.java:98)
        at com.alee.laf.rootpane.WebRootPane.createGlassPane(WebRootPane.java:91)
        at java.desktop/javax.swing.JRootPane.<init>(JRootPane.java:348)
        at com.alee.laf.rootpane.WebRootPane.<init>(WebRootPane.java:75)
        at com.alee.laf.window.WebFrame$WebFrameRootPane.<init>(WebFrame.java:807)
        at com.alee.laf.window.WebFrame.createRootPane(WebFrame.java:227)
        at com.alee.laf.window.WebFrame.initialize(WebFrame.java:185)
        at com.alee.laf.window.WebFrame.<init>(WebFrame.java:165)
        at com.alee.laf.window.WebFrame.<init>(WebFrame.java:150)
        at com.alee.laf.window.WebFrame.<init>(WebFrame.java:125)
        at com.alee.laf.window.WebFrame.<init>(WebFrame.java:78)
        at org.mars_sim.msp.ui.swing.MainWindow.<init>(MainWindow.java:182)
        at org.mars_sim.main.MarsProject.setupMainWindow(MarsProject.java:409)
        at org.mars_sim.main.MarsProject.handleNewSimulation(MarsProject.java:456)
        at org.mars_sim.main.MarsProject.initializeSimulation(MarsProject.java:189)
        at org.mars_sim.main.MarsProject$SimulationTask.run(MarsProject.java:162)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:835)
Caused by: com.alee.managers.style.StyleException: Unable to setup component UI: com.alee.managers.glasspane.WebGlassPane[,0,0,0x0,invalid,layout=com.alee.extended.layout.MultiLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]
        at com.alee.utils.LafUtils.setUI(LafUtils.java:113)
        at com.alee.managers.style.AbstractComponentDescriptor.updateUI(AbstractComponentDescriptor.java:303)
        ... 25 more
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:567)
        at com.alee.utils.ReflectUtils.callMethod(ReflectUtils.java:1635)
        at com.alee.utils.LafUtils.setUI(LafUtils.java:109)
        ... 26 more
Caused by: com.alee.managers.style.StyleException: StyleManager wasn't able to initialize default skin
        at com.alee.managers.style.StyleManager.getSkin(StyleManager.java:950)
        at com.alee.managers.style.StyleData.install(StyleData.java:124)
        at com.alee.managers.style.StyleManager.installSkin(StyleManager.java:1198)
        at com.alee.laf.panel.WebPanelUI.installUI(WebPanelUI.java:57)
        at java.desktop/javax.swing.JComponent.setUI(JComponent.java:685)
        at java.desktop/javax.swing.JPanel.setUI(JPanel.java:150)
        at com.alee.laf.panel.WebPanel.setUI(WebPanel.java:1039)
        ... 32 more
00-Adir-01:000.775 (Severe) MarsProject : Could not create a new simulation, startup cannot continue
mgarin commented 4 years ago

Could you provide a small sample code on which I can reproduce this? As I don't really get the same error by simply running a frame on Java 12+.

Here is a simple frame example I used:

public class Java12Sample
{
    public static void main ( String[] args )
    {
        SwingUtilities.invokeLater ( new Runnable ()
        {
            public void run ()
            {
                WebLookAndFeel.install ();

                JFrame frame = new JFrame ( "Test" );
                frame.add ( new JButton ( "Test" ) );
                frame.setSize ( 500, 500 );
                frame.setLocationRelativeTo ( null );
                frame.setVisible ( true );
            }
        } );
    }
}

Although note that I cannot really run this from WebLaF sources as it requires a workaround available in resulting weblaf-core JAR file. To be more specific - it uses multi-release jar feature to inject different FieldHelper class implementation for Java 12+ runtime. So you need that different version of the FieldHelper class if you're running WebLaF from sources, but only in that case. If you're using WebLaF through Maven or using release artifacts directly there should be no issues.

mgarin commented 4 years ago

Also according to the exceptions stack trace you provided - something is off with L&F/skin initialization. The errors you've shown are simply result of L&F/skin not being initialized properly, for whatever reason.

mokun commented 4 years ago

Yes I'm using its Maven dependency to load 1.2.22

        <dependency>
            <groupId>com.weblookandfeel</groupId>
            <artifactId>weblaf-ui</artifactId>        
            <version>1.2.12</version>
        </dependency>   
        <dependency>
            <groupId>com.weblookandfeel</groupId>
            <artifactId>weblaf-core</artifactId>       
            <version>1.2.12</version>
        </dependency>
        <dependency>
            <groupId>com.weblookandfeel</groupId>
            <artifactId>weblaf-plugin</artifactId>        
            <version>1.2.12</version>
        </dependency>

In case of SimulationConfigEditor, this is how I load weblaf in its constructor :

    public SimulationConfigEditor(SimulationConfig config, MainWindow mainWindow) {

        // Initialize data members.
        this.simulationConfig = config;
        settlementConfig = config.getSettlementConfiguration();
        personConfig = simulationConfig.getPersonConfig();

        hasError = false;

        try {
            // use the weblaf skin
            WebLookAndFeel.install();
            UIManagers.initialize();
        } catch (Exception ex) {
            logger.log(Level.WARNING, Msg.getString("MainWindow.log.lookAndFeelError"), ex); //$NON-NLS-1$
        }

        f = new JFrame();
        ...
    }
mgarin commented 4 years ago

Does the small example I've shown above work for you though? If not, can you provide a full log of exceptions you get with it?

mokun commented 4 years ago

I was looking at UIManager.initialize(). Could my try catch detect exception ?

/**
     * Initializes LaF UI managers.
     * This method should be performed on EDT like other Swing UI operations.
     * Initialization order is important and any changes should be performed with care.
     */
    public static synchronized void initialize ()
    {
        // Ensuring that operation is performed on EDT
        WebLookAndFeel.checkEventDispatchThread ();

        // Initializing managers
        XmlUtils.getXStream ();
        UILanguageManager.initialize ();
        UISettingsManager.initialize ();
        HotkeyManager.initialize ();
        FocusManager.initialize ();
        HoverManager.initialize ();
        TooltipManager.initialize ();
        IconManager.initialize ();
        StyleManager.initialize ();
        AnimationManager.initialize ();
        UIProxyManager.initialize ();
        DragManager.initialize ();
        TaskManager.initialize();
    }
mokun commented 4 years ago

Here's the full stacktrace when running SimulationConfigEditor right now without the try catch.

Note: SimulationConfigEditor is already inside EDT.


D:\eclipse\eclipse-jee-2019-12-R-win32-x86_64\Git\mars-sim\mars-sim-main\target>java -jar m.jar
Command: "C:\Program Files\BellSoft\LibericaJDK-12\bin\java" --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.text=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-opens java.desktop/javax.swing=ALL-UNNAMED --add-opens java.desktop/javax.swing.text=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED --add-opens java.desktop/java.awt.geom=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.desktop/java.beans=ALL-UNNAMED --add-opens java.desktop/javax.swing.table=ALL-UNNAMED --add-opens java.desktop/com.sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.swing=ALL-UNNAMED --add-opens java.desktop/sun.font=ALL-UNNAMED --add-opens java.desktop/javax.swing.plaf.basic=ALL-UNNAMED --add-opens java.desktop/javax.swing.plaf.synth=ALL-UNNAMED --add-opens java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED --add-opens java.desktop/com.sun.java.swing.plaf.gtk=ALL-UNNAMED --add-opens java.desktop/com.apple.laf=ALL-UNNAMED --illegal-access=deny -Djava.util.logging.config.file=logging.properties -cp .;*;jars\* org.mars_sim.main.MarsProject -Xms256m -Xmx1536m -new
WARNING: package com.sun.java.swing.plaf.gtk not in java.desktop
WARNING: package com.apple.laf not in java.desktop
WARNING: package com.sun.awt not in java.desktop
2020-01-22T19:26:47.9 (Config) MarsProject$SimulationTask : Starting Mars Simulation Project v3.1.0 - Build 5260 - 64-bit 12.0.2-BellSoft - 8 CPU threads
2020-01-22T19:26:48.0 (Config) MarsProject : Please proceed to selecting the type of Game Mode in the popped-up console.
2020-01-22T19:26:48.0 (Config) SimulationConfig : /xml folder already existed.
2020-01-22T19:26:48.0 (Config) SimulationConfig : Your version.txt already has the same BUILD 5260 as the core engine.
2020-01-22T19:26:48.4 (Config) SimulationConfig : Done loading all xml files.
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Unable to initialize LaF for class name: com.alee.laf.WebLookAndFeel
        at com.alee.utils.LafUtils.setupLookAndFeel(LafUtils.java:210)
        at com.alee.utils.LafUtils.setupLookAndFeel(LafUtils.java:193)
        at com.alee.laf.WebLookAndFeel.install(WebLookAndFeel.java:1108)
        at com.alee.laf.WebLookAndFeel.install(WebLookAndFeel.java:1087)
        at com.alee.laf.WebLookAndFeel.install(WebLookAndFeel.java:1075)
        at org.mars_sim.msp.ui.swing.configeditor.SimulationConfigEditor.<init>(SimulationConfigEditor.java:126)
        at org.mars_sim.main.MarsProject.lambda$handleNewSimulation$0(MarsProject.java:466)
        at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
        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:389)
        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: com.alee.utils.reflection.ReflectionException: Unable to instantiate skin for class: class com.alee.skin.light.WebLightSkin
        at com.alee.utils.reflection.LazyInstance.create(LazyInstance.java:79)
        at com.alee.managers.style.StyleManager.setSkin(StyleManager.java:1003)
        at com.alee.managers.style.StyleManager.initialize(StyleManager.java:271)
        at com.alee.managers.UIManagers.initialize(UIManagers.java:73)
        at com.alee.laf.WebLookAndFeel.initializeManagers(WebLookAndFeel.java:1065)
        at com.alee.laf.WebLookAndFeel.initialize(WebLookAndFeel.java:391)
        at java.desktop/javax.swing.UIManager.setLookAndFeel(UIManager.java:586)
        at java.desktop/javax.swing.UIManager.setLookAndFeel(UIManager.java:633)
        at com.alee.utils.LafUtils.setupLookAndFeel(LafUtils.java:206)
        ... 19 more
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
        at com.alee.utils.ReflectUtils.createInstance(ReflectUtils.java:1277)
        at com.alee.utils.reflection.LazyInstance.create(LazyInstance.java:74)
        ... 27 more
Caused by: com.thoughtworks.xstream.converters.ConversionException:
---- Debugging information ----
cause-exception     : com.alee.managers.style.StyleException
cause-message       : Unable to load icon set 'class com.alee.iconset.LightIconSet'
class               : com.alee.managers.style.data.SkinInfo
required-type       : com.alee.managers.style.data.SkinInfo
converter-type      : com.alee.managers.style.data.SkinInfoConverter
path                : /skin/iconSet
line number         : 15
version             : not available
-------------------------------
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:79)
        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
        at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
        at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1230)
        at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1214)
        at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1094)
        at com.alee.utils.XmlUtils.fromXML(XmlUtils.java:411)
        at com.alee.utils.XmlUtils.fromXML(XmlUtils.java:373)
        at com.alee.managers.style.XmlSkin.<init>(XmlSkin.java:58)
        at com.alee.skin.light.WebLightSkin.<init>(WebLightSkin.java:35)
        ... 34 more
Caused by: com.alee.managers.style.StyleException: Unable to load icon set 'class com.alee.iconset.LightIconSet'
        at com.alee.managers.style.data.SkinInfoConverter.readIconSet(SkinInfoConverter.java:360)
        at com.alee.managers.style.data.SkinInfoConverter.unmarshal(SkinInfoConverter.java:211)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
        ... 46 more
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
        at com.alee.utils.ReflectUtils.createInstance(ReflectUtils.java:1277)
        at com.alee.managers.style.data.SkinInfoConverter.readIconSet(SkinInfoConverter.java:355)
        ... 48 more
Caused by: com.thoughtworks.xstream.converters.ConversionException:
---- Debugging information ----
cause-exception     : com.alee.managers.icon.IconException
cause-message       : Unable to load XmlIconSet
class               : com.alee.managers.icon.set.XmlIconSet
required-type       : com.alee.managers.icon.set.XmlIconSet
converter-type      : com.alee.managers.icon.set.XmlIconSetConverter
path                : /IconSet
line number         : 1
version             : not available
-------------------------------
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:79)
        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
        at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
        at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1230)
        at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1214)
        at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1193)
        at com.alee.utils.XmlUtils.fromXML(XmlUtils.java:424)
        at com.alee.utils.XmlUtils.fromXML(XmlUtils.java:386)
        at com.alee.managers.icon.set.XmlIconSet.<init>(XmlIconSet.java:48)
        at com.alee.iconset.LightIconSet.<init>(LightIconSet.java:35)
        ... 55 more
Caused by: com.alee.managers.icon.IconException: Unable to load XmlIconSet
        at com.alee.managers.icon.set.XmlIconSetConverter.unmarshal(XmlIconSetConverter.java:98)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
        ... 67 more
Caused by: com.alee.utils.reflection.ReflectionException: Unable to update field modifiers: protected final java.lang.String com.alee.managers.icon.set.AbstractIconSet.id -> 4
        at com.alee.utils.reflection.FieldHelper.setFieldModifiers(FieldHelper.java:52)
        at com.alee.utils.ReflectUtils.setFieldValue(ReflectUtils.java:952)
        at com.alee.utils.ReflectUtils.setFieldValue(ReflectUtils.java:852)
        at com.alee.managers.icon.set.XmlIconSetConverter.unmarshal(XmlIconSetConverter.java:69)
        ... 68 more
mokun commented 4 years ago

Does the small example I've shown above work for you though? If not, can you provide a full log of exceptions you get with it?

I should add that I have no problem running SimulationConfigEditor and MainWindow within my eclipse IDE in Java 12.

So somehow by running the main class using the eclipse launcher inside Eclipse IDE avoid those reflection errors.

It's after I use maven to compile SimulationConfigEditor and MainWindow into a jarfile that I run the binary in Java 12 and reflection errors result.

Unfortunately, I can't compile that snippet you provided above into a jar for testing.

mokun commented 4 years ago

I guess it's because prior to running SimulationConfigEditor and MainWindow, I already have a separate JFrame set up and visible and running in EDT.

after that if I load WebLookAndFeel.install() and UIManagers.initialize() inside SimulationConfigEditor and MainWindow, I get that reflective error.

Testing this theory now...

mokun commented 4 years ago

Also the stacktrace for setting up weblaf inside MainWindow :

Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Unable to initialize LaF for class name: com.alee.laf.WebLookAndFeel
        at com.alee.utils.LafUtils.setupLookAndFeel(LafUtils.java:210)
        at com.alee.utils.LafUtils.setupLookAndFeel(LafUtils.java:193)
        at com.alee.laf.WebLookAndFeel.install(WebLookAndFeel.java:1108)
        at com.alee.laf.WebLookAndFeel.install(WebLookAndFeel.java:1087)
        at com.alee.laf.WebLookAndFeel.install(WebLookAndFeel.java:1075)
        at org.mars_sim.msp.ui.swing.MainWindow.initializeWeblaf(MainWindow.java:893)
        at org.mars_sim.msp.ui.swing.MainWindow.setLookAndFeel(MainWindow.java:1000)
        at org.mars_sim.msp.ui.swing.MainWindow.initializeTheme(MainWindow.java:884)
        at org.mars_sim.msp.ui.swing.MainWindow.<init>(MainWindow.java:179)
        at org.mars_sim.msp.ui.swing.configeditor.SimulationConfigEditor.setupMainWindow(SimulationConfigEditor.java:1208)
        at org.mars_sim.msp.ui.swing.configeditor.SimulationConfigEditor$5.actionPerformed(SimulationConfigEditor.java:361)
        at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
        at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308)
        at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
        at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
        at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
        at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
        at java.desktop/java.awt.Component.processMouseEvent(Component.java:6632)
        at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342)
        at java.desktop/java.awt.Component.processEvent(Component.java:6397)
        at java.desktop/java.awt.Container.processEvent(Container.java:2263)
        at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5008)
        at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
        at java.desktop/java.awt.Component.dispatchEvent(Component.java:4840)
        at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
        at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547)
        at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)
        at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
        at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2762)
        at java.desktop/java.awt.Component.dispatchEvent(Component.java:4840)
        at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
        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:389)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
        at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
        at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:389)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
        at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
        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: com.alee.utils.reflection.ReflectionException: Unable to instantiate skin for class: class com.alee.skin.light.WebLightSkin
        at com.alee.utils.reflection.LazyInstance.create(LazyInstance.java:79)
        at com.alee.managers.style.StyleManager.setSkin(StyleManager.java:1003)
        at com.alee.managers.style.StyleManager.initialize(StyleManager.java:271)
        at com.alee.managers.UIManagers.initialize(UIManagers.java:73)
        at com.alee.laf.WebLookAndFeel.initializeManagers(WebLookAndFeel.java:1065)
        at com.alee.laf.WebLookAndFeel.initialize(WebLookAndFeel.java:391)
        at java.desktop/javax.swing.UIManager.setLookAndFeel(UIManager.java:586)
        at java.desktop/javax.swing.UIManager.setLookAndFeel(UIManager.java:633)
        at com.alee.utils.LafUtils.setupLookAndFeel(LafUtils.java:206)
        ... 46 more
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
        at com.alee.utils.ReflectUtils.createInstance(ReflectUtils.java:1277)
        at com.alee.utils.reflection.LazyInstance.create(LazyInstance.java:74)
        ... 54 more
Caused by: com.thoughtworks.xstream.converters.ConversionException:
---- Debugging information ----
cause-exception     : com.alee.managers.style.StyleException
cause-message       : Unable to load icon set 'class com.alee.iconset.LightIconSet'
class               : com.alee.managers.style.data.SkinInfo
required-type       : com.alee.managers.style.data.SkinInfo
converter-type      : com.alee.managers.style.data.SkinInfoConverter
path                : /skin/iconSet
line number         : 15
version             : not available
-------------------------------
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:79)
        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
        at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
        at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1230)
        at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1214)
        at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1094)
        at com.alee.utils.XmlUtils.fromXML(XmlUtils.java:411)
        at com.alee.utils.XmlUtils.fromXML(XmlUtils.java:373)
        at com.alee.managers.style.XmlSkin.<init>(XmlSkin.java:58)
        at com.alee.skin.light.WebLightSkin.<init>(WebLightSkin.java:35)
        ... 61 more
Caused by: com.alee.managers.style.StyleException: Unable to load icon set 'class com.alee.iconset.LightIconSet'
        at com.alee.managers.style.data.SkinInfoConverter.readIconSet(SkinInfoConverter.java:360)
        at com.alee.managers.style.data.SkinInfoConverter.unmarshal(SkinInfoConverter.java:211)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
        ... 73 more
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
        at com.alee.utils.ReflectUtils.createInstance(ReflectUtils.java:1277)
        at com.alee.managers.style.data.SkinInfoConverter.readIconSet(SkinInfoConverter.java:355)
        ... 75 more
Caused by: com.thoughtworks.xstream.converters.ConversionException:
---- Debugging information ----
cause-exception     : com.alee.managers.icon.IconException
cause-message       : Unable to load XmlIconSet
class               : com.alee.managers.icon.set.XmlIconSet
required-type       : com.alee.managers.icon.set.XmlIconSet
converter-type      : com.alee.managers.icon.set.XmlIconSetConverter
path                : /IconSet
line number         : 1
version             : not available
-------------------------------
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:79)
        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
        at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
        at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1230)
        at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1214)
        at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1193)
        at com.alee.utils.XmlUtils.fromXML(XmlUtils.java:424)
        at com.alee.utils.XmlUtils.fromXML(XmlUtils.java:386)
        at com.alee.managers.icon.set.XmlIconSet.<init>(XmlIconSet.java:48)
        at com.alee.iconset.LightIconSet.<init>(LightIconSet.java:35)
        ... 82 more
Caused by: com.alee.managers.icon.IconException: Unable to load XmlIconSet
        at com.alee.managers.icon.set.XmlIconSetConverter.unmarshal(XmlIconSetConverter.java:98)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
        ... 94 more
Caused by: com.alee.utils.reflection.ReflectionException: Unable to update field modifiers: protected final java.lang.String com.alee.managers.icon.set.AbstractIconSet.id -> 4
        at com.alee.utils.reflection.FieldHelper.setFieldModifiers(FieldHelper.java:52)
        at com.alee.utils.ReflectUtils.setFieldValue(ReflectUtils.java:952)
        at com.alee.utils.ReflectUtils.setFieldValue(ReflectUtils.java:852)
        at com.alee.managers.icon.set.XmlIconSetConverter.unmarshal(XmlIconSetConverter.java:69)
        ... 95 more
mokun commented 4 years ago

if I add back the try catch in SimulationConfigEditor, the stacktrace would look differently as follow (as expected) :

D:\eclipse\eclipse-jee-2019-12-R-win32-x86_64\Git\mars-sim\mars-sim-main\target>java -jar m.jar
Command: "C:\Program Files\BellSoft\LibericaJDK-12\bin\java" --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.text=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-opens java.desktop/javax.swing=ALL-UNNAMED --add-opens java.desktop/javax.swing.text=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED --add-opens java.desktop/java.awt.geom=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.desktop/java.beans=ALL-UNNAMED --add-opens java.desktop/javax.swing.table=ALL-UNNAMED --add-opens java.desktop/com.sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.swing=ALL-UNNAMED --add-opens java.desktop/sun.font=ALL-UNNAMED --add-opens java.desktop/javax.swing.plaf.basic=ALL-UNNAMED --add-opens java.desktop/javax.swing.plaf.synth=ALL-UNNAMED --add-opens java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED --add-opens java.desktop/com.sun.java.swing.plaf.gtk=ALL-UNNAMED --add-opens java.desktop/com.apple.laf=ALL-UNNAMED --illegal-access=deny -Djava.util.logging.config.file=logging.properties -cp .;*;jars\* org.mars_sim.main.MarsProject -Xms256m -Xmx1536m -new
WARNING: package com.sun.java.swing.plaf.gtk not in java.desktop
WARNING: package com.apple.laf not in java.desktop
WARNING: package com.sun.awt not in java.desktop
2020-01-22T20:14:04.6 (Config) MarsProject$SimulationTask : Starting Mars Simulation Project v3.1.0 - Build 5260 - 64-bit 12.0.2-BellSoft - 8 CPU threads
2020-01-22T20:14:04.6 (Config) MarsProject : Please proceed to selecting the type of Game Mode in the popped-up console.
2020-01-22T20:14:04.6 (Config) SimulationConfig : /xml folder already existed.
2020-01-22T20:14:04.6 (Config) SimulationConfig : Your version.txt already has the same BUILD 5260 as the core engine.
2020-01-22T20:14:05.0 (Config) SimulationConfig : Done loading all xml files.
2020-01-22T20:14:09.0 (Warning) SimulationConfigEditor : Could not load system look&feel
Exception in thread "AWT-EventQueue-0" com.alee.managers.style.StyleException: Unable to setup component UI: com.alee.managers.glasspane.WebGlassPane[,0,0,0x0,invalid,layout=com.alee.extended.layout.MultiLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]
        at com.alee.managers.style.AbstractComponentDescriptor.updateUI(AbstractComponentDescriptor.java:308)
        at com.alee.laf.panel.WebPanel.updateUI(WebPanel.java:1045)
        at java.desktop/javax.swing.JPanel.<init>(JPanel.java:86)
        at java.desktop/javax.swing.JPanel.<init>(JPanel.java:95)
        at com.alee.laf.panel.WebPanel.<init>(WebPanel.java:121)
        at com.alee.managers.glasspane.WebGlassPane.<init>(WebGlassPane.java:98)
        at com.alee.laf.rootpane.WebRootPane.createGlassPane(WebRootPane.java:91)
        at java.desktop/javax.swing.JRootPane.<init>(JRootPane.java:348)
        at com.alee.laf.rootpane.WebRootPane.<init>(WebRootPane.java:75)
        at com.alee.laf.window.WebFrame$WebFrameRootPane.<init>(WebFrame.java:807)
        at com.alee.laf.window.WebFrame.createRootPane(WebFrame.java:227)
        at com.alee.laf.window.WebFrame.initialize(WebFrame.java:185)
        at com.alee.laf.window.WebFrame.<init>(WebFrame.java:165)
        at com.alee.laf.window.WebFrame.<init>(WebFrame.java:150)
        at com.alee.laf.window.WebFrame.<init>(WebFrame.java:125)
        at com.alee.laf.window.WebFrame.<init>(WebFrame.java:78)
        at org.mars_sim.msp.ui.swing.configeditor.SimulationConfigEditor.<init>(SimulationConfigEditor.java:135)
        at org.mars_sim.main.MarsProject.lambda$handleNewSimulation$0(MarsProject.java:466)
        at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
        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:389)
        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: com.alee.managers.style.StyleException: Unable to setup component UI: com.alee.managers.glasspane.WebGlassPane[,0,0,0x0,invalid,layout=com.alee.extended.layout.MultiLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]
        at com.alee.utils.LafUtils.setUI(LafUtils.java:113)
        at com.alee.managers.style.AbstractComponentDescriptor.updateUI(AbstractComponentDescriptor.java:303)
        ... 30 more
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:567)
        at com.alee.utils.ReflectUtils.callMethod(ReflectUtils.java:1635)
        at com.alee.utils.LafUtils.setUI(LafUtils.java:109)
        ... 31 more
Caused by: com.alee.managers.style.StyleException: StyleManager wasn't able to initialize default skin
        at com.alee.managers.style.StyleManager.getSkin(StyleManager.java:950)
        at com.alee.managers.style.StyleData.install(StyleData.java:124)
        at com.alee.managers.style.StyleManager.installSkin(StyleManager.java:1198)
        at com.alee.laf.panel.WebPanelUI.installUI(WebPanelUI.java:57)
        at java.desktop/javax.swing.JComponent.setUI(JComponent.java:685)
        at java.desktop/javax.swing.JPanel.setUI(JPanel.java:150)
        at com.alee.laf.panel.WebPanel.setUI(WebPanel.java:1039)
        ... 37 more
mgarin commented 4 years ago

Just a side note - this is not needed:

WebLookAndFeel.install();
UIManagers.initialize();

Install already initializes everything it needs, including all managers, so UIManagers.initialize(); line is not necessary and might actually be harmful in some cases so I recommend removing it.

Besides that - your logs indicate that Java 12+ workaround doesn't work for you for whatever reason:

Caused by: com.alee.utils.reflection.ReflectionException: Unable to update field modifiers: protected final java.lang.String com.alee.managers.icon.set.AbstractIconSet.id -> 4
        at com.alee.utils.reflection.FieldHelper.setFieldModifiers(FieldHelper.java:52)
        at com.alee.utils.ReflectUtils.setFieldValue(ReflectUtils.java:952)
        at com.alee.utils.ReflectUtils.setFieldValue(ReflectUtils.java:852)
        at com.alee.managers.icon.set.XmlIconSetConverter.unmarshal(XmlIconSetConverter.java:69)
        ... 95 more

Also, considering what you said:

It's after I use maven to compile SimulationConfigEditor and MainWindow into a jarfile that I run the binary in Java 12 and reflection errors result.

Are you sure that you are using JVM options I've mentioned before when running it outside of IDE? Those might be crucial to having a successful execution on Java 12+.

mokun commented 4 years ago

Are you sure that you are using JVM options I've mentioned before when running it outside of IDE? Those might be crucial to having a successful execution on Java 12+.

Yes I do. All those JVM options are included as soon as I run the main class. See the 2nd line below.

D:\eclipse\eclipse-jee-2019-12-R-win32-x86_64\Git\mars-sim\mars-sim-main\target>java -jar m.jar
Command: "C:\Program Files\BellSoft\LibericaJDK-12\bin\java" --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.text=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-opens java.desktop/javax.swing=ALL-UNNAMED --add-opens java.desktop/javax.swing.text=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED --add-opens java.desktop/java.awt.geom=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.desktop/java.beans=ALL-UNNAMED --add-opens java.desktop/javax.swing.table=ALL-UNNAMED --add-opens java.desktop/com.sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.swing=ALL-UNNAMED --add-opens java.desktop/sun.font=ALL-UNNAMED --add-opens java.desktop/javax.swing.plaf.basic=ALL-UNNAMED --add-opens java.desktop/javax.swing.plaf.synth=ALL-UNNAMED --add-opens java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED --add-opens java.desktop/com.sun.java.swing.plaf.gtk=ALL-UNNAMED --add-opens java.desktop/com.apple.laf=ALL-UNNAMED --illegal-access=deny -Djava.util.logging.config.file=logging.properties -cp .;*;jars\* org.mars_sim.main.MarsProject -Xms256m -Xmx1536m -new
mgarin commented 4 years ago

Also important question - are you extracting contents of WebLaF binaries to your own JAR you're executing? Because Java 12+ workaround won't work in that case.

mgarin commented 4 years ago

If you have a custom manifest file, you can try adding next line to it:

Multi-Release: true

This is basically what you need to have in the manifest to enable the multi-release feature available in newer Java versions which will use different classes that you might provide in the folder: META-INF/version/{min.java.version}/...

WebLaF has this flag in weblaf-core module since it uses a different FieldHelper class implementation for different Java versions.

mokun commented 4 years ago

Also important question - are you extracting contents of WebLaF binaries to your own JAR you're executing? Because Java 12+ workaround won't work in that case.

No I didn't. Weblaf comes from its maven artifact in a pom.xml.

mokun commented 4 years ago

If you have a custom manifest file, you can try adding next line to it: Multi-Release: true

I can see the FieldHelper.class for java 12 below :

image

Currently, my manifest file is generated automatically by maven does not have the line Multi-Release: true as seen above.

I've tried googling to see how this line can be automatically inserted by maven but found nothing so far.

I guess I could manually do it everytime I'm about to publish a release.

mokun commented 4 years ago

I just added the line <Multi-Release>true</Multi-Release> in my main maven module's pom.xml as well as changing the <manifest> tag to <manifestentries>.

Will compile it under Java 12 to see if it works.

<plugin>
    <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-jar-plugin  : 27 KB -->
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>3.2.0</version>
        <configuration>
            <archive>
                <manifestentries>
                    <Multi-Release>true</Multi-Release>
                    <addClasspath>true</addClasspath>
                    <mainClass>${domainNameMainClass}</mainClass>
                </manifestentries>
            </archive>
        </configuration>
</plugin>
mokun commented 4 years ago

I've just added the line <Multi-Release>true</Multi-Release> and recompiled the binary.

When I run the jarfile, strangely it said no main manifest attribute, in m.jar.

Now I can't start the jarfile at all.

image

mgarin commented 4 years ago

No I didn't. Weblaf comes from its maven artifact in a pom.xml. I can see the FieldHelper.class for java 12 below :

If you aren't extracting WebLaF artifacts into yours/your project then why do you have the FieldHelper class in your project? (at least according to the screenshots provided) I'm a bit confused with that one.

And generally at this point it's mostly guessing about what the issue is without a proper short example that can reproduce the issue outside of your project which adds a layer of complexity. We do use latest WebLaF artifacts in our projects and we never faced this issue with any Java versions as long as artifacts were preserved "as is".

So about the multi-release feature - I'll clarify it once again from the start:

  1. You need to have weblaf-core-x.x.x.jar artifact used as a separate dependency in your project
  2. That artifact needs to contain the alternate FieldHelper class in META-INF/versions/12/com/alee/utils/reflection/FieldHelper.class folder
  3. That artifact needs to have Multi-Release: true line in it's MANIFEST.MF file

All these conditions should be met if you are using WebLaF v1.2.11 or later AND do not change the artifacts anyhow, meaning that your final application uses these JARs "as is".

Optionally, if you do extract libraries into your singular application JAR - you need to add Multi-Release: true line to your own MANIFEST.MF file. It works for WebLaF demo application JAR since I extract all dependencies into it for convenience.

I've just added the line true and recompiled the binary. When I run the jarfile, strangely it said no main manifest attribute, in m.jar Now I can't start the jarfile at all.

Line no main manifest attribute, in m.jar means exactly what it says - for some reason it either can't read your manifest file or it is actually missing the main class. There might as well be some file encoding issue (for instance caused by the editor where you manually edited the file, if you did).

But JUST adding this line in manifest, even for older Java versions, will never cause the no main manifest attribute error as older versions will simply ignore all properties they do not know.

mgarin commented 4 years ago

Here is an example command which I tried with different Java 12+ runtimes:

java --illegal-access=deny --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.text=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-opens java.desktop/javax.swing=ALL-UNNAMED --add-opens java.desktop/javax.swing.text=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED --add-opens java.desktop/java.awt.geom=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.desktop/java.beans=ALL-UNNAMED --add-opens java.desktop/javax.swing.table=ALL-UNNAMED --add-opens java.desktop/com.sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.swing=ALL-UNNAMED --add-opens java.desktop/sun.font=ALL-UNNAMED --add-opens java.desktop/javax.swing.plaf.basic=ALL-UNNAMED --add-opens java.desktop/javax.swing.plaf.synth=ALL-UNNAMED --add-opens java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED --add-opens java.desktop/com.sun.java.swing.plaf.gtk=ALL -jar D:\Downloads\weblaf-demo-1.2.12-jar-with-dependencies.jar

It properly runs the weblaf-demo-1.2.12-jar-with-dependencies.jar demo app which has the weblaf-core module extracted in it. It does have the Multi-Release: true property in manifest, without it it would throw an exception and fail to run.

mokun commented 4 years ago

so let's see if I understand what needs to be done.

If you aren't extracting WebLaF artifacts into yours/your project then why do you have the FieldHelper class in your project?

In my Eclipse IDE development setup, I have never MANUALLY extracted the WebLaF artifacts since adopting v1.2.9 snapshots. If it's being extracted, is it possible that it was done automatically by the maven plug-in ?

or some reason it either can't read your manifest file or it is actually missing the main class.

That's because I changed the <manifest> into <manifestentries> in order to accommodate the line <Multi-Release>true</Multi-Release>. But in doing so, the <mainClass> tag no longer works.

<plugin>
    <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-jar-plugin  : 27 KB -->
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>3.2.0</version>
        <configuration>
            <archive>
                <manifestentries>
                    <Multi-Release>true</Multi-Release>
                    <addClasspath>true</addClasspath>
                    <mainClass>${domainNameMainClass}</mainClass>
                </manifestentries>
            </archive>
        </configuration>
</plugin>

So I'm doing this below now for that maven-jar-plugin to fix the main class issue.

<plugin>
    <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-jar-plugin  : 27 KB -->
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>3.2.0</version>
    <configuration>
        <archive>
            <manifest>
                <addClasspath>true</addClasspath>
                <mainClass>${domainNameMainClass}</mainClass>
            </manifest>
            <manifestEntries>
                <Multi-Release>true</Multi-Release>
            </manifestEntries>
        </archive>
    </configuration>
</plugin>

Now I have a jarfile with the <Multi-Release> attribute as true, but it still doesn't work.

mokun commented 4 years ago
  1. You need to have weblaf-core-x.x.x.jar artifact used as a separate dependency in your project

When you say as a separate dependency, do you mind explaining what it entails ?

Currently, I include weblaf core, weblaf ui, weblaf plugin in a pom.xml in a sub-maven module that needs weblaf.

For all other sub-maven modules, I don't specify any weblaf maven artifacts in their pom.xml.

// found in the mars-sim-ui sub-maven module's pom.xml 
      <dependency>
            <groupId>com.weblookandfeel</groupId>
            <artifactId>weblaf-ui</artifactId>        
            <version>1.2.12</version>
        </dependency>   
        <dependency>
            <groupId>com.weblookandfeel</groupId>
            <artifactId>weblaf-core</artifactId>       
            <version>1.2.12</version>
        </dependency>
        <dependency>
            <groupId>com.weblookandfeel</groupId>
            <artifactId>weblaf-plugin</artifactId>        
            <version>1.2.12</version>
        </dependency>
mokun commented 4 years ago
  1. That artifact needs to contain the alternate FieldHelper class in META-INF/versions/12/com/alee/utils/reflection/FieldHelper.class folder

After compiling the binary. I use a utility to open up the jarfile inside and I discover that META-INF/versions/ folder has 3 separate folders inside. See below :

image

It was generated automatically by maven.

mgarin commented 4 years ago

In my Eclipse IDE development setup, I have never MANUALLY extracted the WebLaF artifacts since adopting v1.2.9 snapshots. If it's being extracted, is it possible that it was done automatically by the maven plug-in ?

I don't know, depends on your Maven project settings. You can simply check the contents of your application JAR and see if all your dependencies are extracted there or not. If yes - then something is certainly doing it.

You need to have weblaf-core-x.x.x.jar artifact used as a separate dependency in your project

When you say as a separate dependency, do you mind explaining what it entails ?

I simply meant that it needs to remain as a separate JAR dependency unless you'll be covering the manifest property by yourself (like it's done in WebLaF demo).

After compiling the binary. I use a utility to open up the jarfile inside and I discover that META-INF/versions/ folder has 3 separate folders inside. See below :

I'm not sure what the other ones are - maybe some stuff coming from other dependencies your project have. I'm pretty sure WebLaF is not the only project that uses the multi-release JAR feature.

But WebLaF currently has only 1 related file that remains at a fixed path:

META-INF/versions/12/com/alee/utils/reflection/FieldHelper.class

You need that class present in your weblaf-core JAR or your own application JAR (if everything is extracted to it) along with the extra Multi-Release: true property in your app manifest.

If these conditions are met, but you're still getting an error - then I'll need a small sample app without any 3rd-party dependencies where it can be reproduced, otherwise I won't really be able to solve the problem.

mokun commented 4 years ago

But WebLaF currently has only 1 related file that remains at a fixed path: META-INF/versions/12/com/alee/utils/reflection/FieldHelper.clas

True. META-INF/versions/9/ and META-INF/versions/10/ have something else and not weblaf's stuff.

I've finally figure out how to start my app with weblaf in Java 12 without crashing.

In maven-jar-plugin, I don't need to change its setting at all.

In maven-assembly-plugin, I don't need to touch what's inside <manifest> and keep it the same as before.

However, I'll need to add a new line <Multi-Release>true</Multi-Release> within <manifestEntries>

Everything seems to be working now. Thanks !

            <plugin>
                <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-jar-plugin  : 27 KB -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>${domainNameMainClass}</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-assembly-plugin 
                    https://maven.apache.org/plugins/maven-assembly-plugin/ : 235 KB -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <mainClass>${domainNameMainClass}</mainClass>
                        </manifest>
                        <manifestEntries>
                            <Multi-Release>true</Multi-Release>
                        </manifestEntries>                      
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id> <!-- this is used for inheritance merges -->
                        <phase>package</phase> <!-- append to the packaging phase. -->
                        <goals>
                            <goal>single</goal> <!-- goals == mojos -->
                        </goals>
                    </execution>
                </executions>
            </plugin>
mgarin commented 4 years ago

Glad it works for you now :) I'll keep this issue open for now though as I still have some plans for improvements to related code.

phillip-at-work commented 4 years ago

Hey mgarin,

I'm having the exact same problem. My project compiles fine with WebLaF in eclipse, but hits the same exception (no need to re-post same stack trace) when I package the fat jar with maven.

I'm including ui, core, ninepatch-editor, and plugin as maven dependencies.

I'm not so clear what user mokun is doing with his pom.xml and his manifest file here (Jan 24):

"That's because I changed the < manifest > into < manifestentries > in order to accommodate the line < Multi-Release > true < / Multi-Release >."

But, alas, trying his solution of adding:

`

true

`

now returns

no main manifest attribute, in /Users/me/target/MyProject-0.0.1-SNAPSHOT-jar-with-dependencies.jar

when I run my jar in terminal with java -jar MyProject-0.0.1-SNAPSHOT-jar-with-dependencies.jar

Any suggestions about what my XML should look like?

Thanks!

mgarin commented 4 years ago

This error:

no main manifest attribute, in /Users/me/target/MyProject-0.0.1-SNAPSHOT-jar-with-dependencies.jar

means that you're missing main class attribute in your manifest file in resulting JAR.

You probably need to specify it separately like @mokun shown above:

<archive>
    <manifest>
        <mainClass>your.main.ClassName</mainClass>
    </manifest>
    <manifestEntries>
        <Multi-Release>true</Multi-Release>
    </manifestEntries>
</archive>

I have similar configuration for WebLaF demo application, you can look at complete pom.xml here: https://github.com/mgarin/weblaf/blob/master/modules/demo/pom.xml#L67

phillip-at-work commented 4 years ago

DOH. Yes, that was my problem, I forgot to add in <mainClass>.

For those of you reading this because you've encountered the same exception when packaging a fat jar, add that XML segment that @mgarin includes above.

Many thanks.