Reading settings throws exception on newest version on Windows

Custom indicators, trading strategies, data export and recording and more...
zcsoka
Posts: 192
Joined: Thu Dec 19, 2019 7:50 pm
Has thanked: 2 times
Been thanked: 13 times

Reading settings throws exception on newest version on Windows

Post by zcsoka » Fri Nov 12, 2021 12:19 pm

Greetings,

On Windows version 7.3.0 build 18, on module load I get the exception below. It is a new module, I have increased the settings version, but the exception still comes. I could not reproduce it on MacOS version 7.2.0 build 20. Did you change something in the enabled modules config or in the java parameters? Have you bumped up the Java version in 7.3? Do you happen to know how to circumvent it? 

Thanks in advance

Code: Select all

 
java.lang.RuntimeException: Error while loading settings for com.zoli.api.futureT.indicators.VWAPstdv.direct, alias: NQZ21@GF, settignsClass: com.zoli.api.futureT.indicators.VWAPstdv.Settings

Your settings may be incompatible with settings saved in file. Do you need to increase settings version?
at velox.api.layer1.b.getSettings(SourceFile:563)
at velox.api.layer1.simplified.InstanceWrapper.getSettings(InstanceWrapper.java:640)
at com.zoli.api.futureT.indicators.VWAPstdv.initialize(VWAPstdv.java:175)
at velox.api.layer1.simplified.InstanceWrapper.start(InstanceWrapper.java:120)
at velox.api.layer1.simplified.SimplifiedL1ApiLoader.startForInstrument(SimplifiedL1ApiLoader.java:359)
at velox.api.layer1.simplified.SimplifiedL1ApiLoader.lambda$onStrategyCheckboxEnabled$4(SimplifiedL1ApiLoader.java:337)
at velox.api.layer1.layers.Layer1ApiInjectorRelay.injectSynchronously(SourceFile:57)
at velox.api.layer1.simplified.SimplifiedL1ApiLoader.onStrategyCheckboxEnabled(SimplifiedL1ApiLoader.java:332)
at velox.api.layer1.exceptionwrapper.a.b.generated.velox_____api_____layer1_____Layer1ApiInstrumentSpecificEnabledStateProvider___I___velox_____api_____layer1_____exceptionwrapper_____b_____e.onStrategyCheckboxEnabled(velox_____api_____layer1_____Layer1ApiInstrumentSpecificEnabledStateProvider___I___velox_____api_____layer1_____exceptionwrapper_____b_____e.java)
at velox.gui.do.a(SourceFile:687)
at velox.gui.do.a(SourceFile:387)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2313)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
at java.desktop/javax.swing.JToggleButton$ToggleButtonModel.setPressed(JToggleButton.java:411)
at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:298)
at java.desktop/java.awt.Component.processMouseEvent(Component.java:6626)
at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3389)
at java.desktop/java.awt.Component.processEvent(Component.java:6391)
at java.desktop/java.awt.Container.processEvent(Container.java:2266)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5001)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4833)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4948)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4575)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4516)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2780)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4833)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:746)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:744)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:743)
at velox.ib.O.dispatchEvent(SourceFile:70)
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 byte java.time.LocalTime.hour accessible: module java.base does not "opens java.time" to unnamed module @4ae82894
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.google.gson.internal.reflect.UnsafeReflectionAccessor.makeAccessible(UnsafeReflectionAccessor.java:44)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:159)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:102)
at com.google.gson.Gson.getAdapter(Gson.java:458)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(CollectionTypeAdapterFactory.java:53)
at com.google.gson.Gson.getAdapter(Gson.java:458)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:117)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:166)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:102)
at com.google.gson.Gson.getAdapter(Gson.java:458)
at com.google.gson.Gson.toJson(Gson.java:696)
at com.google.gson.Gson.toJson(Gson.java:683)
at com.google.gson.Gson.toJson(Gson.java:638)
at com.google.gson.Gson.toJson(Gson.java:618)
at velox.bookmap.lX.a(SourceFile:323)
at velox.bookmap.lX.a(SourceFile:304)
at velox.api.layer1.b.getSettings(SourceFile:560)
... 47 more

Svyatoslav
Site Admin
Posts: 228
Joined: Mon Jun 11, 2018 11:44 am
Has thanked: 2 times
Been thanked: 28 times

Re: Reading settings throws exception on newest version on Windows

Post by Svyatoslav » Fri Nov 12, 2021 12:21 pm

Hi. We did bump up java version, but I don't think that would affect it. I also don't think we changed anything relevant, really. My guess is that you actually do have incompatible settings somehow. If you could share your config file with me directly via any channel - please do, I'll take a look at what's in it.

Svyatoslav
Site Admin
Posts: 228
Joined: Mon Jun 11, 2018 11:44 am
Has thanked: 2 times
Been thanked: 28 times

Re: Reading settings throws exception on newest version on Windows

Post by Svyatoslav » Fri Nov 12, 2021 2:09 pm

Sorry, you are right, java update was the reason:

Code: Select all

Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final byte java.time.LocalTime.hour accessible: module java.base does not "opens java.time" to unnamed module @4ae82894
To serialize/deserialize LocalTime, GSON has to get inside it, and in Java 17 it can't, because it's more strict about accesses. Do you really need LocalTime or would it be ok to store something like a number of nanoseconds inside long?

zcsoka
Posts: 192
Joined: Thu Dec 19, 2019 7:50 pm
Has thanked: 2 times
Been thanked: 13 times

Re: Reading settings throws exception on newest version on Windows

Post by zcsoka » Fri Nov 12, 2021 8:57 pm

I use the LocalTime to manage reset Time stamps and reset deltas, to manage alert suppression for couple of seconds and of course to handle the settings of those. I have to be aware of the timezone to be able to react in the user's time. I build from hour, minute, seconds strings date together, so I leverage the Java date toolkit. Do you have an other package what would be enabled?
I also use the Instant class to get the current time to work with the resets

Svyatoslav
Site Admin
Posts: 228
Joined: Mon Jun 11, 2018 11:44 am
Has thanked: 2 times
Been thanked: 28 times

Re: Reading settings throws exception on newest version on Windows

Post by Svyatoslav » Mon Nov 15, 2021 11:41 am

As I mentioned, this limitation comes from Java, not us. We just don't provide corresponding "--add-opens " flag, so JRE 17 blocks access. So gson library, that we use for serialization, just can't perform it. You have few options:
- using your own serializer and passing a string to bookmap. That way in the object you are passing to bookmap there would only be a string, so bookmap can serialize it with GSON and that's it. That does not solve the issue, only shifts it to your side. However you can use custom serializers to access LocalTime fields in a way allowed by Java (without reading/writing private fields).
- not storing LocalTime in a field. Instead have two fields: timezone as a string and unix epoch timestamp as long. From those two values you can reconstruct LocalTime. This way your getter/setter would be more complicated as those would construct/split LocalTime, but the fields of your object would now be serializable by Gson.
- similar to the previous one, but just read/write fields directly

Point is - with the combination of Gson version that we are using and Java 17 you can't just tell Gson to serialize certain data types due to new restrictions. Previously you had --illegal-access=warn that would just allow everything (with a warning), but now this option is no longer working. https://openjdk.java.net/jeps/403
I'm not sure if Gson update would help - we didn't try. But the above options should let you solve the issue regardless.

zcsoka
Posts: 192
Joined: Thu Dec 19, 2019 7:50 pm
Has thanked: 2 times
Been thanked: 13 times

Re: Reading settings throws exception on newest version on Windows

Post by zcsoka » Mon Nov 15, 2021 12:34 pm

Many thanks, I will check the code and will try get rid of LocalTime from the settings. 

Post Reply