mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
all code in "util" module to create CHM implementation via dedicated factory (see IDEA-116404 Java code compilation does not work with IBM JDK)
This commit is contained in:
@@ -22,7 +22,7 @@ import com.intellij.util.ConcurrencyUtil;
|
||||
import com.intellij.util.ImageLoader;
|
||||
import com.intellij.util.ReflectionUtil;
|
||||
import com.intellij.util.RetinaImage;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ConcurrentMapFactory;
|
||||
import com.intellij.util.containers.WeakHashMap;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -49,7 +49,7 @@ public final class IconLoader {
|
||||
private static boolean USE_DARK_ICONS = UIUtil.isUnderDarcula();
|
||||
|
||||
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
|
||||
private static final ConcurrentMap<URL, CachedImageIcon> ourIconsCache = new ConcurrentHashMap<URL, CachedImageIcon>(100, 0.9f,2);
|
||||
private static final ConcurrentMap<URL, CachedImageIcon> ourIconsCache = ConcurrentMapFactory.DEFAULT_FACTORY.createMap(100, 0.9f, 2);
|
||||
|
||||
/**
|
||||
* This cache contains mapping between icons and disabled icons.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.intellij.util;
|
||||
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ConcurrentMapFactory;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -13,7 +13,7 @@ import java.util.Map;
|
||||
* @author peter
|
||||
*/
|
||||
public class SharedProcessingContext {
|
||||
private final Map<Object, Object> myMap = new ConcurrentHashMap<Object, Object>();
|
||||
private final Map<Object, Object> myMap = ConcurrentMapFactory.DEFAULT_FACTORY.createMap();
|
||||
|
||||
public Object get(@NotNull @NonNls final String key) {
|
||||
return myMap.get(key);
|
||||
|
||||
@@ -20,6 +20,6 @@ package com.intellij.util.containers;
|
||||
*/
|
||||
public class ConcurrentClassMap<T> extends ClassMap<T> {
|
||||
public ConcurrentClassMap() {
|
||||
super(new ConcurrentHashMap<Class,T>());
|
||||
super(ConcurrentMapFactory.DEFAULT_FACTORY.<Class, T>createMap());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package com.intellij.util.containers;
|
||||
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -24,27 +22,8 @@ import java.util.Map;
|
||||
*/
|
||||
public abstract class ConcurrentFactoryMap<T,V> extends FactoryMap<T,V> {
|
||||
|
||||
private interface MapFactory {
|
||||
int DEFAULT_CONCURRENCY_LEVEL = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
MapFactory V8_MAP_FACTORY = new MapFactory() {
|
||||
public <T, V> Map<T, V> createMap() {
|
||||
return new ConcurrentHashMap<T,V>();
|
||||
}
|
||||
};
|
||||
MapFactory DEFAULT_MAP_FACTORY = new MapFactory() {
|
||||
public <T, V> Map<T, V> createMap() {
|
||||
return new java.util.concurrent.ConcurrentHashMap<T,V>(16, 0.75f, DEFAULT_CONCURRENCY_LEVEL);
|
||||
}
|
||||
};
|
||||
|
||||
<T, V> Map<T, V> createMap();
|
||||
}
|
||||
|
||||
private static final MapFactory ourMapFactory = SystemInfo.isOracleJvm || SystemInfo.isAppleJvm? MapFactory.V8_MAP_FACTORY : MapFactory.DEFAULT_MAP_FACTORY;
|
||||
|
||||
@Override
|
||||
protected Map<T, V> createMap() {
|
||||
return ourMapFactory.createMap();
|
||||
return ConcurrentMapFactory.DEFAULT_FACTORY.createMap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,13 +28,13 @@ public class ConcurrentHashSet<K> implements Set<K> {
|
||||
private final ConcurrentMap<K, Boolean> map;
|
||||
|
||||
public ConcurrentHashSet(int initialCapacity) {
|
||||
map = new ConcurrentHashMap<K, Boolean>(initialCapacity);
|
||||
map = ConcurrentMapFactory.DEFAULT_FACTORY.createMap(initialCapacity);
|
||||
}
|
||||
public ConcurrentHashSet() {
|
||||
map = new ConcurrentHashMap<K, Boolean>();
|
||||
map = ConcurrentMapFactory.DEFAULT_FACTORY.createMap();
|
||||
}
|
||||
public ConcurrentHashSet(@NotNull TObjectHashingStrategy<K> hashingStrategy) {
|
||||
map = new ConcurrentHashMap<K, Boolean>(hashingStrategy);
|
||||
map = ConcurrentMapFactory.DEFAULT_FACTORY.createMap(hashingStrategy);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.util.containers;
|
||||
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
public interface ConcurrentMapFactory {
|
||||
int DEFAULT_CONCURRENCY_LEVEL = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
ConcurrentMapFactory V8_MAP_FACTORY = new ConcurrentMapFactory() {
|
||||
public <T, V> ConcurrentMap<T, V> createMap() {
|
||||
return new ConcurrentHashMap<T,V>();
|
||||
}
|
||||
|
||||
public <T, V> ConcurrentMap<T, V> createMap(int initialCapacity) {
|
||||
return new ConcurrentHashMap<T,V>(initialCapacity);
|
||||
}
|
||||
|
||||
public <T, V> ConcurrentMap<T, V> createMap(TObjectHashingStrategy<T> hashStrategy) {
|
||||
return new ConcurrentHashMap<T,V>(hashStrategy);
|
||||
}
|
||||
|
||||
public <T, V> ConcurrentMap<T, V> createMap(int initialCapacity, float loadFactor, int concurrencyLevel) {
|
||||
return new ConcurrentHashMap<T,V>(initialCapacity, loadFactor, concurrencyLevel);
|
||||
}
|
||||
|
||||
public <T, V> ConcurrentMap<T, V> createMap(int initialCapacity, float loadFactor, int concurrencyLevel, @NotNull TObjectHashingStrategy<T> hashingStrategy) {
|
||||
return new ConcurrentHashMap<T,V>(initialCapacity, loadFactor, concurrencyLevel, hashingStrategy);
|
||||
}
|
||||
};
|
||||
|
||||
ConcurrentMapFactory PLATFORM_MAP_FACTORY = new ConcurrentMapFactory() {
|
||||
public <T, V> ConcurrentMap<T, V> createMap() {
|
||||
return createMap(16, 0.75f, DEFAULT_CONCURRENCY_LEVEL);
|
||||
}
|
||||
|
||||
public <T, V> ConcurrentMap<T, V> createMap(int initialCapacity) {
|
||||
return new java.util.concurrent.ConcurrentHashMap<T,V>(initialCapacity);
|
||||
}
|
||||
|
||||
public <T, V> ConcurrentMap<T, V> createMap(TObjectHashingStrategy<T> hashStrategy) {
|
||||
// ignoring strategy parameter, because it is not supported by this implementation
|
||||
return createMap();
|
||||
}
|
||||
|
||||
public <T, V> ConcurrentMap<T, V> createMap(int initialCapacity, float loadFactor, int concurrencyLevel) {
|
||||
return new java.util.concurrent.ConcurrentHashMap<T,V>(initialCapacity, loadFactor, concurrencyLevel);
|
||||
}
|
||||
|
||||
public <T, V> ConcurrentMap<T, V> createMap(int initialCapacity, float loadFactor, int concurrencyLevel, @NotNull TObjectHashingStrategy<T> hashingStrategy) {
|
||||
// ignoring strategy parameter, because it is not supported by this implementation
|
||||
return createMap(initialCapacity, loadFactor, concurrencyLevel);
|
||||
}
|
||||
};
|
||||
|
||||
ConcurrentMapFactory DEFAULT_FACTORY = SystemInfo.isOracleJvm || SystemInfo.isAppleJvm? V8_MAP_FACTORY : PLATFORM_MAP_FACTORY;
|
||||
|
||||
<T, V> ConcurrentMap<T, V> createMap();
|
||||
<T, V> ConcurrentMap<T, V> createMap(int initialCapacity);
|
||||
<T, V> ConcurrentMap<T, V> createMap(TObjectHashingStrategy<T> hashStrategy);
|
||||
<T, V> ConcurrentMap<T, V> createMap(int initialCapacity, float loadFactor, int concurrencyLevel);
|
||||
<T, V> ConcurrentMap<T, V> createMap(int initialCapacity, float loadFactor, int concurrencyLevel, TObjectHashingStrategy<T> hashStrategy);
|
||||
}
|
||||
+1
-1
@@ -28,7 +28,7 @@ public class ConcurrentMostlySingularMultiMap<K, V> extends MostlySingularMultiM
|
||||
@NotNull
|
||||
@Override
|
||||
protected Map<K, Object> createMap() {
|
||||
return new ConcurrentHashMap<K, Object>();
|
||||
return ConcurrentMapFactory.DEFAULT_FACTORY.createMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.Map;
|
||||
public class ConcurrentMultiMap<K,V> extends MultiMap<K,V> {
|
||||
@Override
|
||||
protected Map<K, Collection<V>> createMap() {
|
||||
return new ConcurrentHashMap<K, Collection<V>>();
|
||||
return ConcurrentMapFactory.DEFAULT_FACTORY.createMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -36,7 +36,7 @@ import java.util.concurrent.ConcurrentMap;
|
||||
*/
|
||||
abstract class ConcurrentRefHashMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K, V>, TObjectHashingStrategy<K> {
|
||||
protected final ReferenceQueue<K> myReferenceQueue = new ReferenceQueue<K>();
|
||||
private final ConcurrentHashMap<Key<K, V>, V> myMap; // hashing strategy must be canonical, we compute corresponding hash codes using our own myHashingStrategy
|
||||
private final ConcurrentMap<Key<K, V>, V> myMap; // hashing strategy must be canonical, we compute corresponding hash codes using our own myHashingStrategy
|
||||
@NotNull
|
||||
private final TObjectHashingStrategy<K> myHashingStrategy;
|
||||
|
||||
@@ -149,7 +149,7 @@ abstract class ConcurrentRefHashMap<K, V> extends AbstractMap<K, V> implements C
|
||||
int concurrencyLevel,
|
||||
@NotNull TObjectHashingStrategy<K> hashingStrategy) {
|
||||
myHashingStrategy = hashingStrategy == THIS ? this : hashingStrategy;
|
||||
myMap = new ConcurrentHashMap<Key<K, V>, V>(initialCapacity, loadFactor, concurrencyLevel, CANONICAL);
|
||||
myMap = ConcurrentMapFactory.DEFAULT_FACTORY.<Key<K, V>, V>createMap(initialCapacity, loadFactor, concurrencyLevel, CANONICAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.*;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
abstract class ConcurrentRefValueHashMap<K, V> implements ConcurrentMap<K, V> {
|
||||
private final ConcurrentHashMap<K, MyValueReference<K, V>> myMap;
|
||||
private final ConcurrentMap<K, MyValueReference<K, V>> myMap;
|
||||
protected final ReferenceQueue<V> myQueue = new ReferenceQueue<V>();
|
||||
|
||||
public ConcurrentRefValueHashMap(@NotNull Map<K, V> map) {
|
||||
@@ -35,18 +35,18 @@ abstract class ConcurrentRefValueHashMap<K, V> implements ConcurrentMap<K, V> {
|
||||
}
|
||||
|
||||
public ConcurrentRefValueHashMap() {
|
||||
myMap = new ConcurrentHashMap<K, MyValueReference<K, V>>();
|
||||
myMap = ConcurrentMapFactory.DEFAULT_FACTORY.createMap();
|
||||
}
|
||||
|
||||
public ConcurrentRefValueHashMap(int initialCapacity, float loadFactor, int concurrencyLevel) {
|
||||
myMap = new ConcurrentHashMap<K, MyValueReference<K, V>>(initialCapacity, loadFactor, concurrencyLevel);
|
||||
myMap = ConcurrentMapFactory.DEFAULT_FACTORY.createMap(initialCapacity, loadFactor, concurrencyLevel);
|
||||
}
|
||||
|
||||
public ConcurrentRefValueHashMap(int initialCapacity,
|
||||
float loadFactor,
|
||||
int concurrencyLevel,
|
||||
@NotNull TObjectHashingStrategy<K> hashingStrategy) {
|
||||
myMap = new ConcurrentHashMap<K, MyValueReference<K, V>>(initialCapacity, loadFactor, concurrencyLevel, hashingStrategy);
|
||||
myMap = ConcurrentMapFactory.DEFAULT_FACTORY.createMap(initialCapacity, loadFactor, concurrencyLevel, hashingStrategy);
|
||||
}
|
||||
|
||||
protected interface MyValueReference<K, V> {
|
||||
|
||||
@@ -299,7 +299,7 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
|
||||
@NotNull
|
||||
public static <K, V> ConcurrentMap<K, V> newConcurrentMap() {
|
||||
return new ConcurrentHashMap<K, V>();
|
||||
return ConcurrentMapFactory.DEFAULT_FACTORY.createMap();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.intellij.openapi.util.io.ByteSequence;
|
||||
import com.intellij.openapi.util.io.StreamUtil;
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ConcurrentMapFactory;
|
||||
import com.intellij.util.io.PagePool;
|
||||
import com.intellij.util.io.UnsyncByteArrayInputStream;
|
||||
|
||||
@@ -39,7 +39,7 @@ import java.util.zip.Inflater;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
|
||||
public class RefCountingStorage extends AbstractStorage {
|
||||
private final Map<Integer, Future<?>> myPendingWriteRequests = new ConcurrentHashMap<Integer, Future<?>>();
|
||||
private final Map<Integer, Future<?>> myPendingWriteRequests = ConcurrentMapFactory.DEFAULT_FACTORY.createMap();
|
||||
private int myPendingWriteRequestsSize;
|
||||
private final ThreadPoolExecutor myPendingWriteRequestsExecutor = new ThreadPoolExecutor(1, 1, Long.MAX_VALUE, TimeUnit.DAYS, new LinkedBlockingQueue<Runnable>(), ConcurrencyUtil.newNamedThreadFactory("RefCountingStorage write content helper"));
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
package com.intellij.util.pico;
|
||||
|
||||
import com.intellij.util.ReflectionCache;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.util.containers.ConcurrentMapFactory;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.FList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -34,9 +34,9 @@ public class DefaultPicoContainer implements MutablePicoContainer, Serializable
|
||||
private final PicoContainer parent;
|
||||
private final Set<PicoContainer> children = new HashSet<PicoContainer>();
|
||||
|
||||
private final Map<Object, ComponentAdapter> componentKeyToAdapterCache = new ConcurrentHashMap<Object, ComponentAdapter>();
|
||||
private final Map<Object, ComponentAdapter> componentKeyToAdapterCache = ConcurrentMapFactory.DEFAULT_FACTORY.createMap();
|
||||
private final LinkedHashSetWrapper<ComponentAdapter> componentAdapters = new LinkedHashSetWrapper<ComponentAdapter>();
|
||||
private final Map<String, ComponentAdapter> classNameToAdapter = new ConcurrentHashMap<String, ComponentAdapter>();
|
||||
private final Map<String, ComponentAdapter> classNameToAdapter = ConcurrentMapFactory.DEFAULT_FACTORY.createMap();
|
||||
private final AtomicReference<FList<ComponentAdapter>> nonAssignableComponentAdapters = new AtomicReference<FList<ComponentAdapter>>(FList.<ComponentAdapter>emptyList());
|
||||
|
||||
public DefaultPicoContainer(@NotNull ComponentAdapterFactory componentAdapterFactory, PicoContainer parent) {
|
||||
|
||||
Reference in New Issue
Block a user