Fix bugs for interfaces and a bug in the Class library
authorjzhou <jzhou>
Thu, 3 Mar 2011 02:07:49 +0000 (02:07 +0000)
committerjzhou <jzhou>
Thu, 3 Mar 2011 02:07:49 +0000 (02:07 +0000)
Robust/src/ClassLibrary/MGC/gnu/Calendar.java
Robust/src/ClassLibrary/MGC/gnu/TimeZone.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/IR/TypeUtil.java
Robust/src/Tests/InterfaceTest.java
Robust/src/Tests/StaticInnerClassTest.java

index 46d17b59770b55a35d25b76b5b047377047dbbe6..99160d0f1cf27676c397eb5719cf3d5b66949b71 100644 (file)
@@ -545,7 +545,6 @@ public /*abstract*/ class Calendar
       {
        minimalDaysInFirstWeek = 1;
       }
-
     firstDayOfWeek = 1;
     if (first != null)
       for (int i = 0; i < 8; i++)
index 78a3a32a62893fca5bbcfd78d3c070c3957caace..55b0942f1979f6134ba147be534ccc058787ec8c 100644 (file)
@@ -1772,6 +1772,7 @@ public abstract class TimeZone //implements java.io.Serializable, Cloneable
        //return super.clone();
       TimeZone tz = new TimeZone();
       tz.ID = this.ID;
+      return tz;
       }
     catch (/*CloneNotSupported*/Exception ex)
       {
index 9e99824dc4fd26a8707bc458ec91cd83cc81a518..d48c0f49c4de54fbedab08d69d3065e2e7cde1c6 100644 (file)
@@ -1155,7 +1155,7 @@ public class BuildCode {
       allit=cn.getFieldTable().getAllDescriptorsIterator();
       while(allit.hasNext()) {
        FieldDescriptor fd=(FieldDescriptor)allit.next();
-    if(fd.isStatic() || fd.isVolatile()) {
+    if(fd.isStatic() /*|| fd.isVolatile()*/) {
       continue;
     }
        TypeDescriptor type=fd.getType();
@@ -2176,7 +2176,7 @@ public class BuildCode {
   public void generateFlatOffsetNode(FlatMethod fm, FlatOffsetNode fofn, PrintWriter output) {
     output.println("/* FlatOffsetNode */");
     FieldDescriptor fd=fofn.getField();
-    if(!fd.isStatic() && !fd.isVolatile()) {
+    if(!fd.isStatic() /*&& !fd.isVolatile()*/) {
     output.println(generateTemp(fm, fofn.getDst())+ " = (short)(int) (&((struct "+fofn.getClassType().getSafeSymbol() +" *)0)->"+
                    fd.getSafeSymbol()+");");
     }
@@ -2442,7 +2442,7 @@ public class BuildCode {
   }
 
   protected void generateFlatFieldNode(FlatMethod fm, FlatFieldNode ffn, PrintWriter output) {
-    if(ffn.getField().isStatic() || ffn.getField().isVolatile()) {
+    if(ffn.getField().isStatic()/* || ffn.getField().isVolatile()*/) {
       // static field
       if((fm.getMethod().isStaticBlock()) || (fm.getMethod().isInvokedByStatic()/* && mgcstaticinit*/)) {
        // is a static block or is invoked in some static block
@@ -2467,7 +2467,7 @@ public class BuildCode {
        }
       }
       // redirect to the global_defs_p structure
-      if((ffn.getField().isStatic()) || (ffn.getField().isVolatile()) || (ffn.getSrc().getType().isClassNameRef())) {
+      if((ffn.getField().isStatic()) || (ffn.getSrc().getType().isClassNameRef())) {
        // reference to the static field with Class name
        if (ffn.getField().getType().isPtr())
          output.println(generateTemp(fm, ffn.getDst())+"=global_defs_p->"+ffn.getField().getSafeSymbol()+";");
@@ -2526,7 +2526,7 @@ public class BuildCode {
        }
       }
       // redirect to the global_defs_p structure
-      if((fsfn.getDst().getType().isClassNameRef()) || (fsfn.getField().isStatic()) || (fsfn.getField().isVolatile())) {
+      if((fsfn.getDst().getType().isClassNameRef()) || (fsfn.getField().isStatic()) /*|| (fsfn.getField().isVolatile())*/) {
        // reference to the static field with Class name
        if (fsfn.getField().getType().isPtr())
          output.println("global_defs_p->" +
index c55768f0e570467193c492e495b8893007e7cae7..a704929c47592dfceea4eacd1bbc81dce7e40845 100644 (file)
@@ -205,16 +205,17 @@ NextMethod:
 
   public void createFullTable() {
     subclasstable=new Hashtable();
-    //subIFclasstable = new Hashtable();
     HashSet tovisit=new HashSet();
     HashSet visited=new HashSet();
 
     Iterator classit=state.getClassSymbolTable().getDescriptorsIterator();
     while(classit.hasNext()) {
+      tovisit.clear();
+      visited.clear();
       ClassDescriptor cd=(ClassDescriptor)classit.next();
       ClassDescriptor tmp=cd.getSuperDesc();
       
-      // check tmp's interface ancestors
+      // check cd's interface ancestors
       {
        Iterator it_sifs = cd.getSuperInterfaces();
        while(it_sifs.hasNext()) {
@@ -250,7 +251,7 @@ NextMethod:
          if(!this.subclasstable.containsKey(sif)) {
            this.subclasstable.put(sif, new HashSet());
          }
-         HashSet hs = (HashSet)this.subclasstable/*subIFclasstable*/.get(sif);
+         HashSet hs = (HashSet)this.subclasstable.get(sif);
          hs.add(cd);
           
          Iterator it_sifs = sif.getSuperInterfaces();
index d1a93f5554505b5fe3cbaa685060b65b7c09bf66..892379903702e5c86902ceaafefc001a3711d26a 100644 (file)
@@ -1,6 +1,6 @@
 public interface Instrument {
   // Compile-time constant:
-  int VALUE;// = 5; // static & final
+  int VALUE = 5; // static & final
   // Cannot have method definitions:
   void play(int n); // Automatically public
   void adjust();
@@ -75,7 +75,6 @@ public class InterfaceTest {
   }
   public static void main(String[] args) {
     // Upcasting during addition to the array:
-    Instrument.VALUE=5;
     Instrument[] orchestra = new Instrument[5];
     orchestra[0] = new Wind();
     orchestra[1] = new Percussion();
index a7c555b02e9a0481c6efe67f590ed43615135cf1..042d5f2a8d5c8c5920bb337f373e791142b74424 100644 (file)
@@ -1,4 +1,4 @@
-class Contents {
+interface Contents {
   int value();
 }