Ejemplo n.º 1
0
        protected static bool doInitialize(ClassFile theClass,StackFrame frame)
        {
            if (! theClass.isInitialized()){
                if (log.IsDebugEnabled) log.Debug(String.Format("Initializing {0}",theClass));
                string superClassName = theClass.GetSuperClassName();

                if (superClassName != null) { // got to the top
                    if (log.IsDebugEnabled) log.Debug(String.Format("Need to initialize {0}",superClassName));
                    ClassFile superClass = (ClassFile) classCache[superClassName];

                    if (! doInitialize(superClass,frame)){
                        return false;
                    }
                }

                // TODO: According to the spec, this should be in "textual order"
                if (log.IsDebugEnabled) log.DebugFormat("Executing static initializer");

                theClass.staticInitialize(frame);

                // now we can initialize the original class
                if (log.IsDebugEnabled) log.DebugFormat("Loading fields...");
                FieldInfo[] fields = theClass.getFields();

                if (fields != null){
                foreach (FieldInfo field in fields){
                    if (field == null) {
                        throw new Exception("FIeld is null?");
                    }
                    if (field.isStatic()){
                        if (log.IsDebugEnabled) log.DebugFormat("Static initializing {0}",field);

                    }
                }
                }

                theClass.setInitialized(true);
                return true;
            }
            return true;
        }