harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r415891 - /incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/Segment.java
Date Wed, 21 Jun 2006 03:44:03 GMT
Author: ndbeyer
Date: Tue Jun 20 20:44:02 2006
New Revision: 415891

URL: http://svn.apache.org/viewvc?rev=415891&view=rev
Log:
Apply modified patch for HARMONY-632.

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/Segment.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/Segment.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/Segment.java?rev=415891&r1=415890&r2=415891&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/Segment.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/org/apache/harmony/archive/internal/pack200/Segment.java
Tue Jun 20 20:44:02 2006
@@ -189,14 +189,24 @@
 
 	private int defaultClassMinorVersion;
 
+	private byte[][] fileBits;
+
+	private int numberOfFiles;
+
+	private long[] fileModtime;
+
+	private String[] fileName;
+
+	private long[] fileOptions;
+
+	private long[] fileSize;
+
 	private int innerClassCount;
 
 	private int major;
 
 	private int minor;
 
-	private int numberOfFiles;
-
 	private SegmentOptions options;
 
 	private int segmentsRemaining;
@@ -269,6 +279,14 @@
 			throw new Error("No idea what the adc is for yet");
 	}
 
+	private void parseBcBands(InputStream in) {
+		System.err.println("Not yet implemented");
+	}
+
+	private void parseClassBands(InputStream in) {
+		System.err.println("Not yet implemented");
+	}
+
 	private void parseClassCounts(InputStream in) throws IOException,
 			Pack200Exception {
 		setInnerClassCount(Codec.UNSIGNED5.decode(in));
@@ -584,6 +602,57 @@
 	}
 
 	/**
+	 * Parses the file band headers (not including the actual bits themselves).
+	 * At the end of this parse call, the input stream will be positioned at the
+	 * start of the file_bits themselves, and there will be Sum(file_size) bits
+	 * remaining in the stream with BYTE1 compression. A decent implementation
+	 * will probably just stream the bytes out to the reconstituted Jar rather
+	 * than caching them.
+	 * 
+	 * @param in
+	 *            the input stream to read from
+	 * @throws IOException
+	 *             if a problem occurs during reading from the underlying stream
+	 * @throws Pack200Exception
+	 *             if a problem occurs with an unexpected value or unsupported
+	 *             codec
+	 */
+	private void parseFileBands(InputStream in) throws IOException,
+			Pack200Exception {
+		long last;
+		fileName = parseReferences(in, Codec.UNSIGNED5, numberOfFiles, cpUTF8);
+		fileSize = new long[numberOfFiles];
+		if (options.hasFileSizeHi()) {
+			last = 0;
+			for (int i = 0; i < numberOfFiles; i++) {
+				fileSize[i] = (last = Codec.UNSIGNED5.decode(in, last)) << 32;
+			}
+		}
+		last = 0;
+		for (int i = 0; i < numberOfFiles; i++) {
+			fileSize[i] |= (last = Codec.UNSIGNED5.decode(in, last));
+		}
+		fileModtime = new long[numberOfFiles];
+		if (options.hasFileModtime()) {
+			last = 0;
+			for (int i = 0; i < numberOfFiles; i++) {
+				fileModtime[i] |= (last = Codec.DELTA5.decode(in, last));
+			}
+		}
+		fileOptions = new long[numberOfFiles];
+		if (options.hasFileOptions()) {
+			last = 0;
+			for (int i = 0; i < numberOfFiles; i++) {
+				fileOptions[i] |= (last = Codec.UNSIGNED5.decode(in, last));
+			}
+		}
+	}
+
+	private void parseIcBands(InputStream in) {
+		System.err.println("Not yet implemented");
+	}
+
+	/**
 	 * Helper method to parse <i>count</i> references from <code>in</code>,
 	 * using <code>codec</code> to decode the values as indexes into
 	 * <code>reference</code> (which is populated prior to this call). An
@@ -652,6 +721,12 @@
 		parseCpMethod(in);
 		parseCpIMethod(in);
 		parseAttributeDefinition(in);
+		parseIcBands(in); // Not yet implemented
+		parseClassBands(in); // Not yet implemented
+		parseBcBands(in); // Not yet implemented
+		parseFileBands(in);
+		processFileBits(in); // this just caches them in file_bits; it should
+								// probably start writing here?
 	}
 
 	private void parseSegmentHeader(InputStream in) throws IOException,
@@ -666,6 +741,22 @@
 		parseArchiveSpecialCounts(in);
 		parseCpCounts(in);
 		parseClassCounts(in);
+	}
+
+	private void processFileBits(InputStream in) throws IOException,
+			Pack200Exception {
+		// now read in the bytes
+		fileBits = new byte[numberOfFiles][];
+		for (int i = 0; i < numberOfFiles; i++) {
+			int size = (int) fileSize[i];
+			// TODO This buggers up if file_size > 2^32. Probably an array is
+			// not the right choice, and
+			// we should just serialise the bugger here?
+			fileBits[i] = new byte[size];
+			for (int j = 0; j < size; j++) {
+				fileBits[i][j] = (byte) Codec.BYTE1.decode(in);
+			}
+		}
 	}
 
 	public void setArchiveModtime(long archiveModtime) {



Mime
View raw message