Get a thread local DocumentBuilderFactory.
<p>
DocumentBuilderFactory is NOT thread safe. This method uses a thread
local to create one per calling thread.

@return The instance for this thread.
546723
static DocumentBuilderFactory getDBF() {
        DocumentBuilderFactory dbf = threadDBF.get();
        if (dbf == null) {
            dbf = DocumentBuilderFactory.newInstance();
            dbf.setNamespaceAware(true);
            threadDBF.set(dbf);
        }
        return dbf;
    }
1109160
protected DocumentBuilder getDocumentBuilder() throws ServletException {
        DocumentBuilder documentBuilder = null;
        DocumentBuilderFactory documentBuilderFactory = null;
        try {
            documentBuilderFactory = DocumentBuilderFactory.newInstance();
            documentBuilderFactory.setNamespaceAware(true);
            documentBuilder = documentBuilderFactory.newDocumentBuilder();
        } catch (ParserConfigurationException e) {
            throw new ServletException("jaxp failed");
        }
        return documentBuilder;
    }
1161207
@Nullable
    public static ThreadFactory getDisableInheritableThreadFactory(@Nullable ThreadFactory threadFactory) {
        if (threadFactory == null || isDisableInheritableThreadFactory(threadFactory)) return threadFactory;

        return new DisableInheritableThreadFactoryWrapper(threadFactory);
    }
135688
Document getResourceAsDoc(String resource) throws Exception {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        InputStream is = cl.getResourceAsStream(resource);
        if (is != null) {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            dbf.setNamespaceAware(true);
            // Fortify Mod: prevent external entity injection
            dbf.setExpandEntityReferences(false);
            DocumentBuilder db = dbf.newDocumentBuilder();
            // Fortify Mod: prevent external entity injection 
            TransformerFactory tf = TransformerFactory.newInstance();
            tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
            Transformer t = tf.newTransformer();
            //Transformer t = TransformerFactory.newInstance().newTransformer();
	       // End Fortify Mod
            Document doc = db.newDocument();
            t.transform(new StreamSource(is), new DOMResult(doc));
            // Fortify Mod: Close the InputStream and release its resources
            is.close();
            return doc;
        } else {
            return null;
        }
    }
834255
public static DocumentBuilder newDocumentBuilder() {
        try {
            return PARSER_FACTORY.newDocumentBuilder();
        } catch (ParserConfigurationException e) {
            throw (Error) new AssertionError().initCause(e);
        }
    }
1126321
public static DocumentBuilder getXmlParser() {
    DocumentBuilder db = null;
    try {
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      dbf.setValidating(false);

      //Disable DTD loading and validation
      //See http://stackoverflow.com/questions/155101/make-documentbuilder-parse-ignore-dtd-references
      dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
      dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);

      db = dbf.newDocumentBuilder();
      db.setErrorHandler(new SAXErrorHandler());

    } catch (ParserConfigurationException e) {
      System.err.printf("%s: Unable to create XML parser\n", XMLUtils.class.getName());
      e.printStackTrace();

    } catch(UnsupportedOperationException e) {
      System.err.printf("%s: API error while setting up XML parser. Check your JAXP version\n", XMLUtils.class.getName());
      e.printStackTrace();
    }

    return db;
  }
4793
@Nonnull
  public static DocumentBuilderFactory createDefaultDocumentBuilderFactory ()
  {
    final DocumentBuilderFactory aDocumentBuilderFactory = DocumentBuilderFactory.newInstance ();
    aDocumentBuilderFactory.setNamespaceAware (DEFAULT_DOM_NAMESPACE_AWARE);
    aDocumentBuilderFactory.setValidating (DEFAULT_DOM_VALIDATING);
    aDocumentBuilderFactory.setIgnoringElementContentWhitespace (DEFAULT_DOM_IGNORING_ELEMENT_CONTENT_WHITESPACE);
    aDocumentBuilderFactory.setExpandEntityReferences (DEFAULT_DOM_EXPAND_ENTITY_REFERENCES);
    aDocumentBuilderFactory.setIgnoringComments (DEFAULT_DOM_IGNORING_COMMENTS);
    aDocumentBuilderFactory.setCoalescing (DEFAULT_DOM_COALESCING);
    try
    {
      // Set secure processing to be the default. This is anyway the default in
      // JDK8
      aDocumentBuilderFactory.setFeature (EXMLParserFeature.SECURE_PROCESSING.getName (), true);
    }
    catch (final ParserConfigurationException ex1)
    {
      // Ignore
    }
    try
    {
      aDocumentBuilderFactory.setXIncludeAware (DEFAULT_DOM_XINCLUDE_AWARE);
    }
    catch (final UnsupportedOperationException ex)
    {
      // Ignore
    }
    return aDocumentBuilderFactory;
  }
963266
public DocumentReaderAndWriter<IN> makeReaderAndWriter() {
    DocumentReaderAndWriter<IN> readerAndWriter;
    try {
      readerAndWriter = ((DocumentReaderAndWriter<IN>)
                         Class.forName(flags.readerAndWriter).newInstance());
    } catch (Exception e) {
      throw new RuntimeException(String.format("Error loading flags.readerAndWriter: '%s'", flags.readerAndWriter), e);
    }
    readerAndWriter.init(flags);
    return readerAndWriter;
  }
1002699
public static ExecutorService newSingleThreadDaemonExecutor() {
        return Executors.newSingleThreadExecutor(r -> {
            Thread t = Executors.defaultThreadFactory().newThread(r);
            t.setDaemon(true);
            return t;
        });
    }
1165227
public FragmentBuilder getFragmentBuilder() {
        FragmentBuilder builder = builders.get();

        if (builder == null) {
            if (log.isLoggable(Level.FINEST)) {
                log.finest("Creating new FragmentBuilder");
            }
            builder = new FragmentBuilder();
            builders.set(builder);

            int currentCount = threadCounter.incrementAndGet();
            int builderCount = builder.incrementThreadCount();

            if (log.isLoggable(Level.FINEST)) {
                log.finest("Associate Thread with FragmentBuilder(1): Total Thread Count = " + currentCount
                        + " : Fragment Thread Count = " + builderCount);
                synchronized (threadNames) {
                    threadNames.add(Thread.currentThread().getName());
                }
            }
        }

        return builder;
    }
382787
public AbstractBuilder getMethodBuilder(ClassWriter classWriter) {
        return MethodBuilder.getInstance(context, classWriter.getTypeElement(),
            writerFactory.getMethodWriter(classWriter));
    }
1184955
public static Map<String, Object> get() {
		Map<String, Object> map = JKThreadLocal.thread.get();
		if (map == null) {
			map = new LinkedHashMap<String, Object>();
			JKThreadLocal.set(map);
		}
		return map;
	}
1013946
protected Dispatchable getThreadContext()
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "getThreadContext");
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "getThreadContext");

      return null;
   }
674497
static synchronized DocFileFactory getFactory(Configuration configuration) {
        DocFileFactory f = factories.get(configuration);
        if (f == null) {
            JavaFileManager fm = configuration.getFileManager();
            if (fm instanceof StandardJavaFileManager) {
                f = new StandardDocFileFactory(configuration);
            } else {
                throw new IllegalStateException();
            }
            factories.put(configuration, f);
        }
        return f;
    }
468341
public static MemberSummaryBuilder getInstance(
            ClassWriter classWriter, Context context)
            throws Exception {
        MemberSummaryBuilder builder = new MemberSummaryBuilder(context,
                classWriter.getClassDoc());
        builder.memberSummaryWriters =
                new MemberSummaryWriter[VisibleMemberMap.NUM_MEMBER_TYPES];
        WriterFactory wf = context.configuration.getWriterFactory();
        for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
                builder.memberSummaryWriters[i] =
                    builder.visibleMemberMaps[i].noVisibleMembers() ?
                        null :
                        wf.getMemberSummaryWriter(classWriter, i);
        }
        return builder;
    }
746307
public static CollectionFactoryManager getInstance() {

    if (instance == null) {
      synchronized (CollectionFactoryManagerImpl.class) {
        if (instance == null) {
          CollectionFactoryManagerImpl manager = new CollectionFactoryManagerImpl();
          manager.initialize();
          instance = manager;
        }
      }
    }
    return instance;
  }
91868
public static <K, V> ThreadLocalLoadingCache<K, V> create(CacheLoader<K, V> cacheLoader) {
        return new DefaultThreadLocalLoadingCache<K, V>(checkNotNull(cacheLoader));
    }