Skip to content

Commit

Permalink
Deprecate Throwables.lazyStackTrace.
Browse files Browse the repository at this point in the history
This method is no longer lazy on any current platform. The JDK-internal method it depends on was removed in JDK 9, and the method has never been lazy on Android.

RELNOTES=The `Throwables` methods `lazyStackTrace` and `lazyStackTraceIsLazy` have been deprecated. They are no longer useful on any current platform.
PiperOrigin-RevId: 423821947
  • Loading branch information
eamonnmcmanus authored and Google Java Core Libraries committed Jan 24, 2022
1 parent 7031494 commit 6ebd7d8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions android/guava/src/com/google/common/base/Throwables.java
Expand Up @@ -19,7 +19,6 @@
import static java.util.Collections.unmodifiableList;
import static java.util.Objects.requireNonNull;

import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.VisibleForTesting;
Expand Down Expand Up @@ -380,11 +379,12 @@ public static String getStackTraceAsString(Throwable throwable) {
* exception's creation.
*
* @since 19.0
* @deprecated This method is equivalent to {@link Throwable#getStackTrace()} on JDK versions past
* JDK 8 and on all Android versions. Use {@link Throwable#getStackTrace()} directly, or where
* possible use the {@code java.lang.StackWalker.walk} method introduced in JDK 9.
*/
// TODO(cpovirk): Say something about the possibility that List access could fail at runtime?
@Beta
@Deprecated
@GwtIncompatible // lazyStackTraceIsLazy, jlaStackTrace
// TODO(cpovirk): Consider making this available under GWT (slow implementation only).
public static List<StackTraceElement> lazyStackTrace(Throwable throwable) {
return lazyStackTraceIsLazy()
? jlaStackTrace(throwable)
Expand All @@ -396,8 +396,10 @@ public static List<StackTraceElement> lazyStackTrace(Throwable throwable) {
* documentation.
*
* @since 19.0
* @deprecated This method always returns false on JDK versions past JDK 8 and on all Android
* versions.
*/
@Beta
@Deprecated
@GwtIncompatible // getStackTraceElementMethod
public static boolean lazyStackTraceIsLazy() {
return getStackTraceElementMethod != null && getStackTraceDepthMethod != null;
Expand Down
12 changes: 7 additions & 5 deletions guava/src/com/google/common/base/Throwables.java
Expand Up @@ -19,7 +19,6 @@
import static java.util.Collections.unmodifiableList;
import static java.util.Objects.requireNonNull;

import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.VisibleForTesting;
Expand Down Expand Up @@ -380,11 +379,12 @@ public static String getStackTraceAsString(Throwable throwable) {
* exception's creation.
*
* @since 19.0
* @deprecated This method is equivalent to {@link Throwable#getStackTrace()} on JDK versions past
* JDK 8 and on all Android versions. Use {@link Throwable#getStackTrace()} directly, or where
* possible use the {@code java.lang.StackWalker.walk} method introduced in JDK 9.
*/
// TODO(cpovirk): Say something about the possibility that List access could fail at runtime?
@Beta
@Deprecated
@GwtIncompatible // lazyStackTraceIsLazy, jlaStackTrace
// TODO(cpovirk): Consider making this available under GWT (slow implementation only).
public static List<StackTraceElement> lazyStackTrace(Throwable throwable) {
return lazyStackTraceIsLazy()
? jlaStackTrace(throwable)
Expand All @@ -396,8 +396,10 @@ public static List<StackTraceElement> lazyStackTrace(Throwable throwable) {
* documentation.
*
* @since 19.0
* @deprecated This method always returns false on JDK versions past JDK 8 and on all Android
* versions.
*/
@Beta
@Deprecated
@GwtIncompatible // getStackTraceElementMethod
public static boolean lazyStackTraceIsLazy() {
return getStackTraceElementMethod != null && getStackTraceDepthMethod != null;
Expand Down

0 comments on commit 6ebd7d8

Please sign in to comment.