Open GoogleCodeExporter opened 9 years ago
i have spent the whole night dealing whith this problem, and it still
unresolved.
the jython runs on sun jvm will not call JavaImportHelper at all, and it will
call
this class only when you input some sentence like >>>import
somthingdonotcontaininjreorcodes
so i traced to the place that calls JavaImportHelper:imp.java
*
* @param mod a previously loaded module
* @param parentNameBuffer
* @param name the name of the module to load
* @return null or None
*/
private static PyObject import_next(PyObject mod,
StringBuffer parentNameBuffer, String name, String outerFullName,
PyObject fromlist) {
if (parentNameBuffer.length() > 0) {
parentNameBuffer.append('.');
}
parentNameBuffer.append(name);
String fullName = parentNameBuffer.toString().intern();
PyObject modules = Py.getSystemState().modules;
PyObject ret = modules.__finditem__(fullName);
if (ret != null) {
return ret;
}
if (mod == null) {
ret = find_module(fullName.intern(), name, null);
} else {
ret = mod.impAttr(name.intern());
}
if (ret == null || ret == Py.None) {
if (JavaImportHelper.tryAddPackage(outerFullName, fromlist)) {
ret = modules.__finditem__(fullName);
}
return ret;
}
if (modules.__finditem__(fullName) == null) {
modules.__setitem__(fullName, ret);
} else {
ret = modules.__finditem__(fullName);
}
return ret;
}
so i doing some bugfix to make sure that the ret will not be null or Py.None
Original comment by juanzhew...@gmail.com
on 14 Apr 2008 at 2:35
trace into #ret = find_module(fullName.intern(), name, null);#
path = path == null ? sys.path : path;
for (int i = 0; i < path.__len__(); i++) {
PyObject p = path.__getitem__(i);
// System.err.println("find_module (" + name + ", " + moduleName +
// ") Path: " + path);
PyObject importer = getPathImporter(sys.path_importer_cache,
sys.path_hooks, p);
if (importer != Py.None) {
PyObject findModule = importer.__getattr__("find_module");
loader = findModule.__call__(new PyObject[] { new PyString(
moduleName) });
if (loader != Py.None) {
return loadFromLoader(loader, moduleName);
}
}
ret = loadFromSource(name, moduleName, p);
if (ret != null) {
return ret;
}
}
when i=1, the jython in sun jvm will make ret to be PyJavaClass.
there must be the place where the bug raise.
Original comment by juanzhew...@gmail.com
on 14 Apr 2008 at 2:39
i have reported the java.lang.Package.getPackages() bug to the android team, see
http://code.google.com/p/android/issues/detail?id=680&sort=-id&colspec=ID%20Type
%20Version%20Security%20Status%20Owner%20Summary
Original comment by juanzhew...@gmail.com
on 16 Apr 2008 at 1:40
How to make import * run in case of J2EE ?. Iam using JavaImportHelper , but
apparently that doesnt handle the import * statements. We are stuck with this.
Any
help would be greatly appreciated.
Original comment by anveshre...@gmail.com
on 21 Aug 2009 at 5:15
Original issue reported on code.google.com by
juanzhew...@gmail.com
on 14 Apr 2008 at 11:04