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

Core reflection should use final fields whenever possible

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b40
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Backports

        Description

        We experienced very rare NullPointerExceptions in core reflection in jdk7, like this:

         * at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125)
         * at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
         * at sun.reflect.generics.repository.ClassRepository.getSuperclass(ClassRepository.java:84)
         * at java.lang.Class.getGenericSuperclass(Class.java:692)
         * at com.google.inject.TypeLiteral.getSuperclassTypeParameter(TypeLiteral.java:99)
         * at com.google.inject.TypeLiteral.<init>(TypeLiteral.java:79)

        while experimenting with fixes, we were surprised to discover that making reflection class fields final fixed the problem - that's never happened before on x86 in my memory. Although it's not reproducible on jdk8+, apparently because of the fix in

        8016236: Class.getGenericInterfaces performance improvement

        (which is also a correctness improvement!) we should preserve our work in jdk9 as well.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  martin Martin Buchholz
                  Reporter:
                  martin Martin Buchholz
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: