You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ge...@apache.org on 2006/08/02 18:30:58 UTC

svn commit: r428043 - in /incubator/harmony/enhanced/drlvm/trunk: src/test/verifier_aastore/ src/test/verifier_aastore/src/ src/test/verifier_empty_init/ src/test/verifier_empty_init/src/ vm/vmcore/src/verifier/

Author: geirm
Date: Wed Aug  2 09:30:51 2006
New Revision: 428043

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

Add check for empty init method 

Also added both test sets included in JIRA to
src/test for further integration


Added:
    incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/
    incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/HowTo.txt   (with props)
    incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/src/
    incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/src/Test.java   (with props)
    incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/src/TestAastore.java   (with props)
    incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/src/TestAastore2.j
    incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/src/TestInterface.java   (with props)
    incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_empty_init/
    incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_empty_init/HowTo.txt   (with props)
    incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_empty_init/src/
    incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_empty_init/src/Test.java   (with props)
    incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_empty_init/src/TestEmptyInit.j
Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_dataflow.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_utils.cpp

Added: incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/HowTo.txt
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/HowTo.txt?rev=428043&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/HowTo.txt (added)
+++ incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/HowTo.txt Wed Aug  2 09:30:51 2006
@@ -0,0 +1,14 @@
+How to compile and run test:
+
+1) To compile you need to have a Jasmin version 1.1.
+This can be downloaded from http://jasmin.sourceforge.net
+
+2) The Jasmin distribution contains a jasmin.jar file holding the Jasmin assembler. 
+To compile sources execute the following commands:
+
+$ java -jar <path to Jasmin 1.1>/jasmin.jar src/*.j
+$ javac -d . src/*.java
+
+3) To run test execute the following command:
+
+$ java Test

Propchange: incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/HowTo.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/src/Test.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/src/Test.java?rev=428043&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/src/Test.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/src/Test.java Wed Aug  2 09:30:51 2006
@@ -0,0 +1,14 @@
+public class Test {
+    public static void main(String[] args) {
+        // verify aastore instruction
+        try {            
+            new TestAastore().test();
+            System.out.println("TestAastore: failed");
+        } catch (LinkageError e) {
+            System.out.println("TestAastore: passed: " + e);
+        } catch (Throwable e) {
+            System.out.println("TestAastore: failed: unexpected error " + e);
+            e.printStackTrace();
+        }
+   }
+}
\ No newline at end of file

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

Added: incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/src/TestAastore.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/src/TestAastore.java?rev=428043&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/src/TestAastore.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/src/TestAastore.java Wed Aug  2 09:30:51 2006
@@ -0,0 +1,11 @@
+public class TestAastore implements TestInterface {
+    public void test() {
+        TestAastore2 inst = new TestAastore2();
+        TestAastore[] array = new TestAastore[1];
+        inst.testField = array;
+        inst.test();
+    }
+    public void InterfaceMethod() {
+        return;
+    }
+}
\ No newline at end of file

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

Added: incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/src/TestAastore2.j
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/src/TestAastore2.j?rev=428043&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/src/TestAastore2.j (added)
+++ incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/src/TestAastore2.j Wed Aug  2 09:30:51 2006
@@ -0,0 +1,30 @@
+.class public TestAastore2
+.super java/lang/Object
+.field public testField [LTestInterface;
+
+.method public <init>()V
+   aload_0
+   invokespecial java/lang/Object/<init>()V
+   return
+.end method
+
+.method public test()V
+   .limit stack 3
+   .limit locals 2
+
+   aload_0
+   getfield TestAastore2/testField [LTestInterface;
+   astore_1
+
+   sipush 1
+   sipush 1
+   multianewarray [[LTestAastore; 2
+   sipush 0
+
+   ; target of a aastore instruction not assignment compatible
+   ; with the class type specified in the instruction
+   aload_1
+   aastore
+
+  return
+.end method

Added: incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/src/TestInterface.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/src/TestInterface.java?rev=428043&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/src/TestInterface.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_aastore/src/TestInterface.java Wed Aug  2 09:30:51 2006
@@ -0,0 +1,3 @@
+public interface TestInterface {
+    public void InterfaceMethod();
+}
\ No newline at end of file

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

Added: incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_empty_init/HowTo.txt
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_empty_init/HowTo.txt?rev=428043&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_empty_init/HowTo.txt (added)
+++ incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_empty_init/HowTo.txt Wed Aug  2 09:30:51 2006
@@ -0,0 +1,14 @@
+How to compile and run test:
+
+1) To compile you need to have a Jasmin version 1.1.
+This can be downloaded from http://jasmin.sourceforge.net
+
+2) The Jasmin distribution contains a jasmin.jar file holding the Jasmin assembler. 
+To compile sources execute the following commands:
+
+$ java -jar <path to Jasmin 1.1>/jasmin.jar src/*.j
+$ javac -d . src/Test.java
+
+3) To run test execute the following command:
+
+$ java Test

Propchange: incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_empty_init/HowTo.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_empty_init/src/Test.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_empty_init/src/Test.java?rev=428043&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_empty_init/src/Test.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_empty_init/src/Test.java Wed Aug  2 09:30:51 2006
@@ -0,0 +1,14 @@
+public class Test {
+    public static void main(String [] argv) {
+        // check empty init method
+        try { 
+            Class cl = Class.forName("TestEmptyInit");
+            System.out.println("TestEmptyInit: Fails");
+        } catch (LinkageError e) {
+            System.out.println("TestEmptyInit: Passes: " + e);
+        } catch (Throwable e) {
+            System.out.println("TestEmptyInit: Failed, caught unexpected exception");
+            e.printStackTrace(System.out);
+        }
+    }
+}

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

Added: incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_empty_init/src/TestEmptyInit.j
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_empty_init/src/TestEmptyInit.j?rev=428043&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_empty_init/src/TestEmptyInit.j (added)
+++ incubator/harmony/enhanced/drlvm/trunk/src/test/verifier_empty_init/src/TestEmptyInit.j Wed Aug  2 09:30:51 2006
@@ -0,0 +1,7 @@
+.class public TestEmptyInit
+.super java/lang/Object
+
+.method public <init>()V
+   ; empty init method w/o invokation to othe init method
+   return
+.end method

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_dataflow.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_dataflow.cpp?rev=428043&r1=428042&r2=428043&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_dataflow.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_dataflow.cpp Wed Aug  2 09:30:51 2006
@@ -1115,6 +1115,19 @@
         return VER_OK;
     }
 
+    // check <init> method
+    if( !memcmp( method_get_name( ctex->m_method ), "<init>", 7 )
+        && ctex->m_vtype.m_class != ctex->m_vtype.m_object )
+    {
+        if( invector->m_local->m_type == SM_UNINITIALIZED ) {
+            VERIFY_REPORT( ctex, "(class: " << class_get_name( ctex->m_class ) 
+                << ", method: " << method_get_name( ctex->m_method )
+                << method_get_descriptor( ctex->m_method )
+                << ") Constructor must be invoked" );
+            return VER_ErrorDataFlow;
+        }
+    }
+
     // get first instruction
     vf_Code_t *instr = &ctex->m_code[ctex->m_graph->GetNodeFirstInstr( node_num )];
 
@@ -1336,7 +1349,7 @@
         // fill "this" entry
         const char *name = class_get_name( ctex->m_class );
         vf_ValidType_t *type = vf_create_class_valid_type( name, ctex );
-        if( !strcmp( method_get_name( ctex->m_method ), "<init>" ) ) {
+        if( !memcmp( method_get_name( ctex->m_method ), "<init>", 7 ) ) {
             vector->m_local->m_type = SM_UNINITIALIZED;
         } else {
             vector->m_local->m_type = SM_REF;

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_utils.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_utils.cpp?rev=428043&r1=428042&r2=428043&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_utils.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_utils.cpp Wed Aug  2 09:30:51 2006
@@ -344,6 +344,7 @@
     {
         *out << "CONSTRAINT: have \""
             << constraint->source << "\" need \"" << constraint->target << "\" for method "
+            << class_get_name( method_get_class( m_method ) ) << "."
             << method_get_name( m_method ) << method_get_descriptor( m_method ) << endl;
     }
     return;
@@ -411,10 +412,12 @@
         VERIFY_TRACE( "constraint", "CONSTRAINT: for class \""
             << class_get_name( method_get_class( m_method ) ) << "\" CP index #" << index
             << " check access: have \"" << source << "\" need \"" << target << "\" for method "
+            << class_get_name( method_get_class( m_method ) ) << "."
             << method_get_name( m_method ) << method_get_descriptor( m_method ) );
     } else {
         VERIFY_TRACE( "constraint", "CONSTRAINT: have \""
             << source << "\" need \"" << target << "\" for method "
+            << class_get_name( method_get_class( m_method ) ) << "."
             << method_get_name( m_method ) << method_get_descriptor( m_method ) );
     }
     return;
@@ -1222,7 +1225,7 @@
             VERIFY_DEBUG( "verifying class " << class_get_name( ctex->m_class )
                 << " (method " << method_get_name( ctex->m_method )
                 << method_get_descriptor( ctex->m_method )
-                << ") couldn't resolve field by constant pool index #" << index );
+                << ") couldn't resolve field with constant pool index #" << index );
             return VER_OK;
         }
         if( field_is_protected( field ) ) {
@@ -1235,7 +1238,7 @@
             VERIFY_DEBUG( "verifying class " << class_get_name( ctex->m_class )
                 << " (method " << method_get_name( ctex->m_method )
                 << method_get_descriptor( ctex->m_method )
-                << ") couldn't resolve method by constant pool index #" << index );
+                << ") couldn't resolve method with constant pool index #" << index );
             return VER_OK;
         }
         if( method_is_protected( method ) ) {