yccheok / jstock

JStock is a free stock market software for 28 countries.
https://jstock.org
664 stars 348 forks source link

Upgrade the project to support java 17 and onwards #185

Open MalayPalace opened 1 year ago

MalayPalace commented 1 year ago

On Current Latest Release tag: release_1-0-7-60

Upon starting ./jstock.sh with java jdk openjdk version "17.0.8" 2023-07-18 on OS Ubuntu getting stack trace as below:

/bin/java -Xms64m -Xmx512m --module-path /usr/share/openjfx/lib --add-modules=javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web -jar jstock.jar
Exception in thread "main" 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:369)
        at org.yccheok.jstock.gui.Utils.getXStream(Utils.java:1785)
        at org.yccheok.jstock.gui.Utils.fromXML(Utils.java:1819)
        at org.yccheok.jstock.gui.JStock.getJStockOptionsViaXML(JStock.java:1803)
        at org.yccheok.jstock.gui.JStock.main(JStock.java:1819)
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 @97e1986
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
        at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
        at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
        at com.thoughtworks.xstream.core.util.Fields.locate(Fields.java:40)
        at com.thoughtworks.xstream.converters.collections.TreeMapConverter.<clinit>(TreeMapConverter.java:50)
        ... 10 more

Java version details:

openjdk version "17.0.8" 2023-07-18
OpenJDK Runtime Environment (build 17.0.8+7-Ubuntu-122.04)
OpenJDK 64-Bit Server VM (build 17.0.8+7-Ubuntu-122.04, mixed mode, sharing)
EarBiteR commented 3 months ago

I recently upgraded Linux mint 21.3 to 22 and it downgraded thousands of packages. I tried removing and reinstalling openjdk-21-jre since jstock was failing to load with this reflect error. I reinstalled v.11 and changed the launch script to:

JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64

And I still get these errors but at least it runs! Hope this helps anyone having this problem:

WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by com.thoughtworks.xstream.core.util.Fields (file:/home/ron/bin/jstock/lib/xstream-1.4.11.1.jar) to field java.util.TreeMap.comparator WARNING: Please consider reporting this to the maintainers of com.thoughtworks.xstream.core.util.Fields 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