/** Check that the local variable <code>l</code> is used correctly. */ protected void checkLocal(FlowGraph graph, Local l, DataFlowItem dfIn, DataFlowItem dfOut) throws SemanticException { if (!currCBI.localDeclarations.contains(l.localInstance())) { // it's a local variable that has not been declared within // this scope. The only way this can arise is from an // inner class that is not a member of a class (typically // a local class, or an anonymous class declared in a method, // constructor or initializer). // We need to check that it is a final local, and also // keep track of it, to ensure that it has been definitely // assigned at this point. currCBI.outerLocalsUsed.add(l.localInstance()); } else { MinMaxInitCount initCount = (MinMaxInitCount) dfIn.initStatus.get(l.localInstance()); if (initCount != null && InitCount.ZERO.equals(initCount.getMin())) { // the local variable may not have been initialized. // However, we only want to complain if the local is reachable if (l.reachable()) { throw new SemanticException( "Local variable \"" + l.name() + "\" may not have been initialized", l.position()); } } } }