langtools/src/share/classes/com/sun/tools/javac/util/Context.java
author briangoetz
Wed, 18 Dec 2013 10:29:25 -0500
changeset 22159 682da512ec17
parent 14259 fb94a1df0d53
child 22163 3651128c74eb
permissions -rw-r--r--
8030253: Update langtools to use strings-in-switch 8030262: Update langtools to use foreach loops 8030245: Update langtools to use try-with-resources and multi-catch Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
13844
56339cf983a3 7177970: fix issues in langtools doc comments
jjg
parents: 8614
diff changeset
     2
 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1789
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1789
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1789
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1789
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1789
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.javac.util;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import java.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
 * Support for an abstract context, modelled loosely after ThreadLocal
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
 * but using a user-provided context instead of the current thread.
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 * <p>Within the compiler, a single Context is used for each
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * invocation of the compiler.  The context is then used to ensure a
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * single copy of each compiler phase exists per compiler invocation.
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * <p>The context can be used to assist in extending the compiler by
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * extending its components.  To do that, the extended component must
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * be registered before the base component.  We break initialization
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * cycles by (1) registering a factory for the component rather than
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * the component itself, and (2) a convention for a pattern of usage
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 * in which each base component registers itself by calling an
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * instance method that is overridden in extended components.  A base
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * phase supporting extension would look something like this:
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 *
14259
fb94a1df0d53 8000208: fix langtools javadoc comment issues
jjg
parents: 13844
diff changeset
    47
 * <p><pre>{@code
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 * public class Phase {
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
 *     protected static final Context.Key<Phase> phaseKey =
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 *         new Context.Key<Phase>();
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
 *     public static Phase instance(Context context) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
 *         Phase instance = context.get(phaseKey);
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
 *         if (instance == null)
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
 *             // the phase has not been overridden
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
 *             instance = new Phase(context);
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
 *         return instance;
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
 *     }
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
 *     protected Phase(Context context) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
 *         context.put(phaseKey, this);
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
 *         // other intitialization follows...
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
 *     }
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
 * }
14259
fb94a1df0d53 8000208: fix langtools javadoc comment issues
jjg
parents: 13844
diff changeset
    65
 * }</pre>
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
 * <p>In the compiler, we simply use Phase.instance(context) to get
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
 * the reference to the phase.  But in extensions of the compiler, we
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
 * must register extensions of the phases to replace the base phase,
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
 * and this must be done before any reference to the phase is accessed
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
 * using Phase.instance().  An extended phase might be declared thus:
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
 *
14259
fb94a1df0d53 8000208: fix langtools javadoc comment issues
jjg
parents: 13844
diff changeset
    73
 * <p><pre>{@code
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
 * public class NewPhase extends Phase {
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
 *     protected NewPhase(Context context) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
 *         super(context);
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
 *     }
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
 *     public static void preRegister(final Context context) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
 *         context.put(phaseKey, new Context.Factory<Phase>() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
 *             public Phase make() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
 *                 return new NewPhase(context);
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
 *             }
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
 *         });
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
 *     }
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
 * }
14259
fb94a1df0d53 8000208: fix langtools javadoc comment issues
jjg
parents: 13844
diff changeset
    86
 * }</pre>
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
 * <p>And is registered early in the extended compiler like this
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
 * <p><pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
 *     NewPhase.preRegister(context);
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
 * </pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
 *
5847
1908176fd6e3 6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents: 5520
diff changeset
    94
 *  <p><b>This is NOT part of any supported API.
1908176fd6e3 6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents: 5520
diff changeset
    95
 *  If you write code that depends on this, you do so at your own risk.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
 *  This code and its internal interfaces are subject to change or
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
 *  deletion without notice.</b>
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
public class Context {
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
    /** The client creates an instance of this class for each key.
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
    public static class Key<T> {
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
        // note: we inherit identity equality from Object.
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
     * The client can register a factory for lazy creation of the
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
     * instance.
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
    public static interface Factory<T> {
8614
06e42328ddab 7021650: fix Context issues
jjg
parents: 8032
diff changeset
   111
        T make(Context c);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
    };
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
     * The underlying map storing the data.
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
     * We maintain the invariant that this table contains only
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
     * mappings of the form
13844
56339cf983a3 7177970: fix issues in langtools doc comments
jjg
parents: 8614
diff changeset
   118
     * {@literal Key<T> -> T }
56339cf983a3 7177970: fix issues in langtools doc comments
jjg
parents: 8614
diff changeset
   119
     * or
56339cf983a3 7177970: fix issues in langtools doc comments
jjg
parents: 8614
diff changeset
   120
     * {@literal Key<T> -> Factory<T> }
56339cf983a3 7177970: fix issues in langtools doc comments
jjg
parents: 8614
diff changeset
   121
     */
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   122
    private Map<Key<?>,Object> ht = new HashMap<Key<?>,Object>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
    /** Set the factory for the key in this context. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
    public <T> void put(Key<T> key, Factory<T> fac) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
        checkState(ht);
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
        Object old = ht.put(key, fac);
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
        if (old != null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
            throw new AssertionError("duplicate context value");
8614
06e42328ddab 7021650: fix Context issues
jjg
parents: 8032
diff changeset
   130
        checkState(ft);
06e42328ddab 7021650: fix Context issues
jjg
parents: 8032
diff changeset
   131
        ft.put(key, fac); // cannot be duplicate if unique in ht
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
    /** Set the value for the key in this context. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
    public <T> void put(Key<T> key, T data) {
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   136
        if (data instanceof Factory<?>)
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
            throw new AssertionError("T extends Context.Factory");
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
        checkState(ht);
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
        Object old = ht.put(key, data);
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   140
        if (old != null && !(old instanceof Factory<?>) && old != data && data != null)
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
            throw new AssertionError("duplicate context value");
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
    /** Get the value for the key in this context. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
    public <T> T get(Key<T> key) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
        checkState(ht);
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
        Object o = ht.get(key);
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   148
        if (o instanceof Factory<?>) {
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   149
            Factory<?> fac = (Factory<?>)o;
8614
06e42328ddab 7021650: fix Context issues
jjg
parents: 8032
diff changeset
   150
            o = fac.make(this);
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   151
            if (o instanceof Factory<?>)
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
                throw new AssertionError("T extends Context.Factory");
8032
e1aa25ccdabb 6396503: javac should not require assertions enabled
jjg
parents: 5847
diff changeset
   153
            Assert.check(ht.get(key) == o);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
        /* The following cast can't fail unless there was
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
         * cheating elsewhere, because of the invariant on ht.
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
         * Since we found a key of type Key<T>, the value must
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
         * be of type T.
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
        return Context.<T>uncheckedCast(o);
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
    public Context() {}
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
8614
06e42328ddab 7021650: fix Context issues
jjg
parents: 8032
diff changeset
   166
    /**
06e42328ddab 7021650: fix Context issues
jjg
parents: 8032
diff changeset
   167
     * The table of preregistered factories.
06e42328ddab 7021650: fix Context issues
jjg
parents: 8032
diff changeset
   168
     */
06e42328ddab 7021650: fix Context issues
jjg
parents: 8032
diff changeset
   169
    private Map<Key<?>,Factory<?>> ft = new HashMap<Key<?>,Factory<?>>();
06e42328ddab 7021650: fix Context issues
jjg
parents: 8032
diff changeset
   170
06e42328ddab 7021650: fix Context issues
jjg
parents: 8032
diff changeset
   171
    public Context(Context prev) {
06e42328ddab 7021650: fix Context issues
jjg
parents: 8032
diff changeset
   172
        kt.putAll(prev.kt);     // retain all implicit keys
06e42328ddab 7021650: fix Context issues
jjg
parents: 8032
diff changeset
   173
        ft.putAll(prev.ft);     // retain all factory objects
06e42328ddab 7021650: fix Context issues
jjg
parents: 8032
diff changeset
   174
        ht.putAll(prev.ft);     // init main table with factories
06e42328ddab 7021650: fix Context issues
jjg
parents: 8032
diff changeset
   175
    }
06e42328ddab 7021650: fix Context issues
jjg
parents: 8032
diff changeset
   176
06e42328ddab 7021650: fix Context issues
jjg
parents: 8032
diff changeset
   177
    /*
06e42328ddab 7021650: fix Context issues
jjg
parents: 8032
diff changeset
   178
     * The key table, providing a unique Key<T> for each Class<T>.
06e42328ddab 7021650: fix Context issues
jjg
parents: 8032
diff changeset
   179
     */
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
    private Map<Class<?>, Key<?>> kt = new HashMap<Class<?>, Key<?>>();
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
    private <T> Key<T> key(Class<T> clss) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
        checkState(kt);
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
        Key<T> k = uncheckedCast(kt.get(clss));
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
        if (k == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
            k = new Key<T>();
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
            kt.put(clss, k);
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
        return k;
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
    public <T> T get(Class<T> clazz) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
        return get(key(clazz));
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
    public <T> void put(Class<T> clazz, T data) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
        put(key(clazz), data);
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
    public <T> void put(Class<T> clazz, Factory<T> fac) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
        put(key(clazz), fac);
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
     * TODO: This method should be removed and Context should be made type safe.
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
     * This can be accomplished by using class literals as type tokens.
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
    @SuppressWarnings("unchecked")
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
    private static <T> T uncheckedCast(Object o) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
        return (T)o;
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
    public void dump() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
        for (Object value : ht.values())
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
            System.err.println(value == null ? null : value.getClass());
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
    public void clear() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
        ht = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
        kt = null;
8614
06e42328ddab 7021650: fix Context issues
jjg
parents: 8032
diff changeset
   220
        ft = null;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
    private static void checkState(Map<?,?> t) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
        if (t == null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
            throw new IllegalStateException();
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
}