support subclasses accessing protected fields
authorcrawshaw <crawshaw@ibex.org>
Thu, 23 Dec 2004 13:58:49 +0000 (13:58 +0000)
committercrawshaw <crawshaw@ibex.org>
Thu, 23 Dec 2004 13:58:49 +0000 (13:58 +0000)
darcs-hash:20041223135849-2eb37-cfc6c1e834054e4e46fe51a8d27aaabebb036d93.gz

src/java/org/ibex/tool/Compiler.java

index 6d46890..4ce113c 100644 (file)
@@ -414,9 +414,13 @@ public class Compiler {
         LoadedClass(Class c) {
             this.c = c;
 
-            Field[] fields = c.getFields();
-            f = new IBinaryField[fields.length];
-            for (int i=0; i < f.length; i++) f[i] = new LoadedField(fields[i]);
+            Field[] fields = c.getDeclaredFields();
+            List flist = new ArrayList(fields.length);
+            for (int i=0; i < fields.length; i++)
+                if (!Modifier.isPrivate(fields[i].getModifiers()))
+                    flist.add(new LoadedField(fields[i]));
+            f = new IBinaryField[flist.size()];
+            flist.toArray(f);
 
             Class[] interfaces = c.getInterfaces();
             inf = new char[interfaces.length][];
@@ -430,14 +434,15 @@ public class Compiler {
             Constructor[] constructors = c.getDeclaredConstructors();
             Method[] methods = c.getDeclaredMethods();
             if (methods.length + constructors.length > 0) {
-                meth = new IBinaryMethod[methods.length + constructors.length];
-                int i=0;
+                List m = new ArrayList(methods.length + constructors.length);
                 for (int j=0; j < methods.length; j++)
-                    meth[i++] = new LoadedMethod(methods[j]);
+                    if (!Modifier.isPrivate(methods[j].getModifiers()))
+                        m.add(new LoadedMethod(methods[j]));
                 for (int j=0; j < constructors.length; j++)
-                    meth[i++] = new LoadedConstructor(constructors[j]);
+                    if (!Modifier.isPrivate(constructors[j].getModifiers()))
+                        m.add(new LoadedConstructor(constructors[j]));
+                meth = new IBinaryMethod[m.size()]; m.toArray(meth);
             }
-
         }
 
         public char[] getName() { return name(c); }