Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.0
scilab
scilab-java9-ClassLoader.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File scilab-java9-ClassLoader.patch of Package scilab
Index: scilab-6.0.1/modules/jvm/src/java/org/scilab/modules/jvm/ClassPath.java =================================================================== --- scilab-6.0.1.orig/modules/jvm/src/java/org/scilab/modules/jvm/ClassPath.java +++ scilab-6.0.1/modules/jvm/src/java/org/scilab/modules/jvm/ClassPath.java @@ -62,7 +62,7 @@ public class ClassPath { */ public static void addURL(final URL u, int i) { - final URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader(); + final URLClassLoader sysloader = new URLClassLoader (new URL[] {}, ClassLoader.getSystemClassLoader()); Class sysclass = URLClassLoader.class; try { @@ -94,12 +94,8 @@ public class ClassPath { */ public static String[] getClassPath() { - URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader(); - URL[] path = sysloader.getURLs(); - String[] paths = new String[path.length]; - for (int i = 0; i < path.length; i++) { - paths[i] = path[i].getFile(); - } + ClassLoader sysloader = ClassLoader.getSystemClassLoader(); + String[] paths = {""}; return paths; } Index: scilab-6.0.1/bin/scilab =================================================================== --- scilab-6.0.1.orig/bin/scilab +++ scilab-6.0.1/bin/scilab @@ -620,6 +620,10 @@ detect_java_vm() { ;; esac + # Hack to enable frontloading all needed and optional jars during load; TO BE USED IN CONJUNCTION WITH RPM SPECFILE SED HACK + export _JAVA_OPTIONS="${_JAVA_OPTIONS} -Djava.class.path=@SPEC_ALL_JAR_CLASSPATHS@ -Djava.library.path=@SPEC_SCI_LIB_PATH@ -Djava.add.modules=java.xml.bind" + + ####### END OF JAVA ENV DETECTION/SETTING ###### } Index: scilab-6.0.1/configure.ac =================================================================== --- scilab-6.0.1.orig/configure.ac +++ scilab-6.0.1/configure.ac @@ -1037,6 +1037,10 @@ interface for JOGL2 - or libGL (OpenGL l JEUCLID_CORE=$PACKAGE_JAR_FILE AC_SUBST(JEUCLID_CORE) + # JAF required for xmlto* functions + AC_JAVA_CHECK_JAR([jaf],[javax.activation.MimetypesFileTypeMap],[JAF : JavaBeans Activation Framework]) + JAF=$PACKAGE_JAR_FILE + AC_SUBST(JAF) ################ Mandatory for graphic_export features ##### # XML to PDF/other Translator Index: scilab-6.0.1/configure =================================================================== --- scilab-6.0.1.orig/configure +++ scilab-6.0.1/configure @@ -809,6 +809,7 @@ FREEHEP_GRAPHICSIO FREEHEP_GRAPHICS2D FOP JEUCLID_CORE +JAF JROSETTA_ENGINE JROSETTA_API LUCENE_PARSER @@ -17826,6 +17827,224 @@ $as_echo "$as_me: WARNING: Could not fin JEUCLID_CORE=$PACKAGE_JAR_FILE + # JavaBeans Activation Framework + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking jaf" >&5 +$as_echo_n "checking jaf... " >&6; } + PACKAGE_JAR_FILE= + + DEFAULT_JAR_DIR="$(pwd)/thirdparty/ $(pwd)/jar/ /usr/local/java/ /usr/local/java/jar /usr/local/share/java/ /usr/local/share/java/jar/ /usr/local/lib/java/ $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null | sort) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null) /opt/java/lib/" + + jar_resolved="$(find $DEFAULT_JAR_DIR -maxdepth 1 \( -type f -name 'jaf.jar' -or -name 'libjaf.jar' -or -name 'libjaf-java.jar' -or -name 'jaf*.jar' \) 2>/dev/null |tr '\n' ':')." + + if test ! -f conftestSharedChecker.class ; then + + cat << \EOF > conftestSharedChecker.java +// #line 14982 "configure" +import java.util.regex.Pattern; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; + +public class conftestSharedChecker { + + /** + * Required arguments : + * argv[0]: name of the jar package + * argv[1]: name of the class (with the package prefix) + * argv[2]: possible paths of the jar package (separated by ':') + * + * Optional arguments: + * argv[3]: field or method used to retrieve the version + * argv[4]: expected version + * argv[5]: String comparator : + * "=" for exact version + */ + public static void main(String[] argv) { + final String packageName = argv[0]; + final String className = argv[1]; + final String[] jarList = argv[2].split(":"); + + ArrayList<URL> found = new ArrayList<>(); + for(String jar : jarList) + { + try { + File f = new File(jar); + if (f.exists()) { + found.add(f.toURI().toURL()); + } + } catch (IOException ex) { + System.err.println(ex.toString()); + } + } + + URLClassLoader localClassLoader = new URLClassLoader(found.toArray(new URL[found.size()])); + URL klassURL = null; + Class<?> klass = null; + try { + String resourceName = className.replace(".", "/") + ".class"; + klassURL = localClassLoader.getResource(resourceName); + klass = localClassLoader.loadClass(className); + } catch (ClassNotFoundException ex) { + System.err.println(className + " not found"); + System.exit(-1); + } + + String pathURL = klassURL.getPath().substring(0, klassURL.getPath().indexOf('!')); + String path = pathURL.substring(pathURL.indexOf(':') + 1); + System.err.println("found: " + path); + + if (argv.length > 3) { + checkVersion(klass, argv); + } + + System.out.println(path); + } + + private static void checkVersion(Class<?> klass, String[] argv) throws SecurityException, IllegalArgumentException { + final String versionMethod = argv[3]; + final String expected = argv[4]; + final String atLeastOrEqual; + if (argv.length > 5) + atLeastOrEqual = argv[5]; + else + atLeastOrEqual = "<="; + + try { + try { + Field field = klass.getField(versionMethod); + Object value = field.get(null); + compareAndDisplay(atLeastOrEqual, expected, value); + } catch (NoSuchFieldException fe) { + Method method = null; + try { + method = klass.getMethod(versionMethod); + } catch (NoSuchMethodException ex) { + System.err.println(ex.toString()); + System.exit(-3); + } + + try { + Object value = method.invoke(null); + compareAndDisplay(atLeastOrEqual, expected, value); + } catch (NullPointerException ex) { + Object value = method.invoke(klass.newInstance()); + compareAndDisplay(atLeastOrEqual, expected, value); + } + } + } catch (IllegalAccessException ex) { + System.err.println(ex); + System.exit(-2); + } catch (InvocationTargetException ex) { + System.err.println(ex); + System.exit(-2); + } catch (InstantiationException ex) { + System.err.println(ex); + System.exit(-2); + } + } + + private static void compareAndDisplay(String atLeastOrEqual, String expected, Object value) { + int cmp = compare(expected, value.toString()); + + switch(atLeastOrEqual) { + case ">": + if (cmp > 0) { + return; + } else { + System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value); + System.exit(-4); + } + case "==": + if (cmp == 0) { + return; + } else { + System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value); + System.exit(-4); + } + case "<=": + if (cmp <= 0) { + return; + } else { + System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value); + System.exit(-4); + } + default: + System.err.println("unable to compare with "+atLeastOrEqual); + System.exit(-4); + } + } + + private static int compare(String v1, String v2) { + String s1 = normalisedVersion(v1); + String s2 = normalisedVersion(v2); + + System.err.println("compare: " + v1 + " normalised to " + s1); + System.err.println("compare: " + v2 + " normalised to " + s2); + return s1.compareTo(s2); + } + + private static String normalisedVersion(String version) { + return normalisedVersion(version, ".", 4); + } + + private static String normalisedVersion(String version, String sep, int maxWidth) { + String[] split = Pattern.compile(sep, Pattern.LITERAL).split(version); + StringBuilder sb = new StringBuilder(); + for (String s : split) { + sb.append(String.format("%" + maxWidth + 's', s)); + } + return sb.toString(); + } +} +EOF + + CLASSPATH=$ac_java_classpath + export CLASSPATH + cmd="$JAVAC ${JAVAC_FLAGS} conftestSharedChecker.java" + if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5) ; then + echo "configure: conftestSharedChecker.class available" >&5 + else + echo "configure: failed program was:" >&5 + cat conftestSharedChecker.java >&5 + echo "configure: CLASSPATH was $CLASSPATH" >&5 + fi + + fi + + CLASSPATH=$ac_java_classpath + export CLASSPATH + cmd="$JAVA conftestSharedChecker jaf javax.activation.MimetypesFileTypeMap $jar_resolved " + if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5); then + PACKAGE_JAR_FILE=$(tail -n 1 conftestSharedChecker.java.output); + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PACKAGE_JAR_FILE" >&5 +$as_echo "$PACKAGE_JAR_FILE" >&6; } + echo "yes" >&5 + # append the found file to the classpath to manage jar dependency + ac_java_classpath="$ac_java_classpath:$PACKAGE_JAR_FILE" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + if test "" = "yes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Could not find or use the Java package/jar jaf used by Scilab Gui - JavaBeans Activation Framework (looking for package javax.activation.MimetypesFileTypeMap)" >&5 +$as_echo "$as_me: WARNING: Could not find or use the Java package/jar jaf used by Scilab Gui - JavaBeans Activation Framework (looking for package javax.activation.MimetypesFileTypeMap)" >&2;} + else + as_fn_error $? "Could not find or use the Java package/jar jaf used by Scilab Gui - JavaBeans Activation Framework (looking for package javax.activation.MimetypesFileTypeMap)" "$LINENO" 5 + fi + fi + if test -f conftestSharedChecker.java.output; then + rm conftestSharedChecker.java.output + fi + + JAF=$PACKAGE_JAR_FILE + ################ Mandatory for graphic_export features ##### # XML to PDF/other Translator Index: scilab-6.0.1/etc/classpath.xml.in =================================================================== --- scilab-6.0.1.orig/etc/classpath.xml.in +++ scilab-6.0.1/etc/classpath.xml.in @@ -79,6 +79,8 @@ The option is "disableUnderMode" and can <path value="@GLUEGEN2_RT@"/> +<path value="@JAF@"/> + <!-- Temp. loaded at startup --> <path value="$SCILAB/modules/types/jar/org.scilab.modules.types.jar"/> <!-- END --> Index: scilab-6.0.1/Makefile.in =================================================================== --- scilab-6.0.1.orig/Makefile.in +++ scilab-6.0.1/Makefile.in @@ -630,6 +630,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTLLIBS = @INTLLIBS@ INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +JAF= @JAF@ JAR = @JAR@ JAVA = @JAVA@ JAVAC = @JAVAC@
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor