msmobility / silo

SILO Model Java Code
GNU General Public License v2.0
18 stars 27 forks source link

Incompatible with new Java versions #355

Open Qinnnnn opened 1 year ago

Qinnnnn commented 1 year ago

SILO is not compatible with new Java versions like Java 17. Need to test different Java versions and adapt SILO to the latest. (?)

key2000 commented 1 year ago

Thank you Qin, In my case, Java 11.0.18 did not work, but 11.0.15 did. This may be specific to my computer.

key2000 commented 1 year ago

By the way, when simulating both road and public transport in Matsim, the speed of public transport vehicles becomes very slow. Based on my previous experience with public transport simulations, I remember that reducing the flowCapacityFactor and storageCapacityFactor slows down the vehicle speed, and setting them to 1 achieves the desired speed. If you happen to know how to properly control the speed of public transport vehicles when decreasing the CapacityFactor in a simulation that combines road and public transport, I would greatly appreciate any advice you can provide.

jakobrehmann commented 1 year ago

@Qinnnnn I've run into the same problem with Java versions. This is a bit of an issue for the SILO-MATSim Integration, because newest version of MATSim relies on Java 17.

I've started to look into why migration to 17 doesn't work seamlessly, and I'll share what I've figured out so far. The error I get is...

java.lang.NullPointerException: Cannot invoke "javax.script.Compilable.compile(String)" because "compileEngine" is null

    at de.tum.bgu.msm.util.js.JavaScriptCalculator.compileScript(JavaScriptCalculator.java:50)
    at de.tum.bgu.msm.util.js.JavaScriptCalculator.<init>(JavaScriptCalculator.java:27)
    at de.tum.bgu.msm.models.relocation.DwellingUtilityStrategyImpl.<init>(DwellingUtilityStrategyImpl.java:12)
    at de.tum.bgu.msm.ModelBuilderMuc.getModelContainerForMuc(ModelBuilderMuc.java:88)
    at de.tum.bgu.msm.transportModel.matsim.SiloMucTest.runThisTest(SiloMucTest.java:58)
    at de.tum.bgu.msm.transportModel.matsim.SiloMucTest.testMain(SiloMucTest.java:40)
...

If I am understanding it correctly, some of SILO's models/methods are in the form of Javascript scripts. These scripts loaded and executed using the class JavaScriptCalculator; this class actually is part of MITO and not SILO. (Note: It is also tagged as deprecated). Within JavaScriptCalculator, the javascript engine nashorn is loaded.

nashorn was deprecated in Java 11. This is why the following warning message always shows up in the logs when SILO is run: "Warning: Nashorn engine is planned to be removed from a future JDK release"

nashorn was ultimately removed in Java 15. Thus, when running SILO with Java 17, we get the "compileEngine" is null error.

What can we do about this? My colleague @rakow suggested that we could load nashorn as a maven dependency. Alternatively, would it be possible to just translate the javascript code into java?