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

Lock coarsening works for local variables, breaks for fields

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 9, 10
    • hotspot

      The issue was originally found while investigating
       http://www.javaspecialists.eu/archive/Issue217.html

      The essence of the issue is following. If you have a class:

      class C {
        synchronized void work(); { ... }
      }

      ...and you have two potential users:

      class U {
        private C c = new C();

        void user1() {
           c.work();
           c.work();
           c.work();
           c.work();
        }

        void user2() {
           C lc = c;
           lc.work();
           lc.work();
           lc.work();
           lc.work();
        }
      }

      ...then lock coarsening works perfectly well for user2(), but not for user1(), even though both are similar.

      One might think the memory model issues are involved, but in the case of empty work() methods, both
      transformations are valid.

            Unassigned Unassigned
            shade Aleksey Shipilev
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: