Deprecated API
Contents
-
ClassDescriptionThis class has moved to
com.google.common.util.concurrent
. Please useForwardingBlockingDeque
instead.UseTraverser
instead. All instance methods have their equivalent on the result ofTraverser.forTree(tree)
wheretree
implementsSuccessorsFunction
, which has a similar API asTreeTraverser.children(T)
or can be the same lambda function as passed intoTreeTraverser.using(Function)
.This class is scheduled to be removed in October 2019.
-
Exception ClassDescriptionThis exception is no longer thrown by
com.google.common
. Previously, it was thrown byMapMaker
computing maps. When support for computing maps was removed fromMapMaker
, it was added toCacheBuilder
, which throwsExecutionException
,UncheckedExecutionException
, andExecutionError
. Any code that is still catchingComputationException
may need to be updated to catch some of those types instead. (Note that this type, though deprecated, is not planned to be removed from Guava.)
-
FieldDescriptionUse
StandardCharsets.ISO_8859_1
instead.UseStandardCharsets.US_ASCII
instead.UseStandardCharsets.UTF_16
instead.UseStandardCharsets.UTF_16BE
instead.UseStandardCharsets.UTF_16LE
instead.UseStandardCharsets.UTF_8
instead.
-
MethodDescriptionProvided only to satisfy the
Predicate
interface; useCharMatcher.matches(char)
instead.Many digits are supplementary characters; see the class documentation.Most invisible characters are supplementary characters; see the class documentation.Many digits are supplementary characters; see the class documentation.Most letters are supplementary characters; see the class documentation.Most letters and digits are supplementary characters; see the class documentation.Some lowercase characters are supplementary characters; see the class documentation.Some uppercase characters are supplementary characters; see the class documentation.Many such characters are supplementary characters; see the class documentation.Provided to satisfy theFunction
interface; useConverter.convert(A)
instead.Provided only to satisfy theBiPredicate
interface; useEquivalence.equivalent(T, T)
instead.This method is equivalent toThrowable.getStackTrace()
on JDK versions past JDK 8 and on all Android versions. UseThrowable.getStackTrace()
directly, or where possible use thejava.lang.StackWalker.walk
method introduced in JDK 9.This method always returns false on JDK versions past JDK 8 and on all Android versions.To preserve behavior, usethrow e
orthrow new RuntimeException(e)
directly, or use a combination ofThrowables.throwIfUnchecked(java.lang.Throwable)
andthrow new RuntimeException(e)
. But consider whether users would be better off if your API threw a different type of exception. For background on the deprecation, read Why we deprecatedThrowables.propagate
.UseThrowables.throwIfInstanceOf(java.lang.Throwable, java.lang.Class<X>)
, which has the same behavior but rejectsnull
.UseThrowables.throwIfUnchecked(java.lang.Throwable)
, which has the same behavior but rejectsnull
.Use a combination ofThrowables.throwIfInstanceOf(java.lang.Throwable, java.lang.Class<X>)
andThrowables.throwIfUnchecked(java.lang.Throwable)
, which togther provide the same behavior except that they rejectnull
.Use a combination of two calls toThrowables.throwIfInstanceOf(java.lang.Throwable, java.lang.Class<X>)
and one call toThrowables.throwIfUnchecked(java.lang.Throwable)
, which togther provide the same behavior except that they rejectnull
.Provided to satisfy theFunction
interface; useLoadingCache.get(K)
orLoadingCache.getUnchecked(K)
instead.For aListMultimap
that automatically trims to size, useImmutableListMultimap
. If you need a mutable collection, remove thetrimToSize
call, or switch to aHashMap<K, ArrayList<V>>
.UseComparisonChain.compareFalseFirst(boolean, boolean)
; or, if the parameters passed are being either negated or reversed, undo the negation or reversal and useComparisonChain.compareTrueFirst(boolean, boolean)
.Internal method, useMultiset.entrySet()
.instances ofFluentIterable
don't need to be converted toFluentIterable
This method does not make sense for bimaps and should not be called.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.There is no reason to use this; it always returnsthis
.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.UseImmutableSortedMap.naturalOrder()
, which offers better type-safety.This method is not currently implemented, and may never be.Unsupported by ImmutableSortedMap.Builder.Not supported for ImmutableSortedMap.Pass a key of typeComparable
to useImmutableSortedMap.of(Comparable, Object)
.Pass keys of typeComparable
to useImmutableSortedMap.of(Comparable, Object, Comparable, Object)
.Pass keys of typeComparable
to useImmutableSortedMap.of(Comparable, Object, Comparable, Object, Comparable, Object)
.Pass keys of typeComparable
to useImmutableSortedMap.of(Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object)
.Pass keys of typeComparable
to useImmutableSortedMap.of(Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object)
.Pass keys of typeComparable
to useImmutableSortedMap.of(Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object)
.Pass keys of typeComparable
to useImmutableSortedMap.of(Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object)
.Pass keys of typeComparable
to useImmutableSortedMap.of(Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object)
.Pass keys of typeComparable
to useImmutableSortedMap.of(Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object)
.Pass keys of typeComparable
to useImmutableSortedMap.of(Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object)
.UseImmutableSortedMap.copyOf(ImmutableMap.ofEntries(...))
.Unsupported operation.Unsupported operation.UseImmutableSortedMultiset.naturalOrder()
, which offers better type-safety.Pass parameters of typeComparable
to useImmutableSortedMultiset.copyOf(Comparable[])
.Pass a parameter of typeComparable
to useImmutableSortedMultiset.of(Comparable)
.Pass the parameters of typeComparable
to useImmutableSortedMultiset.of(Comparable, Comparable)
.Pass the parameters of typeComparable
to useImmutableSortedMultiset.of(Comparable, Comparable, Comparable)
.Pass the parameters of typeComparable
to useImmutableSortedMultiset.of(Comparable, Comparable, Comparable, Comparable)
.Pass the parameters of typeComparable
to useImmutableSortedMultiset.of(Comparable, Comparable, Comparable, Comparable, Comparable)
.Pass the parameters of typeComparable
to useImmutableSortedMultiset.of(Comparable, Comparable, Comparable, Comparable, Comparable, Comparable, Comparable...)
.Unsupported operation.Unsupported operation.UseImmutableSortedSet.naturalOrder()
, which offers better type-safety.Not supported by ImmutableSortedSet.Pass parameters of typeComparable
to useImmutableSortedSet.copyOf(Comparable[])
.Pass a parameter of typeComparable
to useImmutableSortedSet.of(Comparable)
.Pass the parameters of typeComparable
to useImmutableSortedSet.of(Comparable, Comparable)
.Pass the parameters of typeComparable
to useImmutableSortedSet.of(Comparable, Comparable, Comparable)
.Pass the parameters of typeComparable
to useImmutableSortedSet.of(Comparable, Comparable, Comparable, Comparable)
.Pass the parameters of typeComparable
to useImmutableSortedSet.of(Comparable, Comparable, Comparable, Comparable, Comparable)
.Pass the parameters of typeComparable
to useImmutableSortedSet.of(Comparable, Comparable, Comparable, Comparable, Comparable, Comparable, Comparable...)
.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.no need to use thisno need to use thisno need to use thisno need to use thisno need to use thisno need to use thisno need to use thisUseCollections.binarySearch(List, Object, Comparator)
directly.no need to use thisProvided only to satisfy thePredicate
interface; useRange.contains(C)
instead.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.Unsupported operation.There is no reason to use this; just invokecollection.stream()
directly.Store theComparator
alongside theTable
. Or, if you know that theTable
contains at least one value, you can retrieve theComparator
with:((SortedMap<C, V>) table.rowMap().values().iterator().next()).comparator();
.Usetable.rowKeySet().comparator()
instead.Use((NavigableSet<K>) multimap.keySet()).comparator()
instead.UseTraverser.breadthFirst(N)
instead, which has the same behavior.UseTraverser.depthFirstPostOrder(N)
instead, which has the same behavior.UseTraverser.depthFirstPreOrder(N)
instead, which has the same behavior.UseTraverser.forTree(com.google.common.graph.SuccessorsFunction<N>)
instead. If you are using a lambda, these methods have exactly the same signature.Unsupported operation.Unsupported operation.Unsupported operation.no need to use thisno need to use thisno need to use thisProvided only to satisfy thePredicate
interface; useBloomFilter.mightContain(T)
instead.This returnsObject.hashCode()
; you almost certainly mean to callhash().asInt()
.If you must interoperate with a system that requires MD5, then use this method, despite its deprecation. But if you can choose your hash function, avoid MD5, which is neither fast nor secure. As of January 2017, we suggest:- For security:
Hashing.sha256()
or a higher-level API. - For speed:
Hashing.goodFastHash(int)
, though see its docs for caveats.
This implementation produces incorrect hash values from theHashFunction.hashString(java.lang.CharSequence, java.nio.charset.Charset)
method if the string contains non-BMP characters. UseHashing.murmur3_32_fixed()
instead.This implementation produces incorrect hash values from theHashFunction.hashString(java.lang.CharSequence, java.nio.charset.Charset)
method if the string contains non-BMP characters. UseHashing.murmur3_32_fixed(int)
instead.If you must interoperate with a system that requires SHA-1, then use this method, despite its deprecation. But if you can choose your hash function, avoid SHA-1, which is neither fast nor secure. As of January 2017, we suggest:- For security:
Hashing.sha256()
or a higher-level API. - For speed:
Hashing.goodFastHash(int)
, though see its docs for caveats.
This method is dangerous as it discards the high byte of every character. For UTF-8, usewrite(s.getBytes(StandardCharsets.UTF_8))
.PreferasCharSink(to, charset, FileWriteMode.APPEND).write(from)
. This method is scheduled to be removed in October 2019.PreferasCharSource(from, charset).copyTo(to)
.For Android users, see the Data and File Storage overview to select an appropriate temporary directory (perhapscontext.getCacheDir()
), and create your own directory under that. (For example, you might usenew File(context.getCacheDir(), "directoryname").mkdir()
, or, if you need an arbitrary number of temporary directories, you might have to generate multiple directory names in a loop untilmkdir()
returnstrue
.) For JRE users, preferFiles.createTempDirectory(java.nio.file.Path, java.lang.String, java.nio.file.attribute.FileAttribute<?>...)
, transforming it to aFile
usingtoFile()
if needed. To restrict permissions as this method does, passPosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwx------"))
to your call tocreateTempDirectory
.PreferasByteSource(file).hash(hashFunction)
.PreferasByteSource(file).read(processor)
.PreferasCharSource(file, charset).readFirstLine()
.PreferasCharSource(file, charset).readLines(callback)
.PreferasCharSource(file, charset).read()
.PreferasCharSink(to, charset).write(from)
.The semantics ofwriteBytes(String s)
are considered dangerous. Please useLittleEndianDataOutputStream.writeUTF(String s)
,LittleEndianDataOutputStream.writeChars(String s)
or another write method instead.UseStats.meanOf(java.lang.Iterable<? extends java.lang.Number>)
instead, noting the less strict handling of non-finite values.UseStats.meanOf(java.lang.Iterable<? extends java.lang.Number>)
instead, noting the less strict handling of non-finite values.UseStats.meanOf(java.lang.Iterable<? extends java.lang.Number>)
instead, noting the less strict handling of non-finite values.UseStats.meanOf(java.lang.Iterable<? extends java.lang.Number>)
instead, noting the less strict handling of non-finite values.UseStats.meanOf(java.lang.Iterable<? extends java.lang.Number>)
instead, noting the less strict handling of non-finite values.unsupported operationunsupported operationunsupported operationunsupported operationunsupported operationunsupported operationCreatingFuture
s of closeable types is dangerous in general because the underlying value may never be closed if theFuture
is canceled after its operation begins. Consider replacing code that createsListenableFuture
s of closeable types, including those that pass them to this method, withClosingFuture.submit(ClosingCallable, Executor)
in order to ensure that resources do not leak. Or, to start a pipeline with aListenableFuture
that doesn't create values that should be closed, useClosingFuture.from(com.google.common.util.concurrent.ListenableFuture<V>)
.no need to use this - For security:
-
ConstructorDescriptionCreate instances by using the static factory methods of the class.Use the static factory methods of the class. There is no reason to create an instance of
Quantiles
.Prefer ExecutionError(java.lang.@org.jspecify.annotations.Nullable Error) a constructor that accepts a cause: Users of this class typically expect for instances to have a non-null cause. At the moment, you can usually still preserve behavior by passing an explicitnull
cause. Note, however, that passing an explicitnull
cause prevents anyone from callingThrowable.initCause(java.lang.Throwable)
later, so it is not quite equivalent to using a constructor that omits the cause.Prefer ExecutionError(java.lang.@org.jspecify.annotations.Nullable String,java.lang.@org.jspecify.annotations.Nullable Error) a constructor that accepts a cause: Users of this class typically expect for instances to have a non-null cause. At the moment, you can usually still preserve behavior by passing an explicitnull
cause. Note, however, that passing an explicitnull
cause prevents anyone from callingThrowable.initCause(java.lang.Throwable)
later, so it is not quite equivalent to using a constructor that omits the cause.Prefer UncheckedExecutionException(java.lang.@org.jspecify.annotations.Nullable Throwable) a constructor that accepts a cause: Users of this class typically expect for instances to have a non-null cause. At the moment, you can usually still preserve behavior by passing an explicitnull
cause. Note, however, that passing an explicitnull
cause prevents anyone from callingThrowable.initCause(java.lang.Throwable)
later, so it is not quite equivalent to using a constructor that omits the cause.Prefer UncheckedExecutionException(java.lang.@org.jspecify.annotations.Nullable String,java.lang.@org.jspecify.annotations.Nullable Throwable) a constructor that accepts a cause: Users of this class typically expect for instances to have a non-null cause. At the moment, you can usually still preserve behavior by passing an explicitnull
cause. Note, however, that passing an explicitnull
cause prevents anyone from callingThrowable.initCause(java.lang.Throwable)
later, so it is not quite equivalent to using a constructor that omits the cause.
-
Enum ConstantDescriptionThis property was deprecated in Java 8 and removed in Java 9. We do not plan to remove this API from Guava, but if you are using it, it is probably not doing what you want.