jdk/src/share/classes/javax/swing/text/html/parser/DTD.java
changeset 6862 f66eb6b6a6b9
parent 5506 202f599c92aa
child 24494 67129b9360d2
--- a/jdk/src/share/classes/javax/swing/text/html/parser/DTD.java	Fri Jun 18 13:18:42 2010 +0400
+++ b/jdk/src/share/classes/javax/swing/text/html/parser/DTD.java	Mon Jun 21 16:47:05 2010 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
 
 package javax.swing.text.html.parser;
 
+import sun.awt.AppContext;
+
 import java.io.PrintStream;
 import java.io.File;
 import java.io.FileInputStream;
@@ -314,13 +316,14 @@
     }
 
     /**
-     * The hashtable of DTDs.
+     * The hashtable key of DTDs in AppContext.
      */
-    static Hashtable<String, DTD> dtdHash = new Hashtable<String, DTD>();
+    private static final Object DTD_HASH_KEY = new Object();
 
-  public static void putDTDHash(String name, DTD dtd) {
-    dtdHash.put(name, dtd);
-  }
+    public static void putDTDHash(String name, DTD dtd) {
+        getDtdHash().put(name, dtd);
+    }
+
     /**
      * Returns a DTD with the specified <code>name</code>.  If
      * a DTD with that name doesn't exist, one is created
@@ -332,13 +335,27 @@
      */
     public static DTD getDTD(String name) throws IOException {
         name = name.toLowerCase();
-        DTD dtd = dtdHash.get(name);
+        DTD dtd = getDtdHash().get(name);
         if (dtd == null)
           dtd = new DTD(name);
 
         return dtd;
     }
 
+    private static Hashtable<String, DTD> getDtdHash() {
+        AppContext appContext = AppContext.getAppContext();
+
+        Hashtable<String, DTD> result = (Hashtable<String, DTD>) appContext.get(DTD_HASH_KEY);
+
+        if (result == null) {
+            result = new Hashtable<String, DTD>();
+
+            appContext.put(DTD_HASH_KEY, result);
+        }
+
+        return result;
+    }
+
     /**
      * Recreates a DTD from an archived format.
      * @param in  the <code>DataInputStream</code> to read from