Deprecated API
Contents
-
Deprecated ClassesClassDescriptionThis class has moved to
com.google.common.util.concurrent. Please useForwardingBlockingDequeinstead.UseTraverserinstead. All instance methods have their equivalent on the result ofTraverser.forTree(tree)wheretreeimplementsSuccessorsFunction, 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.
-
Deprecated Exception ClassesException ClassDescriptionThis exception is no longer thrown by
com.google.common. Previously, it was thrown byMapMakercomputing maps. When support for computing maps was removed fromMapMaker, it was added toCacheBuilder, which throwsExecutionException,UncheckedExecutionException, andExecutionError. Any code that is still catchingComputationExceptionmay 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.)
-
Deprecated FieldsFieldDescriptionUse
StandardCharsets.ISO_8859_1instead.UseStandardCharsets.US_ASCIIinstead.UseStandardCharsets.UTF_16instead.UseStandardCharsets.UTF_16BEinstead.UseStandardCharsets.UTF_16LEinstead.UseStandardCharsets.UTF_8instead.
-
Deprecated MethodsMethodDescriptionProvided only to satisfy the
Predicateinterface; 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 only to satisfy thePredicateinterface; useCharMatcher.matches(char)instead.Provided to satisfy theFunctioninterface; useConverter.convert(A)instead.Provided only to satisfy theBiPredicateinterface; 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.walkmethod introduced in JDK 9.This method always returns false on JDK versions past JDK 8 and on all Android versions.To preserve behavior, usethrow eorthrow 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 theFunctioninterface; useLoadingCache.get(K)orLoadingCache.getUnchecked(K)instead.For aListMultimapthat automatically trims to size, useImmutableListMultimap. If you need a mutable collection, remove thetrimToSizecall, 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 ofFluentIterabledon't need to be converted toFluentIterableThis method does not make sense for bimaps and should not be called.Unsupported operation.Merging values does not make sense for aBiMap.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 typeComparableto useImmutableSortedMap.of(Comparable, Object).Pass keys of typeComparableto useImmutableSortedMap.of(Comparable, Object, Comparable, Object).Pass keys of typeComparableto useImmutableSortedMap.of(Comparable, Object, Comparable, Object, Comparable, Object).Pass keys of typeComparableto useImmutableSortedMap.of(Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object).Pass keys of typeComparableto useImmutableSortedMap.of(Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object).Pass keys of typeComparableto useImmutableSortedMap.of(Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object).Pass keys of typeComparableto useImmutableSortedMap.of(Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object).Pass keys of typeComparableto useImmutableSortedMap.of(Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object).Pass keys of typeComparableto useImmutableSortedMap.of(Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object, Comparable, Object).Pass keys of typeComparableto 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 typeComparableto useImmutableSortedMultiset.copyOf(Comparable[]).Pass a parameter of typeComparableto useImmutableSortedMultiset.of(Comparable).Pass the parameters of typeComparableto useImmutableSortedMultiset.of(Comparable, Comparable).Pass the parameters of typeComparableto useImmutableSortedMultiset.of(Comparable, Comparable, Comparable).Pass the parameters of typeComparableto useImmutableSortedMultiset.of(Comparable, Comparable, Comparable, Comparable).Pass the parameters of typeComparableto useImmutableSortedMultiset.of(Comparable, Comparable, Comparable, Comparable, Comparable).Pass the parameters of typeComparableto 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 typeComparableto useImmutableSortedSet.copyOf(Comparable[]).Pass a parameter of typeComparableto useImmutableSortedSet.of(Comparable).Pass the parameters of typeComparableto useImmutableSortedSet.of(Comparable, Comparable).Pass the parameters of typeComparableto useImmutableSortedSet.of(Comparable, Comparable, Comparable).Pass the parameters of typeComparableto useImmutableSortedSet.of(Comparable, Comparable, Comparable, Comparable).Pass the parameters of typeComparableto useImmutableSortedSet.of(Comparable, Comparable, Comparable, Comparable, Comparable).Pass the parameters of typeComparableto 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 thePredicateinterface; useRange.contains(C)instead.Provided only to satisfy thePredicateinterface; 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 theComparatoralongside theTable. Or, if you know that theTablecontains at least one value, you can retrieve theComparatorwith:((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 thePredicateinterface; useBloomFilter.mightContain(T)instead.Provided only to satisfy thePredicateinterface; 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 aFileusingtoFile()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 operationCreatingFutures of closeable types is dangerous in general because the underlying value may never be closed if theFutureis canceled after its operation begins. Consider replacing code that createsListenableFutures 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 aListenableFuturethat doesn't create values that should be closed, useClosingFuture.from(com.google.common.util.concurrent.ListenableFuture<V>).no need to use this - For security:
-
Deprecated ConstructorsConstructorDescriptionCreate 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 explicitnullcause. Note, however, that passing an explicitnullcause 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 explicitnullcause. Note, however, that passing an explicitnullcause 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 explicitnullcause. Note, however, that passing an explicitnullcause 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 explicitnullcause. Note, however, that passing an explicitnullcause prevents anyone from callingThrowable.initCause(java.lang.Throwable)later, so it is not quite equivalent to using a constructor that omits the cause.
-
Deprecated Enum ConstantsEnum 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.