Revision: 5353
          http://sourceforge.net/p/jump-pilot/code/5353
Author:   edso
Date:     2017-03-05 15:35:20 +0000 (Sun, 05 Mar 2017)
Log Message:
-----------
preliminary java9 support, CORE starts now, some errors are caught and shown in 
log error though

Modified Paths:
--------------
    core/trunk/src/com/vividsolutions/jump/workbench/JUMPWorkbench.java
    
core/trunk/src/com/vividsolutions/jump/workbench/plugin/PlugInClassLoader.java
    
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/skin/InstallSkinsPlugIn.java
    
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/skin/SkinOptionsPanel.java

Modified: core/trunk/src/com/vividsolutions/jump/workbench/JUMPWorkbench.java
===================================================================
--- core/trunk/src/com/vividsolutions/jump/workbench/JUMPWorkbench.java 
2017-03-05 15:04:30 UTC (rev 5352)
+++ core/trunk/src/com/vividsolutions/jump/workbench/JUMPWorkbench.java 
2017-03-05 15:35:20 UTC (rev 5353)
@@ -144,11 +144,10 @@
     return iconlist;
   }
 
-  // for java 1.5-
-  public static final ImageIcon APP_ICON = IconLoader.icon("app-icon.gif");
-  // for java 1.6+
-  public static final ArrayList APP_ICONS = appIcons();
-
+  // icons for frame and desktop purposes eg. alt+tab listing
+  public static final ArrayList<Image> APP_ICONS = appIcons();
+  public static final ImageIcon APP_ICON = new ImageIcon(APP_ICONS.get(0));
+  
   // -- dont change the following strings
   public final static String PROPERTIES_OPTION = "properties";
   public final static String DEFAULT_PLUGINS = "default-plugins";
@@ -206,21 +205,11 @@
     }
   }
 
-  private static ImageIcon icon;
-
+  /**
+   * getter for the frame icon
+   */
   public static ImageIcon getIcon() {
-    // java 1.5 is really bad with transparent pngs, so we stick with the gif
-    if (!(icon instanceof ImageIcon)) {
-      Double jre_version = Double.parseDouble(System
-          .getProperty("java.version").substring(0, 3));
-      if (jre_version < 1.6) {
-        icon = APP_ICON;
-      } else {
-        icon = new ImageIcon();
-        icon.setImage((Image) APP_ICONS.get(0));
-      }
-    }
-    return icon;
+    return APP_ICON;
   }
 
   /**

Modified: 
core/trunk/src/com/vividsolutions/jump/workbench/plugin/PlugInClassLoader.java
===================================================================
--- 
core/trunk/src/com/vividsolutions/jump/workbench/plugin/PlugInClassLoader.java  
    2017-03-05 15:04:30 UTC (rev 5352)
+++ 
core/trunk/src/com/vividsolutions/jump/workbench/plugin/PlugInClassLoader.java  
    2017-03-05 15:35:20 UTC (rev 5353)
@@ -1,13 +1,35 @@
 package com.vividsolutions.jump.workbench.plugin;
 
+import java.io.File;
+import java.io.IOException;
 import java.net.URL;
 import java.net.URLClassLoader;
+import java.nio.file.InvalidPathException;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
 
+import com.vividsolutions.jump.workbench.Logger;
+
 public class PlugInClassLoader extends URLClassLoader {
 
   public PlugInClassLoader(ClassLoader parent) {
     super(new URL[0], parent);
-    addUrls(((URLClassLoader) parent).getURLs());
+    // up to java8 we could get the classpath from the app classloader
+    if (parent instanceof URLClassLoader) {
+      addUrls(((URLClassLoader) parent).getURLs());
+    }
+    // that changed in java9, now we build it from the java property
+    else {
+      List ucp = new ArrayList<URL>();
+//      System.out.println(parent.getClass());
+//      String cp = System.getProperty("java.class.path");
+//      System.out.println(cp);
+//      addClassPathToUCP(cp, ucp);
+//      System.out.println(ucp);
+      
+      addUrls((URL[])ucp.toArray(new URL[] {}));
+    }
   }
 
   public PlugInClassLoader(URL[] urls) {
@@ -36,16 +58,14 @@
     }
 
     // we prefer this class loader to the sun.misc.Launcher one to have all OJ
-    // classes within one classloader, advantages are: 
+    // classes within one classloader, advantages are:
     // - instanceof does not work over different classloaders
     // - we override some classes from extension jars (wfs, deegree), which is
-    //   only possible if they are found before the ones in the jars
-    // Note: 
+    // only possible if they are found before the ones in the jars
+    // Note:
     // exception is this class which is already instantiated with
     // sun.misc.Launcher so we keep it that way
-    if (c == null
-        && !name
-            
.equals("com.vividsolutions.jump.workbench.plugin.PlugInClassLoader")) {
+    if (c == null && 
!name.equals("com.vividsolutions.jump.workbench.plugin.PlugInClassLoader")) {
       try {
         c = findClass(name);
       } catch (ClassNotFoundException e) {
@@ -53,15 +73,13 @@
     }
 
     // this classloader is always loaded by the default cl, so find it there
-    if (c == null
-        && name
-            
.equals("com.vividsolutions.jump.workbench.plugin.PlugInClassLoader")) {
+    if (c == null && 
name.equals("com.vividsolutions.jump.workbench.plugin.PlugInClassLoader")) {
       try {
         c = getParent().loadClass(name);
       } catch (ClassNotFoundException e) {
       }
     }
-    
+
     return c;
   }
 
@@ -75,4 +93,39 @@
       addURL(url);
     }
   }
+
+  /**
+   * Converts the elements in the given class path to file URLs and adds them 
to
+   * the given URL List.
+   */
+  private static void addClassPathToUCP(String cp, List<URL> ucp) {
+    int off = 0;
+    int next;
+    while ((next = cp.indexOf(File.pathSeparator, off)) != -1) {
+      URL url = toFileURL(cp.substring(off, next));
+      if (url != null)
+        ucp.add(url);
+      off = next + 1;
+    }
+
+    // remaining
+    URL url = toFileURL(cp.substring(off));
+    if (url != null)
+      ucp.add(url);
+  }
+
+  /**
+   * Attempts to convert the given string to a file URL.
+   *
+   * @apiNote This is called by the VM
+   */
+  private static URL toFileURL(String s) {
+    try {
+      return Paths.get(s).toRealPath().toUri().toURL();
+    } catch (InvalidPathException | IOException ignore) {
+      // malformed path string or class path element does not exist
+      Logger.warn(ignore);
+      return null;
+    }
+  }
 };
\ No newline at end of file

Modified: 
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/skin/InstallSkinsPlugIn.java
===================================================================
--- 
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/skin/InstallSkinsPlugIn.java
     2017-03-05 15:04:30 UTC (rev 5352)
+++ 
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/skin/InstallSkinsPlugIn.java
     2017-03-05 15:35:20 UTC (rev 5353)
@@ -40,6 +40,7 @@
 
 import com.vividsolutions.jts.util.Assert;
 import com.vividsolutions.jump.I18N;
+import com.vividsolutions.jump.workbench.Logger;
 import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn;
 import com.vividsolutions.jump.workbench.plugin.PlugInContext;
 import com.vividsolutions.jump.workbench.ui.OptionsDialog;
@@ -65,11 +66,11 @@
           return (LookAndFeel) Class.forName(lookAndFeelClassName)
               .newInstance();
         } catch (InstantiationException e) {
-          Assert.shouldNeverReachHere(e.toString());
+          Logger.error(e);
         } catch (IllegalAccessException e) {
-          Assert.shouldNeverReachHere(e.toString());
+          Logger.error(e);
         } catch (ClassNotFoundException e) {
-          Assert.shouldNeverReachHere(e.toString());
+          Logger.error(e);
         }
 
         return null;

Modified: 
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/skin/SkinOptionsPanel.java
===================================================================
--- 
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/skin/SkinOptionsPanel.java
       2017-03-05 15:04:30 UTC (rev 5352)
+++ 
core/trunk/src/com/vividsolutions/jump/workbench/ui/plugin/skin/SkinOptionsPanel.java
       2017-03-05 15:35:20 UTC (rev 5353)
@@ -52,8 +52,8 @@
 
 import com.vividsolutions.jump.I18N;
 import com.vividsolutions.jump.util.Blackboard;
+import com.vividsolutions.jump.workbench.Logger;
 import com.vividsolutions.jump.workbench.plugin.PlugInContext;
-import com.vividsolutions.jump.workbench.ui.OptionsDialog;
 import com.vividsolutions.jump.workbench.ui.OptionsPanel;
 import com.vividsolutions.jump.workbench.ui.TrackedPopupMenu;
 import com.vividsolutions.jump.workbench.ui.plugin.PersistentBlackboardPlugIn;
@@ -93,7 +93,15 @@
       for (Iterator i = ((Collection) blackboard.get(SKINS_KEY)).iterator(); i
           .hasNext();) {
         LookAndFeelProxy proxy = (LookAndFeelProxy) i.next();
-        String proxy_skin = proxy.getLookAndFeel().getClass().getName();
+        String proxy_skin = null;
+        try {
+          proxy_skin = proxy.getLookAndFeel().getClass().getName();
+        } catch (NullPointerException e) {
+          // preliminary Workaround: since java9 we cannot access _all_ skins 
anymore
+          Logger.error(e);
+          continue;
+        }
+
         model.addElement(proxy);
 
         // activate saved laf if available


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Jump-pilot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to