From 1b401b0632341eadc8c68226549f96415fdc405a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Cl=C3=A9ment=20DAVID?= Date: Fri, 8 Dec 2017 17:50:25 +0100 Subject: [PATCH] Xcos: remove the runtime check for JGraphX and Batik Change-Id: Ib8b22a8fe8d8baf748cd4578cb7b99768bf6131b --- scilab/CHANGES.md | 1 + .../src/java/org/scilab/modules/xcos/Xcos.java | 55 -------------------- 2 files changed, 1 insertion(+), 55 deletions(-) diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md index 9e2c9b2..77848e8 100644 --- a/scilab/CHANGES.md +++ b/scilab/CHANGES.md @@ -392,6 +392,7 @@ the [development mailing list](dev@lists.scilab.org) for a particular toolbox. * [#8842](http://bugzilla.scilab.org/show_bug.cgi?id=8842): Assigning the pointer of a builtin function to a new structure failed. * [#9297](http://bugzilla.scilab.org/show_bug.cgi?id=9297): Assigning a mlist to a structure's field failed. * [#9519](http://bugzilla.scilab.org/show_bug.cgi?id=9519): The console menu `File -> Open a file` opened any file in Scinotes. Binary files like .zcos blocked Scinotes. +* [#9617](http://bugzilla.scilab.org/show_bug.cgi?id=9617): Xcos run-time version check was too conservative. * [#9838](http://bugzilla.scilab.org/show_bug.cgi?id=9838): `evstr` poorly supported simple comments in input expressions. * [#10270](http://bugzilla.scilab.org/show_bug.cgi?id=10270): `execstr(["%val=[int16(1)";"]"])` needed entering twice to be actually performed. * [#11196](http://bugzilla.scilab.org/show_bug.cgi?id=11196): Some recursive extractions from a mlist failed. diff --git a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/Xcos.java b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/Xcos.java index 55cdbfd..61b606d 100644 --- a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/Xcos.java +++ b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/Xcos.java @@ -97,15 +97,6 @@ public final class Xcos { private static final String LOAD_XCOS_LIBS_LOAD_SCICOS = "prot=funcprot(); funcprot(0); loadXcosLibs(); loadScicos(); funcprot(prot); clear prot"; - /* - * Dependencies version - */ - private static final List MXGRAPH_VERSIONS = null; - private static final List BATIK_VERSIONS = Arrays.asList("1.7", "1.8pre", "1.8"); - - private static final String UNABLE_TO_LOAD_JGRAPHX = Messages.gettext("Unable to load the jgraphx library.\nExpecting version %s ; Getting version %s ."); - private static final String UNABLE_TO_LOAD_BATIK = Messages.gettext("Unable to load the Batik library. \nExpecting version %s ; Getting version %s ."); - private static final String CALLED_OUTSIDE_THE_EDT_THREAD = "Called outside the EDT thread."; private static final Logger LOG = Logger.getLogger(Xcos.class.getName()); @@ -164,9 +155,6 @@ public final class Xcos { LOG.severe(e.toString()); } - /* Check the dependencies at startup time */ - checkDependencies(); - /* * Allocate data */ @@ -214,49 +202,6 @@ public final class Xcos { } /** - * Check the dependencies and the version dependencies. - * - * This method use runtime class loading to handle ClassNotFoundException. - * - * This method catch any exception and rethrow it with a well defined message. Thus it doesn't pass the IllegalCatch metrics. - */ - // CSOFF: IllegalCatch - // CSOFF: MagicNumber - private void checkDependencies() { - final ClassLoader loader = ClassLoader.getSystemClassLoader(); - - /* JGraphx */ - String mxGraphVersion = ""; - try { - final Class klass = loader.loadClass("com.mxgraph.view.mxGraph"); - mxGraphVersion = (String) klass.getDeclaredField("VERSION").get(null); - - if (MXGRAPH_VERSIONS != null && !MXGRAPH_VERSIONS.contains(mxGraphVersion)) { - throw new Exception(); - } - } catch (final Throwable e) { - throw new RuntimeException(String.format(UNABLE_TO_LOAD_JGRAPHX, MXGRAPH_VERSIONS.get(0), mxGraphVersion), e); - } - - /* Batik */ - String batikVersion = null; - try { - final Class klass = loader.loadClass("org.apache.batik.Version"); - batikVersion = klass.getPackage().getImplementationVersion().split("\\+")[0]; - - if (!BATIK_VERSIONS.contains(batikVersion)) { - throw new Exception(); - } - - } catch (final Throwable e) { - throw new RuntimeException(String.format(UNABLE_TO_LOAD_BATIK, BATIK_VERSIONS.get(0), batikVersion), e); - } - } - - // CSON: MagicNumber - // CSON: IllegalCatch - - /** * @return the per Scilab application, Xcos instance */ public static synchronized Xcos getInstance() { -- 1.7.9.5