langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Context.java
changeset 32454 b0ac04e0fefe
parent 31751 ec251536a004
child 42828 cce89649f958
equal deleted inserted replaced
32453:8eebd1f0b8ea 32454:b0ac04e0fefe
   117      * mappings of the form
   117      * mappings of the form
   118      * {@literal Key<T> -> T }
   118      * {@literal Key<T> -> T }
   119      * or
   119      * or
   120      * {@literal Key<T> -> Factory<T> }
   120      * {@literal Key<T> -> Factory<T> }
   121      */
   121      */
   122     private final Map<Key<?>,Object> ht = new HashMap<>();
   122     protected final Map<Key<?>,Object> ht = new HashMap<>();
   123 
   123 
   124     /** Set the factory for the key in this context. */
   124     /** Set the factory for the key in this context. */
   125     public <T> void put(Key<T> key, Factory<T> fac) {
   125     public <T> void put(Key<T> key, Factory<T> fac) {
   126         checkState(ht);
   126         checkState(ht);
   127         Object old = ht.put(key, fac);
   127         Object old = ht.put(key, fac);
   171     /*
   171     /*
   172      * The key table, providing a unique Key<T> for each Class<T>.
   172      * The key table, providing a unique Key<T> for each Class<T>.
   173      */
   173      */
   174     private final Map<Class<?>, Key<?>> kt = new HashMap<>();
   174     private final Map<Class<?>, Key<?>> kt = new HashMap<>();
   175 
   175 
   176     private <T> Key<T> key(Class<T> clss) {
   176     protected <T> Key<T> key(Class<T> clss) {
   177         checkState(kt);
   177         checkState(kt);
   178         Key<T> k = uncheckedCast(kt.get(clss));
   178         Key<T> k = uncheckedCast(kt.get(clss));
   179         if (k == null) {
   179         if (k == null) {
   180             k = new Key<>();
   180             k = new Key<>();
   181             kt.put(clss, k);
   181             kt.put(clss, k);