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

More thread safety problems in core reflection

    XMLWordPrintable

Details

    • b15
    • generic
    • generic
    • Not verified

    Backports

      Description

        We have noticed thread safety problems in the JDK sources for core reflection. We can fix these by:
        making effectively final fields truly final, as was done in
        JDK-8062771: Core reflection should use final fields whenever possible

        and also by using thread-safe constructs on lazy init-once variables in the tree-shaped data structure rooted by Class objects, most obviously by making fields volatile.

        Here are changes we made locally at Google:

        http://cr.openjdk.java.net/~martin/webrevs/openjdk7/Class-thread-safety/
        http://cr.openjdk.java.net/~martin/webrevs/openjdk8/Class-thread-safety/

        We think these would be good to include in JDK update releases.

        For jdk9, we can and should make similar changes, but we can be more ambitious and try to improve by ensuring that the initialization is truly once, and perhaps take advantage of new core support for volatile fields expected in jdk9. Or use Unsafe with CAS.

        Attachments

          Issue Links

            Activity

              People

                jfranck Joel Borggrén-Franck (Inactive)
                martin Martin Buchholz
                Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: