[Scilab-Dev] Scilab GUI and adv-cli fail to launch with java 9

badshah400 at gmail.com badshah400 at gmail.com
Sat Feb 24 00:09:39 CET 2018


Update: I managed to get scilab 6.0.1 working full and proper with java
9, albeit by making use of rather hackish means. Here is what I did:
   1. Neutered the addURL and getClassPath functions
      (modules/jvm/src/java/org/scilab/modules/jvm/ClassPath.java) so that
      they don't throw typecasting exceptions during conversion from
      ClassLoader to URLClassLoader. A java expert (i.e. the opposite of
      me) may be able to adapt these functions properly so that on-demand
      loading of jars still works, thus nullifying the need for point 3
      below.
   2. Add jaf to etc/classpath.xml[.in] as the java.se.ee version of
      java.activation module is obsoleted. Since it is still needed for
      the xmlto* functions used during building the documentation, one
      adds an external jaf implementation (e.g. geronimo, gnu, etc.) to
      the required jars. I have implemented this completely in the
      autotools way, so configure checks for it like all other required
      jars and so on.
   3. This is the ugly hack: I read all the jar classpaths in
      etc/classpath.xml and pass them all via the -Djava.class.path
      argument to the env variable _JAVA_OPTIONS. I also pass the
      appropriate library paths from etc/librarypath.xml to _JAVA_OPTIONS
      by using -Djava.library.path. The corresponding env variable
      _JAVA_OPTIONS is set in the bin/scilab script. Classpaths to all
      mandatorily and on-demand required jars are consequently loaded
      right during scilab startup, and scilab thereafter works perfectly
      (so far, from my tests).

In case frontloading all classpaths in this manner is acceptable going
forwards, I can obviously adapt my implementation of point 3 in an
autotools way, by running automake over bin/scilab.in to generate
bin/scilab. For now, I simply hack the bin/scilab script by using some
sed tricks after running make in the spec file. The appropriate patch
is [1], and the spec file is [2].

I would be really grateful for any comments, reviews, and suggestions.

Cheerio.

[1] https://build.opensuse.org/package/view_file/home:badshah400:branches:science/scilab/scilab-java9-ClassLoader.patch?expand=1
[2] https://build.opensuse.org/package/view_file/home:badshah400:branches:science/scilab/scilab.spec?expand=1

On Thu, 2018-02-22 at 18:57 +0100, Atri Bhattacharya wrote:
> Apparently the problem is this (from JDK 9 Release Notes[1]):
> 
> > The application class loader is no longer an instance of
> > java.net.URLClassLoader (an implementation detail that was never
> > specified in previous releases). Code that assumes that
> > ClassLoader::getSytemClassLoader returns a URLClassLoader object
> > will need to be updated. Note that Java SE and the JDK do not
> > provide an API for applications or libraries to dynamically augment
> > the class path at run-time.
> 
> Consequently, the functions <addURL> and <getClassPath> in
> `modules/jvm/src/java/org/scilab/modules/jvm/ClassPath.java` fail
> because of the casting of ClassLoader to URLClassLoader. None of the
> class paths actually gets passed to the main code, and all hell
> ensues. I could get around this by manually passing paths to all the
> necessary *.jar files to _JAVA_OPTIONS. There is likely a better way,
> but so far it beats me.
> 
> Cheers.
> 
> [1] http://www.oracle.com/technetwork/java/javase/9-relnote-issues-37
> 04069.html
>  
> 
> On 22 February 2018 at 13:39, Atri Bhattacharya <badshah400 at gmail.com
> > wrote:
> > Dear Clément,
> > 
> > On Wed, 2018-02-21 at 15:25 +0000, Clément David wrote:
> > > Hello Atri,
> > >
> > > Thanks for your work on porting Scilab to jdk9 ;
> > 
> > You are welcome. It's mostly based on self-interest: I use scilab
> > regularly (mostly on the command line though) on openSUSE
> > Tumbleweed.
> > 
> > > this NoClassDefFoundError usually comes from a mis-
> > > compilation check the jar content and be sure to load it
> > correctly.
> > 
> > I think the jar content looks ok. I think it's some incompatibility
> > between jdk 8 and 9 that prevents the classpath from being
> > correctly
> > used. The same binary works with jdk 8 (even though it is compiled
> > against jdk 9) once the jre paths in the scilab script are
> > appropriately adapted; but it doesn't with jdk 9.
> > 
> > > About the patches, I just
> > > started to review them and will push them on the 6.0 branch after
> > > fixing the build on my machine;
> > 
> > Many thanks. It will be great if these patches are upstreamed; it
> > would
> > certainly reduce my work (I maintain Scilab packages for openSUSE)
> > during version upgrades.
> > 
> > Best wishes.
> > 
> > 
> > > Le mercredi 21 février 2018 à 13:19 +0100, Atri Bhattacharya a
> > écrit
> > > :
> > > > Hi,
> > > > After several patches to fix building against java 9, I have
> > been
> > > > finally able to get scilab 6.0.1 building on openSUSE
> > Tumbleweed.
> > > > However, during run time, I now see a ClassNotFoundError, as
> > > > follows:
> > > > --------------------
> > > > :~> SCIVERBOSE=1 scilab
> > > > SCILABBIN : scilab-bin
> > > > DISABLE_JAVA_DETECTION : 0
> > > > SCILAB_MODE : gui
> > > > OS : Linux
> > > > MODEL : x86_64
> > > > IS_SCILAB_BINARY : 0
> > > > Using specified vm: /usr/lib64/jvm/java
> > > > JAVA_HOME : /usr/lib64/jvm/java
> > > > SCI : /usr/share/scilab/
> > > > SCIBIN : /usr/bin/scilab-bin
> > > > PATH :
> > > >
> > /usr/share/scilab/:/usr/share/scilab//bin:/usr/bin:/home/badshah400
> > > > /bin
> > > >
> > :/usr/local/bin:/usr/bin:/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin
> > > > CLASSPATH :
> > > > /usr/share/scilab//modules/core/jar/org.scilab.modules.core.jar
> > > > EGL_DRIVER :
> > > > LD_LIBRARY_PATH :
> > > >
> > /usr/lib64/jvm/java/lib/:/usr/lib64/jvm/java/lib/server/:/usr/lib64
> > > > /jvm
> > > > /java/lib/native_threads/
> > > > DOCBOOK : /usr/share/xml/docbook/stylesheet/nwalsh/current/
> > > > WARNING: An illegal reflective access operation has occurred
> > > > WARNING: Illegal reflective access by
> > > > org.scilab.modules.jvm.LibraryPath
> > > >
> > (file:/usr/share/scilab/modules/jvm/jar/org.scilab.modules.jvm.jar)
> > > > to
> > > > field java.lang.ClassLoader.sys_paths
> > > > WARNING: Please consider reporting this to the maintainers of
> > > > org.scilab.modules.jvm.LibraryPath
> > > > 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
> > > > Could not access to the Main Scilab Class:
> > > > Exception in thread "main" java.lang.NoClassDefFoundError:
> > > > org/scilab/modules/core/Scilab
> > > > Caused by: java.lang.ClassNotFoundException:
> > > > org.scilab.modules.core.Scilab
> > > >     at
> > > >
> > java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinC
> > > > lass
> > > > Loader.java:582)
> > > >     at
> > > >
> > java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass
> > > > (Cla
> > > > ssLoaders.java:185)
> > > >     at
> > > > java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
> > > >
> > > > Scilab cannot create Scilab Java Main-Class (we have not been
> > able
> > > > to
> > > > find the main Scilab class. Check if the Scilab and thirdparty
> > > > packages
> > > > are available).
> > > > --------------
> > > >
> > > > All patches are available at [1], and also documented on
> > > > http://bugzilla.scilab.org/show_bug.cgi?id=15328
> > > > where unfortunately, I have not seen the needle move much over
> > the
> > > > recent days.
> > > >
> > > > Scilab does work with java 1.8.0 (have to adapt the JRE paths
> > > > appropriately in bin/scilab); however, as soon as java 9 is
> > used
> > > > the
> > > > above error is manifested. If someone can help fix this issue,
> > that
> > > > will be very helpful.
> > > >
> > > > openSUSE uses Java 9 by default now, which means as of now
> > scilab
> > > > is
> > > > badly broken -- only scilab-cli works -- on openSUSE Tumbleweed
> > and
> > > > soon to be released Leap 15.0. Unless Scilab's compatibility
> > issues
> > > > are
> > > > fixed, we will have to drop it from the distro unfortunately.
> > > >
> > > > Thanks and best wishes.
> > > >
> > > > [1] https://build.opensuse.org/package/show/home:badshah400:bra
> > nche
> > > > s:science/scilab
> > > >
> > >
> > > _______________________________________________
> > > dev mailing list
> > > dev at lists.scilab.org
> > > http://lists.scilab.org/mailman/listinfo/dev
> > --
> > Atri Bhattacharya
> > Thu 22 Feb 12:28:07 CET 2018
> > 
> > Sent from openSUSE Tumbleweed on my laptop.
> 
> 
> 



More information about the dev mailing list