From: <cg...@us...> - 2009-01-01 00:37:53
|
Revision: 5827 http://jython.svn.sourceforge.net/jython/?rev=5827&view=rev Author: cgroves Date: 2009-01-01 00:37:49 +0000 (Thu, 01 Jan 2009) Log Message: ----------- Remove the last vestiges of lazily loaded classes. Will reevaluate their presence if performance problems come up. Modified Paths: -------------- trunk/jython/src/org/python/core/PyJavaPackage.java trunk/jython/src/org/python/core/packagecache/PackageManager.java trunk/jython/src/org/python/core/packagecache/PathPackageManager.java Modified: trunk/jython/src/org/python/core/PyJavaPackage.java =================================================================== --- trunk/jython/src/org/python/core/PyJavaPackage.java 2009-01-01 00:35:27 UTC (rev 5826) +++ trunk/jython/src/org/python/core/PyJavaPackage.java 2009-01-01 00:37:49 UTC (rev 5827) @@ -91,13 +91,11 @@ return ret; } - public PyObject addLazyClass(String name) { - // TODO - make lazy PyJavaType - return null; - } - - /** Add statically known classes. - * @param classes their names as comma-separated string + /** + * Add statically known classes. + * + * @param classes + * their names as comma-separated string */ public void addPlaceholders(String classes) { StringTokenizer tok = new StringTokenizer(classes, ",@"); @@ -114,11 +112,10 @@ } /** - * Used for 'from xyz import *', dynamically dir pkg filling up __dict__. - * It uses {@link PackageManager#doDir} implementation furnished by - * the control package manager with instatiate true. The package - * manager should lazily load classes with {@link #addLazyClass} in - * the package. + * Used for 'from xyz import *', dynamically dir pkg filling up __dict__. It uses + * {@link PackageManager#doDir} implementation furnished by the control package manager with + * instantiate true. The package manager should load classes with {@link #addClass} in the + * package. * * @return list of member names */ Modified: trunk/jython/src/org/python/core/packagecache/PackageManager.java =================================================================== --- trunk/jython/src/org/python/core/packagecache/PackageManager.java 2009-01-01 00:35:27 UTC (rev 5826) +++ trunk/jython/src/org/python/core/packagecache/PackageManager.java 2009-01-01 00:37:49 UTC (rev 5827) @@ -3,6 +3,7 @@ package org.python.core.packagecache; +import org.python.core.Py; import org.python.core.PyJavaPackage; import org.python.core.PyList; import org.python.core.PyObject; @@ -33,7 +34,7 @@ /** * Dynamically check if pkg.name exists as java pkg in the controlled * hierarchy. Should be overriden. - * + * * @param pkg parent pkg name * @param name candidate name * @return true if pkg exists @@ -43,7 +44,7 @@ /** * Reports the specified package content names. Should be overriden. Used by * {@link PyJavaPackage#__dir__} and {@link PyJavaPackage#fillDir}. - * + * * @return resulting list of names (PyList of PyString) * @param jpkg queried package * @param instantiate if true then instatiate reported names in package dict @@ -55,7 +56,7 @@ /** * Append a directory to the list of directories searched for java packages * and java classes. - * + * * @param dir A directory. */ public abstract void addDirectory(java.io.File dir); @@ -63,7 +64,7 @@ /** * Append a directory to the list of directories searched for java packages * and java classes. - * + * * @param dir A directory name. */ public abstract void addJarDir(String dir, boolean cache); @@ -71,7 +72,7 @@ /** * Append a jar file to the list of locations searched for java packages and * java classes. - * + * * @param jarfile A directory name. */ public abstract void addJar(String jarfile, boolean cache); @@ -102,12 +103,12 @@ return ret; } - PyList clsNames = cls.keys(); - for (int i = 0; i < clsNames.__len__(); i++) { - PyObject name = clsNames.pyget(i); - if (!dict.has_key(name)) - jpkg.addLazyClass(name.toString()); + for (PyObject pyname : cls.keys().asIterable()) { + if (!dict.has_key(pyname)) { + String name = pyname.toString(); + jpkg.addClass(name, Py.findClass(name)); + } } return dict.keys(); @@ -149,7 +150,7 @@ * Creates package/updates statically known classes info. Uses * {@link PyJavaPackage#addPackage(java.lang.String, java.lang.String) }, * {@link PyJavaPackage#addPlaceholders}. - * + * * @param name package name * @param classes comma-separated string * @param jarfile involved jarfile; can be null @@ -184,11 +185,11 @@ //Empty or 1 byte file. return -1; } - //int minor = + //int minor = istream.readShort(); //int major = istream.readShort(); - + // Check versions??? // System.out.println("magic: "+magic+", "+major+", "+minor); int nconstants = istream.readShort(); Modified: trunk/jython/src/org/python/core/packagecache/PathPackageManager.java =================================================================== --- trunk/jython/src/org/python/core/packagecache/PathPackageManager.java 2009-01-01 00:35:27 UTC (rev 5826) +++ trunk/jython/src/org/python/core/packagecache/PathPackageManager.java 2009-01-01 00:37:49 UTC (rev 5827) @@ -164,7 +164,7 @@ if (pkgCand) { jpkg.addPackage(jname); } else { - jpkg.addLazyClass(jname); + jpkg.addClass(jname, Py.findClass(jname)); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |