diff --git a/Lib/test/test_java_integration.py b/Lib/test/test_java_integration.py index 807ea61fb..1415093bc 100644 --- a/Lib/test/test_java_integration.py +++ b/Lib/test/test_java_integration.py @@ -20,6 +20,10 @@ from org.python.core.util import FileUtil from org.python.tests import BeanImplementation, Child, Listenable, CustomizableMapHolder +#Just for test_import_star +#java.util.regex was chosen for its small number of classes to reduce the pollution. +from java.util.regex import * + class InstantiationTest(unittest.TestCase): def test_cant_instantiate_abstract(self): self.assertRaises(TypeError, Component) @@ -378,6 +382,10 @@ def test_adding_attributes(self): self.assertEquals(7, m.initial) self.assertEquals(None, m.nonexistent, "Nonexistent fields should be passed on to the Map") + def test_import_star(self): + #Depends on "from java.util.regex import *" at the top. + x = Pattern.compile("foo") + self.assertEquals(x.flags(), 0) def test_main(): test_support.run_unittest(InstantiationTest, diff --git a/src/org/python/core/packagecache/PackageManager.java b/src/org/python/core/packagecache/PackageManager.java index 9501c5cbd..1a6f09a70 100644 --- a/src/org/python/core/packagecache/PackageManager.java +++ b/src/org/python/core/packagecache/PackageManager.java @@ -107,7 +107,7 @@ protected PyList basicDoDir(PyJavaPackage jpkg, boolean instantiate, for (PyObject pyname : cls.keys().asIterable()) { if (!dict.has_key(pyname)) { String name = pyname.toString(); - jpkg.addClass(name, Py.findClass(name)); + jpkg.addClass(name, Py.findClass(jpkg.__name__ + "." + name)); } } diff --git a/src/org/python/core/packagecache/PathPackageManager.java b/src/org/python/core/packagecache/PathPackageManager.java index 135c0ff67..63c3838e3 100644 --- a/src/org/python/core/packagecache/PathPackageManager.java +++ b/src/org/python/core/packagecache/PathPackageManager.java @@ -164,7 +164,7 @@ protected void doDir(PyList path, PyList ret, PyJavaPackage jpkg, if (pkgCand) { jpkg.addPackage(jname); } else { - jpkg.addClass(jname, Py.findClass(jname)); + jpkg.addClass(jname, Py.findClass(jpkg.__name__ + "." + jname)); } }