harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r506363 - in /harmony/enhanced/classlib/trunk/modules/pack200/src: main/java/org/apache/harmony/pack200/ test/java/org/apache/harmony/pack200/tests/ test/resources/org/apache/harmony/pack200/tests/
Date Mon, 12 Feb 2007 08:07:38 GMT
Author: hindessm
Date: Mon Feb 12 00:07:38 2007
New Revision: 506363

URL: http://svn.apache.org/viewvc?view=rev&rev=506363
Log:
Applied pack200 patches from "[#HARMONY-3153] [classlib][pack200] Support for GZip compressed
files automatically if GZip magic header found".

Added:
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/resources/org/apache/harmony/pack200/tests/JustResources.pack.gz
  (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java?view=diff&rev=506363&r1=506362&r2=506363
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java
Mon Feb 12 00:07:38 2007
@@ -146,6 +146,17 @@
 	public static Segment parse(InputStream in) throws IOException,
 			Pack200Exception {
 		Segment segment = new Segment();
+		// See if file is GZip compressed
+		if (in.markSupported()) {
+			in.mark(2);
+			if (((in.read() & 0xFF) | (in.read() & 0xFF) << 8) == GZIPInputStream.GZIP_MAGIC)
{
+				in.reset();
+				in = new GZIPInputStream(in);
+			} else {
+				in.reset();
+			}
+
+		}
 		segment.parseSegment(in);
 		return segment;
 	}
@@ -796,18 +807,19 @@
 		// look through each method
 		int codeBands = 0;
 		AttributeLayout layout = attributeDefinitionMap.getAttributeLayout(
-				AttributeLayout.ATTRIBUTE_CODE,
-				AttributeLayout.CONTEXT_METHOD);
+				AttributeLayout.ATTRIBUTE_CODE, AttributeLayout.CONTEXT_METHOD);
 
 		for (int i = 0; i < classCount; i++) {
 			for (int j = 0; j < methodFlags[i].length; j++) {
 				long flag = methodFlags[i][j];
-				if (layout.matches(flag)) 
+				if (layout.matches(flag))
 					codeBands++;
 			}
 		}
 		if (codeBands > 0)
-			throw new Error("Can't handle non-abstract, non-native methods/initializers at the moment
(found " + codeBands + " code bands)");
+			throw new Error(
+					"Can't handle non-abstract, non-native methods/initializers at the moment (found "
+							+ codeBands + " code bands)");
 		debug("unimplemented code_headers");
 		debug("unimplemented code_max_stack");
 		debug("unimplemented code_max_na_locals");

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java?view=diff&rev=506363&r1=506362&r2=506363
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/SegmentTest.java
Mon Feb 12 00:07:38 2007
@@ -15,9 +15,11 @@
  *  limitations under the License.
  */
 package org.apache.harmony.pack200.tests;
-//NOTE: Do not use generics in this code; it needs to run on JVMs < 1.5
-//NOTE: Do not extract strings as messages; this code is still a work-in-progress
-//NOTE: Also, don't get rid of 'else' statements for the hell of it ...
+
+// NOTE: Do not use generics in this code; it needs to run on JVMs < 1.5
+// NOTE: Do not extract strings as messages; this code is still a
+// work-in-progress
+// NOTE: Also, don't get rid of 'else' statements for the hell of it ...
 import org.apache.harmony.pack200.Segment;
 
 import junit.framework.TestCase;
@@ -27,10 +29,6 @@
  * @version $Revision: $
  */
 public class SegmentTest extends TestCase {
-	/**
-	 * @param args
-	 * @throws Exception
-	 */
 // Commented on request in HARMONY-2246
 // Will be uncommented later     
 //	public void testHelloWorld() throws Exception {
@@ -38,12 +36,20 @@
 //				.getResourceAsStream("/org/apache/harmony/pack200/tests/HelloWorld.pack")));
 //	}
 	/**
-	 * @param args
 	 * @throws Exception
 	 */
 	public void testJustResources() throws Exception {
-		assertNotNull(Segment.parse(Segment.class
-				.getResourceAsStream("/org/apache/harmony/pack200/tests/JustResources.pack")));
+		assertNotNull(Segment
+				.parse(Segment.class
+						.getResourceAsStream("/org/apache/harmony/pack200/tests/JustResources.pack")));
+	}
+	/**
+	 * @throws Exception
+	 */
+	public void testJustResourcesGZip() throws Exception {
+		assertNotNull(Segment
+				.parse(Segment.class
+						.getResourceAsStream("/org/apache/harmony/pack200/tests/JustResources.pack.gz")));
 	}
 
 }

Added: harmony/enhanced/classlib/trunk/modules/pack200/src/test/resources/org/apache/harmony/pack200/tests/JustResources.pack.gz
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/resources/org/apache/harmony/pack200/tests/JustResources.pack.gz?view=auto&rev=506363
==============================================================================
Binary file - no diff available.

Propchange: harmony/enhanced/classlib/trunk/modules/pack200/src/test/resources/org/apache/harmony/pack200/tests/JustResources.pack.gz
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message