|
From: <no...@so...> - 2001-01-12 12:11:52
|
Bug #128540, was updated on 2001-Jan-12 03:23
Here is a current snapshot of the bug.
Project: Jython
Category: Core
Status: Closed
Resolution: Later
Bug Group: None
Priority: 5
Submitted by: nobody
Assigned to : nobody
Summary: Importing java classes, constructing java classes
Details: In my app I don't use CLASSPATH much 'cause it gonna be somewhat
big (about 50 jars)
Instead of this I use wildcard as argument to my app-launcher, which parses
wildcard and finds every jar i need (builds net of ClassLoaders etc.) and
Class.forName("anyClass"); works just fine in any piece of app.
Jython package manager(SysPackageManager.java) uses "java.class.path"
property alot when huntin' for jars.
In my app-launcher expand-java.class.path code was added
someth' like that
String currPath = System.getProperty("java.class.path");
String separator = ";";
currPath += separator + "myPackage.jar";
System.setProperty("java.class.path", currPath);
After that modification alot of
*sys-package-mgr*: processing new(modified) jar, 'X:\a\b\c.jar'
was shown at the Jython initialization /Py.initPython();/ assuming
everithing Ok.
BUT!
"from a.b.c.d import myClass" - ImportError: cannot import name myClass
"from a.b.c.d import *" - Ok
"dir()" - names of classes with myClass among... Hm?????
"d = new myClass()" -
java.lang.NullPointerException
at java.lang.Class.isAssignableFrom(Native Method)
at org.python.core.PyJavaClass.init__class__(PyJavaClass.java:143)
at org.python.core.PyJavaClass.init(PyJavaClass.java:214)
at org.python.core.PyJavaClass.initLazy(PyJavaClass.java:78)
at org.python.core.PyJavaClass.initialize(PyJavaClass.java:94)
at
org.python.core.PyJavaClass.initConstructors(PyJavaClass.java:629)
at org.python.core.PyJavaClass.__call__(PyJavaClass.java:781)
at org.python.core.PyObject.__call__(PyObject.java:260)
at org.python.pycode._pyx4.f$0(<console>)
at org.python.pycode._pyx4.call_function(<console>)
at org.python.core.PyTableCode.call(PyTableCode.java:155)
at org.python.core.Py.runCode(Py.java:1050)
at org.python.core.Py.exec(Py.java:1071)
at
org.python.util.PythonInterpreter.exec(PythonInterpreter.java:124)
When I put jar containing myClass.class in CLASSPATH explicitly -
everithing perfect.
Try to put something like
String currPath = System.getProperty("java.class.path");
String separator = ";";
currPath += separator + "myPackage.jar";
System.setProperty("java.class.path", currPath);
at the beginning of org.python.util.jython and don't put myPackage.jar at
CLASSPATH and HAVE FUN ;)
an...@ib...
Follow-Ups:
Date: 2001-Jan-12 04:12
By: bckfnn
Comment:
The "*sys-package-mgr*: processing ..." are done only to support the dir()
and "from .. import *" on java packages. The actual loading of the class is
performed by a basic Class.forName(..).
So it is no surprise that dir() works, but that import doesn't.
However, this this more of a feature request than a bug. A task have
created to describe the feature:
"Loading java classes from other sources" (#24502)
The bug report will be closed, but rest assured that the feature is
important and that Jython will improve in this area.
-------------------------------------------------------
For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=128540&group_id=12867
|