--- jython/src/org/python/core/packagecache/CachedJarsPackageManager.java 2009-09-26 11:43:16.000000000 -0600 +++ ../jython/src/org/python/core/packagecache/CachedJarsPackageManager.java 2010-04-27 12:37:12.176372979 -0600 @@ -366,6 +366,10 @@ while (true) { String packageName = istream.readUTF(); String classes = istream.readUTF(); + // Handle multiple chunks of classes and concatenate them together + if (packs.containsKey(packageName)) { + classes = packs.get(packageName) + classes; + } packs.put(packageName, classes); } } catch (EOFException eof) { @@ -391,8 +395,12 @@ for (Entry kv : zipPackages.entrySet()) { String classes = kv.getValue(); - ostream.writeUTF(kv.getKey()); - ostream.writeUTF(classes); + for(String part : splitString(classes, 65535)){ + // For each chunk, write the package name + // followed by the classes + ostream.writeUTF(kv.getKey()); + ostream.writeUTF(part); + } } ostream.close(); } catch (IOException ioe) { @@ -401,6 +409,45 @@ } /** + * Split up a string into several chunks based on a certain size + * + * The writeCacheFile method will use the writeUTF method on a + * DataOutputStream which only allows writing 64k chunks, so use + * this utility method to split it up + * + * @param str - The string to split up into chunks + * @param maxLength - The max size a string should be + * @return - An array of strings, each of which will not be larger than maxLength + */ + protected static String[] splitString(String str, int maxLength) { + if (str==null) { + return null; + } + // Determine number of chunks + int len = str.length(); + int fullChunks = len / maxLength; + boolean lastChunkEmpty = fullChunks*maxLength == len; + + // Setup size of array based on number of chunks + int size = fullChunks; + if (!lastChunkEmpty) { + size++; + } + + int i = 0; + String[] chunks = new String[size]; + for (i=0; i