Apply workaround for compiler bug.
Manually ported over from upstream CL
https://code.google.com/p/guava-libraries/source/detail?r=0b11aaacc0a7623675755a30aa1b172ad1150644
Change-Id: Iae3fad220c424722d1716d9c17c85d5c0b3549e6
diff --git a/guava-tests/test/com/google/common/collect/ComputingConcurrentHashMapTest.java b/guava-tests/test/com/google/common/collect/ComputingConcurrentHashMapTest.java
index 3a75690..71fe754 100644
--- a/guava-tests/test/com/google/common/collect/ComputingConcurrentHashMapTest.java
+++ b/guava-tests/test/com/google/common/collect/ComputingConcurrentHashMapTest.java
@@ -25,7 +25,7 @@
import static com.google.common.collect.MapMakerInternalMapTest.checkExpirationTimes;
import com.google.common.base.Function;
-import com.google.common.collect.ComputingConcurrentHashMap.ComputingMapAdapter;
+import com.google.common.collect.MapMaker.ComputingMapAdapter;
import com.google.common.collect.MapMaker.RemovalCause;
import com.google.common.collect.MapMakerInternalMap.ReferenceEntry;
import com.google.common.collect.MapMakerInternalMap.Segment;
diff --git a/guava/src/com/google/common/collect/ComputingConcurrentHashMap.java b/guava/src/com/google/common/collect/ComputingConcurrentHashMap.java
index 4b0c18a..1e37edc 100644
--- a/guava/src/com/google/common/collect/ComputingConcurrentHashMap.java
+++ b/guava/src/com/google/common/collect/ComputingConcurrentHashMap.java
@@ -19,14 +19,12 @@
import com.google.common.base.Equivalence;
import com.google.common.base.Function;
-import com.google.common.base.Throwables;
import com.google.common.collect.MapMaker.RemovalCause;
import com.google.common.collect.MapMaker.RemovalListener;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.io.Serializable;
import java.lang.ref.ReferenceQueue;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException;
@@ -372,38 +370,6 @@
}
}
- /**
- * Overrides get() to compute on demand. Also throws an exception when {@code null} is returned
- * from a computation.
- */
- static final class ComputingMapAdapter<K, V>
- extends ComputingConcurrentHashMap<K, V> implements Serializable {
- private static final long serialVersionUID = 0;
-
- ComputingMapAdapter(MapMaker mapMaker,
- Function<? super K, ? extends V> computingFunction) {
- super(mapMaker, computingFunction);
- }
-
- @SuppressWarnings("unchecked") // unsafe, which is one advantage of Cache over Map
- @Override
- public V get(Object key) {
- V value;
- try {
- value = getOrCompute((K) key);
- } catch (ExecutionException e) {
- Throwable cause = e.getCause();
- Throwables.propagateIfInstanceOf(cause, ComputationException.class);
- throw new ComputationException(cause);
- }
-
- if (value == null) {
- throw new NullPointerException(computingFunction + " returned null for key " + key + ".");
- }
- return value;
- }
- }
-
// Serialization Support
private static final long serialVersionUID = 4;
diff --git a/guava/src/com/google/common/collect/MapMaker.java b/guava/src/com/google/common/collect/MapMaker.java
index 9cec045..330018e 100644
--- a/guava/src/com/google/common/collect/MapMaker.java
+++ b/guava/src/com/google/common/collect/MapMaker.java
@@ -26,8 +26,8 @@
import com.google.common.base.Equivalences;
import com.google.common.base.Function;
import com.google.common.base.Objects;
+import com.google.common.base.Throwables;
import com.google.common.base.Ticker;
-import com.google.common.collect.ComputingConcurrentHashMap.ComputingMapAdapter;
import com.google.common.collect.MapMakerInternalMap.Strength;
import java.io.Serializable;
@@ -40,6 +40,7 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
@@ -666,7 +667,7 @@
public <K, V> ConcurrentMap<K, V> makeComputingMap(
Function<? super K, ? extends V> computingFunction) {
return useNullMap()
- ? new ComputingMapAdapter<K, V>(this, computingFunction)
+ ? new MapMaker.ComputingMapAdapter<K, V>(this, computingFunction)
: new NullComputingConcurrentMap<K, V>(this, computingFunction);
}
@@ -947,4 +948,36 @@
}
}
+ /**
+ * Overrides get() to compute on demand. Also throws an exception when {@code null} is returned
+ * from a computation.
+ */
+ static final class ComputingMapAdapter<K, V>
+ extends ComputingConcurrentHashMap<K, V> implements Serializable {
+ private static final long serialVersionUID = 0;
+
+ ComputingMapAdapter(MapMaker mapMaker,
+ Function<? super K, ? extends V> computingFunction) {
+ super(mapMaker, computingFunction);
+ }
+
+ @SuppressWarnings("unchecked") // unsafe, which is one advantage of Cache over Map
+ @Override
+ public V get(Object key) {
+ V value;
+ try {
+ value = getOrCompute((K) key);
+ } catch (ExecutionException e) {
+ Throwable cause = e.getCause();
+ Throwables.propagateIfInstanceOf(cause, ComputationException.class);
+ throw new ComputationException(cause);
+ }
+
+ if (value == null) {
+ throw new NullPointerException(computingFunction + " returned null for key " + key + ".");
+ }
+ return value;
+ }
+ }
+
}