JDK 14 RFR of JDK-8226809: Circular reference in printed stack trace is not correctly indented & ambiguous

Brian Burkhalter brian.burkhalter at oracle.com
Sat Jun 29 00:09:04 UTC 2019


Hi Joe,

I think this patch and its revised output looks OK and agree about not adding a test for it.

Brian

> On Jun 28, 2019, at 4:42 PM, Joe Darcy <joe.darcy at oracle.com> wrote:
> […]
> 
> and the revised code prints this more helpfully as
> 
> java.lang.Exception: first
>     at DejaVuStackTrace.main(DejaVuStackTrace.java:3)
>     Suppressed: java.lang.Exception: second
>         at DejaVuStackTrace.main(DejaVuStackTrace.java:4)
>         Suppressed: java.lang.Exception: third
>             at DejaVuStackTrace.main(DejaVuStackTrace.java:6)
>             Suppressed: java.lang.Exception: fourth
>                 at DejaVuStackTrace.main(DejaVuStackTrace.java:8)
>                 Suppressed: [CIRCULAR REFERENCE: java.lang.Exception: first]
>                 Suppressed: java.lang.Exception: fifth
>                     at DejaVuStackTrace.main(DejaVuStackTrace.java:14)
>             Caused by: [CIRCULAR REFERENCE: java.lang.Exception: second]
> 
> The format of the printed stack trace is not specified and I don't think it is worthwhile to write a regression test for this change.
> 
> Cheers,
> 
> -Joe
> 
> diff -r c9093341cfe2 src/java.base/share/classes/java/lang/Throwable.java
> --- a/src/java.base/share/classes/java/lang/Throwable.java    Fri Jun 28 13:02:18 2019 -0700
> +++ b/src/java.base/share/classes/java/lang/Throwable.java    Fri Jun 28 16:34:15 2019 -0700
> @@ -693,7 +693,7 @@
>                                           Set<Throwable> dejaVu) {
>          assert Thread.holdsLock(s.lock());
>          if (dejaVu.contains(this)) {
> -            s.println("\t[CIRCULAR REFERENCE:" + this + "]");
> +            s.println(prefix + caption + "[CIRCULAR REFERENCE: " + this + "]");
>          } else {
>              dejaVu.add(this);
>              // Compute number of frames in common between this and enclosing trace
> 



More information about the core-libs-dev mailing list