return lookupAndCacheConstant(e);
}
private Constant lookupAndCacheConstant(E e) {
synchronized (modLock) {
Constant c;
// Recheck, in case another thread loaded the table
if (cacheGuard != 0 && (c = cache[e.ordinal()]) != null) {
return c;
}
EnumSet<E> enums = EnumSet.allOf(enumType);
ConstantSet cset = getConstants();
if (cache == null) {
cache = new Constant[enums.size()];
}
long known = 0, unknown = 0;
for (Enum v : enums) {
c = cset.getConstant(v.name());
if (c == null) {
if (bitmask) {
// Flag the value as unknown - real values will be
// inserted once all values are resolved, so there are
// no collisions
unknown |= (1L << v.ordinal());
c = new UnknownConstant(0, v.name());
} else {
c = new UnknownConstant(nextUnknown.getAndAdd(1), v.name());
}
} else if (bitmask) {
known |= c.longValue();
}
cache[v.ordinal()] = c;
}
//