code: public void checkInternalState(String msg, boolean linkedOnly, Map<String,Source> srcs) {
          boolean baad = false;
          Map<String,Source> original = new HashMap<String,Source>();
          Map<String,Source> calculated = new HashMap<String,Source>();
  
          for (String s : sources.keySet()) {
              Source ss = sources.get(s);
              if (ss.isLinkedOnly() == linkedOnly) {
                  calculated.put(s,ss);
              }
          }
          for (String s : srcs.keySet()) {
              Source ss = srcs.get(s);
              if (ss.isLinkedOnly() == linkedOnly) {
                  original.put(s,ss);
              }
          }
          if (original.size() != calculated.size()) {
              Log.error("INTERNAL ERROR "+msg+" original and calculated are not the same size!");
              baad = true;
          }
          if (!original.keySet().equals(calculated.keySet())) {
              Log.error("INTERNAL ERROR "+msg+" original and calculated do not have the same domain!");
              baad = true;
          }
          if (!baad) {
              for (String s : original.keySet()) {
                  Source s1 = original.get(s);
                  Source s2 = calculated.get(s);
                  if (s1 == null || s2 == null || !s1.equals(s2)) {
                      Log.error("INTERNAL ERROR "+msg+" original and calculated have differing elements for "+s);
                  }
                  baad = true;
              }
          }
          if (baad) {
              for (String s : original.keySet()) {
                  Source ss = original.get(s);
                  Source sss = calculated.get(s);
                  if (sss == null) {
                      Log.error("The file "+s+" does not exist in calculated tree of sources.");
                  }
              }
              for (String s : calculated.keySet()) {
                  Source ss = calculated.get(s);
                  Source sss = original.get(s);
                  if (sss == null) {
                      Log.error("The file "+s+" does not exist in original set of found sources.");
                  }
              }
          }
      }
docs: Verify that the setModules method above did the right thing when
  running through the module->package->source structure.