VisTrails / VisTrails

VisTrails is an open-source data analysis and visualization tool. It provides a comprehensive provenance infrastructure that maintains detailed history information about the steps followed and data derived in the course of an exploratory task: VisTrails maintains provenance of data products, of the computational processes that derive these products and their executions.
http://www.vistrails.org
BSD 3-Clause "New" or "Revised" License
102 stars 45 forks source link

Fix java_vm:add_on_classpath() on JPype #9

Open remram44 opened 12 years ago

remram44 commented 12 years ago

It should be possible to build a URLClassLoader to be able to load classes from JARs that were not present in the initial CLASSPATH. However, JPype's classloader seems to have a bug: if it doesn't find a class, it throws java.lang.NoClassDefFoundError without allowing the other classloaders to try.

remram44 commented 12 years ago

This code shows the issue:

import jpype
jpype.startJVM('C:\\Program Files (x86)\\Java\\jdk1.6.0_25\\jre\\bin\\client\\jvm.dll')

url = jpype.java.io.File("C:\\classloadertest.jar").toURI().toURL()
classloader = jpype.java.net.URLClassLoader(jpype.JArray(jpype.java.net.URL)([url]))
c = classloader.loadClass("classloadertests.Test") # raises java.lang.NoClassDefFoundError

This is not even the correct exception; Java throws java.lang.ClassNotFoundException if no class with this name is found.

remram44 commented 12 years ago

IMHO this should be fixed in JPype: https://github.com/remram44/jpype/issues/2

I wasn't able to find a workaround.