harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjanu...@apache.org
Subject svn commit: r775965 - in /harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200: CpBands.java FileBands.java Segment.java SegmentHeader.java
Date Mon, 18 May 2009 14:22:21 GMT
Author: sjanuary
Date: Mon May 18 14:22:15 2009
New Revision: 775965

URL: http://svn.apache.org/viewvc?rev=775965&view=rev
Log:
Pack200 - fix two bugs in FileBands - not including file modtimes and not using correct set
of file names.

Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.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/Segment.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java?rev=775965&r1=775964&r2=775965&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java
Mon May 18 14:22:15 2009
@@ -597,4 +597,9 @@
         return getCPIMethod(getCPClass(owner), name, desc);
     }
 
+    public boolean existsCpClass(String className) {
+        CPClass cpClass = (CPClass) stringsToCpClass.get(className);
+        return cpClass != null;
+    }
+
 }

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=775965&r1=775964&r2=775965&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 May 18 14:22:15 2009
@@ -18,44 +18,58 @@
 
 import java.io.IOException;
 import java.io.OutputStream;
+import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
 
 import org.apache.harmony.pack200.Archive.File;
+import org.objectweb.asm.ClassReader;
 
 public class FileBands extends BandSet {
 
     private final CPUTF8[] fileName;
     private int[] file_name;
-    private final long[] file_modtime;
+    private final int[] file_modtime;
     private final long[] file_size;
     private final int[] file_options;
     private final byte[][] file_bits;
 
     public FileBands(CpBands cpBands, SegmentHeader segmentHeader,
-            List files, int effort) {
+            List files, List classes, int effort) {
         super(effort, segmentHeader);
         int size =  files.size();
         fileName = new CPUTF8[size];
-        file_modtime = new long[size];
+        file_modtime = new int[size];
         file_size = new long[size];
         file_options = new int[size];
-        CPUTF8 emptyString = cpBands.getCPUtf8("");
         int totalSize = 0;
         file_bits = new byte[files.size()][];
-         for (int i = 0; i < files.size(); i++) {
+        int archiveModtime = segmentHeader.getArchive_modtime();
+
+        Set classNames = new HashSet();
+        for (Iterator iterator = classes.iterator(); iterator.hasNext();) {
+            ClassReader reader = (ClassReader) iterator.next();
+            classNames.add(reader.getClassName());
+        }
+        CPUTF8 emptyString = cpBands.getCPUtf8("");
+        for (int i = 0; i < files.size(); i++) {
              File file = (File)files.get(i);
              String name = file.getName();
-             fileName[i] = cpBands.getCPUtf8(name); // TODO: sometimes this can be the empty
string
              if(name.endsWith(".class")) {
-//                 fileName[i] = emptyString;
                  file_options[i] |= (1 << 1);
-//             } else {
-//                 fileName[i] = cpBands.getCPUtf8(name);
+                 if(classNames.contains(name.substring(0, name.length() - 6))) {
+                     fileName[i] = emptyString;
+                 } else {
+                     fileName[i] = cpBands.getCPUtf8(name);
+                 }
+             } else {
+                 fileName[i] = cpBands.getCPUtf8(name);
              }
              byte[] bytes = file.getContents();
              file_size[i] = bytes.length;
              totalSize += file_size[i];
-             file_modtime[i] = file.getModtime();
+             file_modtime[i] = (int)(file.getModtime() - archiveModtime);
              file_bits[i] = file.getContents();
          }
     }
@@ -72,7 +86,7 @@
         out.write(encodeFlags("file_size", file_size, Codec.UNSIGNED5,
                 Codec.UNSIGNED5, segmentHeader.have_file_size_hi()));
         if (segmentHeader.have_file_modtime()) {
-            out.write(encodeBandInt("file_modtime", file_name, Codec.DELTA5));
+            out.write(encodeBandInt("file_modtime", file_modtime, Codec.DELTA5));
         }
         if (segmentHeader.have_file_options()) {
             out.write(encodeBandInt("file_options", file_options,

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=775965&r1=775964&r2=775965&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 May 18 14:22:15 2009
@@ -59,7 +59,7 @@
         icBands = new IcBands(segmentHeader, cpBands, effort);
         classBands = new ClassBands(this, classes.size(), effort);
         bcBands = new BcBands(cpBands, this, effort);
-        fileBands = new FileBands(cpBands, segmentHeader, files, effort);
+        fileBands = new FileBands(cpBands, segmentHeader, files, classes, effort);
 
         processClasses(classes);
 

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java?rev=775965&r1=775964&r2=775965&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java
Mon May 18 14:22:15 2009
@@ -59,7 +59,7 @@
     private int file_count;
 
     private boolean deflate_hint;
-    private boolean have_file_modtime;
+    private boolean have_file_modtime = true;
     private boolean have_file_options = true;
     private boolean have_file_size_hi;
     private boolean have_class_flags_hi;
@@ -201,6 +201,10 @@
         this.archive_modtime = archive_modtime;
     }
 
+    public int getArchive_modtime() {
+        return archive_modtime;
+    }
+
     public void setFile_count(int file_count) {
         this.file_count = file_count;
     }



Mime
View raw message