harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r447091 - in /incubator/harmony/enhanced/drlvm/trunk: src/test/final_method_test/ src/test/final_method_test/finalmethodtest/ vm/vmcore/include/ vm/vmcore/src/class_support/
Date Sun, 17 Sep 2006 16:30:37 GMT
Author: geirm
Date: Sun Sep 17 09:30:37 2006
New Revision: 447091

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

Package-private final method is considered to be overridden in another package(IncompatibleClassChangeError)

tested on ubuntu - passed the included test (committed to src/test for later orgainzation)
and smoke and c-unit


Added:
    incubator/harmony/enhanced/drlvm/trunk/src/test/final_method_test/
    incubator/harmony/enhanced/drlvm/trunk/src/test/final_method_test/FinalMethodTest.java
  (with props)
    incubator/harmony/enhanced/drlvm/trunk/src/test/final_method_test/finalmethodtest/
    incubator/harmony/enhanced/drlvm/trunk/src/test/final_method_test/finalmethodtest/A.java
  (with props)
Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Prepare.cpp

Added: incubator/harmony/enhanced/drlvm/trunk/src/test/final_method_test/FinalMethodTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/src/test/final_method_test/FinalMethodTest.java?view=auto&rev=447091
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/src/test/final_method_test/FinalMethodTest.java
(added)
+++ incubator/harmony/enhanced/drlvm/trunk/src/test/final_method_test/FinalMethodTest.java
Sun Sep 17 09:30:37 2006
@@ -0,0 +1,18 @@
+import finalmethodtest.A;
+
+
+class B extends A {
+	    private void m() {
+                   System.out.println("PASSED");
+		        }
+	        public void test() {
+			        m();
+				    }
+}
+
+public class FinalMethodTest {
+	    public static void main(String[] args) {
+		            new B().test();
+			        }
+
+} 

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

Added: incubator/harmony/enhanced/drlvm/trunk/src/test/final_method_test/finalmethodtest/A.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/src/test/final_method_test/finalmethodtest/A.java?view=auto&rev=447091
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/src/test/final_method_test/finalmethodtest/A.java
(added)
+++ incubator/harmony/enhanced/drlvm/trunk/src/test/final_method_test/finalmethodtest/A.java
Sun Sep 17 09:30:37 2006
@@ -0,0 +1,8 @@
+package finalmethodtest;
+
+public abstract class A {
+	     final void m() {
+		            System.out.println("m");
+			        }
+} 
+

Propchange: incubator/harmony/enhanced/drlvm/trunk/src/test/final_method_test/finalmethodtest/A.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h?view=diff&rev=447091&r1=447090&r2=447091
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h Sun Sep 17 09:30:37 2006
@@ -894,6 +894,7 @@
     bool is_public()            {return (_access_flags&ACC_PUBLIC)?true:false;}
     bool is_private()           {return (_access_flags&ACC_PRIVATE)?true:false;}
     bool is_protected()         {return (_access_flags&ACC_PROTECTED)?true:false;}
+    bool is_package_private()   {return !(is_public()||is_protected()||is_public())?true:false;}
     bool is_static()            {return (_access_flags&ACC_STATIC)?true:false;}
     bool is_final()             {return (_access_flags&ACC_FINAL)?true:false;}
     bool is_strict()            {return (_access_flags&ACC_STRICT)?true:false;}

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Prepare.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Prepare.cpp?view=diff&rev=447091&r1=447090&r2=447091
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Prepare.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Prepare.cpp Sun Sep
17 09:30:37 2006
@@ -858,9 +858,25 @@
                 for (j = 0;  j < n_super_virtual_method_entries;  j++) {
                     Method *m = super_vtable_descriptors[j];
                     if (name == m->get_name() && desc == m->get_descriptor())
{
-                        if( m->is_final() && !m->is_private() ) {
-                            clss->state = ST_Error;
-                            return;
+                        if(m->is_final()) {
+                            if(m->is_private()
+                                || (m->is_package_private() 
+                                    && m->get_class()->package != method.get_class()->package))
+                            {
+                                // We allow to override private final and
+                                // default (package private) final methods
+                                // from superclasses since they are not accessible
+                                // from descendants.
+                                // Note: for package private methods this statement
+                                // is true only for classes from different packages
+                            } else {
+                                REPORT_FAILED_CLASS_CLASS(clss->class_loader, clss,
+                                    "java/lang/VerifyError",
+                                    "An attempt is made to override final method "
+                                    << m->get_class()->name->bytes <<
"."
+                                    << m->get_name()->bytes << m->get_descriptor()->bytes);
+                                return;
+                            }
                         }
                         // method doesn't override m if method has package access
                         // and is in a different runtime package than m.
@@ -1373,8 +1389,6 @@
     //
     assign_offsets_to_class_methods(clss);
     if(clss->state == ST_Error) {
-        REPORT_FAILED_CLASS_CLASS(clss->class_loader, clss,
-            "java/lang/IncompatibleClassChangeError", clss->name->bytes);
         return false;
     }
     //



Mime
View raw message