harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r1022506 - in /harmony/enhanced/java/branches/mrh: ./ classlib/ classlib/modules/archive/src/main/java/java/util/jar/ classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ classlib/modules/instrument/src/tes...
Date Thu, 14 Oct 2010 13:00:50 GMT
Author: hindessm
Date: Thu Oct 14 13:00:49 2010
New Revision: 1022506

URL: http://svn.apache.org/viewvc?rev=1022506&view=rev
Log:
Merge changes up to trunk@1022493.

Added:
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/common/
      - copied from r1022493, harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/common/
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/common/org/
      - copied from r1022493, harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/common/org/
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/common/org/apache/
      - copied from r1022493, harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/common/org/apache/
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/
      - copied from r1022493, harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/
      - copied from r1022493, harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/
      - copied from r1022493, harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/javac/
      - copied from r1022493, harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/javac/
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/javac/MainTest.java
      - copied unchanged from r1022493, harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/javac/MainTest.java
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/javah/
      - copied from r1022493, harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/javah/
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/javah/Test/
      - copied from r1022493, harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/javah/Test/
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/javah/Test/Test01.java
      - copied unchanged from r1022493, harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/javah/Test/Test01.java
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/javah/Test02.java
      - copied unchanged from r1022493, harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/javah/Test02.java
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/serialver/
      - copied from r1022493, harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/serialver/
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/serialver/NoSerialize.java
      - copied unchanged from r1022493, harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/serialver/NoSerialize.java
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/serialver/Point.java
      - copied unchanged from r1022493, harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/serialver/Point.java
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/serialver/Test.java
      - copied unchanged from r1022493, harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tests/tools/serialver/Test.java
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tools/
      - copied from r1022493, harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tools/
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tools/keytool/
      - copied from r1022493, harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tools/keytool/
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tools/keytool/tests/
      - copied from r1022493, harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tools/keytool/tests/
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tools/toolutils/
      - copied from r1022493, harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tools/toolutils/
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tools/toolutils/tests/
      - copied from r1022493, harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tools/toolutils/tests/
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tools/toolutils/tests/KeyStoreLoaderSaverTest.java
      - copied unchanged from r1022493, harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/common/org/apache/harmony/tools/toolutils/tests/KeyStoreLoaderSaverTest.java
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/unix/
      - copied from r1022493, harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/unix/
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/windows/
      - copied from r1022493, harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/test/java/windows/
Removed:
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/src/test/java/org/
Modified:
    harmony/enhanced/java/branches/mrh/   (props changed)
    harmony/enhanced/java/branches/mrh/classlib/   (props changed)
    harmony/enhanced/java/branches/mrh/classlib/modules/archive/src/main/java/java/util/jar/InitManifest.java
    harmony/enhanced/java/branches/mrh/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java
    harmony/enhanced/java/branches/mrh/classlib/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/InstrumentTestHelper.java
    harmony/enhanced/java/branches/mrh/classlib/modules/logging/src/main/java/java/util/logging/LogManager.java
    harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/lang/AbstractStringBuilder.java
    harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/lang/String.java
    harmony/enhanced/java/branches/mrh/classlib/support/src/test/java/tests/support/Support_Exec.java
    harmony/enhanced/java/branches/mrh/common_resources/   (props changed)
    harmony/enhanced/java/branches/mrh/drlvm/   (props changed)
    harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/build.xml

Propchange: harmony/enhanced/java/branches/mrh/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Oct 14 13:00:49 2010
@@ -1,2 +1,2 @@
 /harmony/enhanced/java/branches/mrh:935751
-/harmony/enhanced/java/trunk:935751-1005442
+/harmony/enhanced/java/trunk:935751-1022493

Propchange: harmony/enhanced/java/branches/mrh/classlib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Oct 14 13:00:49 2010
@@ -1,4 +1,4 @@
 /harmony/enhanced/classlib/trunk:926318-926838
 /harmony/enhanced/java/branches/mrh/classlib:935751
-/harmony/enhanced/java/trunk/classlib:935751-1005442
+/harmony/enhanced/java/trunk/classlib:935751-1022493
 /harmony/enhanced/trunk/classlib:476395-926317

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/archive/src/main/java/java/util/jar/InitManifest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/archive/src/main/java/java/util/jar/InitManifest.java?rev=1022506&r1=1022505&r2=1022506&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/archive/src/main/java/java/util/jar/InitManifest.java
(original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/archive/src/main/java/java/util/jar/InitManifest.java
Thu Oct 14 13:00:49 2010
@@ -186,6 +186,7 @@ class InitManifest {
                 if (linebreak == 1) {
                     decode(mark, last, false);
                     mark = pos;
+                    last = mark;
                     linebreak = 0;
                     continue;
                 }

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java?rev=1022506&r1=1022505&r2=1022506&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java
(original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java
Thu Oct 14 13:00:49 2010
@@ -46,6 +46,8 @@ public class ManifestTest extends TestCa
     private static final String MANIFEST_CONTENTS = "Manifest-Version: 1.0\nBundle-Name:
ClientSupport\nBundle-Description: Provides SessionService, AuthenticationService. Extends
RegistryService.\nBundle-Activator: com.ibm.ive.eccomm.client.support.ClientSupportActivator\nImport-Package:
com.ibm.ive.eccomm.client.services.log,\n com.ibm.ive.eccomm.client.services.registry,\n com.ibm.ive.eccomm.service.registry;
specification-version=1.0.0,\n com.ibm.ive.eccomm.service.session; specification-version=1.0.0,\n
com.ibm.ive.eccomm.service.framework; specification-version=1.2.0,\n org.osgi.framework; specification-version=1.0.0,\n
org.osgi.service.log; specification-version=1.0.0,\n com.ibm.ive.eccomm.flash; specification-version=1.2.0,\n
com.ibm.ive.eccomm.client.xml,\n com.ibm.ive.eccomm.client.http.common,\n com.ibm.ive.eccomm.client.http.client\nImport-Service:
org.osgi.service.log.LogReaderService\n org.osgi.service.log.LogService,\n com.ibm.ive.eccomm.service.registry.Regis
 tryService\nExport-Package: com.ibm.ive.eccomm.client.services.authentication; specification-version=1.0.0,\n
com.ibm.ive.eccomm.service.authentication; specification-version=1.0.0,\n com.ibm.ive.eccomm.common;
specification-version=1.0.0,\n com.ibm.ive.eccomm.client.services.registry.store; specification-version=1.0.0\nExport-Service:
com.ibm.ive.eccomm.service.authentication.AuthenticationService,\n com.ibm.ive.eccomm.service.session.SessionService\nBundle-Vendor:
IBM\nBundle-Version: 1.2.0\n";
     
     private static final String MANIFEST_CONTENTS_1 = "Manifest-Version: 2.0\nBundle-Name:
ClientSupport\nBundle-Description: Provides SessionService, AuthenticationService. Extends
RegistryService.\nBundle-Activator: com.ibm.ive.eccomm.client.support.ClientSupportActivator\nImport-Package:
com.ibm.ive.eccomm.client.services.log,\n com.ibm.ive.eccomm.client.services.registry,\n com.ibm.ive.eccomm.service.registry;
specification-version=2.0.0,\n com.ibm.ive.eccomm.service.session; specification-version=2.0.0,\n
com.ibm.ive.eccomm.service.framework; specification-version=2.1.0,\n org.osgi.framework; specification-version=2.0.0,\n
org.osgi.service.log; specification-version=2.0.0,\n com.ibm.ive.eccomm.flash; specification-version=2.2.0,\n
com.ibm.ive.eccomm.client.xml,\n com.ibm.ive.eccomm.client.http.common,\n com.ibm.ive.eccomm.client.http.client\nImport-Service:
org.osgi.service.log.LogReaderService\n org.osgi.service.log.LogService,\n com.ibm.ive.eccomm.service.registry.Reg
 istryService\nExport-Package: com.ibm.ive.eccomm.client.services.authentication; specification-version=1.0.0,\n
com.ibm.ive.eccomm.service.authentication; specification-version=1.0.0,\n com.ibm.ive.eccomm.common;
specification-version=1.0.0,\n com.ibm.ive.eccomm.client.services.registry.store; specification-version=1.0.0\nExport-Service:
com.ibm.ive.eccomm.service.authentication.AuthenticationService,\n com.ibm.ive.eccomm.service.session.SessionService\nBundle-Vendor:
IBM\nBundle-Version: 1.2.0\n";
+    
+    private static final String MANIFEST_CONTENTS_2 = "Manifest-Version: 1.0\nName: value\n
\n"; // Note penultimate line is single space
 
     private File resources;
 
@@ -153,6 +155,10 @@ public class ManifestTest extends TestCa
         Attributes namedEntryAttributes = (Attributes) (entries.get(""));
         assertEquals("Should be 6 named entry attributes", 6,
                 namedEntryAttributes.size());
+        
+        // Regression test for HARMONY-6669
+        new Manifest(new ByteArrayInputStream(
+            MANIFEST_CONTENTS_2.getBytes("ISO-8859-1")));
     }
 
     /**

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/InstrumentTestHelper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/InstrumentTestHelper.java?rev=1022506&r1=1022505&r2=1022506&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/InstrumentTestHelper.java
(original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/InstrumentTestHelper.java
Thu Oct 14 13:00:49 2010
@@ -36,6 +36,7 @@ import java.util.jar.JarFile;
 import java.util.jar.JarOutputStream;
 import java.util.jar.Manifest;
 import java.util.zip.ZipEntry;
+import tests.support.Support_Exec;
 
 public class InstrumentTestHelper {
     private Manifest manifest;
@@ -52,9 +53,9 @@ public class InstrumentTestHelper {
 
     private List<String> classpath = new ArrayList<String>();
 
-    private StringBuilder stdOut = new StringBuilder();
+    private String stdOut;
 
-    private StringBuilder stdErr = new StringBuilder();
+    private String stdErr;
 
     private int exitCode;
 
@@ -148,40 +149,11 @@ public class InstrumentTestHelper {
     }
 
     private void runAgentTest() throws IOException, InterruptedException {
-        String[] args = new String[2];
-        args[0] = "-javaagent:" + commandAgent;
-        if (commandAgentOptions != null
-                && commandAgentOptions.trim().length() != 0) {
-            args[0] += "=" + commandAgentOptions;
-        }
-
-        args[1] = mainClass.getName();
-
-        Process process = execJava(args, getClasspath());
-        process.waitFor();
-
-        exitCode = process.exitValue();
-    }
-
-    private Process execJava(String[] args, String[] classpath)
-            throws IOException {
-        // this function returns the resulting process from the exec
-        StringBuilder command;
-        String testVMArgs;
-        StringTokenizer st;
-
-        List<String> execArgs = new ArrayList<String>(3 + args.length);
-
-        // construct the name of executable file
-        String executable = System.getProperty("java.home");
-        if (!executable.endsWith(File.separator)) {
-            executable += File.separator;
-        }
-        executable += "bin" + File.separator + "java";
-        execArgs.add(executable);
+        List<String> execArgs = new ArrayList<String>(4);
 
         // add classpath string
         StringBuilder classPathString = new StringBuilder();
+        String[] classpath = getClasspath();
         if (classpath != null && classpath.length > 0) {
             boolean isFirst = true;
             for (String element : classpath) {
@@ -199,67 +171,17 @@ public class InstrumentTestHelper {
             execArgs.add(classPathString.toString());
         }
 
-        // parse hy.test.vmargs if was given
-        testVMArgs = System.getProperty("hy.test.vmargs");
-        if (testVMArgs != null) {
-            st = new StringTokenizer(testVMArgs, " ");
-            while (st.hasMoreTokens()) {
-                execArgs.add(st.nextToken());
-            }
-        }
-
-        // add custom args given as parameter
-        for (String arg : args) {
-            execArgs.add(arg);
-        }
-
-        // construct command line string and print it to stdout
-        command = new StringBuilder(execArgs.get(0));
-        for (int i = 1; i < execArgs.size(); i++) {
-            command.append(" ");
-            command.append(execArgs.get(i));
-        }
-        System.out.println("Exec: " + command.toString());
-        System.out.println();
-
-        // execute java process
-        final Process proc = Runtime.getRuntime().exec(
-                execArgs.toArray(new String[execArgs.size()]));
-
-        final String lineSeparator = System.getProperty("line.separator");
-        Thread errReader = new Thread(new Runnable() {
-            public void run() {
-                BufferedReader reader = new BufferedReader(
-                        new InputStreamReader(proc.getErrorStream()));
-                String line = null;
-                try {
-                    while ((line = reader.readLine()) != null) {
-                        stdErr.append(line).append(lineSeparator);
-                    }
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-        });
-        errReader.start();
-
-        Thread outReader = new Thread(new Runnable() {
-            public void run() {
-                BufferedReader reader = new BufferedReader(
-                        new InputStreamReader(proc.getInputStream()));
-                String line = null;
-                try {
-                    while ((line = reader.readLine()) != null) {
-                        stdOut.append(line).append(lineSeparator);
-                    }
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-        });
-        outReader.start();
-
-        return proc;
+        execArgs.add("-javaagent:" + commandAgent
+                     + ((commandAgentOptions != null
+                         && commandAgentOptions.trim().length() != 0)
+                        ? "=" + commandAgentOptions
+                        : ""));
+        execArgs.add(mainClass.getName());
+
+        Object[] res = Support_Exec.runJava(execArgs, null, false);
+        exitCode = ((Integer)res[0]).intValue();
+        stdOut = (String)res[1];
+        stdErr = (String)res[2];
     }
 
     private void generateJars() throws FileNotFoundException, IOException,
@@ -308,11 +230,11 @@ public class InstrumentTestHelper {
     }
 
     public String getStdOut() {
-        return stdOut.toString();
+        return stdOut;
     }
 
     public String getStdErr() {
-        return stdErr.toString();
+        return stdErr;
     }
 
     public String[] getClasspath() {

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/logging/src/main/java/java/util/logging/LogManager.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/logging/src/main/java/java/util/logging/LogManager.java?rev=1022506&r1=1022505&r2=1022506&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/logging/src/main/java/java/util/logging/LogManager.java
(original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/logging/src/main/java/java/util/logging/LogManager.java
Thu Oct 14 13:00:49 2010
@@ -32,6 +32,8 @@ import java.util.Collection;
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
 import java.util.Properties;
 import java.util.Set;
 import java.util.StringTokenizer;
@@ -321,26 +323,46 @@ public class LogManager {
         }
 
         // find children
-        // TODO: performance can be improved here?
-        Collection<Logger> allLoggers = loggers.values();
-        boolean emptyName = name.length() == 0;
-        String namePrefix = name + '.';
-        for (final Logger child : allLoggers) {
-            Logger oldParent = child.getParent();
-            if (parent == oldParent
-                    && (emptyName || child.getName().startsWith(namePrefix))) {
-                final Logger thisLogger = logger;
-                AccessController.doPrivileged(new PrivilegedAction<Object>() {
+        final boolean isNameEmpty = (name.length() == 0);
+        final Logger thisLogger = logger;
+        final String namePrefix = isNameEmpty ? "" : name + '.';
+        /*
+         * find only children under the current parent (others can
+         * not be children of the new logger)
+         */
+        if (parent == null) {
+            // parent is root, need to check all loggers to find children.
+            final Collection<Logger> allLoggers = loggers.values();
+            AccessController
+                    .doPrivileged(new PrivilegedAction<Object>() {
+                        public Object run() {
+                            for (final Logger child : allLoggers) {
+                                if (null == child.getParent()
+                                        && (child.getName().startsWith(namePrefix)))
{
+                                    child.setParent(thisLogger);
+                                }
+                            }
+                            return null;
+                        }
+            });
+        } else {
+            final List<Logger> childs = parent.children;
+            final Logger oldParent = parent;
+            AccessController.doPrivileged(new PrivilegedAction<Object>() {
                     public Object run() {
-                        child.setParent(thisLogger);
+                        final List toBeRemoved = new LinkedList();
+                        for (final Logger element : childs) {
+                            final String elementName = element.getName();
+                            if (elementName != null && elementName.startsWith(namePrefix))
{
+                                element.setParent(thisLogger);
+                                toBeRemoved.add(element);
+                            }
+                        }
+                        // remove child as the parent has been changed
+                        oldParent.children.removeAll(toBeRemoved);
                         return null;
                     }
                 });
-                if (null != oldParent) {
-                    // -- remove from old parent as the parent has been changed
-                    oldParent.children.remove(child);
-                }
-            }
         }
     }
 

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/lang/AbstractStringBuilder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/lang/AbstractStringBuilder.java?rev=1022506&r1=1022505&r2=1022506&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/lang/AbstractStringBuilder.java
(original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/lang/AbstractStringBuilder.java
Thu Oct 14 13:00:49 2010
@@ -77,9 +77,6 @@ abstract class AbstractStringBuilder {
     }
 
     AbstractStringBuilder(int capacity) {
-        if (capacity < 0) {
-            throw new NegativeArraySizeException();
-        }
         value = new char[capacity];
     }
 

Modified: harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/lang/String.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/lang/String.java?rev=1022506&r1=1022505&r2=1022506&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/lang/String.java
(original)
+++ harmony/enhanced/java/branches/mrh/classlib/modules/luni/src/main/java/java/lang/String.java
Thu Oct 14 13:00:49 2010
@@ -267,21 +267,18 @@ public final class String implements Ser
      */
     @Deprecated
     public String(byte[] data, int high, int start, int length) {
-        if (data != null) {
-            // start + length could overflow, start/length maybe MaxInt
-            if (start >= 0 && 0 <= length && length <= data.length
- start) {
-                offset = 0;
-                value = new char[length];
-                count = length;
-                high <<= 8;
-                for (int i = 0; i < count; i++) {
-                    value[i] = (char) (high + (data[start++] & 0xff));
-                }
-            } else {
-                throw new StringIndexOutOfBoundsException();
+        // putting the data.length check first forces the NPE
+        // start + length could overflow, start/length maybe MaxInt
+        if (length <= data.length - start && start >= 0 && 0 <=
length) {
+            offset = 0;
+            value = new char[length];
+            count = length;
+            high <<= 8;
+            for (int i = 0; i < count; i++) {
+                value[i] = (char) (high + (data[start++] & 0xff));
             }
         } else {
-            throw new NullPointerException();
+            throw new StringIndexOutOfBoundsException();
         }
     }
 
@@ -495,11 +492,7 @@ public final class String implements Ser
      */
     public String(int[] codePoints, int offset, int count) {
         super();
-        if (codePoints == null) {
-            throw new NullPointerException();
-        }
-        if (offset < 0 || count < 0
-                || (long) offset + (long) count > codePoints.length) {
+        if (offset < 0 || count < 0 || offset > codePoints.length - count) {
             throw new IndexOutOfBoundsException();
         }
         this.offset = 0;
@@ -523,9 +516,6 @@ public final class String implements Ser
      * @since 1.5
      */
     public String(StringBuilder sb) {
-        if (sb == null) {
-            throw new NullPointerException();
-        }
         this.offset = 0;
         this.count = sb.length();
         this.value = new char[this.count];
@@ -1226,10 +1216,7 @@ public final class String implements Ser
      */
     public boolean regionMatches(int thisStart, String string, int start,
             int length) {
-        if (string == null) {
-            throw new NullPointerException();
-        }
-        if (start < 0 || string.count - start < length) {
+        if (string.count - start < length || start < 0) {
             return false;
         }
         if (thisStart < 0 || count - thisStart < length) {
@@ -1728,10 +1715,6 @@ public final class String implements Ser
      * @since 1.5
      */
     public boolean contentEquals(CharSequence cs) {
-        if (cs == null) {
-            throw new NullPointerException();
-        }
-
         int len = cs.length();
 
         if (len != count) {
@@ -1940,9 +1923,6 @@ public final class String implements Ser
      * @since 1.5
      */
     public boolean contains(CharSequence cs) {
-        if (cs == null) {
-            throw new NullPointerException();
-        }
         return indexOf(cs.toString()) >= 0;
     }
 

Modified: harmony/enhanced/java/branches/mrh/classlib/support/src/test/java/tests/support/Support_Exec.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/classlib/support/src/test/java/tests/support/Support_Exec.java?rev=1022506&r1=1022505&r2=1022506&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/classlib/support/src/test/java/tests/support/Support_Exec.java
(original)
+++ harmony/enhanced/java/branches/mrh/classlib/support/src/test/java/tests/support/Support_Exec.java
Thu Oct 14 13:00:49 2010
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintStream;
 import java.util.ArrayList;
+import java.util.List;
 import java.util.StringTokenizer;
 
 import junit.framework.TestCase;
@@ -30,28 +31,88 @@ import junit.framework.TestCase;
 public class Support_Exec extends TestCase {
 
     /**
+     * Exec java returns the exitCode, and stdOut and stdErr as strings
+     */
+    public static Object[] runJava(List<String> args, String[] envp,
+                                   boolean displayOutput)
+            throws IOException, InterruptedException {
+        String executable = System.getProperty("java.home");
+        if (!executable.endsWith(File.separator)) {
+            executable += File.separator;
+        }
+        executable += "bin" + File.separator + "java";
+
+        // parse hy.test.vmargs if was given
+        String testVMArgs = System.getProperty("hy.test.vmargs");
+        if (testVMArgs != null) {
+            StringTokenizer st = new StringTokenizer(testVMArgs, " ");
+            int i = 0; // add at the beginning but maintain order
+            while (st.hasMoreTokens()) {
+                args.add(i++, st.nextToken());
+            }
+        }
+
+        return run(executable, args, envp, displayOutput);
+    }
+
+    /**
+     * Exec command returns the exitCode, and stdOut and stdErr as strings
+     */
+    public static Object[] run(String command, List<String> args, String[] envp,
+                               boolean displayOutput)
+            throws IOException, InterruptedException {
+        Object[] arr = exec(command, args, envp, displayOutput);
+
+        Process proc = (Process) arr[0];
+        StringBuilder output = new StringBuilder();
+        InputStream in = proc.getInputStream();
+        int result;
+        byte[] bytes = new byte[1024];
+
+        while ((result = in.read(bytes)) != -1) {
+            output.append(new String(bytes, 0, result));
+            if (displayOutput) {
+                System.out.write(bytes, 0, result);
+            }
+        }
+
+        in.close();
+        proc.waitFor();
+        int exitCode = proc.exitValue();
+        proc.destroy();
+        return new Object[] {
+            Integer.valueOf(exitCode),
+            output.toString(),
+            ((StringBuilder)arr[1]).toString()
+        };
+    }
+        
+    /**
      *  This function returns the output of the process as a string
      */
-	public static String execJava(String[] args, String[] classpath,
-			boolean displayOutput) throws IOException, InterruptedException {
+    public static String execJava(String[] args, String[] classpath,
+                                  boolean displayOutput)
+        throws IOException, InterruptedException {
         Object[] arr =
-                execJavaCommon(args, classpath, null, displayOutput, true);
+            execJavaCommon(args, classpath, null, displayOutput, true);
 
-        return getProcessOutput(arr, displayOutput);
-	}
+        return getProcessOutput(arr, displayOutput, true);
+    }
 
     /**
      * This function returns the output of the process as a string
      */
-	public static String execJava(String[] args, String[] classpath, String[] envp,
-			boolean displayOutput) throws IOException, InterruptedException {
-		Object[] arr =
-                execJavaCommon(args, classpath, envp, displayOutput, false);
+    public static String execJava(String[] args, String[] classpath,
+                                  String[] envp, boolean displayOutput)
+            throws IOException, InterruptedException {
+        Object[] arr =
+            execJavaCommon(args, classpath, envp, displayOutput, false);
 
-        return getProcessOutput(arr, displayOutput);
-	}
+        return getProcessOutput(arr, displayOutput, true);
+    }
 
-    private static String getProcessOutput(Object[] arr, boolean displayOutput)
+    private static String getProcessOutput(Object[] arr, boolean displayOutput,
+                                           boolean checkStderr)
             throws IOException, InterruptedException {
         Process proc = (Process) arr[0];
         StringBuilder output = new StringBuilder();
@@ -61,7 +122,6 @@ public class Support_Exec extends TestCa
 
         while ((result = in.read(bytes)) != -1) {
             output.append(new String(bytes, 0, result));
-
             if (displayOutput) {
                 System.out.write(bytes, 0, result);
             }
@@ -69,47 +129,48 @@ public class Support_Exec extends TestCa
 
         in.close();
         proc.waitFor();
-        checkStderr(arr);
+        if (checkStderr) {
+            checkStderr(arr);
+        }
         proc.destroy();
 
         return output.toString();
     }
 
     public static void checkStderr(Object[] execArgs) {
-		StringBuilder errBuf = (StringBuilder) execArgs[1];
+            StringBuilder errBuf = (StringBuilder) execArgs[1];
 
-        synchronized (errBuf) {
-			if (errBuf.length() > 0) {
-				fail(errBuf.toString());
-			}
-		}
-	}
+            synchronized (errBuf) {
+                if (errBuf.length() > 0) {
+                    fail(errBuf.toString());
+                }
+            }
+    }
 
     public static Object[] execJava2(String[] args, String[] classpath,
-			boolean displayOutput) throws IOException, InterruptedException {
+                                     boolean displayOutput)
+            throws IOException, InterruptedException {
         return execJavaCommon(args, classpath, null, displayOutput, true);
     }
 
     private static Object[] execJavaCommon(String[] args, String[] classpath,
-			String[] envp, boolean displayOutput, boolean appendToSystemClassPath)
+                                           String[] envp,
+                                           boolean displayOutput,
+                                           boolean appendToSystemClassPath)
             throws IOException, InterruptedException {
         // this function returns the resulting process from the exec
-		ArrayList<String> execArgs = null;
-		StringBuilder classPathString = new StringBuilder();
+        ArrayList<String> execArgs = null;
+        StringBuilder classPathString = new StringBuilder();
         StringBuilder command;
-        String executable;
-        String testVMArgs;
-        StringTokenizer st;
 
         execArgs = new ArrayList<String>(3 + args.length);
 
         // construct the name of executable file
-        executable = System.getProperty("java.home");
+        String executable = System.getProperty("java.home");
         if (!executable.endsWith(File.separator)) {
             executable += File.separator;
         }
-        executable += "bin" + File.separator;
-        execArgs.add(executable + "java");
+        executable += "bin" + File.separator + "java";
 
         // add classpath string
         if (classpath != null) {
@@ -121,7 +182,7 @@ public class Support_Exec extends TestCa
         if (appendToSystemClassPath) {
             execArgs.add("-cp");
             execArgs.add(System.getProperty("java.class.path") +
-                    classPathString);
+                         classPathString);
         } else {
             if (classpath != null) {
                 execArgs.add("-cp");
@@ -130,9 +191,9 @@ public class Support_Exec extends TestCa
         }
 
         // parse hy.test.vmargs if was given
-        testVMArgs = System.getProperty("hy.test.vmargs");
+        String testVMArgs = System.getProperty("hy.test.vmargs");
         if (testVMArgs != null) {
-            st = new StringTokenizer(testVMArgs, " ");
+            StringTokenizer st = new StringTokenizer(testVMArgs, " ");
 
             while (st.hasMoreTokens()) {
                 execArgs.add(st.nextToken());
@@ -143,74 +204,85 @@ public class Support_Exec extends TestCa
         for (String arg : args) {
             execArgs.add(arg);
         }
+        return exec(executable, execArgs, envp, displayOutput);
+    }
+
+    private static Object[] exec(String command, List<String> args,
+                                 String[] envp,
+                                 boolean displayOutput)
+            throws IOException, InterruptedException {
+        // this function returns the resulting process from the exec
+        args.add(0, command);
 
-        // construct command line string and print it to stdout
-        //if (displayOutput) {
-            command = new StringBuilder(execArgs.get(0));
-            for (int i = 1; i < execArgs.size(); i++) {
-                command.append(" ");
-                command.append(execArgs.get(i));
+        if (displayOutput) {
+            StringBuilder commandLine;
+            // construct command line string and print it to stdout
+            commandLine = new StringBuilder(args.get(0));
+            for (int i = 1; i < args.size(); i++) {
+                commandLine.append(" ");
+                commandLine.append(args.get(i));
             }
+            System.out.println("Exec: " + commandLine.toString());
             System.out.println();
-            System.out.println("Exec: " + command.toString());
-        //}
+        }
 
         // execute java process
-        final Process proc = Runtime.getRuntime().exec(
-                execArgs.toArray(new String[execArgs.size()]), envp);
-		final StringBuilder errBuf = new StringBuilder();
-		Thread errThread = new Thread(new Runnable() {
-			public void run() {
-				synchronized (errBuf) {
-                    InputStream err;
-                    int result;
-                    byte[] bytes = new byte[1024];
-
-                    synchronized (proc) {
-						proc.notifyAll();
-					}
-
-                    err = proc.getErrorStream();
-                    try {
-						while ((result = err.read(bytes)) != -1) {
-							System.err.write(bytes, 0, result);
-							errBuf.append(new String(bytes));
-						}
-						err.close();
-					} catch (IOException e) {
-						ByteArrayOutputStream out = new ByteArrayOutputStream();
-						PrintStream printer = new PrintStream(out);
-
-                        e.printStackTrace();
-						e.printStackTrace(printer);
-						printer.close();
-						errBuf.append(new String(out.toByteArray()));
-					}
-				}
-			}
-		});
+        final Process proc =
+            Runtime.getRuntime().exec(args.toArray(new String[args.size()]),
+                                      envp);
+
+        final StringBuilder errBuf = new StringBuilder();
+        Thread errThread = new Thread(new Runnable() {
+                public void run() {
+                    synchronized (errBuf) {
+                        InputStream err;
+                        int result;
+                        byte[] bytes = new byte[1024];
+
+                        synchronized (proc) {
+                            proc.notifyAll();
+                        }
+
+                        err = proc.getErrorStream();
+                        try {
+                            while ((result = err.read(bytes)) != -1) {
+                                System.err.write(bytes, 0, result);
+                                errBuf.append(new String(bytes));
+                            }
+                            err.close();
+                        } catch (IOException e) {
+                            ByteArrayOutputStream out =
+                                new ByteArrayOutputStream();
+                            PrintStream printer = new PrintStream(out);
+                            
+                            e.printStackTrace();
+                            e.printStackTrace(printer);
+                            printer.close();
+                            errBuf.append(new String(out.toByteArray()));
+                        }
+                    }
+                }
+            });
 
         synchronized (proc) {
-			errThread.start();
-			// wait for errThread to start
-			int count = 0;
-			boolean isFinished = false;
-			while(!isFinished) {
-			    try {
-			        proc.wait();
-			        isFinished = true;
-			    } catch (InterruptedException e) {
-			        if(++count == 2) {
-			            throw e;
-			        }
-			    }
-			}
-			if(count > 0) {
-			    Thread.currentThread().interrupt();
-			}
-		}
-
+            errThread.start();
+            // wait for errThread to start
+            int count = 0;
+            boolean isFinished = false;
+            while(!isFinished) {
+                try {
+                    proc.wait();
+                    isFinished = true;
+                } catch (InterruptedException e) {
+                    if(++count == 2) {
+                        throw e;
+                    }
+                }
+            }
+            if(count > 0) {
+                Thread.currentThread().interrupt();
+            }
+        }
         return new Object[] { proc, errBuf };
-	}
-
+    }
 }

Propchange: harmony/enhanced/java/branches/mrh/common_resources/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Oct 14 13:00:49 2010
@@ -1,4 +1,4 @@
 /harmony/enhanced/java/branches/mrh/common_resources:935751
-/harmony/enhanced/java/trunk/common_resources:935751-1005442
+/harmony/enhanced/java/trunk/common_resources:935751-1022493
 /harmony/enhanced/trunk/common_resources:476395-921782
 /incubator/harmony/enhanced/trunk/common_resources:292550-476394

Propchange: harmony/enhanced/java/branches/mrh/drlvm/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Oct 14 13:00:49 2010
@@ -1,5 +1,5 @@
 /harmony/enhanced/java/branches/mrh/drlvm:935751
-/harmony/enhanced/java/trunk/drlvm:935751-1005442
+/harmony/enhanced/java/trunk/drlvm:935751-1022493
 /harmony/enhanced/trunk/drlvm:476395-926313
 /harmony/enhanced/trunk/working_vm:476396-920147
 /incubator/harmony/enhanced/trunk/working_vm:423974-476394

Modified: harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/build.xml?rev=1022506&r1=1022505&r2=1022506&view=diff
==============================================================================
--- harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/build.xml (original)
+++ harmony/enhanced/java/branches/mrh/jdktools/modules/jdktools/build.xml Thu Oct 14 13:00:49
2010
@@ -194,7 +194,8 @@
         <compile-tests description="${hy.module} tests">
             <javac-elements>
                 <src>
-                    <pathelement location="src/test/java" />
+                    <pathelement location="src/test/java/common" />
+                    <pathelement location="src/test/java/${hy.os.family}" />
                 </src>
                 <exclude name="org/apache/harmony/tests/tools/serialver/**"
                          if="is.select"/>



Mime
View raw message