code: private <S extends Symbol> S nameToSymbol(ModuleSymbol module, String nameStr, Class<S> clazz) {
          Name name = names.fromString(nameStr);
          // First check cache.
          Symbol sym = (clazz == ClassSymbol.class)
                      ? syms.getClass(module, name)
                      : syms.lookupPackage(module, name);
  
          try {
              if (sym == null)
                  sym = javaCompiler.resolveIdent(module, nameStr);
  
              sym.complete();
  
              return (sym.kind != ERR &&
                      sym.exists() &&
                      clazz.isInstance(sym) &&
                      name.equals(sym.getQualifiedName()))
                  ? clazz.cast(sym)
                  : null;
          } catch (CompletionFailure e) {
              return null;
          }
      }
docs: Returns a symbol given the type's or package's canonical name,
  or null if the name isn't found.