Issue1230

classification
Title: importing with '*' from java packages does not work with 2.5b1
Type: Severity: normal
Components: Versions: 2.5b1
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: fwierzbicki Nosy List: cgroves, fwierzbicki, marcdownie, yanne
Priority: Keywords:

Created on 2009-01-12.10:34:47 by yanne, last changed 2009-01-24.19:10:53 by cgroves.

Messages
msg4031 (view) Author: Janne Härkönen (yanne) Date: 2009-01-12.10:34:46
Jython 2.5b1 (trunk:5903:5905, Jan 9 2009, 16:01:29) 
[Java HotSpot(TM) Server VM (Sun Microsystems Inc.)] on java1.6.0_10
Type "help", "copyright", "credits" or "license" for more information.
>>> from java.lang import *
>>> String('test')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not callable
>>>


Jython 2.2.1 on java1.6.0_10
Type "copyright", "credits" or "license" for more information.
>>> from java.lang import *
>>> String('test')
test
>>>
msg4039 (view) Author: Marc Downie (marcdownie) Date: 2009-01-13.05:30:00
To my eye, the bogus lines of code are (at least) the calls to Py.findClass at 
PackageManager.java:110 and PathPackageManager.java:167

If I replace:

jpkg.addClass(jname, Py.findClass(jname));

with 

jpkg.addClass(jname, Py.findClass(jpkg.__name__+"."+jname));

In both spots, then I can import * on both my own classes (on my classpath and 
available through my custom classloaders) and on, say, java.lang.* things in the 
bootclasspath.

It's possible (likely?) that this should actually be a call to this.findClass(...) 
but to prove that I'd need to have a handle on the difference between Py.findClass 
and Py.findClassEx.
msg4043 (view) Author: Marc Downie (marcdownie) Date: 2009-01-13.17:52:29
One additional comment: Now that I have "from X import *" 'working' in 
my codebase under trunk + the above patch, I suspect that I'm feeling 
the effects of the elimination of lazy class loading. My startup time 
has at least doubled with almost all of the extra time being spent 
loading the classes 'referenced' by those '*'. If there was an 
evaluation of the cost & benefits of removing lazy class loading --- and 
I could see it going either way --- then it might need to be redone in 
the light of an actually working 'from X import *'.
msg4065 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2009-01-22.04:18:12
Marc Downie's suggested fix applied in r5957.  We'll watch for
performance implications.
msg4069 (view) Author: Charlie Groves (cgroves) Date: 2009-01-24.19:10:53
Jython's startup is just slower with 2.5 in general:

11:00:56$ time java -jar ~/jython2.2.1/jython.jar -c "print"


real	0m0.881s
user	0m1.061s
sys	0m0.157s
11:01:01$ time java -jar ~/jython2.5b1/jython.jar -c "print"


real	0m2.597s
user	0m3.278s
sys	0m0.337s

We haven't done much optimization in 2.5 yet, so there are probably some  
easy things to pick up to get it back closer to its old speed.  That 
should happen before 2.5 final comes out.
History
Date User Action Args
2009-01-24 19:10:53cgrovessetnosy: + cgroves
messages: + msg4069
2009-01-22 04:18:12fwierzbickisetstatus: open -> closed
assignee: fwierzbicki
resolution: fixed
messages: + msg4065
nosy: + fwierzbicki
2009-01-13 17:52:30marcdowniesetmessages: + msg4043
2009-01-13 05:30:23marcdowniesetnosy: + marcdownie
messages: + msg4039
versions: + 2.5b1
2009-01-12 10:34:47yannecreate