Java 类java.util.IdentityHashMap 实例源码

项目:incubator-servicecomb-java-chassis    文件:OperationInstancesDiscoveryFilter.java   
protected Map<MicroserviceVersionMeta, Map<String, MicroserviceInstance>> groupByVersion(Invocation invocation,
    Map<String, MicroserviceInstance> instances) {
  OperationMeta latestOperationMeta = invocation.getOperationMeta();
  MicroserviceMeta latestMicroserviceMeta = latestOperationMeta.getSchemaMeta().getMicroserviceMeta();
  AppManager appManager = RegistryUtils.getServiceRegistry().getAppManager();
  MicroserviceVersions MicroserviceVersions =
      appManager.getOrCreateMicroserviceVersions(latestMicroserviceMeta.getAppId(), latestMicroserviceMeta.getName());

  Map<MicroserviceVersionMeta, Map<String, MicroserviceInstance>> versionMap = new IdentityHashMap<>();
  for (MicroserviceInstance instance : instances.values()) {
    MicroserviceVersionMeta versionMeta = MicroserviceVersions.getVersion(instance.getServiceId());
    Map<String, MicroserviceInstance> versionInstances = versionMap.computeIfAbsent(versionMeta, vm -> {
      return new HashMap<>();
    });
    versionInstances.put(instance.getInstanceId(), instance);
  }
  return versionMap;
}
项目:wherehowsX    文件:MockSchemaRegistryClient.java   
@Override
public synchronized String register(String subject, Schema schema)
    throws IOException, RestClientException {
  Map<Schema, String> schemaIdMap;
  if (schemaCache.containsKey(subject)) {
    schemaIdMap = schemaCache.get(subject);
  } else {
    schemaIdMap = new IdentityHashMap<Schema, String>();
    schemaCache.put(subject, schemaIdMap);
  }

  if (schemaIdMap.containsKey(schema)) {
    return schemaIdMap.get(schema);
  } else {
    String id = getIdFromRegistry(subject, schema);
    schemaIdMap.put(schema, id);
    idCache.get(null).put(id, schema);
    return id;
  }
}
项目:wherehowsX    文件:CachedSchemaRegistryClient.java   
@Override
public synchronized String register(String subject, Schema schema)
    throws IOException, RestClientException {
  Map<Schema, String> schemaIdMap;
  if (schemaCache.containsKey(subject)) {
    schemaIdMap = schemaCache.get(subject);
  } else {
    schemaIdMap = new IdentityHashMap<Schema, String>();
    schemaCache.put(subject, schemaIdMap);
  }

  if (schemaIdMap.containsKey(schema)) {
    return schemaIdMap.get(schema);
  } else {
    if (schemaIdMap.size() >= identityMapCapacity) {
      throw new IllegalStateException("Too many schema objects created for " + subject + "!");
    }
    String id = registerAndGetId(subject, schema);
    schemaIdMap.put(schema, id);
    idCache.get(null).put(id, schema);
    return id;
  }
}
项目:wherehowsX    文件:CachedSchemaRegistryClient.java   
@Override
public synchronized int getVersion(String subject, Schema schema)
    throws IOException, RestClientException{
  Map<Schema, Integer> schemaVersionMap;
  if (versionCache.containsKey(subject)) {
    schemaVersionMap = versionCache.get(subject);
  } else {
    schemaVersionMap = new IdentityHashMap<Schema, Integer>();
    versionCache.put(subject, schemaVersionMap);
  }

  if (schemaVersionMap.containsKey(schema)) {
    return schemaVersionMap.get(schema);
  }  else {
    if (schemaVersionMap.size() >= identityMapCapacity) {
      throw new IllegalStateException("Too many schema objects created for " + subject + "!");
    }
    int version = getVersionFromRegistry(subject, schema);
    schemaVersionMap.put(schema, version);
    return version;
  }
}
项目:incubator-netbeans    文件:CloneableEditorSupportRedirector.java   
static CloneableEditorSupport findRedirect(CloneableEditorSupport one, boolean check) {
    Map<Lookup,CloneableEditorSupport> all = CHECKED.get();
    if (all == null) {
        all = new IdentityHashMap<Lookup, CloneableEditorSupport>();
        CHECKED.set(all);
    }
    final Lookup lkp = one.getLookup();
    try {
        if (check && all.containsKey(lkp)) {
            return null;
        }
        all.put(lkp, one);
        for (CloneableEditorSupportRedirector r : Lookup.getDefault().lookupAll(CloneableEditorSupportRedirector.class)) {
            CloneableEditorSupport ces = r.redirect(lkp);
            if (ces != null && ces != one) {
                return ces;
            }
        }
        return null;
    } finally {
        all.remove(lkp);
    }
}
项目:incubator-netbeans    文件:BatchUtilities.java   
public static Map<ClasspathInfo, Collection<FileObject>> sortFiles(Collection<? extends FileObject> from) {
    Map<CPCategorizer, Collection<FileObject>> m = new HashMap<CPCategorizer, Collection<FileObject>>();

    for (FileObject f : from) {
        CPCategorizer cpCategorizer = new CPCategorizer(f);

        Collection<FileObject> files = m.get(cpCategorizer);

        if (files == null) {
            m.put(cpCategorizer, files = new LinkedList<FileObject>());
        }

        files.add(f);
    }

    Map<ClasspathInfo, Collection<FileObject>> result = new IdentityHashMap<ClasspathInfo, Collection<FileObject>>();

    for (Entry<CPCategorizer, Collection<FileObject>> e : m.entrySet()) {
        result.put(ClasspathInfo.create(e.getKey().boot, e.getKey().compile, e.getKey().source), e.getValue());
    }

    return result;
}
项目:OperatieBRP    文件:OnderzoekMapperImpl.java   
private static Map<Onderzoek, Lo3Onderzoek> vulOnderzoeken(final Collection<Onderzoek> onderzoeken) {
    final Map<Onderzoek, Lo3Onderzoek> resultaat = new IdentityHashMap<>();

    for (final Onderzoek onderzoek : onderzoeken) {

        final OnderzoekStandaardRecord onderzoekActueel = bepaalLaatsteRecord(onderzoek.getStandaard());
        Assert.notNull(onderzoekActueel, "Geen actueel record voor onderzoek gevonden.");
        if (onderzoekActueel != null) {
            final String lo3GegevensInOnderzoek = bepaalGegevensInOnderzoek(onderzoekActueel);
            final Lo3Datum datumIngangOnderzoek = new BrpDatum(onderzoekActueel.getDatumAanvang(), null).converteerNaarLo3Datum();

            final boolean isOnderzoekBeindigd = StatusOnderzoek.AFGESLOTEN.getNaam().equals(onderzoekActueel.getStatus());
            final Lo3Datum datumEindeOnderzoek = isOnderzoekBeindigd ? new BrpDatum(onderzoekActueel.getDatumEinde(), null).converteerNaarLo3Datum() : null;

            final Lo3Onderzoek lo3Onderzoek = new Lo3Onderzoek(new Lo3Integer(lo3GegevensInOnderzoek, null), datumIngangOnderzoek, datumEindeOnderzoek);

            resultaat.put(onderzoek, lo3Onderzoek);
        }
    }
    return resultaat;
}
项目:incubator-netbeans    文件:Flow.java   
private void computeDataFlow() {
    Map<Tree, Collection<Tree>> res = new IdentityHashMap<Tree, Collection<Tree>>(7);
    for (Map.Entry<Tree, Iterable<? extends TreePath>> e : assignmentsForUse.entrySet()) {
        Tree k = e.getKey();
        for (TreePath p : e.getValue()) {
            if (p == null) {
                continue;
            }
            Tree l = p.getLeaf();
            Collection<Tree> users = res.get(l);
            if (users == null) {
                users = new ArrayList<Tree>(2);
                res.put(l, users);
            }
            users.add(k);
        }
    }
    dataFlow = res;
}
项目:JavaGraph    文件:IdentityHashMapTest.java   
@Test
public void testIdentityHashMap() {
    for (int i = 0; i < 100000; i++) {
        Map<Integer,String> test = new IdentityHashMap<>();
        for (int k = 0; k < 7; k++) {
            test.put(new Integer(k), "");
        }
        Iterator<Integer> testIter = test.keySet().iterator();
        while (testIter.hasNext()) {
            Integer elem = testIter.next();
            if (elem.intValue() != 6) {
                testIter.remove();
            }
        }
        assertEquals(1, test.keySet().size());
        assertEquals(Collections.singleton(new Integer(6)), test.keySet());
    }
}
项目:jdk8u-jdk    文件:DistinctEntrySetElements.java   
public static void main(String[] args) throws Exception {
    final IdentityHashMap<String, String> identityHashMap =
        new IdentityHashMap<>();

    identityHashMap.put("One", "Un");
    identityHashMap.put("Two", "Deux");
    identityHashMap.put("Three", "Trois");

    Set<Map.Entry<String, String>> entrySet = identityHashMap.entrySet();
    HashSet<Map.Entry<String, String>> hashSet = new HashSet<>(entrySet);

    // NB: These comparisons are valid in this case because none of the
    //     keys put into 'identityHashMap' above are equal to any other.
    if (false == hashSet.equals(entrySet)) {
        throw new RuntimeException("Test FAILED: Sets are not equal.");
    }
    if (hashSet.hashCode() != entrySet.hashCode()) {
        throw new RuntimeException("Test FAILED: Set's hashcodes are not equal.");
    }
}
项目:openjdk-jdk10    文件:EntrySetIteratorRemoveInvalidatesEntry.java   
public static void main(String[] args) throws Exception {
    final IdentityHashMap<String, String> identityHashMap =
        new IdentityHashMap<>();

    identityHashMap.put("One", "Un");
    identityHashMap.put("Two", "Deux");
    identityHashMap.put("Three", "Trois");

    Iterator<Map.Entry<String, String>> entrySetIterator =
        identityHashMap.entrySet().iterator();
    Map.Entry<String, String> entry = entrySetIterator.next();

    entrySetIterator.remove();

    try {
        entry.getKey();
        throw new RuntimeException("Test FAILED: Entry not invalidated by removal.");
    } catch (Exception e) { }
}
项目:jsf-sdk    文件:PojoUtils.java   
@SuppressWarnings("unchecked")
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    if (method.getDeclaringClass() == Object.class) {
        return method.invoke(map, args);
    }
    String methodName = method.getName();
    Object value = null;
    if (methodName.length() > 3 && methodName.startsWith("get")) {
        value = map.get(methodName.substring(3, 4).toLowerCase() + methodName.substring(4));
    } else if (methodName.length() > 2 && methodName.startsWith("is")) {
        value = map.get(methodName.substring(2, 3).toLowerCase() + methodName.substring(3));
    } else {
        value = map.get(methodName.substring(0, 1).toLowerCase() + methodName.substring(1));
    }
    if (value instanceof Map<?,?> && ! Map.class.isAssignableFrom(method.getReturnType())) {
        value = realize0((Map<String, Object>) value, method.getReturnType(), null, new IdentityHashMap<Object, Object>());
    }
    return value;
}
项目:cryptotrader    文件:TemplateAgentTest.java   
@Test
public void testReconcile() throws Exception {

    Map<Instruction, String> values = new IdentityHashMap<>();
    values.put(CreateInstruction.builder().build(), "i1");
    values.put(CancelInstruction.builder().build(), "i2");
    values.put(null, "i3");
    values.put(CancelInstruction.builder().build(), null);
    Request request = Request.builder().build();
    doReturn(TRUE).when(target).checkCreated(same(context), any(), eq("i1"), any(), any());
    doReturn(TRUE).when(target).checkCancelled(same(context), any(), eq("i2"), any(), any());

    Map<Instruction, Boolean> results = target.reconcile(context, request, values);
    assertEquals(results.size(), 2);
    results.values().forEach(Assert::assertTrue);
    verify(target).checkCreated(same(context), any(), eq("i1"), any(), any());
    verify(target).checkCancelled(same(context), any(), eq("i2"), any(), any());

    // No input
    assertEquals(target.reconcile(context, request, null).size(), 0);

}
项目:openjdk-jdk10    文件:MapWithCollisionsProviders.java   
private static <T> Collection<Object[]> makeMapsMoreTypes(String desc,
                                                          T[] keys,
                                                          T val) {
    Collection<Object[]> cases = new ArrayList<>();
    cases.add(createCase("Hashtable with " + desc,
                         new Hashtable<>(), keys, val));
    cases.add(createCase("IdentityHashMap with " + desc,
                         new IdentityHashMap<>(), keys, val));
    cases.add(createCase("TreeMap with " + desc,
                         new TreeMap<>(), keys, val));
    cases.add(createCase("WeakHashMap with " + desc,
                         new WeakHashMap<>(), keys, val));
    cases.add(createCase("ConcurrentHashMap with " + desc,
                         new ConcurrentHashMap<>(), keys, val));
    cases.add(createCase("ConcurrentSkipListMap with " + desc,
                         new ConcurrentSkipListMap<>(), keys, val));
    return cases;
}
项目:dooo    文件:AbstractRedisService.java   
/**
 * 获取单例
 *
 * @param redisPropertiesFilename
 * @param tClass
 * @param <T>
 * @return
 */
public static <T extends AbstractRedisService> T getRedisService(String redisPropertiesFilename, Class<T> tClass) {
    IdentityHashMap<Class, ? extends AbstractRedisService> redisServices = INSTANCES.get(redisPropertiesFilename);
    if (redisServices != null) {
        return (T) redisServices.get(tClass);
    }
    IdentityHashMap<Class, AbstractRedisService> newRedisServices = new IdentityHashMap<>();
    RedisConfig redisConfig = getRedisConfig(redisPropertiesFilename);
    newRedisServices.put(AppInfoCacheServiceAbstract.class, new AppInfoCacheServiceAbstract(redisConfig));
    newRedisServices.put(InterfaceInfoCacheServiceAbstract.class, new InterfaceInfoCacheServiceAbstract(redisConfig));
    newRedisServices.put(TokenInfoCacheServiceAbstract.class, new TokenInfoCacheServiceAbstract(redisConfig));
    newRedisServices.put(FrequencyCacheServiceAbstract.class, new FrequencyCacheServiceAbstract(redisConfig));
    newRedisServices.put(StatisticsCacheServiceAbstract.class, new StatisticsCacheServiceAbstract(redisConfig));
    newRedisServices.put(VerificationCodeServiceAbstract.class, new VerificationCodeServiceAbstract(redisConfig));
    newRedisServices.put(AuthCodeCacheServiceAbstract.class, new AuthCodeCacheServiceAbstract(redisConfig));
    redisServices = INSTANCES.putIfAbsent(redisPropertiesFilename, newRedisServices);
    if (redisServices == null) {
        redisServices = newRedisServices;
    }
    return (T) redisServices.get(tClass);
}
项目:lams    文件:LoadContexts.java   
/**
 * Currently unused
 *
 * @param resultSet The result set
 *
 * @return The entity load context
 */
@SuppressWarnings( {"UnusedDeclaration"})
public EntityLoadContext getEntityLoadContext(ResultSet resultSet) {
    EntityLoadContext context = null;
    if ( entityLoadContexts == null ) {
        entityLoadContexts = new IdentityHashMap<ResultSet, EntityLoadContext>( 8 );
    }
    else {
        context = entityLoadContexts.get( resultSet );
    }
    if ( context == null ) {
        context = new EntityLoadContext( this, resultSet );
        entityLoadContexts.put( resultSet, context );
    }
    return context;
}
项目:dremio-oss    文件:ConstantExpressionIdentifier.java   
private boolean checkChildren(LogicalExpression e, IdentityHashMap<LogicalExpression, Object> value, boolean transmitsConstant){
  List<LogicalExpression> constants = Lists.newLinkedList();
  boolean constant = true;

  for(LogicalExpression child : e){
    if(child.accept(this, value)){
      constants.add(child);
    }else{
      constant = false;
    }
  }

  // if one or more clauses isn't constant, this isn't constant.  this also isn't a constant if it operates on a set.
  if(!constant || !transmitsConstant){
    for(LogicalExpression c: constants){
      value.put(c, true);
    }
  }
  return constant && transmitsConstant;
}
项目:QDrill    文件:ConstantExpressionIdentifier.java   
/**
 * Get a list of expressions that mark boundaries into a constant space.
 * @param e
 * @return
 */
public static Set<LogicalExpression> getConstantExpressionSet(LogicalExpression e){
  IdentityHashMap<LogicalExpression, Object> map = new IdentityHashMap<>();
  ConstantExpressionIdentifier visitor = new ConstantExpressionIdentifier();


  if(e.accept(visitor, map) && map.isEmpty()){
    // if we receive a constant value here but the map is empty, this means the entire tree is a constant.
    // note, we can't use a singleton collection here because we need an identity set.
    map.put(e, true);
    return map.keySet();
  }else if(map.isEmpty()){
    // so we don't continue to carry around a map, we let it go here and simply return an empty set.
    return Collections.emptySet();
  }else{
    return map.keySet();
  }
}
项目:Equella    文件:InitialiserServiceImpl.java   
private Object processMap(Object parent, Property property, Map<?, ?> mapObj, IdentityHashMap<Object, Object> map,
    Map<Object, Object> evictees, InitialiserCallback callback, List<PropertySet> propsToSet)
{
    Map<Object, Object> newMap = getSupportedMap(mapObj);

    for( Map.Entry<?, ?> entry : mapObj.entrySet() )
    {
        Object newKey = processObject(parent, property, entry.getKey(), null, map, evictees, callback, propsToSet);
        Object newVal = processObject(parent, property, entry.getValue(), null, map, evictees, callback,
            propsToSet);
        newMap.put(newKey, newVal);
    }

    map.put(mapObj, newMap);
    return newMap;
}
项目:guava-mock    文件:AbstractBiMapTest.java   
public void testIdentityEntrySetIteratorRemove() {
  BiMap<Integer, String> bimap = new AbstractBiMap<Integer, String>(
      new IdentityHashMap<Integer, String>(),
      new IdentityHashMap<String, Integer>()) {};
  bimap.put(1, "one");
  bimap.put(2, "two");
  bimap.put(3, "three");
  Iterator<Entry<Integer, String>> iterator = bimap.entrySet().iterator();
  iterator.next();
  iterator.next();
  iterator.remove();
  iterator.next();
  iterator.remove();
  assertEquals(1, bimap.size());
  assertEquals(1, bimap.inverse().size());
}
项目:dubbox-hystrix    文件:JavaBeanSerializeUtil.java   
public static JavaBeanDescriptor serialize(Object obj, JavaBeanAccessor accessor) {
    if (obj == null) {
        return null;
    }
    if (obj instanceof JavaBeanDescriptor) {
        return (JavaBeanDescriptor)obj;
    }
    IdentityHashMap<Object, JavaBeanDescriptor> cache = new IdentityHashMap<Object, JavaBeanDescriptor>();
    JavaBeanDescriptor result = createDescriptorIfAbsent(obj, accessor, cache);
    return result;
}
项目:GitHub    文件:JSONSerializer.java   
public void setContext(SerialContext parent, Object object, Object fieldName, int features, int fieldFeatures) {
    if (out.disableCircularReferenceDetect) {
        return;
    }

    this.context = new SerialContext(parent, object, fieldName, features, fieldFeatures);
    if (references == null) {
        references = new IdentityHashMap<Object, SerialContext>();
    }
    this.references.put(object, context);
}
项目:javaide    文件:ResourceRepository.java   
public synchronized void clear() {
    mCleared = true;
    mFolderMap = new EnumMap<ResourceFolderType, List<ResourceFolder>>(
            ResourceFolderType.class);
    mResourceMap = new EnumMap<ResourceType, Map<String, ResourceItem>>(
            ResourceType.class);

    mReadOnlyListMap =
        new IdentityHashMap<Map<String, ResourceItem>, Collection<ResourceItem>>();
}
项目:Matcher    文件:Matcher.java   
private static <T> void sanitizeMatches(Map<T, T> matches) {
    Set<T> matched = Collections.newSetFromMap(new IdentityHashMap<>(matches.size()));
    Set<T> conflictingMatches = Collections.newSetFromMap(new IdentityHashMap<>());

    for (T cls : matches.values()) {
        if (!matched.add(cls)) {
            conflictingMatches.add(cls);
        }
    }

    if (!conflictingMatches.isEmpty()) {
        matches.values().removeAll(conflictingMatches);
    }
}
项目:wherehowsX    文件:MockSchemaRegistryClient.java   
private void generateVersion(String subject, Schema schema) {
  ArrayList<Integer> versions = getAllVersions(subject);
  Map<Schema, Integer> schemaVersionMap;
  int currentVersion;
  if (versions.isEmpty()) {
    schemaVersionMap = new IdentityHashMap<Schema, Integer>();
    currentVersion = 1;
  } else {
    schemaVersionMap = versionCache.get(subject);
    currentVersion = versions.get(versions.size() - 1) + 1;
  }
  schemaVersionMap.put(schema, currentVersion);
  versionCache.put(subject, schemaVersionMap);
}
项目:cryptotrader    文件:TemplateInstructorTest.java   
@Test
public void testMerge() {

    CreateInstruction new1 = CreateInstruction.builder().price(valueOf(11)).size(valueOf(21)).build();
    CreateInstruction new2 = CreateInstruction.builder().price(valueOf(12)).size(valueOf(22)).build();
    CreateInstruction new3 = CreateInstruction.builder().price(valueOf(13)).size(valueOf(23)).build();
    CreateInstruction new4 = CreateInstruction.builder().price(valueOf(14)).size(valueOf(24)).build();
    CreateInstruction new5 = CreateInstruction.builder().price(valueOf(15)).size(valueOf(25)).build();
    CreateInstruction new6 = CreateInstruction.builder().price(null).size(valueOf(26)).build();
    CreateInstruction new7 = CreateInstruction.builder().price(valueOf(17)).size(null).build();
    CreateInstruction new8 = CreateInstruction.builder().price(valueOf(18)).size(valueOf(0)).build();
    List<CreateInstruction> creates = asList(new4, new8, new2, new7, new3, new6, new5, new1); // Shuffled

    CancelInstruction cancel1 = CancelInstruction.builder().build();
    CancelInstruction cancel2 = CancelInstruction.builder().build();
    CancelInstruction cancel3 = CancelInstruction.builder().build();
    CancelInstruction cancel4 = CancelInstruction.builder().build();
    Map<CancelInstruction, Order> cancels = new IdentityHashMap<>();
    cancels.put(cancel1, mock(Order.class)); // Net
    cancels.put(cancel2, mock(Order.class)); // Cancel - no price
    cancels.put(cancel3, mock(Order.class)); // Cancel - no size
    cancels.put(cancel4, mock(Order.class)); // Net
    when(cancels.get(cancel1).getOrderPrice()).thenReturn(new1.getPrice());
    when(cancels.get(cancel1).getRemainingQuantity()).thenReturn(new1.getSize());
    when(cancels.get(cancel2).getOrderPrice()).thenReturn(null);
    when(cancels.get(cancel2).getRemainingQuantity()).thenReturn(new2.getSize());
    when(cancels.get(cancel3).getOrderPrice()).thenReturn(new3.getPrice());
    when(cancels.get(cancel3).getRemainingQuantity()).thenReturn(null);
    when(cancels.get(cancel4).getOrderPrice()).thenReturn(new4.getPrice());
    when(cancels.get(cancel4).getRemainingQuantity()).thenReturn(new4.getSize());

    List<Instruction> results = target.merge(creates, cancels);
    assertEquals(results.size(), 5); // cancel(o2, o3) + create(c2, c4, c5)
    assertTrue(results.contains(cancel2));
    assertTrue(results.contains(cancel3));
    assertTrue(results.contains(new2));
    assertTrue(results.contains(new3));
    assertTrue(results.contains(new5));

}
项目:openjdk-jdk10    文件:DebugConfigImpl.java   
@Override
public RuntimeException interceptException(DebugContext debug, Throwable e) {
    if (e instanceof BailoutException && !DebugOptions.InterceptBailout.getValue(options)) {
        return null;
    }

    OptionValues interceptOptions = new OptionValues(options,
                    DebugOptions.Count, null,
                    DebugOptions.Time, null,
                    DebugOptions.TrackMemUse, null,
                    DebugOptions.Verify, null,
                    DebugOptions.Dump, ":" + BASIC_LEVEL,
                    DebugOptions.Log, ":" + BASIC_LEVEL);
    DebugConfigImpl config = new DebugConfigImpl(interceptOptions, output, dumpHandlers, verifyHandlers);
    ScopeImpl scope = debug.currentScope;
    scope.updateFlags(config);
    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        e.printStackTrace(new PrintStream(baos));
        debug.log("Exception raised in scope %s: %s", debug.getCurrentScopeName(), baos);
        Map<Object, Object> firstSeen = new IdentityHashMap<>();
        for (Object o : debug.context()) {
            // Only dump a context object once.
            if (!firstSeen.containsKey(o)) {
                firstSeen.put(o, o);
                if (DebugOptions.DumpOnError.getValue(options) || DebugOptions.Dump.getValue(options) != null) {
                    debug.dump(DebugContext.BASIC_LEVEL, o, "Exception: %s", e);
                } else {
                    debug.log("Context obj %s", o);
                }
            }
        }
    } finally {
        scope.updateFlags(this);
    }
    return null;
}
项目:incubator-netbeans    文件:NbTestCase.java   
private static String findRefsFromRoot(final Object target, final Set<?> rootsHint) throws Exception {
        int count = Integer.getInteger("assertgc.paths", 1);
        StringBuilder sb = new StringBuilder();
        final Map<Object,Void> skip = new IdentityHashMap<Object,Void>();

        org.netbeans.insane.scanner.Filter knownPath = new org.netbeans.insane.scanner.Filter() {
            public @Override boolean accept(Object obj, Object referredFrom, Field reference) {
                return !skip.containsKey(obj);
}
        };

        while (count-- > 0) {
            @SuppressWarnings("unchecked")
            Map<Object,Path> m = LiveReferences.fromRoots(Collections.singleton(target), (Set<Object>)rootsHint, null, knownPath);
            Path p = m.get(target);
            if (p == null) {
                break;
            }
            if (sb.length() > 0) {
                sb.append("\n\n");
            }
            sb.append(p);
            for (; p != null; p=p.nextNode()) {
                Object o = p.getObject();
                if (o != target) {
                    skip.put(o, null);
                }
            }
        }
        return sb.length() > 0 ? sb.toString() : "Not found!!!";
    }
项目:monarch    文件:TXState.java   
private void lockTXRegions(IdentityHashMap<LocalRegion, TXRegionState> regions) {
  Iterator<Map.Entry<LocalRegion, TXRegionState>> it = regions.entrySet().iterator();
  while (it.hasNext()) {
    Map.Entry<LocalRegion, TXRegionState> me = it.next();
    LocalRegion r = me.getKey();
    r.getRegionMap().lockRegionForAtomicTX(r);
  }
}
项目:incubator-netbeans    文件:ProjectHooks.java   
@Override
public void classPathsChange(AbstractClassPathProvider.ClassPathsChangeEvent event) {
    final Map<String,Set<ClassPath>> snapshot = new HashMap<>();
    for (String cpType : event.getChangedClassPathTypes()) {
        if (classPathTypes.contains(cpType)) {
            final ClassPath[] cps = cpProvider.getProjectClassPaths(cpType);
            final Set<ClassPath> newCps = Collections.newSetFromMap(new IdentityHashMap<>());
            Collections.addAll(newCps, cps);
            snapshot.put(cpType, newCps);
        }
    }
    if (!snapshot.isEmpty()) {
        updateClassPathCache(snapshot);
    }
}
项目:openjdk-jdk10    文件:OverloadedDynamicMethod.java   
private static Set<Class<?>> createPrimitiveWrapperTypes() {
    final Map<Class<?>, Class<?>> classes = new IdentityHashMap<>();
    addClassHierarchy(classes, Boolean.class);
    addClassHierarchy(classes, Byte.class);
    addClassHierarchy(classes, Character.class);
    addClassHierarchy(classes, Short.class);
    addClassHierarchy(classes, Integer.class);
    addClassHierarchy(classes, Long.class);
    addClassHierarchy(classes, Float.class);
    addClassHierarchy(classes, Double.class);
    return classes.keySet();
}
项目:myfaces-trinidad    文件:UIXTableTemplate.java   
/**
 * Reset the cache of child components used in getContainerClientId
 */
private void _resetContainerClientIdCache()
{
  if(_containerClientIdCache == null)
    _containerClientIdCache = new IdentityHashMap<UIComponent, Boolean>();
  else
    _containerClientIdCache.clear();

  TableUtils.cacheHeaderFooterFacets(this, _containerClientIdCache);
  TableUtils.cacheColumnHeaderFooterFacets(this, _containerClientIdCache);
}
项目:jdk8u-jdk    文件:Capacity.java   
/**
 * Checks that inserting (threshold+1) item causes resizing
 * of the internal storage
 */
@Test(dataProvider = "sizes")
public void passingThresholdCausesResize(int size) throws Throwable {
    final int threshold = threshold(size);
    IdentityHashMap<Object,Object> m = new IdentityHashMap<>(threshold);
    int initialCapacity = capacity(m);

    growUsingPut(m, threshold);
    assertCapacity(m, initialCapacity);

    growUsingPut(m, 1);
    assertCapacity(m, 2 * initialCapacity);
}
项目:Equella    文件:InitialiserServiceImpl.java   
@Override
public void initialiseClones(Object object)
{
    IdentityHashMap<Object, Object> map = new IdentityHashMap<Object, Object>();
    Map<Object, Object> evictees = new IdentityHashMap<Object, Object>();
    initialiseClones(object, map, evictees, null, null);
    evictFromSession(evictees.keySet());
}
项目:OpenJSharp    文件:TypeUtilities.java   
private static <K, V> Map<V, K> invertMap(final Map<K, V> map) {
    final Map<V, K> inverted = new IdentityHashMap<>(map.size());
    for(final Map.Entry<K, V> entry: map.entrySet()) {
        inverted.put(entry.getValue(), entry.getKey());
    }
    return Collections.unmodifiableMap(inverted);
}
项目:incubator-netbeans    文件:EmbeddedIndexerTest.java   
private void globalPathRegistry_register(String id, ClassPath... classpaths) {
    Map<ClassPath,Void> map = registeredClasspaths.get(id);
    if (map == null) {
        map = new IdentityHashMap<ClassPath, Void>();
        registeredClasspaths.put(id, map);
    }
    for (ClassPath cp :  classpaths) {
        map.put(cp,null);
    }
    GlobalPathRegistry.getDefault().register(id, classpaths);
}
项目:incubator-netbeans    文件:ProxyLookup.java   
private Set<Lookup> identityHashSet(Collection<Lookup> current) {
    Map<Lookup,Void> map = new IdentityHashMap<Lookup, Void>();
    for (Lookup lookup : current) {
        map.put(lookup, null);
    }
    return map.keySet();
}
项目:dubbocloud    文件:JavaBeanSerializeUtil.java   
public static Object deserialize(JavaBeanDescriptor beanDescriptor, ClassLoader loader) {
    if (beanDescriptor == null) {
        return null;
    }
    IdentityHashMap<JavaBeanDescriptor, Object> cache = new IdentityHashMap<JavaBeanDescriptor, Object>();
    Object result = instantiateForDeserialize(beanDescriptor, loader, cache);
    deserializeInternal(result, beanDescriptor, loader, cache);
    return result;
}
项目:incubator-netbeans    文件:QuerySupportTest.java   
private void globalPathRegistry_register(String id, ClassPath [] classpaths) {
    Set<ClassPath> set = registeredClasspaths.get(id);
    if (set == null) {
        set = Collections.newSetFromMap(new IdentityHashMap<ClassPath, Boolean>());
        registeredClasspaths.put(id, set);
    }
    for (ClassPath cp :  classpaths) {
        set.add(cp);
    }
    GlobalPathRegistry.getDefault().register(id, classpaths);
}
项目:incubator-netbeans    文件:IndexerOrderingTest.java   
private void globalPathRegistry_register(String id, ClassPath [] classpaths) {
    Map<ClassPath,Void> map = registeredClasspaths.get(id);
    if (map == null) {
        map = new IdentityHashMap<ClassPath, Void>();
        registeredClasspaths.put(id, map);
    }
    for (ClassPath cp :  classpaths) {
        map.put(cp,null);
    }
    GlobalPathRegistry.getDefault().register(id, classpaths);
}