1) Support final declaration for methods
authorbdemsky <bdemsky>
Thu, 13 Sep 2007 01:00:00 +0000 (01:00 +0000)
committerbdemsky <bdemsky>
Thu, 13 Sep 2007 01:00:00 +0000 (01:00 +0000)
2) Make the start method of the thread class final...to prevent terrible things from happening

Robust/src/ClassLibrary/ThreadDSM.java
Robust/src/IR/Tree/Modifiers.java
Robust/src/IR/Tree/SemanticCheck.java
Robust/src/Runtime/thread.c

index 7498028298042307f9619560477196b6266a30ae..f6ba8cf362e5f53fe07f26419055ff27eb7fd914 100644 (file)
@@ -1,5 +1,8 @@
 public class Thread {
-    public native void start(int mid);
+    /* Don't allow overriding this method.  If you do, it will break dispatch
+     * because we don't have the type information necessary. */
+
+    public final native void start(int mid);
 
     public native static void sleep(long millis);
     
index d4270d8d5cdbf92ecf25d8cdd4b6e53254112fbb..98e032d9ca148232f6e0a8fe17dcea3c41f48eb4 100644 (file)
@@ -46,6 +46,10 @@ public class Modifiers {
        return ((value&NATIVE)!=0);
     }
 
+    public boolean isFinal() {
+       return ((value&FINAL)!=0);
+    }
+
     public String toString() {
        String st="";
        if ((value&PUBLIC)!=0)
index 12e5223c5a6d68345c1e19d9ff6fb4183c94fe2a..5e1c2d23bfe63dcf8b5d28a0ebfb1a198fd2de56 100644 (file)
@@ -57,7 +57,6 @@ public class SemanticCheck {
            checkTask(td);
            
        }
-
     }
 
     public void checkTypeDescriptor(TypeDescriptor td) {
@@ -203,7 +202,18 @@ public class SemanticCheck {
     }
 
     public void checkMethodBody(ClassDescriptor cd, MethodDescriptor md) {
-       //System.out.println("Processing method:"+md);
+       ClassDescriptor superdesc=cd.getSuperDesc();
+       if (superdesc!=null) {
+           Set possiblematches=superdesc.getMethodTable().getSet(md.getSymbol());
+           for(Iterator methodit=possiblematches.iterator();methodit.hasNext();) {
+               MethodDescriptor matchmd=(MethodDescriptor)methodit.next();
+               if (md.matches(matchmd)) {
+                   if (matchmd.getModifiers().isFinal()) {
+                       throw new Error("Try to override final method in method:"+md+" declared in  "+cd);
+                   }
+               }
+           }
+       }
        BlockNode bn=state.getMethodBody(md);
        checkBlockNode(md, md.getParameterTable(),bn);
     }
index 19996537a3fcd2381d06eafb606eaa7cbe31b2c1..817db2e7ccb0d422c8c42020a3b33434c2508ec0 100644 (file)
@@ -121,6 +121,6 @@ void CALL01(___Thread______nativeCreate____, struct ___Thread___ * ___this___) {
 
 #ifdef DSTM
 void CALL12(___Thread______start____I, int ___mid___, struct ___Thread___ * ___this___, int ___mid___) {
-  startRemoteThread((unsigned int *)VAR(___this___), ___mid___);
+  startRemoteThread((unsigned int)VAR(___this___), ___mid___);
 }
 #endif