harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r467437 - in /incubator/harmony/enhanced/drlvm/trunk: src/test/harmony-1800/ src/test/harmony-1800/testExec1.java vm/vmcore/src/kernel_classes/javasrc/java/lang/Runtime.java
Date Tue, 24 Oct 2006 18:51:28 GMT
Author: geirm
Date: Tue Oct 24 11:51:27 2006
New Revision: 467437

URL: http://svn.apache.org/viewvc?view=rev&rev=467437
Log:
HARMONY-1800

Test case and fix - fix solves problem, and does no harm.

Ubuntu 6 - c-unit-, smoke, ~kernel


Added:
    incubator/harmony/enhanced/drlvm/trunk/src/test/harmony-1800/
    incubator/harmony/enhanced/drlvm/trunk/src/test/harmony-1800/testExec1.java   (with props)
Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Runtime.java

Added: incubator/harmony/enhanced/drlvm/trunk/src/test/harmony-1800/testExec1.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/src/test/harmony-1800/testExec1.java?view=auto&rev=467437
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/src/test/harmony-1800/testExec1.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/src/test/harmony-1800/testExec1.java Tue Oct 24
11:51:27 2006
@@ -0,0 +1,43 @@
+import junit.framework.TestCase;
+import java.io.*;
+public class testExec1 extends TestCase {
+	    
+	    public void testExec() {
+		            String [] cmdL = new String[5];
+			            cmdL[0] = System.getProperty("java.home")+File.separator+"bin"+File.separator+"java";
+				            cmdL[1] = "-classpath";
+					            cmdL[2] = ".";
+						            cmdL[3] = "testExec1_App";
+							            cmdL[4] = null;
+								            try {
+										                Process p = Runtime.getRuntime().exec(cmdL);
+												            p.waitFor();
+													                int ans = p.exitValue();
+															            InputStream is = p.getErrorStream();
+																                int toRead = is.available();
+																		            byte[] out = new byte[100];
+																			                int sz = 0;
+																					            while (true) {
+																							                    int r = is.read();
+																									                    if (r == -1) {
+																												                        break;
+																															                }
+																											                    out[sz] = (byte)r;
+																													                    sz++;
+																															                    if (sz == 100) {
+																																		                        break;
+																																					                }
+																																	                }
+																						                System.out.println("========Application error message======");
+																								            System.out.println(new String (out, 0, sz));
+																									                System.out.println("=======================================");
+
+																											            fail("NullPointerException was not thrown. exitValue
= " + ans);
+																												            } catch (NullPointerException e) {
+																														            } catch (Exception e) {
+																																                e.printStackTrace();
+																																		            fail("Unexpected exception was thrown: " +
e);
+																																			            }
+									         }
+}
+

Propchange: incubator/harmony/enhanced/drlvm/trunk/src/test/harmony-1800/testExec1.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Runtime.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Runtime.java?view=diff&rev=467437&r1=467436&r2=467437
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Runtime.java
(original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Runtime.java
Tue Oct 24 11:51:27 2006
@@ -683,6 +683,17 @@
         if (command.length() == 0) {
             throw new IllegalArgumentException();
         }
+        if (envp != null) {
+            if (envp.length != 0) {
+                for (int i = 0; i < envp.length; i++) {
+                    if (envp[i] == null) {
+                        throw new NullPointerException("An element of envp shouldn't be empty.");
+                    }
+                }
+            } else {
+                envp = null;
+            }
+        }
 
         StringTokenizer st = new StringTokenizer(command);
         String[] cmdarray = new String[st.countTokens()];
@@ -738,10 +749,22 @@
         if (cmdarray.length == 0) {
             throw new IndexOutOfBoundsException();
         }
-        //XXX:
-        //#IN004# Should we check cmdarray's direction values: cmdarray[i] != null ?
-        //#IN004# Should we check: envp != null ?
-        //#IN004# Should we check envp's direction values: envp[i] != null ?
+        for (int i = 0; i < cmdarray.length; i++) {
+            if (cmdarray[i] == null) {
+                throw new NullPointerException("An element of cmdarray shouldn't be empty.");
+            }
+        }
+        if (envp != null) {
+            if (envp.length != 0) {
+                for (int i = 0; i < envp.length; i++) {
+                    if (envp[i] == null) {
+                        throw new NullPointerException("An element of envp shouldn't be empty.");
+                    }
+                }
+            } else {
+                envp = null;
+            }
+        }
 
         String dirPathName = (dir != null ? dir.getPath() : null);
 



Mime
View raw message