harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r798469 [26/28] - in /harmony/enhanced/classlib/branches/java6: ./ depends/build/platform/ depends/files/ depends/jars/ depends/manifests/icu4j_4.0/ depends/manifests/icu4j_4.2.1/ depends/manifests/icu4j_4.2.1/META-INF/ make/ modules/access...
Date Tue, 28 Jul 2009 09:30:48 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java?rev=798469&r1=798468&r2=798469&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java Tue Jul 28 09:30:33 2009
@@ -16,21 +16,15 @@
  */
 package org.apache.harmony.pack200;
 
-import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.ArrayList;
-import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.List;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 import java.util.jar.JarInputStream;
-import java.util.jar.JarOutputStream;
-import java.util.jar.Manifest;
 import java.util.zip.GZIPOutputStream;
 
 /**
@@ -41,7 +35,7 @@
  */
 public class Archive {
 
-    private final JarInputStream inputStream;
+    private final JarInputStream jarInputStream;
     private final OutputStream outputStream;
     private JarFile jarFile;
     private long currentSegmentSize;
@@ -57,8 +51,9 @@
      */
     public Archive(JarInputStream inputStream, OutputStream outputStream,
             PackingOptions options) throws IOException {
-        this.inputStream = inputStream;
-        if(options == null) { // use all defaults
+        jarInputStream = inputStream;
+        if(options == null) {
+            // use all defaults
             options = new PackingOptions();
         }
         this.options = options;
@@ -88,7 +83,7 @@
         }
         this.outputStream = new BufferedOutputStream(outputStream);
         this.jarFile = jarFile;
-        inputStream = null;
+        jarInputStream = null;
         PackingUtils.config(options);
     }
 
@@ -98,194 +93,126 @@
      * @throws IOException
      */
     public void pack() throws Pack200Exception, IOException {
-        int effort = options.getEffort();
-        if(effort == 0) {
+        if (0 == options.getEffort()) {
             doZeroEffortPack();
         } else {
-            List classes = new ArrayList();
-            List files = new ArrayList();
-            long segmentLimit = options.getSegmentLimit();
-            List segmentUnitList = new ArrayList();
-            if (inputStream != null) {
-                Manifest manifest = jarFile != null ? jarFile.getManifest()
-                        : inputStream.getManifest();
-                if (manifest != null) {
-                    PackingUtils.log("Pack META-INF/MANIFEST.MF");
-                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
-                    manifest.write(baos);
-                    files.add(new File("META-INF/MANIFEST.MF", baos.toByteArray(), 0));
-                }
-                JarEntry jarEntry = inputStream.getNextJarEntry();
-                while (jarEntry != null) {
-                    if(jarEntry.getName().startsWith("META-INF")) {
-                        PackingUtils.log("Pack " + jarEntry.getName());
-                    }
-                    boolean added = addJarEntry(jarEntry,
-                            new BufferedInputStream(inputStream), classes,
-                            files);
-                    if (!added) { // not added because segment has reached
-                        // maximum size
-                        if(classes.size() > 0 || files.size() > 0) {
-                            segmentUnitList.add(new SegmentUnit(classes, files));
-                            classes = new ArrayList();
-                            files = new ArrayList();
-                            currentSegmentSize = 0;
-                            addJarEntry(jarEntry, new BufferedInputStream(inputStream), classes, files);
-                            currentSegmentSize = 0; // ignore the size of the first entry for compatibility with the RI
-                        }
-                    } else if (segmentLimit == 0 && estimateSize(jarEntry) > 0) {
-                        // create a new segment for each class unless size = 0
-                        segmentUnitList.add(new SegmentUnit(classes, files));
-                        classes = new ArrayList();
-                        files = new ArrayList();
-                    }
-                    jarEntry = inputStream.getNextJarEntry();
-                }
-            } else {
-                Enumeration jarEntries = jarFile.entries();
-                while (jarEntries.hasMoreElements()) {
-                    JarEntry jarEntry = (JarEntry) jarEntries.nextElement();
-                    boolean added = addJarEntry(jarEntry, new BufferedInputStream(
-                            jarFile.getInputStream(jarEntry)), classes, files);
-                    if (!added) { // not added because segment has reached maximum
-                        // size
-                        segmentUnitList.add(new SegmentUnit(classes, files));
-                        classes = new ArrayList();
-                        files = new ArrayList();
-                        currentSegmentSize = 0;
-                        addJarEntry(jarEntry, new BufferedInputStream(jarFile
-                                .getInputStream(jarEntry)), classes, files);
-                        currentSegmentSize = 0; // ignore the size of the first entry for compatibility with the RI
-                    } else if (segmentLimit == 0 && estimateSize(jarEntry) > 0) {
-                        // create a new segment for each class unless size = 0
-                        segmentUnitList.add(new SegmentUnit(classes, files));
-                        classes = new ArrayList();
-                        files = new ArrayList();
-                    }
-                }
-            }
-            if(classes.size() > 0 || files.size() > 0) {
-                segmentUnitList.add(new SegmentUnit(classes, files));
-            }
-
-            int size = segmentUnitList.size();
-            int classFileAmount = 0;
-            int fileAmount = 0;
-            int totalByteAmount = 0;
-            int totalPackedByteAmount = 0;
-            SegmentUnit segmentUnit = null;
-            for (int index = 0; index < size; index++) {
-                segmentUnit = (SegmentUnit) segmentUnitList.get(index);
-                classFileAmount += segmentUnit.classList.size();
-                fileAmount += segmentUnit.fileList.size();
-                new Segment().pack(segmentUnit, outputStream, options);
-                totalByteAmount += segmentUnit.getByteAmount();
-                totalPackedByteAmount += segmentUnit.getPackedByteAmount();
-            }
-            PackingUtils.log("Total: Packed " + fileAmount + " files including "
-                    + classFileAmount + " classes of " + totalByteAmount
-                    + " input bytes into " + totalPackedByteAmount + " bytes");
-
-            outputStream.close();
+            doNormalPack();
         }
     }
 
     private void doZeroEffortPack() throws IOException, Pack200Exception {
         PackingUtils.log("Start to perform a zero-effort packing");
-        JarOutputStream jarOutputStream = new JarOutputStream(outputStream);
-        if(inputStream != null) {
-            Manifest manifest = inputStream.getManifest();
-            if (manifest != null) {
-                jarOutputStream.putNextEntry(new JarEntry("META-INF/"));
-                jarOutputStream.closeEntry();
-                PackingUtils.log("Packed \"META-INF\" folder");
-                
-                ByteArrayOutputStream baos = new ByteArrayOutputStream();
-                manifest.write(baos);
-                jarOutputStream.putNextEntry(new JarEntry("META-INF/MANIFEST.MF"));
-                jarOutputStream.write(baos.toByteArray());
-                jarOutputStream.closeEntry();
-                PackingUtils.log("Packed META-INF/MANIFEST.MF");
-            }
-            BufferedInputStream buff = new BufferedInputStream(inputStream);
-            JarEntry jarEntry;
-            while ((jarEntry = inputStream.getNextJarEntry()) != null) {
-                jarOutputStream.putNextEntry(jarEntry);
-                byte[] bytes = new byte[(int) jarEntry.getSize()];
-                int bytesRead = buff.read(bytes);
-                if(bytesRead != jarEntry.getSize()) {
-                    throw new Pack200Exception("Error reading from input jar file");
-                }
-                jarOutputStream.write(bytes, 0, bytesRead);
-                jarOutputStream.closeEntry();
-                PackingUtils.log("Packed " + jarEntry.getName());
-            }
-            jarOutputStream.close();
+        if (jarInputStream != null) {
+            PackingUtils.copyThroughJar(jarInputStream, outputStream);
         } else {
-            Enumeration jarEntries = jarFile.entries();
-            while (jarEntries.hasMoreElements()) {
-                JarEntry jarEntry = (JarEntry) jarEntries.nextElement();
-                InputStream inStream = new BufferedInputStream(
-                        jarFile.getInputStream(jarEntry));
-                jarOutputStream.putNextEntry(jarEntry);
-                byte[] bytes = new byte[16384];
-                int bytesRead = inStream.read(bytes);
-                while (bytesRead != -1) {
-                    jarOutputStream.write(bytes, 0, bytesRead);
-                    bytesRead = inStream.read(bytes);
-                }
-                jarOutputStream.closeEntry();
-                PackingUtils.log("Packed " + jarEntry.getName());
-            }
-            jarOutputStream.close();
+            PackingUtils.copyThroughJar(jarFile, outputStream);
+        }
+    }
+
+    private void doNormalPack() throws IOException, Pack200Exception {
+        PackingUtils.log("Start to perform a normal packing");
+        List packingFileList;
+        if (jarInputStream != null) {
+            packingFileList = PackingUtils.getPackingFileListFromJar(
+                    jarInputStream, options.isKeepFileOrder());
+        } else {
+            packingFileList = PackingUtils.getPackingFileListFromJar(jarFile,
+                    options.isKeepFileOrder());
         }
+
+        List segmentUnitList = splitIntoSegments(packingFileList);
+        int previousByteAmount = 0;
+        int packedByteAmount = 0;
+
+        int segmentSize = segmentUnitList.size();
+        SegmentUnit segmentUnit;
+        for (int index = 0; index < segmentSize; index++) {
+            segmentUnit = (SegmentUnit) segmentUnitList.get(index);
+            new Segment().pack(segmentUnit, outputStream, options);
+            previousByteAmount += segmentUnit.getByteAmount();
+            packedByteAmount += segmentUnit.getPackedByteAmount();
+        }
+
+        PackingUtils.log("Total: Packed " + previousByteAmount
+                + " input bytes of " + packingFileList.size() + " files into "
+                + packedByteAmount + " bytes in " + segmentSize + " segments");
+
+        outputStream.close();
     }
 
-    private boolean addJarEntry(JarEntry jarEntry, InputStream stream,
-            List javaClasses, List files) throws IOException, Pack200Exception {
+    private List splitIntoSegments(List packingFileList) throws IOException,
+            Pack200Exception {
+        List segmentUnitList = new ArrayList();
+        List classes = new ArrayList();
+        List files = new ArrayList();
         long segmentLimit = options.getSegmentLimit();
-        String name = jarEntry.getName();
-        long size = jarEntry.getSize();
-        if (size > Integer.MAX_VALUE) {
-            throw new RuntimeException("Large Class!"); // TODO: Should probably allow this
-        } else if (size < 0) {
-            size = 0;
-//            throw new RuntimeException("Error: size for " + name + " is " + size);
+        
+        int size = packingFileList.size();
+        PackingFile packingFile;
+        for (int index = 0; index < size; index++) {
+            packingFile = (PackingFile) packingFileList.get(index);
+            if (!addJarEntry(packingFile, classes, files)) {
+                // not added because segment has reached maximum size
+                segmentUnitList.add(new SegmentUnit(classes, files));
+                classes = new ArrayList();
+                files = new ArrayList();
+                currentSegmentSize = 0;
+                // add the jar to a new segment
+                addJarEntry(packingFile, classes, files);
+                // ignore the size of first entry for compatibility with RI
+                currentSegmentSize = 0;
+            } else if (segmentLimit == 0 && estimateSize(packingFile) > 0) {
+                // create a new segment for each class unless size is 0
+                segmentUnitList.add(new SegmentUnit(classes, files));
+                classes = new ArrayList();
+                files = new ArrayList();
+            }
         }
-        if(segmentLimit != -1 && segmentLimit != 0) {
-            // -1 is a special case where only one segment is created and
-            // 0 is a special case where one segment is created for each file except for files in "META-INF"
+        if (classes.size() > 0 && files.size() > 0) {
+            segmentUnitList.add(new SegmentUnit(classes, files));
+        }
+        return segmentUnitList;
+    }
 
-            long packedSize = estimateSize(jarEntry);
-            if (packedSize + currentSegmentSize > segmentLimit && currentSegmentSize > 0) {
-                return false; // don't add this JarEntry to the current segment
+    private boolean addJarEntry(PackingFile packingFile, List javaClasses,
+            List files) throws IOException, Pack200Exception {
+        long segmentLimit = options.getSegmentLimit();
+        if (segmentLimit != -1 && segmentLimit != 0) {
+            // -1 is a special case where only one segment is created and
+            // 0 is a special case where one segment is created for each file
+            // except for files in "META-INF"
+            long packedSize = estimateSize(packingFile);
+            if (packedSize + currentSegmentSize > segmentLimit
+                    && currentSegmentSize > 0) {
+                // don't add this JarEntry to the current segment
+                return false;
             } else {
-                currentSegmentSize += packedSize; // do add this JarEntry
+                // do add this JarEntry
+                currentSegmentSize += packedSize;
             }
         }
-        byte[] bytes = new byte[(int) size];
-        int read = stream.read(bytes);
-        if (read != size) {
-            throw new RuntimeException("Error reading from stream");
-        }
+
+        String name = packingFile.getName();
         if (name.endsWith(".class") && !options.isPassFile(name)) {
-            Pack200ClassReader classParser = new Pack200ClassReader(bytes);
+            Pack200ClassReader classParser = new Pack200ClassReader(
+                    packingFile.contents);
             classParser.setFileName(name);
             javaClasses.add(classParser);
-            bytes = new byte[0];
+            packingFile.contents = new byte[0];
         }
-        files.add(new File(name, bytes, jarEntry.getTime()));
+        files.add(packingFile);
         return true;
     }
 
-    private long estimateSize(JarEntry jarEntry) {
-        // The heuristic used here is for compatibility with the RI and should not be changed
-        String name = jarEntry.getName();
-        if(name.startsWith("META-INF") || name.startsWith("/META-INF")) {
+    private long estimateSize(PackingFile packingFile) {
+        // The heuristic used here is for compatibility with the RI and should
+        // not be changed
+        String name = packingFile.getName();
+        if (name.startsWith("META-INF") || name.startsWith("/META-INF")) {
             return 0;
         } else {
-            long fileSize = jarEntry.getSize();
-            if(fileSize < 0) {
+            long fileSize = packingFile.contents.length;
+            if (fileSize < 0) {
                 fileSize = 0;
             }
             return name.length() + fileSize + 5;
@@ -313,9 +240,9 @@
                 byteAmount += classReader.b.length;
             }
 
-            File file;
+            PackingFile file;
             for (Iterator iterator = fileList.iterator(); iterator.hasNext();) {
-                file = (File) iterator.next();
+                file = (PackingFile) iterator.next();
                 byteAmount += file.contents.length;
             }
         }
@@ -349,16 +276,28 @@
         }
     }
 
-    static class File {
+    static class PackingFile {
 
         private final String name;
         private byte[] contents;
         private final long modtime;
+        private final boolean deflateHint;
+        private final boolean isDirectory;
 
-        public File(String name, byte[] contents, long modtime) {
+        public PackingFile(String name, byte[] contents, long modtime) {
             this.name = name;
             this.contents = contents;
             this.modtime = modtime;
+            deflateHint = false;
+            isDirectory = false;
+        }
+
+        public PackingFile(byte[] bytes, JarEntry jarEntry) {
+            name = jarEntry.getName();
+            contents = bytes;
+            modtime = jarEntry.getTime();
+            deflateHint = jarEntry.getMethod() == JarEntry.DEFLATED;
+            isDirectory = jarEntry.isDirectory();
         }
 
         public byte[] getContents() {
@@ -373,13 +312,17 @@
             return modtime;
         }
 
-        public String toString() {
-            return name;
-        }
-
         public void setContents(byte[] contents) {
             this.contents = contents;
         }
+
+        public boolean isDefalteHint() {
+            return deflateHint;
+        }
+
+        public boolean isDirectory(){
+            return isDirectory;
+        }
     }
 
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java?rev=798469&r1=798468&r2=798469&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java Tue Jul 28 09:30:33 2009
@@ -22,8 +22,9 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+import java.util.TimeZone;
 
-import org.apache.harmony.pack200.Archive.File;
+import org.apache.harmony.pack200.Archive.PackingFile;
 import org.apache.harmony.pack200.Archive.SegmentUnit;
 import org.objectweb.asm.ClassReader;
 
@@ -45,7 +46,7 @@
             PackingOptions options, SegmentUnit segmentUnit, int effort) {
         super(effort, segmentHeader);
         List fileList = segmentUnit.getFileList();
-        int size =  fileList.size();
+        int size = fileList.size();
         fileName = new CPUTF8[size];
         file_modtime = new int[size];
         file_size = new long[size];
@@ -55,30 +56,52 @@
         int archiveModtime = segmentHeader.getArchive_modtime();
 
         Set classNames = new HashSet();
-        for (Iterator iterator = segmentUnit.getClassList().iterator(); iterator.hasNext();) {
+        for (Iterator iterator = segmentUnit.getClassList().iterator(); iterator
+                .hasNext();) {
             ClassReader reader = (ClassReader) iterator.next();
             classNames.add(reader.getClassName());
         }
         CPUTF8 emptyString = cpBands.getCPUtf8("");
+        long modtime;
+        int latestModtime = Integer.MIN_VALUE;
+        boolean isLatest = !PackingOptions.KEEP.equals(options
+                .getModificationTime());
         for (int i = 0; i < size; i++) {
-             File file = (File)fileList.get(i);
-             String name = file.getName();
-             if(name.endsWith(".class") && !options.isPassFile(name)) {
-                 file_options[i] |= (1 << 1);
-                 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] = (int)(file.getModtime() - archiveModtime);
-             file_bits[i] = file.getContents();
-         }
+            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))) {
+                    fileName[i] = emptyString;
+                } else {
+                    fileName[i] = cpBands.getCPUtf8(name);
+                }
+            } else {
+                fileName[i] = cpBands.getCPUtf8(name);
+            }
+            // 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 = (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] = packingFile.getContents();
+        }
+
+        if (isLatest) {
+            for (int index = 0; index < size; index++) {
+                file_modtime[index] = latestModtime;
+            }
+        }
     }
 
     /**

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java?rev=798469&r1=798468&r2=798469&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java Tue Jul 28 09:30:33 2009
@@ -39,7 +39,7 @@
     private boolean gzip = true;
     private boolean stripDebug = false;
     private boolean keepFileOrder = true;
-    private long segmentLimit = 1000000;
+    private long segmentLimit = 1000000L;
     private int effort = 5;
     private String deflateHint = KEEP;
     private String modificationTime = KEEP;
@@ -123,6 +123,10 @@
         return deflateHint;
     }
 
+    public boolean isKeepDeflateHint() {
+        return KEEP.equals(deflateHint);
+    }
+
     public void setDeflateHint(String deflateHint) {
         this.deflateHint = deflateHint;
     }
@@ -132,6 +136,13 @@
     }
 
     public void setModificationTime(String modificationTime) {
+        if (!KEEP.equals(modificationTime)
+                && !"latest".equals(modificationTime)) {
+            throw new IllegalArgumentException(
+                    "Bad argument: -m "
+                            + modificationTime
+                            + " ? transmit modtimes should be either latest or keep (default)");
+        }
         this.modificationTime = modificationTime;
     }
 

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingUtils.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingUtils.java?rev=798469&r1=798468&r2=798469&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingUtils.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingUtils.java Tue Jul 28 09:30:33 2009
@@ -16,7 +16,22 @@
  */
 package org.apache.harmony.pack200;
 
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
 import java.util.logging.FileHandler;
 import java.util.logging.Level;
 import java.util.logging.LogManager;
@@ -24,6 +39,8 @@
 import java.util.logging.Logger;
 import java.util.logging.SimpleFormatter;
 
+import org.apache.harmony.pack200.Archive.PackingFile;
+
 public class PackingUtils {
 
     private static PackingLogger packingLogger;
@@ -68,4 +85,166 @@
         packingLogger.log(Level.INFO, message);
     }
 
+    /**
+     * When effort is 0, the packer copys through the original jar input stream
+     * without compression
+     * 
+     * @param jarInputStream
+     *            the jar input stream
+     * @param jarOutputStream
+     *            the jar output stream
+     * @throws IOException
+     */
+    public static void copyThroughJar(JarInputStream jarInputStream,
+            OutputStream outputStream) throws IOException {
+        Manifest manifest = jarInputStream.getManifest();
+        JarOutputStream jarOutputStream = new JarOutputStream(outputStream,
+                manifest);
+        jarOutputStream.setComment("PACK200");
+        log("Packed " + JarFile.MANIFEST_NAME);
+
+        byte[] bytes = new byte[16384];
+        JarEntry jarEntry;
+        int bytesRead;
+        while ((jarEntry = jarInputStream.getNextJarEntry()) != null) {
+            jarOutputStream.putNextEntry(jarEntry);
+            while ((bytesRead = jarInputStream.read(bytes)) != -1) {
+                jarOutputStream.write(bytes, 0, bytesRead);
+            }
+            log("Packed " + jarEntry.getName());
+        }
+        jarInputStream.close();
+        jarOutputStream.close();
+    }
+
+    /**
+     * When effort is 0, the packer copys through the original jar file without
+     * compression
+     * 
+     * @param jarFile
+     *            the input jar file
+     * @param jarOutputStream
+     *            the jar output stream
+     * @throws IOException
+     */
+    public static void copyThroughJar(JarFile jarFile, OutputStream outputStream)
+            throws IOException {
+        JarOutputStream jarOutputStream = new JarOutputStream(outputStream);
+        jarOutputStream.setComment("PACK200");
+        byte[] bytes = new byte[16384];
+        Enumeration entries = jarFile.entries();
+        InputStream inputStream;
+        JarEntry jarEntry;
+        int bytesRead;
+        while (entries.hasMoreElements()) {
+            jarEntry = (JarEntry) entries.nextElement();
+            jarOutputStream.putNextEntry(jarEntry);
+            inputStream = jarFile.getInputStream(jarEntry);
+            while ((bytesRead = inputStream.read(bytes)) != -1) {
+                jarOutputStream.write(bytes, 0, bytesRead);
+            }
+            jarOutputStream.closeEntry();
+            log("Packed " + jarEntry.getName());
+        }
+        jarFile.close();
+        jarOutputStream.close();
+    }
+
+    public static List getPackingFileListFromJar(JarInputStream jarInputStream,
+            boolean keepFileOrder) throws IOException {
+        List packingFileList = new ArrayList();
+
+        // add manifest file
+        Manifest manifest = jarInputStream.getManifest();
+        if (manifest != null) {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            manifest.write(baos);
+            packingFileList.add(new PackingFile(JarFile.MANIFEST_NAME, baos
+                    .toByteArray(), 0));
+        }
+
+        // add rest of entries in the jar
+        JarEntry jarEntry;
+        byte[] bytes;
+        while ((jarEntry = jarInputStream.getNextJarEntry()) != null) {
+            bytes = readJarEntry(jarEntry, new BufferedInputStream(
+                    jarInputStream));
+            packingFileList.add(new PackingFile(bytes, jarEntry));
+        }
+
+        // check whether it need reorder packing file list
+        if (!keepFileOrder) {
+            reorderPackingFiles(packingFileList);
+        }
+        return packingFileList;
+    }
+
+    public static List getPackingFileListFromJar(JarFile jarFile,
+            boolean keepFileOrder) throws IOException {
+        List packingFileList = new ArrayList();
+        Enumeration jarEntries = jarFile.entries();
+        JarEntry jarEntry;
+        byte[] bytes;
+        while (jarEntries.hasMoreElements()) {
+            jarEntry = (JarEntry) jarEntries.nextElement();
+            bytes = readJarEntry(jarEntry, new BufferedInputStream(jarFile
+                    .getInputStream(jarEntry)));
+            packingFileList.add(new PackingFile(bytes, jarEntry));
+        }
+
+        // check whether it need reorder packing file list
+        if (!keepFileOrder) {
+            reorderPackingFiles(packingFileList);
+        }
+        return packingFileList;
+    }
+
+    private static byte[] readJarEntry(JarEntry jarEntry,
+            InputStream inputStream) throws IOException {
+        long size = jarEntry.getSize();
+        if (size > Integer.MAX_VALUE) {
+            // TODO: Should probably allow this
+            throw new RuntimeException("Large Class!");
+        } else if (size < 0) {
+            size = 0;
+        }
+        byte[] bytes = new byte[(int) size];
+        if (inputStream.read(bytes) != size) {
+            throw new RuntimeException("Error reading from stream");
+        }
+        return bytes;
+    }
+
+    private static void reorderPackingFiles(List packingFileList) {
+        Iterator iterator = packingFileList.iterator();
+        PackingFile packingFile;
+        while (iterator.hasNext()) {
+            packingFile = (PackingFile) iterator.next();
+            if (packingFile.isDirectory()) {
+                // remove directory entries
+                iterator.remove();
+            }
+        }
+
+        // Sort files by name, "META-INF/MANIFEST.MF" should be put in the 1st
+        // position
+        Collections.sort(packingFileList, new Comparator() {
+            public int compare(Object arg0, Object arg1) {
+                if (arg0 instanceof PackingFile && arg1 instanceof PackingFile) {
+                    String fileName0 = ((PackingFile) arg0).getName();
+                    String fileName1 = ((PackingFile) arg1).getName();
+                    if (fileName0.equals(fileName1)) {
+                        return 0;
+                    } else if (JarFile.MANIFEST_NAME.equals(fileName0)) {
+                        return -1;
+                    } else if (JarFile.MANIFEST_NAME.equals(fileName1)) {
+                        return 1;
+                    }
+                    return fileName0.compareTo(fileName1);
+                }
+                throw new IllegalArgumentException();
+            }
+        });
+    }
+
 }
\ No newline at end of file

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java?rev=798469&r1=798468&r2=798469&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java Tue Jul 28 09:30:33 2009
@@ -23,7 +23,7 @@
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.harmony.pack200.Archive.File;
+import org.apache.harmony.pack200.Archive.PackingFile;
 import org.apache.harmony.pack200.Archive.SegmentUnit;
 import org.objectweb.asm.AnnotationVisitor;
 import org.objectweb.asm.Attribute;
@@ -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);
@@ -163,7 +167,7 @@
                 boolean found = false;
                 for (Iterator iterator2 = segmentUnit.getFileList().iterator(); iterator2
                         .hasNext();) {
-                    File file = (File) iterator2.next();
+                    PackingFile file = (PackingFile) iterator2.next();
                     if(file.getName().equals(name)) {
                         found = true;
                         file.setContents(classReader.b);

Modified: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/Archive.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/Archive.java?rev=798469&r1=798468&r2=798469&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/Archive.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/Archive.java Tue Jul 28 09:30:33 2009
@@ -232,6 +232,11 @@
         this.logFile = new FileOutputStream(logFileName);
     }
 
+    public void setLogFile(String logFileName, boolean append)
+            throws FileNotFoundException {
+        logFile = new FileOutputStream(logFileName, true);
+    }
+
     public void setDeflateHint(boolean deflateHint) {
         overrideDeflateHint = true;
         this.deflateHint = deflateHint;

Propchange: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200Adapter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jul 28 09:30:33 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200Adapter.java:782694-790471
+/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200Adapter.java:782694-798021

Propchange: harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200PackerAdapter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jul 28 09:30:33 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200PackerAdapter.java:782694-790471
+/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java5/org/apache/harmony/pack200/Pack200PackerAdapter.java:782694-798021

Modified: harmony/enhanced/classlib/branches/java6/modules/portlib/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/portlib/build.xml?rev=798469&r1=798468&r2=798469&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/portlib/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/portlib/build.xml Tue Jul 28 09:30:33 2009
@@ -19,15 +19,10 @@
 <project name="PORTLIB Build" default="build" basedir=".">
     <description>Build for PORTLIB component</description>
 
-    <!-- import common properties -->
+    <property name="hy.module" value="portlib" />
     <property name="hy.hdk" location="${basedir}/../../deploy" />
     <import file="${hy.hdk}/build/ant/properties.xml" />
 
-    <property name="tests.output" location="../../build/test_report" />
-
-    <!-- set global properties for this build. -->
-    <xmlproperty file="make/hyproperties.xml" semanticAttributes="true" />
-
     <property file="../../make/depends.properties" />
     <property name="fdlibm.zip" location="${depends.oss}/fdlibm_5.2.zip" />
     <available property="hythr.available"
@@ -57,7 +52,7 @@
     <target name="copy-native-includes"
             depends="-copy-thread-include,-copy-thread-stub-include" >
         <copy todir="${hy.hdk}/include" overwrite="yes">
-            <fileset dir="${hy.portlib.src.main.native}/include/shared">
+            <fileset dir="src/main/native/include/shared">
                 <include name="hyport.h" />
                 <include name="hycomp.h" />
                 <include name="hyporterror.h" />
@@ -71,7 +66,7 @@
             </fileset>
         </copy>
         <copy todir="${hy.hdk}/include" overwrite="yes">
-            <fileset dir="${hy.portlib.src.main.native}/include/${hy.os.family}">
+            <fileset dir="src/main/native/include/${hy.os.family}">
                 <include name="hymutex.h" />
                 <include name="hysock.h" />
                 <include name="hyportpg.h" />
@@ -81,7 +76,7 @@
 
     <target name="-copy-thread-include" unless="hy.skip.thr" >
         <copy todir="${hy.hdk}/include" overwrite="yes">
-            <fileset dir="${hy.portlib.src.main.native}/include/shared">
+            <fileset dir="src/main/native/include/shared">
                 <include name="hythread.h" />
             </fileset>
         </copy>
@@ -89,7 +84,7 @@
 
     <target name="-copy-thread-stub-include" if="hy.skip.thr" >
         <copy todir="${hy.hdk}/include" overwrite="yes">
-            <fileset dir="${hy.portlib.src.main.native}/thrstub/shared">
+            <fileset dir="src/main/native/thrstub/shared">
                 <include name="hythread.h" />
             </fileset>
         </copy>
@@ -100,21 +95,21 @@
         depends="-build-native,-build-native-thread,-build-native-thrstub,-build-native-port" />
     <target name="-build-native">
        <!-- Build common lib -->
-        <make dir="${hy.portlib.src.main.native}/common/${hy.os.family}" />
+        <make dir="src/main/native/common/${hy.os.family}" />
 
         <!-- Build pool lib -->
-        <make dir="${hy.portlib.src.main.native}/pool/${hy.os.family}" />
+        <make dir="src/main/native/pool/${hy.os.family}" />
     </target>
 
     <target name="-build-native-thread" unless="hy.skip.thr">
         <!-- Build thread dll -->
-        <make dir="${hy.portlib.src.main.native}/thread/${hy.os.family}" />
+        <make dir="src/main/native/thread/${hy.os.family}" />
 
         <antcall target="-build-copy-thread" />
 
         <!-- Copy link exports file on z/OS -->
         <copy todir="${hy.hdk}/lib" overwrite="yes">
-            <fileset dir="${hy.portlib.src.main.native}/thread/${hy.os.family}">
+            <fileset dir="src/main/native/thread/${hy.os.family}">
                 <include name="*${linklib.suffix}" if="is.zos" />
             </fileset>
         </copy>
@@ -122,7 +117,7 @@
 
     <target name="-build-copy-thread" unless="hy.thr.nodeploy">
         <copy todir="${hy.jdk}/jre/bin" overwrite="yes">
-            <fileset dir="${hy.portlib.src.main.native}/thread">
+            <fileset dir="src/main/native/thread">
                 <include name="*${shlib.suffix}*" />
                 <include name="*${progdb.suffix}*" if="is.windows" />
                 <exclude name="*${manifest.suffix}"/>
@@ -132,16 +127,16 @@
 
     <target name="-build-native-thrstub" if="hy.skip.thr">
         <!-- Build thread dll -->
-        <make dir="${hy.portlib.src.main.native}/thrstub/${hy.os.family}" />
+        <make dir="src/main/native/thrstub/${hy.os.family}" />
 
         <copy todir="${hy.hdk}/lib" overwrite="yes">
-            <fileset dir="${hy.portlib.src.main.native}/thrstub">
+            <fileset dir="src/main/native/thrstub">
                 <include name="*${shlib.suffix}*" />
                 <include name="*${progdb.suffix}*" if="is.windows" />
                 <exclude name="*${manifest.suffix}"/>
             </fileset>
             <!-- Copy link exports file on z/OS -->
-            <fileset dir="${hy.portlib.src.main.native}/thrstub/${hy.os.family}">
+            <fileset dir="src/main/native/thrstub/${hy.os.family}">
                 <include name="*${linklib.suffix}" if="is.zos" />
             </fileset>
         </copy>
@@ -149,10 +144,10 @@
 
     <target name="-build-native-port">
         <!-- Build port dll -->
-        <make dir="${hy.portlib.src.main.native}/port/${hy.os.family}" />
+        <make dir="src/main/native/port/${hy.os.family}" />
 
         <copy todir="${hy.jdk}/jre/bin" overwrite="yes">
-            <fileset dir="${hy.portlib.src.main.native}/port">
+            <fileset dir="src/main/native/port">
                 <include name="*${shlib.suffix}*" />
                 <include name="*${progdb.suffix}*" if="is.windows" />
                 <exclude name="*${manifest.suffix}"/>
@@ -160,7 +155,7 @@
         </copy>
         <!-- Copy link exports file on z/OS -->
         <copy todir="${hy.hdk}/lib" overwrite="yes">
-            <fileset dir="${hy.portlib.src.main.native}/port/${hy.os.family}">
+            <fileset dir="src/main/native/port/${hy.os.family}">
                 <include name="*${linklib.suffix}" if="is.zos" />
             </fileset>
         </copy>
@@ -168,11 +163,11 @@
 
     <!-- Clean natives -->
     <target name="clean-native" depends="-clean-native-tests">
-        <make dir="${hy.portlib.src.main.native}/thread/${hy.os.family}" target="clean" />
-        <make dir="${hy.portlib.src.main.native}/thrstub/${hy.os.family}" target="clean" />
-        <make dir="${hy.portlib.src.main.native}/port/${hy.os.family}" target="clean" />
-        <make dir="${hy.portlib.src.main.native}/common/${hy.os.family}" target="clean" />
-        <make dir="${hy.portlib.src.main.native}/pool/${hy.os.family}" target="clean" />
+        <make dir="src/main/native/thread/${hy.os.family}" target="clean" />
+        <make dir="src/main/native/thrstub/${hy.os.family}" target="clean" />
+        <make dir="src/main/native/port/${hy.os.family}" target="clean" />
+        <make dir="src/main/native/common/${hy.os.family}" target="clean" />
+        <make dir="src/main/native/pool/${hy.os.family}" target="clean" />
     </target>
 
     <target name="clean" depends="clean-native-includes" />
@@ -203,20 +198,20 @@
     </target>
 
     <target name="-compile-native-tests" if="test.portlib">
-        <make dir="${hy.portlib.src.test.native}/init/${hy.os.family}" />
-        <make dir="${hy.portlib.src.test.native}/hycpu/${hy.os.family}" />
-        <make dir="${hy.portlib.src.test.native}/hyerror/${hy.os.family}" />
-        <make dir="${hy.portlib.src.test.native}/hyfile/${hy.os.family}" />
-        <make dir="${hy.portlib.src.test.native}/hyfiletext/${hy.os.family}" />
-        <make dir="${hy.portlib.src.test.native}/hygp/${hy.os.family}" />
-        <make dir="${hy.portlib.src.test.native}/hymem/${hy.os.family}" />
-        <make dir="${hy.portlib.src.test.native}/hynls/${hy.os.family}" />
-        <make dir="${hy.portlib.src.test.native}/hyport/${hy.os.family}" />
-        <make dir="${hy.portlib.src.test.native}/hystr/${hy.os.family}" />
-        <make dir="${hy.portlib.src.test.native}/hytime/${hy.os.family}" />
-        <make dir="${hy.portlib.src.test.native}/hysysinfo/${hy.os.family}" />
-        <make dir="${hy.portlib.src.test.native}/hyipcmutex/${hy.os.family}" />
-        <make dir="${hy.portlib.src.test.native}/hymmap/${hy.os.family}" />
+        <make dir="src/test/native/init/${hy.os.family}" />
+        <make dir="src/test/native/hycpu/${hy.os.family}" />
+        <make dir="src/test/native/hyerror/${hy.os.family}" />
+        <make dir="src/test/native/hyfile/${hy.os.family}" />
+        <make dir="src/test/native/hyfiletext/${hy.os.family}" />
+        <make dir="src/test/native/hygp/${hy.os.family}" />
+        <make dir="src/test/native/hymem/${hy.os.family}" />
+        <make dir="src/test/native/hynls/${hy.os.family}" />
+        <make dir="src/test/native/hyport/${hy.os.family}" />
+        <make dir="src/test/native/hystr/${hy.os.family}" />
+        <make dir="src/test/native/hytime/${hy.os.family}" />
+        <make dir="src/test/native/hysysinfo/${hy.os.family}" />
+        <make dir="src/test/native/hyipcmutex/${hy.os.family}" />
+        <make dir="src/test/native/hymmap/${hy.os.family}" />
     </target>
 
     <target name="-run-native-tests" if="test.portlib">
@@ -241,7 +236,7 @@
         <exec-native test="hymmap" />
 	
         <move todir="${tests.output}">
-            <fileset dir="${hy.portlib}">
+            <fileset dir=".">
                 <include name="TEST-*.xml"/>
             </fileset>
         </move>
@@ -250,33 +245,33 @@
     </target>
 
     <target name="-clean-native-tests" >
-        <make dir="${hy.portlib.src.test.native}/init/${hy.os.family}" 
+        <make dir="src/test/native/init/${hy.os.family}" 
               target="clean" />
-        <make dir="${hy.portlib.src.test.native}/hycpu/${hy.os.family}" 
+        <make dir="src/test/native/hycpu/${hy.os.family}" 
               target="clean" />
-        <make dir="${hy.portlib.src.test.native}/hyerror/${hy.os.family}" 
+        <make dir="src/test/native/hyerror/${hy.os.family}" 
               target="clean" />
-        <make dir="${hy.portlib.src.test.native}/hyfile/${hy.os.family}" 
+        <make dir="src/test/native/hyfile/${hy.os.family}" 
               target="clean" />
-        <make dir="${hy.portlib.src.test.native}/hyfiletext/${hy.os.family}" 
+        <make dir="src/test/native/hyfiletext/${hy.os.family}" 
               target="clean" />
-        <make dir="${hy.portlib.src.test.native}/hygp/${hy.os.family}" 
+        <make dir="src/test/native/hygp/${hy.os.family}" 
               target="clean" />
-        <make dir="${hy.portlib.src.test.native}/hymem/${hy.os.family}" 
+        <make dir="src/test/native/hymem/${hy.os.family}" 
               target="clean" />
-        <make dir="${hy.portlib.src.test.native}/hynls/${hy.os.family}" 
+        <make dir="src/test/native/hynls/${hy.os.family}" 
               target="clean" />
-        <make dir="${hy.portlib.src.test.native}/hyport/${hy.os.family}" 
+        <make dir="src/test/native/hyport/${hy.os.family}" 
               target="clean" />
-        <make dir="${hy.portlib.src.test.native}/hystr/${hy.os.family}" 
+        <make dir="src/test/native/hystr/${hy.os.family}" 
               target="clean" />
-        <make dir="${hy.portlib.src.test.native}/hytime/${hy.os.family}" 
+        <make dir="src/test/native/hytime/${hy.os.family}" 
               target="clean" />
-        <make dir="${hy.portlib.src.test.native}/hysysinfo/${hy.os.family}" 
+        <make dir="src/test/native/hysysinfo/${hy.os.family}" 
               target="clean" />
-        <make dir="${hy.portlib.src.test.native}/hyipcmutex/${hy.os.family}" 
+        <make dir="src/test/native/hyipcmutex/${hy.os.family}" 
               target="clean" />
-        <make dir="${hy.portlib.src.test.native}/hymmap/${hy.os.family}" 
+        <make dir="src/test/native/hymmap/${hy.os.family}" 
               target="clean" />
     </target>
 
@@ -290,7 +285,7 @@
         <sequential>
             <property name="@{test}.name"
                       value="native.portlib.@{test}" />
-            <exec executable="${hy.portlib.src.test.native}/@{test}/@{test}${exe.suffix}"
+            <exec executable="src/test/native/@{test}/@{test}${exe.suffix}"
                   failonerror="false"
                   outputproperty="@{test}.output"
                   resultproperty="@{test}.resultcode" >

Modified: harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/shared/hystrftime.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/shared/hystrftime.c?rev=798469&r1=798468&r2=798469&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/shared/hystrftime.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/shared/hystrftime.c Tue Jul 28 09:30:33 2009
@@ -100,7 +100,7 @@
               format++;
               break;
             case 'Y':
-              if (index + 4 >= bufLen - 1)
+              if (index + 4 >= bufLen)
                 {
                   return bufLen;
                 }
@@ -110,7 +110,7 @@
               format++;
               break;
             case 'm':
-              if (index + 2 >= bufLen - 1)
+              if (index + 2 >= bufLen)
                 {
                   return bufLen;
                 }
@@ -120,7 +120,7 @@
               format++;
               break;
             case 'b':
-              if (index + strlen (abbMonthName[tm.month - 1]) >= bufLen - 1)
+              if (index + strlen (abbMonthName[tm.month - 1]) >= bufLen)
                 {
                   return bufLen;
                 }
@@ -131,7 +131,7 @@
               format++;
               break;
             case 'd':
-              if (index + 2 >= bufLen - 1)
+              if (index + 2 >= bufLen)
                 {
                   return bufLen;
                 }
@@ -141,7 +141,7 @@
               format++;
               break;
             case 'H':
-              if (index + 2 >= bufLen - 1)
+              if (index + 2 >= bufLen)
                 {
                   return bufLen;
                 }
@@ -151,7 +151,7 @@
               format++;
               break;
             case 'M':
-              if (index + 2 >= bufLen - 1)
+              if (index + 2 >= bufLen)
                 {
                   return bufLen;
                 }
@@ -161,7 +161,7 @@
               format++;
               break;
             case 'S':
-              if (index + 2 >= bufLen - 1)
+              if (index + 2 >= bufLen)
                 {
                   return bufLen;
                 }

Modified: harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/unix/hyfiletext.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/unix/hyfiletext.c?rev=798469&r1=798468&r2=798469&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/unix/hyfiletext.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/unix/hyfiletext.c Tue Jul 28 09:30:33 2009
@@ -230,14 +230,14 @@
   const U_8 *cursor = buf;
   IDATA newLength = 0;
   int hasHighChars = 0;
+  int wcresult;
   /* reset the shift state */
-  wctomb (NULL, 0);
+  wcresult = wctomb (NULL, 0);
   while (cursor < end)
     {
       if ((*cursor & 0x80) == 0x80)
         {
           char temp[MB_CUR_MAX];
-          int wcresult;
           U_16 unicode;
           U_32 numberU8Consumed =
             decodeUTF8CharN (cursor, &unicode, end - cursor);

Modified: harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/unix/hyosdump.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/unix/hyosdump.c?rev=798469&r1=798468&r2=798469&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/unix/hyosdump.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/unix/hyosdump.c Tue Jul 28 09:30:33 2009
@@ -83,7 +83,10 @@
       if (lastSep != NULL)
         {
           lastSep[1] = '\0';
-          chdir (filename);
+          if (0 != chdir (filename))
+            {
+              return -1;
+            }
         }
 
       /* Ensure we get default action (core) - reset primary&app handlers */

Modified: harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/unix/hysl.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/unix/hysl.c?rev=798469&r1=798468&r2=798469&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/unix/hysl.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/portlib/src/main/native/port/unix/hysl.c Tue Jul 28 09:30:33 2009
@@ -303,7 +303,7 @@
   end = &errBuf[bufLen - 1];
   walk = error;
   /* reset the shift state */
-  mbtowc (NULL, NULL, 0);
+  ret = mbtowc (NULL, NULL, 0);
   while (*walk)
     {
       ret = mbtowc (&ch, walk, MB_CUR_MAX);

Modified: harmony/enhanced/classlib/branches/java6/modules/prefs/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/prefs/build.xml?rev=798469&r1=798468&r2=798469&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/prefs/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/prefs/build.xml Tue Jul 28 09:30:33 2009
@@ -21,27 +21,11 @@
 <project name="PREFS Build" default="build" basedir=".">
     <description>Build for PREFS component</description>
 
-    <!-- import common properties -->
+    <property name="hy.module" value="prefs" />
     <property name="hy.hdk" location="${basedir}/../../deploy" />
     <import file="${hy.hdk}/build/ant/properties.xml" />
 
-    <property name="tests.output" location="../../build/test_report" />
-
-    <!-- set global properties for this build. -->
-    <xmlproperty file="make/hyproperties.xml" semanticAttributes="true" />
-
-    <fileset id="classes" dir="${hy.build}">
-        <or>
-            <present targetdir="${hy.prefs.src.main.java}" />
-            <present targetdir="${hy.prefs.src.main.java}">
-                <mapper type="regexp"
-                        from="^(.*?)(\$$[^/\\\.]*)?\.class$$"
-                        to="\1.java"/>
-            </present>
-        </or>
-    </fileset>
-
-    <property name="prefs.exclude.file" location="${hy.hdk}/build/prefs.exclude" />
+    <property file="../../make/depends.properties" />
 
     <target name="build" depends="compile-java, copy-resources, build-jar" />
 
@@ -57,23 +41,23 @@
     </target>
 
     <!-- internal target for local and global test run sequence -->
-    <target name="-test-module" depends="build, compile-tests, prepare-exclude, run-tests" />
+    <target name="-test-module" depends="build, run-tests" />
 
     <!-- Build natives. Currently there are only windows natives for
      prefs, so we check if we are on a windows platform -->
     <target name="build-native" depends="build-native-all" />
     <target name="build-native-all" if="is.windows">
-        <make dir="${hy.prefs.src.main.native}/prefs/${hy.os.family}" />
+        <make dir="src/main/native/prefs/${hy.os.family}" />
 
         <!-- Copy the built shared libs over to the jre/bin dir -->
         <copy todir="${hy.jdk}/jre/bin" overwrite="yes">
-            <fileset dir="${hy.prefs.src.main.native}/prefs">
+            <fileset dir="src/main/native/prefs">
                 <include name="*${shlib.suffix}*"/>
                 <include name="*${progdb.suffix}*" if="is.windows" />
                 <exclude name="*${manifest.suffix}"/>
             </fileset>
             <!-- Copy link exports file on z/OS -->
-            <fileset dir="${hy.prefs.src.main.native}/prefs/${hy.os.family}">
+            <fileset dir="src/main/native/prefs/${hy.os.family}">
                 <include name="*${linklib.suffix}*" if="is.zos" />
             </fileset>
         </copy>
@@ -82,6 +66,7 @@
     <target name="clean">
         <delete file="${hy.jdk}/jre/lib/boot/prefs.jar" />
         <delete file="${hy.jdk}/jre/lib/boot/prefs-src.jar" />
+        <delete dir="${tests.hdk.dir}" failonerror="false" />
         <delete failonerror="false">
             <fileset refid="classes" />
         </delete>
@@ -89,20 +74,19 @@
     </target>
 
     <!-- Clean natives. Currently there are only windows natives for
-     prefs, so we check if we are on a windows platform -->
+         prefs, so we check if we are on a windows platform -->
     <target name="clean-native" if="is.windows">
-    <make dir="${hy.prefs.src.main.native}/prefs/${hy.os.family}" target="clean" />
+        <make dir="src/main/native/prefs/${hy.os.family}" target="clean" />
     </target>
 
-
     <target name="compile-java">
         <echo message="Compiling PREFS classes" />
 
-        <mkdir dir="${hy.build}" />
+        <mkdir dir="../../build/classes" />
 
         <javac sourcepath=""
-               srcdir="${hy.prefs.src.main.java}"
-               destdir="${hy.build}"
+               srcdir="src/main/java"
+               destdir="../../build/classes"
                compiler="${hy.javac.compiler}"
                memoryMaximumSize="${hy.javac.maxmem}"
                source="${hy.javac.source}" 
@@ -120,9 +104,9 @@
     </target>
 
     <target name="copy-resources">
-        <mkdir dir="${hy.build}" />
-        <copy todir="${hy.build}" includeemptydirs="false">
-            <fileset dir="${hy.prefs.src.main.java}">
+        <mkdir dir="../../build/classes" />
+        <copy todir="../../build/classes" includeemptydirs="false">
+            <fileset dir="src/main/java">
                 <exclude name="**/*.java" />
             </fileset>
         </copy>
@@ -130,7 +114,7 @@
 
     <target name="build-jar" depends="svn-info">
         <jar destfile="${hy.jdk}/jre/lib/boot/prefs.jar"
-             manifest="${hy.prefs}/META-INF/MANIFEST.MF"
+             manifest="META-INF/MANIFEST.MF"
              compress="${hy.jar.compress}">
             <fileset refid="classes" />
             <manifest>
@@ -141,7 +125,7 @@
         </jar>
 
         <jar destfile="${hy.jdk}/jre/lib/boot/prefs-src.jar">
-            <fileset dir="${hy.prefs.src.main.java}" />
+            <fileset dir="src/main/java" />
             <manifest>
                 <attribute name="Implementation-Version" value="${svn.info}"/> 
             </manifest>
@@ -150,109 +134,48 @@
         </jar>
     </target>
 
-    <target name="compile-tests" depends="copy-test-resources">
-        <echo message="Compiling PREFS tests" />
-
-        <mkdir dir="${hy.prefs.bin.test}" />
-
-        <javac srcdir="${hy.prefs.src.test.java}"
-               destdir="${hy.prefs.bin.test}"
-               sourcepath=""
-               compiler="${hy.javac.compiler}"
-               memoryMaximumSize="${hy.javac.maxmem}"
-               source="${hy.javac.source}" 
-               target="${hy.javac.target}"
-               debug="${hy.javac.debug}">
-
-            <compilerarg line="${build.compilerarg}" />
-
-            <bootclasspath>
-                <fileset dir="${hy.jdk}/jre/lib/boot">
-                    <include name="**/*.jar" />
-                </fileset>
-            </bootclasspath>
-            <classpath location="../../build/tests" />
-            <classpath location="${hy.hdk}/build/test/support.jar" />
-        </javac>
-    </target>
-
-    <target name="prepare-exclude">
-       <prepare-exclude-list moduleName="prefs" dir="./make"
-                             result="${prefs.exclude.file}"/>
-    </target>
-
-    <target name="run-tests">
-
-        <mkdir dir="${tests.output}" />
-
-        <property name="test.jre.home" value="${hy.jdk}/jre" />
-
-        <junit fork="yes"
-            forkmode="perBatch"
-            timeout="${hy.test.timeout}"
-            printsummary="withOutAndErr"
-            errorproperty="test.errors"
-            failureproperty="test.failures"
-            showoutput="on"
-            dir="${basedir}"
-            jvm="${test.jre.home}/bin/java">
-
-            <assertions enableSystemAssertions="true">
-                <enable />
-            </assertions>
+    <target name="test-jar" depends="svn-info,compile-tests">
+        <mkdir dir="${tests.hdk.dir}" />
 
-            <jvmarg line="${hy.test.vmargs}" />
+        <copy file="make/run-test.xml" tofile="${tests.hdk.dir}/build.xml" />
 
-            <classpath>
-                <pathelement path="${hy.prefs.bin.test}"/>
-            </classpath>
-            <classpath location="../../build/tests" />
-            <classpath location="${hy.hdk}/build/test/support.jar" />
-
-            <formatter type="xml" />
-
-            <batchtest todir="${tests.output}" haltonfailure="no" >
-
-                <fileset dir="${hy.prefs.src.test.java}">
-                    <!-- if ${test.case}     -->
-                    <include name="${converted.tc}" if="test.case" />
-                    <!-- unless ${test.case} -->
-                    <include name="**/*Test.java" unless="test.case" />
-                    <excludesfile name="${prefs.exclude.file}" unless="test.case" />
-
-                    <!--  These tests run in a separate jvm below -->
-                    <exclude name="org/apache/harmony/prefs/tests/java/util/prefs/FilePreferencesImplTest.java" unless="test.case" />
-                </fileset>
-            </batchtest>
+        <jar destfile="${tests.hdk.dir}/prefs_tests.jar">
+            <fileset dir="bin/test" />
+            <manifest>
+                <attribute name="Implementation-Version" value="${svn.info}"/> 
+            </manifest>
+            <metainf refid="hy.required.metainf-files"/>
+        </jar>
 
-            <batchtest todir="${tests.output}" haltonfailure="no" unless="test.case" >
-                <fileset dir="${hy.prefs.src.test.java}">
-                    <include name="org/apache/harmony/prefs/tests/java/util/prefs/FilePreferencesImplTest.java" />
-                </fileset>
-            </batchtest>
+        <mkdir dir="${tests.excludes.hdk.dir}"/>
+        <copy todir="${tests.excludes.hdk.dir}">
+            <fileset dir="make" includes="exclude*"/>
+            <filterchain>
+                <tokenfilter>
+                    <replaceregex pattern="\.java" replace="\.class" flags="g"/>
+                </tokenfilter>
+            </filterchain>
+        </copy>
 
-        </junit>
-        <antcall target="touch-failures-file" />
-        <antcall target="touch-errors-file" />
-    </target>
+        <copy todir="${tests.resources.hdk.dir}">
+            <fileset dir="src/test/resources" />
+        </copy>
 
-    <target name="touch-failures-file" if="test.failures">
-        <echo file="${tests.output}/test.failures"
-            append="true">prefs${line.separator}</echo>
+        <copy file="../../${junit.jar}" todir="${hy.hdk}/build/test" />
     </target>
 
-    <target name="touch-errors-file" if="test.errors">
-        <echo file="${tests.output}/test.errors"
-            append="true">prefs${line.separator}</echo>
+    <target name="compile-tests">
+        <compile-tests description="prefs tests">
+            <javac-elements>
+                <src>
+                    <pathelement location="src/test/java" />
+                </src>
+            </javac-elements>
+        </compile-tests>
     </target>
 
-    <target name="copy-test-resources">
-        <mkdir dir="${hy.prefs.bin.test}" />
-        <copy todir="${hy.prefs.bin.test}" includeemptydirs="false">
-            <fileset dir="${hy.prefs.src.test.resources}">
-                <exclude name="**/*.java" />
-            </fileset>
-        </copy>
+    <target name="run-tests" depends="test-jar">
+        <ant dir="${tests.hdk.dir}" target="test-module" />
     </target>
 
 </project>

Modified: harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java?rev=798469&r1=798468&r2=798469&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java Tue Jul 28 09:30:33 2009
@@ -329,7 +329,7 @@
         // "abc"
 
         pref.put("testGetByteArrayKey", "abc=");
-        pref.put("testGetByteArrayKey2", new String(b64Array));
+        pref.put("testGetByteArrayKey2", new String(b64Array, "UTF-8"));
         pref.put("invalidKey", "<>?");
         // assertTrue(Arrays.equals(new byte[0], p.getByteArray(
         // "testGetByteArrayKey", new byte[0])));

Modified: harmony/enhanced/classlib/branches/java6/modules/print/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/print/build.xml?rev=798469&r1=798468&r2=798469&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/print/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/print/build.xml Tue Jul 28 09:30:33 2009
@@ -19,36 +19,11 @@
 <project name="Print Build" default="build" basedir=".">
     <description>Build for Print component</description>
 
-    <!-- import common properties -->
+    <property name="hy.module" value="print" />
     <property name="hy.hdk" location="${basedir}/../../deploy" />
     <import file="${hy.hdk}/build/ant/properties.xml" />
 
-    <property name="tests.output" location="../../build/test_report" />
-
-    <!-- set global properties for this build. -->
-    <xmlproperty file="make/hyproperties.xml" semanticAttributes="true" />
-
-    <property name="hy.print.src.main.java.platform"
-              value="${hy.print.src.main.java}/../${hy.os.family}" />
-
-    <fileset id="classes" dir="${hy.build}">
-        <or>
-            <present targetdir="${hy.print.src.main.java}" />
-            <present targetdir="${hy.print.src.main.java}">
-                <mapper type="regexp"
-                        from="^(.*?)(\$$[^/\\\.]*)?\.class$$"
-                        to="\1.java"/>
-            </present>
-            <present targetdir="${hy.print.src.main.java.platform}" />
-            <present targetdir="${hy.print.src.main.java.platform}">
-                <mapper type="regexp"
-                        from="^(.*?)(\$$[^/\\\.]*)?\.class$$"
-                        to="\1.java"/>
-            </present>
-        </or>
-    </fileset>
-
-    <property name="print.exclude.file" location="${hy.hdk}/build/print.exclude" />
+    <property file="../../make/depends.properties" />
 
     <target name="build" depends="compile-java, copy-resources, build-jar" />
 
@@ -64,11 +39,12 @@
     </target>
 
     <!-- internal target for local and global test run sequence -->
-    <target name="-test-module" depends="build, compile-tests, prepare-exclude, run-tests" />
+    <target name="-test-module" depends="build, run-tests" />
 
     <target name="clean">
-        <delete file="${hy.jdk}/jre/lib/boot/${hy.print.packaging.jarname}.jar" />
-        <delete file="${hy.jdk}/jre/lib/boot/${hy.print.packaging.jarname}-src.jar" />
+        <delete file="${hy.jdk}/jre/lib/boot/print.jar" />
+        <delete file="${hy.jdk}/jre/lib/boot/print-src.jar" />
+        <delete dir="${tests.hdk.dir}" failonerror="false" />
         <delete failonerror="false">
             <fileset refid="classes" />
         </delete>
@@ -76,18 +52,18 @@
     </target>
 
     <target name="clean-native" if="is.windows">
-        <make dir="${hy.print.src.main.native}/print/${hy.os.family}"
+        <make dir="src/main/native/print/${hy.os.family}"
               target="clean" />
     </target>
 
     <target name="compile-java">
         <echo message="Compiling PRINT classes" />
 
-        <mkdir dir="${hy.build}" />
+        <mkdir dir="../../build/classes" />
 
         <javac sourcepath=""
-               srcdir="${hy.print.src.main.java}"
-               destdir="${hy.build}"
+               srcdir="src/main/java/common"
+               destdir="../../build/classes"
                compiler="${hy.javac.compiler}"
                memoryMaximumSize="${hy.javac.maxmem}"
                source="${hy.javac.source}" 
@@ -106,10 +82,10 @@
     
     <target name="build-native" depends="build-native-all" />
     <target name="build-native-all" if="is.windows">
-        <make dir="${hy.print.src.main.native}/print/${hy.os.family}" />
+        <make dir="src/main/native/print/${hy.os.family}" />
         <!-- Copy the built shared libs over to the jre/bin dir -->
         <copy todir="${hy.jdk}/jre/bin" overwrite="yes">
-            <fileset dir="${hy.print.src.main.native}/print/">
+            <fileset dir="src/main/native/print/">
                 <include name="*${shlib.suffix}*"/>
                 <include name="*${progdb.suffix}*" if="is.windows" />
                 <exclude name="*${manifest.suffix}"/>
@@ -117,16 +93,16 @@
         </copy>
         <!-- Copy link exports file on z/OS -->
         <copy todir="${hy.hdk}/lib" overwrite="yes">
-            <fileset dir="${hy.print.src.main.native}/print/${hy.os.family}">
+            <fileset dir="src/main/native/print/${hy.os.family}">
                 <include name="*${linklib.suffix}" if="is.zos" />
             </fileset>
         </copy>
     </target>
 
     <target name="copy-resources">
-        <mkdir dir="${hy.build}" />
-        <copy todir="${hy.build}" includeemptydirs="false">
-            <fileset dir="${hy.print.src.main.java}">
+        <mkdir dir="../../build/classes" />
+        <copy todir="../../build/classes" includeemptydirs="false">
+            <fileset dir="src/main/java/common">
                 <exclude name="**/*.java" />
                 <exclude name="**/javax.print.StreamPrintServiceFactory" />
                 <exclude name="**/javax.print.PrintServiceLookup" />
@@ -135,14 +111,14 @@
     </target>
 
     <target name="build-jar" depends="svn-info">
-        <jar destfile="${hy.jdk}/jre/lib/boot/${hy.print.packaging.jarname}.jar"
-             manifest="${hy.print}/META-INF/MANIFEST.MF"
+        <jar destfile="${hy.jdk}/jre/lib/boot/print.jar"
+             manifest="META-INF/MANIFEST.MF"
              compress="${hy.jar.compress}">
             <metainf prefix="META-INF/services"
-                dir="${hy.print.src.main.java}/org/apache/harmony/x/print"
+                dir="src/main/java/common/org/apache/harmony/x/print"
                 includes="javax.print.StreamPrintServiceFactory"/>
             <metainf prefix="META-INF/services"
-                dir="${hy.print.src.main.java.platform}/org/apache/harmony/x/print"
+                dir="src/main/java/${hy.os.family}/org/apache/harmony/x/print"
                 includes="javax.print.PrintServiceLookup"/>
             <fileset refid="classes" />
             <manifest>
@@ -152,15 +128,15 @@
             <metainf refid="hy.required.metainf-files"/>
         </jar>
 
-        <jar destfile="${hy.jdk}/jre/lib/boot/${hy.print.packaging.jarname}-src.jar">
+        <jar destfile="${hy.jdk}/jre/lib/boot/print-src.jar">
             <metainf prefix="META-INF/services"
-                dir="${hy.print.src.main.java}/org/apache/harmony/x/print"
+                dir="src/main/java/common/org/apache/harmony/x/print"
                 includes="javax.print.StreamPrintServiceFactory"/>
             <metainf prefix="META-INF/services"
-                dir="${hy.print.src.main.java.platform}/org/apache/harmony/x/print"
+                dir="src/main/java/${hy.os.family}/org/apache/harmony/x/print"
                 includes="javax.print.PrintServiceLookup"/>
-            <fileset dir="${hy.print.src.main.java}" />
-            <fileset dir="${hy.print.src.main.java.platform}" />
+            <fileset dir="src/main/java/common" />
+            <fileset dir="src/main/java/${hy.os.family}" />
             <manifest>
                 <attribute name="Implementation-Version" value="${svn.info}"/> 
             </manifest>
@@ -169,92 +145,44 @@
         </jar>
     </target>
 
-    <target name="compile-tests">
-        <echo message="Compiling Print tests" />
-
-        <mkdir dir="${hy.print.bin.test}" />
-
-        <javac srcdir="${hy.print.src.test.java}"
-               destdir="${hy.print.bin.test}"
-               sourcepath=""
-               compiler="${hy.javac.compiler}"
-               memoryMaximumSize="${hy.javac.maxmem}"
-               source="${hy.javac.source}" 
-               target="${hy.javac.target}"
-               debug="${hy.javac.debug}">
-
-            <compilerarg line="${build.compilerarg}" />
-
-            <bootclasspath>
-                <fileset dir="${hy.jdk}/jre/lib/boot">
-                    <include name="**/*.jar" />
-                </fileset>
-            </bootclasspath>
-            <classpath location="../../build/tests" />
-        </javac>
-    </target>
-
-    <target name="prepare-exclude">
-       <prepare-exclude-list moduleName="print" dir="./make"
-                             result="${print.exclude.file}"/>
-    </target>
-
-    <target name="run-tests">
-
-        <mkdir dir="${tests.output}" />
-
-        <property name="test.jre.home" value="${hy.jdk}/jre" />
-
-        <junit fork="yes"
-               forkmode="${hy.test.forkmode}"
-               timeout="${hy.test.timeout}"
-               printsummary="withOutAndErr"
-               errorproperty="test.errors"
-               failureproperty="test.failures"
-               showoutput="on"
-               dir="${basedir}"
-               jvm="${test.jre.home}/bin/java">
-
-            <assertions enableSystemAssertions="true">
-                <enable />
-            </assertions>
-
-            <jvmarg line="${hy.test.vmargs}" />
-
-            <env key="JAVA_HOME" value="${test.jre.home}"/>
-
-            <classpath>
-                <pathelement path="${hy.print.bin.test}"/>
-            </classpath>
-
-            <formatter type="xml" />
+    <target name="test-jar" depends="svn-info,compile-tests">
+        <mkdir dir="${tests.hdk.dir}" />
+        
+        <copy file="make/run-test.xml" tofile="${tests.hdk.dir}/build.xml" />
+        
+        <jar destfile="${tests.hdk.dir}/print_tests.jar">
+            <fileset dir="bin/test" />
+            <manifest>
+                <attribute name="Implementation-Version" value="${svn.info}"/> 
+            </manifest>
+            <metainf refid="hy.required.metainf-files"/>
+        </jar>
 
-            <batchtest todir="${tests.output}" haltonfailure="no">
+        <mkdir dir="${tests.excludes.hdk.dir}"/>
+        <copy todir="${tests.excludes.hdk.dir}">
+            <fileset dir="make" includes="exclude*"/>
+            <filterchain>
+                <tokenfilter>
+                    <replaceregex pattern="\.java" replace="\.class" flags="g"/>
+                </tokenfilter>
+            </filterchain>
+        </copy>
 
-                <fileset dir="${hy.print.src.test.java}">
-                    <!-- if ${test.case}     -->
-                    <include name="${converted.tc}" if="test.case"/>
-                    <!-- unless ${test.case} -->
-                    <!-- Don't add **/*Test.java here since
-                         there are some tests in javax.print.ValueTests -->
-                    <include name="**/*.java" unless="test.case"/>
-                    <excludesfile name="${print.exclude.file}"
-                                  unless="test.case"/>
-                </fileset>
-            </batchtest>
-        </junit>
-        <antcall target="touch-failures-file" />
-        <antcall target="touch-errors-file" />
+        <copy file="../../${junit.jar}" todir="${hy.hdk}/build/test" />
     </target>
 
-    <target name="touch-failures-file" if="test.failures">
-        <echo file="${tests.output}/test.failures"
-            append="true">print${line.separator}</echo>
+    <target name="compile-tests">
+        <compile-tests description="print tests">
+            <javac-elements>
+                <src>
+                    <pathelement location="src/test/api/java/common" />
+                </src>
+            </javac-elements>
+        </compile-tests>
     </target>
 
-    <target name="touch-errors-file" if="test.errors">
-        <echo file="${tests.output}/test.errors"
-            append="true">print${line.separator}</echo>
+    <target name="run-tests" depends="test-jar">
+        <ant dir="${tests.hdk.dir}" target="test-module" />
     </target>
 
 </project>

Modified: harmony/enhanced/classlib/branches/java6/modules/regex/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/regex/build.xml?rev=798469&r1=798468&r2=798469&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/regex/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/regex/build.xml Tue Jul 28 09:30:33 2009
@@ -1,46 +1,29 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+ 
       http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.
+ 
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
 -->
 
 <project name="REGEX Build" default="build" basedir=".">
     <description>Build for REGEX component</description>
 
+    <property name="hy.module" value="regex" />
     <property name="hy.hdk" location="${basedir}/../../deploy" />
     <import file="${hy.hdk}/build/ant/properties.xml" />
 
-    <property name="tests.output" location="../../build/test_report" />
-
-    <!-- set global properties for this build. -->
-    <xmlproperty file="make/hyproperties.xml" semanticAttributes="true" />
-
-    <fileset id="classes" dir="${hy.build}">
-        <or>
-            <present targetdir="${hy.regex.src.main.java}" />
-            <present targetdir="${hy.regex.src.main.java}">
-                <mapper type="regexp"
-                        from="^(.*?)(\$$[^/\\\.]*)?\.class$$"
-                        to="\1.java"/>
-            </present>
-        </or>
-    </fileset>
-
-    <property name="regex.exclude.file" location="${hy.hdk}/build/regex.exclude" />
+    <property file="../../make/depends.properties" />
 
     <target name="build" depends="compile-java, copy-resources, build-jar" />
 
@@ -56,11 +39,12 @@
     </target>
 
     <!-- internal target for local and global test run sequence -->
-    <target name="-test-module" depends="build, compile-tests, prepare-exclude, run-tests" />
+    <target name="-test-module" depends="build, run-tests" />
 
     <target name="clean">
         <delete file="${hy.jdk}/jre/lib/boot/regex.jar" />
         <delete file="${hy.jdk}/jre/lib/boot/regex-src.jar" />
+        <delete dir="${tests.hdk.dir}" failonerror="false" />
         <delete failonerror="false">
             <fileset refid="classes" />
         </delete>
@@ -70,11 +54,11 @@
     <target name="compile-java">
         <echo message="Compiling REGEX classes" />
 
-        <mkdir dir="${hy.build}" />
+        <mkdir dir="../../build/classes" />
 
         <javac sourcepath=""
-               srcdir="${hy.regex.src.main.java}"
-               destdir="${hy.build}"
+               srcdir="src/main/java"
+               destdir="../../build/classes"
                compiler="${hy.javac.compiler}"
                memoryMaximumSize="${hy.javac.maxmem}"
                source="${hy.javac.source}" 
@@ -92,9 +76,9 @@
     </target>
 
     <target name="copy-resources">
-        <mkdir dir="${hy.build}" />
-        <copy todir="${hy.build}" includeemptydirs="false">
-            <fileset dir="${hy.regex.src.main.java}">
+        <mkdir dir="../../build/classes" />
+        <copy todir="../../build/classes" includeemptydirs="false">
+            <fileset dir="src/main/java">
                 <exclude name="**/*.java" />
             </fileset>
         </copy>
@@ -102,7 +86,7 @@
 
     <target name="build-jar" depends="svn-info">
         <jar destfile="${hy.jdk}/jre/lib/boot/regex.jar"
-             manifest="${hy.regex}/META-INF/MANIFEST.MF"
+             manifest="META-INF/MANIFEST.MF"
              compress="${hy.jar.compress}">
             <fileset refid="classes" />
             <manifest>
@@ -113,7 +97,7 @@
         </jar>
 
         <jar destfile="${hy.jdk}/jre/lib/boot/regex-src.jar">
-            <fileset dir="${hy.regex.src.main.java}" />
+            <fileset dir="src/main/java" />
             <manifest>
                 <attribute name="Implementation-Version" value="${svn.info}"/> 
             </manifest>
@@ -122,91 +106,48 @@
         </jar>
     </target>
 
-    <target name="compile-tests">
-        <echo message="Compiling REGEX tests" />
-
-        <mkdir dir="${hy.regex.bin.test}" />
-
-        <javac srcdir="${hy.regex.src.test.java}"
-               destdir="${hy.regex.bin.test}"
-               sourcepath=""
-               compiler="${hy.javac.compiler}"
-               memoryMaximumSize="${hy.javac.maxmem}"
-               source="${hy.javac.source}" 
-               target="${hy.javac.target}"
-               debug="${hy.javac.debug}">
-
-            <compilerarg line="${build.compilerarg}" />
+    <target name="test-jar" depends="svn-info,compile-tests">
+        <mkdir dir="${tests.hdk.dir}" />
+        
+        <copy file="make/run-test.xml" tofile="${tests.hdk.dir}/build.xml" />
+        
+        <jar destfile="${tests.hdk.dir}/regex_tests.jar">
+            <fileset dir="bin/test" />
+            <manifest>
+                <attribute name="Implementation-Version" value="${svn.info}"/> 
+            </manifest>
+            <metainf refid="hy.required.metainf-files"/>
+        </jar>
 
-            <bootclasspath>
-                <fileset dir="${hy.jdk}/jre/lib/boot">
-                    <include name="**/*.jar" />
-                </fileset>
-            </bootclasspath>
-            <classpath location="${hy.hdk}/build/test/support.jar" />
-            <classpath location="../../build/tests" />
-        </javac>
-    </target>
+        <mkdir dir="${tests.excludes.hdk.dir}"/>
+        <copy todir="${tests.excludes.hdk.dir}">
+            <fileset dir="make" includes="exclude*"/>
+            <filterchain>
+                <tokenfilter>
+                    <replaceregex pattern="\.java" replace="\.class" flags="g"/>
+                </tokenfilter>
+            </filterchain>
+        </copy>
+        
+        <copy todir="${tests.resources.hdk.dir}">
+            <fileset dir="src/test/resources" />
+        </copy>
 
-    <target name="prepare-exclude">
-       <prepare-exclude-list moduleName="regex" dir="./make"
-                             result="${regex.exclude.file}"/>
-    </target>
-
-    <target name="run-tests">
-
-        <mkdir dir="${tests.output}" />
-
-        <property name="test.jre.home" value="${hy.jdk}/jre" />
-
-        <junit fork="yes"
-               forkmode="${hy.test.forkmode}"
-               timeout="${hy.test.timeout}"
-               printsummary="withOutAndErr"
-               errorproperty="test.errors"
-               failureproperty="test.failures"
-               showoutput="on"
-               dir="${basedir}"
-               jvm="${test.jre.home}/bin/java">
-
-            <assertions enableSystemAssertions="true">
-                <enable />
-            </assertions>
-
-            <jvmarg line="${hy.test.vmargs}" />
-
-            <classpath>
-                <pathelement path="${hy.regex.bin.test}"/>
-            </classpath>
-            <classpath location="${hy.hdk}/build/test/support.jar" />
-            <classpath location="../../build/tests" />
-            <classpath location="${hy.regex.src.test.resources}" />
-
-            <formatter type="xml" />
-
-            <batchtest todir="${tests.output}" haltonfailure="no" >
-
-                <fileset dir="${hy.regex.src.test.java}">
-                    <!-- if ${test.case}     -->
-                    <include name="${converted.tc}" if="test.case" />
-                    <!-- unless ${test.case} -->
-                    <include name="**/*Test.java" unless="test.case" />
-                    <excludesfile name="${regex.exclude.file}" unless="test.case" />
-                </fileset>
-            </batchtest>
-        </junit>
-        <antcall target="touch-failures-file" />
-        <antcall target="touch-errors-file" />
+        <copy file="../../${junit.jar}" todir="${hy.hdk}/build/test" />
     </target>
 
-    <target name="touch-failures-file" if="test.failures">
-        <echo file="${tests.output}/test.failures"
-            append="true">regex${line.separator}</echo>
+    <target name="compile-tests">
+        <compile-tests description="regex tests">
+            <javac-elements>
+                <src>
+                    <pathelement location="src/test/java" />
+                </src>
+            </javac-elements>
+        </compile-tests>
     </target>
 
-    <target name="touch-errors-file" if="test.errors">
-        <echo file="${tests.output}/test.errors"
-            append="true">regex${line.separator}</echo>
+    <target name="run-tests" depends="test-jar">
+        <ant dir="${tests.hdk.dir}" target="test-module" />
     </target>
 
 </project>



Mime
View raw message