/** * Check that the set of <code>LocalInstance</code>s <code>localsUsed</code>, which is the set of * locals used in the inner class declared by <code>cb</code> are initialized before the class * declaration. */ protected void checkLocalsUsedByInnerClass( FlowGraph graph, ClassBody cb, Set localsUsed, DataFlowItem dfIn, DataFlowItem dfOut) throws SemanticException { for (Iterator iter = localsUsed.iterator(); iter.hasNext(); ) { LocalInstance li = (LocalInstance) iter.next(); MinMaxInitCount initCount = (MinMaxInitCount) dfOut.initStatus.get(li); if (!currCBI.localDeclarations.contains(li)) { // the local wasn't defined in this scope. currCBI.outerLocalsUsed.add(li); } else if (initCount == null || InitCount.ZERO.equals(initCount.getMin())) { // initCount will in general not be null, as the local variable // li is declared in the current class; however, if the inner // class is declared in the initializer of the local variable // declaration, then initCount could in fact be null, as we // leave the inner class before we have performed flowLocalDecl // for the local variable declaration. throw new SemanticException( "Local variable \"" + li.name() + "\" must be initialized before the class " + "declaration.", cb.position()); } } }