Message7167

Author MrMeanie
Recipients MrMeanie, amak, tklink
Date 2012-05-29.18:24:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1338315845.33.0.374340017809.issue1867@psf.upfronthosting.co.za>
In-reply-to
Content
I have found that this issue affects from-import-* statements. When working with my own codebase, from-import-* statements fail to import contents when trying to load from class files within the file system, or from within a jar.

Using Tomas' example of java.security.spec, we can see that standard Jython imports the classes properly:

Using normal Jython:
C:\jython2.7a1>jython
Jython 2.7a1 (default:4f5e3c12edc0, May 16 2012, 13:40:33)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_31
Type "help", "copyright", "credits" or "license" for more information.
>>> from java.security.spec import *
>>> dir()
['AlgorithmParameterSpec', 'DSAParameterSpec', 'DSAPrivateKeySpec', 'DSAPublicKeySpec', 'ECField', 'ECFieldF2m', 'ECFiel
dFp', 'ECGenParameterSpec', 'ECParameterSpec', 'ECPoint', 'ECPrivateKeySpec', 'ECPublicKeySpec', 'EllipticCurve', 'Encod
edKeySpec', 'InvalidKeySpecException', 'InvalidParameterSpecException', 'KeySpec', 'MGF1ParameterSpec', 'PKCS8EncodedKey
Spec', 'PSSParameterSpec', 'RSAKeyGenParameterSpec', 'RSAMultiPrimePrivateCrtKeySpec', 'RSAOtherPrimeInfo', 'RSAPrivateC
rtKeySpec', 'RSAPrivateKeySpec', 'RSAPublicKeySpec', 'X509EncodedKeySpec', '__doc__', '__name__', '__package__']
>>>


Standalune Jython imports nothing:

Using Jython standalone:
C:\jython2.7a1_s>java -jar jython.jar
Jython 2.7a1 (default:4f5e3c12edc0, May 16 2012, 13:40:33)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_31
Type "help", "copyright", "credits" or "license" for more information.
>>> from java.security.spec import *
>>> dir()
['__doc__', '__name__', '__package__']
>>>


If anyone is interested, I did some digging through the Jython codebase yesterday. I get the impression that org.python.code.JavaImportHelper is being used when the standard caching import system cannot be used, as is the case with the standalone. JavaImportHelper will handle import statements of the form 'import java.net.URL' and 'from java.net import URL' but not of the form 'from java.net import *'. In these cases, a representation of the Java package is created, but not populated.
History
Date User Action Args
2012-05-29 18:24:05MrMeaniesetmessageid: <1338315845.33.0.374340017809.issue1867@psf.upfronthosting.co.za>
2012-05-29 18:24:05MrMeaniesetrecipients: + MrMeanie, amak, tklink
2012-05-29 18:24:05MrMeanielinkissue1867 messages
2012-05-29 18:24:04MrMeaniecreate