From: bdemsky Date: Thu, 13 Sep 2007 01:00:00 +0000 (+0000) Subject: 1) Support final declaration for methods X-Git-Tag: preEdgeChange~449 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=cdb4db2ee2a231b03a46551d9fbd88087f1fdf06;p=IRC.git 1) Support final declaration for methods 2) Make the start method of the thread class final...to prevent terrible things from happening --- diff --git a/Robust/src/ClassLibrary/ThreadDSM.java b/Robust/src/ClassLibrary/ThreadDSM.java index 74980282..f6ba8cf3 100644 --- a/Robust/src/ClassLibrary/ThreadDSM.java +++ b/Robust/src/ClassLibrary/ThreadDSM.java @@ -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); diff --git a/Robust/src/IR/Tree/Modifiers.java b/Robust/src/IR/Tree/Modifiers.java index d4270d8d..98e032d9 100644 --- a/Robust/src/IR/Tree/Modifiers.java +++ b/Robust/src/IR/Tree/Modifiers.java @@ -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) diff --git a/Robust/src/IR/Tree/SemanticCheck.java b/Robust/src/IR/Tree/SemanticCheck.java index 12e5223c..5e1c2d23 100644 --- a/Robust/src/IR/Tree/SemanticCheck.java +++ b/Robust/src/IR/Tree/SemanticCheck.java @@ -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); } diff --git a/Robust/src/Runtime/thread.c b/Robust/src/Runtime/thread.c index 19996537..817db2e7 100644 --- a/Robust/src/Runtime/thread.c +++ b/Robust/src/Runtime/thread.c @@ -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