Issue227422

classification
Title: Importing java-classes from non-defaul ClassLoaders
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: later
Dependencies: Superseder:
Assigned To: Nosy List: bckfnn, nobody, pedronis
Priority: low Keywords:

Created on 2001-01-03.17:30:59 by anonymous, last changed 2001-05-10.10:59:04 by nobody.

Messages
msg245 (view) Author: Nobody/Anonymous (nobody) Date: 2001-01-03.17:30:59
I have my own classloader, which loads Jython also.
When I run this 

+++++++
package a.b.c
import org.python.util.PythonInterpreter;
import org.python.core.*;

public class Test{

    public static void main(String args[]) throws Exception  {
    
        PythonInterpreter interp = new PythonInterpreter();
        interp.exec("from a.b.c import Test");
        interp.exec("s = Test.countLetters('wednesday')");
        PyObject x = interp.get("s");
        System.out.println("s=" + x);
   }

    public static String countLetters(String str){
        return "Word '"+str+"' has "+ str.length() + " letters";
    }

}
++++++++++++++++
I have 
"ImportError: no module named a"

But when I explicitly write my.jar(a.b.c.Test) to classpath - everithing is Ok.

What about usin' Thead.getContextClassLoader() in Py.findClass() or something?

PS can't register so my e-mail is andrew@ibis.odessa.ua
msg246 (view) Author: Samuele Pedroni (pedronis) Date: 2001-01-03.20:05:39
more a feature request than a bug. (sorry)

notes:
 * simply making java loading through 'import' thread-context-class-loader related: a bad confusing hack, won't do that
 * simply setting PySystemState.classLoader at init:
  not really a workaround, by now too many jythonc-related
  side-effects, e.g. sys.path loading disabled ...

This is part of the poor-man-freezing design issue
(after 2.0):

with jython -jar ... or java -jar ...

what kind of:
 python importing
 java loading
 sys-package-manager init
to offer? ...
msg247 (view) Author: Finn Bock (bckfnn) Date: 2001-01-12.12:05:38
This feature request is described in a new task (#24502) :

 "Loading java classes from other sources"

The bug report will be closed.
msg248 (view) Author: Nobody/Anonymous (nobody) Date: 2001-05-10.10:59:04
Logged In: NO 

This is also a problem when trying to embed Jython (2.0)
into the JVM of Oracle8iR3:
java.lang.SecurityException: relative pathnames are not
allowed(./JythonOracle)
  at
oracle.aurora.rdbms.SecurityManagerImpl.checkFileIsAbsolute(SecurityManagerImpl.java)
  at
oracle.aurora.rdbms.SecurityManagerImpl.checkRead(SecurityManagerImpl.java)
  at java.io.File.isDirectory(File.java)
  at org.python.core.imp.loadFromPath(imp:285)
  at org.python.core.imp.loadFromPath(imp:252)
  at org.python.core.imp.load(imp:357)
  at org.python.core.imp.load(imp:376)
  at org.python.core.imp.importName(imp:447)
  at org.python.core.imp.importName(imp:509)
  at org.python.core.ImportFunction.load(__builtin__:967)
  at
org.python.core.ImportFunction.__call__(__builtin__:961)
  at org.python.core.PyObject.__call__(PyObject:250)
  at org.python.core.__builtin__.__import__(__builtin__:921)
  at org.python.core.imp.importAll(imp:592)
  at org.python.pycode._pyx0.f$0(<string>)
  at org.python.pycode._pyx0.call_function(<string>)
  at org.python.core.PyTableCode.call(PyTableCode:155)
  at org.python.core.Py.runCode(Py:1055)
  at org.python.core.Py.exec(Py:1076)
  at
org.python.util.PythonInterpreter.exec(PythonInterpreter:135)
  at SimpleEmbedded.getresult(SimpleEmbedded:17)
History
Date User Action Args
2001-01-03 17:30:59anonymouscreate