Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8317818

Combinatorial explosion during 'this' escape analysis

    XMLWordPrintable

Details

    • 21
    • b20
    • generic
    • generic

    Backports

      Description

        The 'this' escape analyzer takes forever analyzing this class:

        ```
        public class Test {
            private Object obj;
            public Test() {
                getObject();
            }
            private Object getObject() {
                if (this.obj == null) {
                    this.obj = new Object();
                    getObject().hashCode();
                    getObject().hashCode();
                    getObject().hashCode();
                    getObject().hashCode();
                    getObject().hashCode();
                    getObject().hashCode();
                    getObject().hashCode();
                    getObject().hashCode();
                    getObject().hashCode();
                    getObject().hashCode();
                    getObject().hashCode();
                    getObject().hashCode();
                    getObject().hashCode();
                    getObject().hashCode();
                    getObject().hashCode();
                    getObject().hashCode();
                }
                return this.obj;
            }
        }
        ```
        The problem is that the recursion detector keys on the method call site, not the target method itself, so if there are multiple recursive call sites inside the target method then you end up recursing through all possible combinations of call sites before stopping the recursion.

        The fix is simple - key on the method itself, not the call site.

        Attachments

          Issue Links

            Activity

              People

                acobbs Archie Cobbs
                acobbs Archie Cobbs
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: