harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r569421 - in /harmony/enhanced/drlvm/trunk: src/test/regression/H4654/ src/test/regression/H4654/OOMEPrintStackTrace.java src/test/regression/H4654/Test.java vm/vmcore/src/init/vm_init.cpp
Date Fri, 24 Aug 2007 15:32:02 GMT
Author: gshimansky
Date: Fri Aug 24 08:32:01 2007
New Revision: 569421

URL: http://svn.apache.org/viewvc?rev=569421&view=rev
Log:
Applied patch from HARMONY-4654
[drlvm][classloader][init] assertion on OOME class is not initialized


Added:
    harmony/enhanced/drlvm/trunk/src/test/regression/H4654/
    harmony/enhanced/drlvm/trunk/src/test/regression/H4654/OOMEPrintStackTrace.java   (with
props)
    harmony/enhanced/drlvm/trunk/src/test/regression/H4654/Test.java   (with props)
Modified:
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H4654/OOMEPrintStackTrace.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H4654/OOMEPrintStackTrace.java?rev=569421&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H4654/OOMEPrintStackTrace.java (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H4654/OOMEPrintStackTrace.java Fri Aug
24 08:32:01 2007
@@ -0,0 +1,27 @@
+package org.apache.harmony.drlvm.tests.regression.h4654;
+
+/**
+ * Tests that VM doesn't crash in printStackTrace() for OOME.
+ */
+
+public class OOMEPrintStackTrace {
+
+    public static void main(String[] args) {
+        int size = 1;
+
+        try {
+            for (int i = 0; 0 < 10; i++) {
+                System.out.println("Allocating 10^" + i + " longs...");
+                long[] b = new long[size];
+                size *= 10;
+            }
+        } catch (OutOfMemoryError e) {
+            printStackTrace(e);
+        }
+    }
+
+    static public void printStackTrace(Throwable e) {
+        e.printStackTrace();
+    }
+
+}

Propchange: harmony/enhanced/drlvm/trunk/src/test/regression/H4654/OOMEPrintStackTrace.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H4654/Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H4654/Test.java?rev=569421&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H4654/Test.java (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H4654/Test.java Fri Aug 24 08:32:01 2007
@@ -0,0 +1,72 @@
+package org.apache.harmony.drlvm.tests.regression.h4654;
+
+import java.io.File;
+import java.io.InputStreamReader;
+import java.io.BufferedReader;
+import junit.framework.TestCase;
+
+/**
+ * Tests that VM doesn't crash in printStackTrace() for OOME.
+ * Runs VM in child process for the 'TestClass' and checks that it doesn't
+ * crash and returns zero exitValue.
+ * Child process for the test application is required because crash didn't
+ * reproduce in junit test (main class derived from junit.framework.TestCase).
+ */
+public class Test extends TestCase {
+
+    final static String testClass =
+       "org.apache.harmony.drlvm.tests.regression.h4654.OOMEPrintStackTrace";
+
+    public static void main(String[] args) {
+        (new Test()).test();
+    }
+
+    public void test() {
+        ProcessBuilder pb = new ProcessBuilder(
+            System.getProperty("java.home") + File.separator + "bin" +
+                    File.separator+"java",
+            "-XX:vm.assert_dialog=false",
+            "-cp",
+            System.getProperty("java.class.path"),
+            testClass
+        );
+
+        // merge stderr adn stdout for child VM process
+        pb.redirectErrorStream(true);
+
+        System.out.println("Command line for child VM:");
+
+        for (String arg : pb.command()) {
+            System.out.println("  " + arg);
+        }
+
+        int exitValue = -1;
+
+        try {
+            System.out.println("Launching child VM...");
+            Process p = pb.start();
+            System.out.println("Child VM started.");
+
+            BufferedReader childOut = new BufferedReader(new InputStreamReader(
+                    p.getInputStream()));
+
+            BufferedReader childErr = new BufferedReader(new InputStreamReader(
+                    p.getErrorStream()));
+
+            String outLine;
+
+            while (null != (outLine = childOut.readLine())) {
+                System.out.println("child-out>   " + outLine);
+            }
+
+            System.out.println("Waiting for child VM process to finish...");
+
+            exitValue = p.waitFor();
+            System.out.println("Child VM finished. Exit value = " + exitValue);
+        } catch (Throwable exc) {
+            exc.printStackTrace();
+        }
+
+        assertTrue(exitValue == 0);
+    }
+}

Propchange: harmony/enhanced/drlvm/trunk/src/test/regression/H4654/Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp?rev=569421&r1=569420&r2=569421&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp Fri Aug 24 08:32:01 2007
@@ -758,6 +758,7 @@
     vm_env->java_lang_Object->object =
         class_alloc_new_object(vm_env->JavaLangObject_Class);    
     // Create java.lang.OutOfMemoryError.
+    class_initialize(vm_env->java_lang_OutOfMemoryError_Class);
     vm_env->java_lang_OutOfMemoryError = oh_allocate_global_handle();
     vm_env->java_lang_OutOfMemoryError->object = 
         class_alloc_new_object(vm_env->java_lang_OutOfMemoryError_Class);



Mime
View raw message