Revision: 5582
          http://sourceforge.net/p/jump-pilot/code/5582
Author:   michaudm
Date:     2017-11-26 14:15:47 +0000 (Sun, 26 Nov 2017)
Log Message:
-----------
add appendToClassPathForInstrumentation method to PlugInClassLoader so that it 
can be started from IDE using code instrumentation

Modified Paths:
--------------
    core/trunk/ChangeLog
    
core/trunk/src/com/vividsolutions/jump/workbench/plugin/PlugInClassLoader.java

Modified: core/trunk/ChangeLog
===================================================================
--- core/trunk/ChangeLog        2017-11-22 19:44:00 UTC (rev 5581)
+++ core/trunk/ChangeLog        2017-11-26 14:15:47 UTC (rev 5582)
@@ -3,6 +3,10 @@
 # 2. make sure that lines break at 80 chars for constricted display situations
 #<-------------------------------- 80 chars 
---------------------------------->#
 
+2017-11-26 mmichaud <m.michael.mich...@orange.fr>
+  * add appendToClassPathForInstrumentation method to PlugInClassLoader
+    so that it can be started from IDE using code instrumentation
+
 2017-11-19 mmichaud <m.michael.mich...@orange.fr>
   * hack to solve #448 about creating new folders in JFCWithEnterAction
 

Modified: 
core/trunk/src/com/vividsolutions/jump/workbench/plugin/PlugInClassLoader.java
===================================================================
--- 
core/trunk/src/com/vividsolutions/jump/workbench/plugin/PlugInClassLoader.java  
    2017-11-22 19:44:00 UTC (rev 5581)
+++ 
core/trunk/src/com/vividsolutions/jump/workbench/plugin/PlugInClassLoader.java  
    2017-11-26 14:15:47 UTC (rev 5582)
@@ -1,7 +1,10 @@
 package com.vividsolutions.jump.workbench.plugin;
 
+import sun.net.www.ParseUtil;
+
 import java.io.File;
 import java.io.IOException;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.nio.file.InvalidPathException;
@@ -127,4 +130,30 @@
       return null;
     }
   }
+
+  /**
+   * This class loader supports dynamic additions to the class path
+   * at runtime.
+   *
+   * @see java.lang.instrument.Instrumentation#appendToSystemClassLoaderSearch
+   */
+  private  void appendToClassPathForInstrumentation(String path) {
+    assert(Thread.holdsLock(this));
+
+    // addURL is a no-op if path already contains the URL
+    super.addURL( getFileURL(new File(path)) );
+  }
+
+  static  URL getFileURL(File file) {
+    try {
+      file = file.getCanonicalFile();
+    } catch (IOException e) {}
+
+    try {
+      return ParseUtil.fileToEncodedURL(file);
+    } catch (MalformedURLException e) {
+      // Should never happen since we specify the protocol...
+      throw new InternalError();
+    }
+  }
 };
\ No newline at end of file


------------------------------------------------------------------------------
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
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to