harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhouke...@apache.org
Subject svn commit: r791419 - in /harmony/enhanced: classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/ jdktools/trunk/modules/jretools/src/main/java/org/apache/harmony/jretools/pack200/
Date Mon, 06 Jul 2009 09:24:13 GMT
Author: zhoukevin
Date: Mon Jul  6 09:24:11 2009
New Revision: 791419

URL: http://svn.apache.org/viewvc?rev=791419&view=rev
Log:
Implement -H cmd line option for pack200

Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java
    harmony/enhanced/jdktools/trunk/modules/jretools/src/main/java/org/apache/harmony/jretools/pack200/Main.java

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java?rev=791419&r1=791418&r2=791419&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java
Mon Jul  6 09:24:11 2009
@@ -274,7 +274,7 @@
             javaClasses.add(classParser);
             bytes = new byte[0];
         }
-        files.add(new PackingFile(name, bytes, jarEntry.getTime()));
+        files.add(new PackingFile(name, bytes, jarEntry));
         return true;
     }
 
@@ -354,11 +354,20 @@
         private final String name;
         private byte[] contents;
         private final long modtime;
+        private final boolean deflateHint;
 
         public PackingFile(String name, byte[] contents, long modtime) {
             this.name = name;
             this.contents = contents;
             this.modtime = modtime;
+            deflateHint = false;
+        }
+
+        public PackingFile(String name, byte[] contents, JarEntry jarEntry) {
+            this.name = name;
+            this.contents = contents;
+            modtime = jarEntry.getTime();
+            deflateHint = (jarEntry.getMethod() == JarEntry.DEFLATED);
         }
 
         public byte[] getContents() {
@@ -380,6 +389,10 @@
         public void setContents(byte[] contents) {
             this.contents = contents;
         }
+
+        public boolean isDefalteHint() {
+            return deflateHint;
+        }
     }
 
 }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java?rev=791419&r1=791418&r2=791419&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java
Mon Jul  6 09:24:11 2009
@@ -67,8 +67,8 @@
         boolean isLatest = !PackingOptions.KEEP.equals(options
                 .getModificationTime());
         for (int i = 0; i < size; i++) {
-            PackingFile file = (PackingFile) fileList.get(i);
-            String name = file.getName();
+            PackingFile packingFile = (PackingFile) fileList.get(i);
+            String name = packingFile.getName();
             if (name.endsWith(".class") && !options.isPassFile(name)) {
                 file_options[i] |= (1 << 1);
                 if (classNames.contains(name.substring(0, name.length() - 6))) {
@@ -79,18 +79,22 @@
             } else {
                 fileName[i] = cpBands.getCPUtf8(name);
             }
-            byte[] bytes = file.getContents();
+            // set deflate_hint for file element
+            if (options.isKeepDeflateHint() && packingFile.isDefalteHint()) {
+                file_options[i] |= 0x1;
+            }
+            byte[] bytes = packingFile.getContents();
             file_size[i] = bytes.length;
             totalSize += file_size[i];
 
             // update modification time
-            modtime = (file.getModtime() + TimeZone.getDefault().getRawOffset()) / 1000L;
+            modtime = (packingFile.getModtime() + TimeZone.getDefault().getRawOffset()) /
1000L;
             file_modtime[i] = (int) (modtime - archiveModtime);
             if (isLatest && latestModtime < file_modtime[i]) {
                 latestModtime = file_modtime[i];
             }
 
-            file_bits[i] = file.getContents();
+            file_bits[i] = packingFile.getContents();
         }
 
         if (isLatest) {

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java?rev=791419&r1=791418&r2=791419&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java
Mon Jul  6 09:24:11 2009
@@ -123,6 +123,10 @@
         return deflateHint;
     }
 
+    public boolean isKeepDeflateHint() {
+        return KEEP.equals(deflateHint);
+    }
+
     public void setDeflateHint(String deflateHint) {
         this.deflateHint = deflateHint;
     }

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?rev=791419&r1=791418&r2=791419&view=diff
==============================================================================
--- 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 Jul  6 09:24:11 2009
@@ -85,6 +85,10 @@
         segmentHeader = new SegmentHeader();
         segmentHeader.setFile_count(segmentUnit.fileListSize());
         segmentHeader.setHave_all_code_flags(!stripDebug);
+        if (!options.isKeepDeflateHint()) {
+            segmentHeader.setDeflate_hint("true".equals(options
+                    .getDeflateHint()));
+        }
         
         PackingUtils.log("Setup constant pool bands for the segment");
         cpBands = new CpBands(this, effort);

Modified: harmony/enhanced/jdktools/trunk/modules/jretools/src/main/java/org/apache/harmony/jretools/pack200/Main.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jretools/src/main/java/org/apache/harmony/jretools/pack200/Main.java?rev=791419&r1=791418&r2=791419&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jretools/src/main/java/org/apache/harmony/jretools/pack200/Main.java
(original)
+++ harmony/enhanced/jdktools/trunk/modules/jretools/src/main/java/org/apache/harmony/jretools/pack200/Main.java
Mon Jul  6 09:24:11 2009
@@ -356,9 +356,9 @@
                 inputStream, jarOutputStream);
         unpacker.setVerbose(options.isVerbose());
         unpacker.setQuiet(options.isQuiet());
-        String deflateHint = options.getDeflateHint();
-        if(!"keep".equals(deflateHint)) {
-            unpacker.setDeflateHint("true".equals(deflateHint));
+        // set deflate_hint option
+        if (!options.isKeepDeflateHint()) {
+            unpacker.setDeflateHint("true".equals(options.getDeflateHint()));
         }
         //TODO: log file config should be handled
         unpacker.unpack();



Mime
View raw message