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

Stronger enforcement for reference counting Symbols

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P3 P3
    • 11
    • 9
    • hotspot
    • None

      Currently there is a somewhat weak enforcement in the way Symbols are reference counted:

      SymbolTable operations increments the Symbols refcount before returning the Symbol to the caller.The caller is responsible for releasing the reference count on retirement.

      Ideally, the type system should enforce this mechanism to avoid leaking and to reduce the explicit responsibility on the caller/client.

      Currently there is a TempNewSymbol helper handle class that goes some way towards helping. It does however have a public type conversion constructor/operator that takes a Symbol* but does not increment the Symbols refcount. It's destructor does decrease the refcount however, which means there is an asymmetry here that could be problematic in the case that the TempNewSymbol is used in other context's from the one intended (that is, receiving a Symbol from one of SymbolTable's operations (where the refcount increment resides)).

      We should investigate ways to ensure stronger enforcement about the reference counting, this could involve ideas related to having SymbolTable operations return handle classes (smart pointers) that would assist in ensuring proper copy semantics.

            coleenp Coleen Phillimore
            mgronlun Markus Grönlund
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: