XStream
  1. XStream
  2. XSTR-552

Improve performance of PureJavaReflectionProvider.fieldDefinedInClass

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.1
    • Fix Version/s: 1.4
    • Component/s: Core
    • Labels:
      None

      Description

      After running my xstream serialization/deserialization through a profiler (YourKit), I found that PureJavaReflectionProvider.fieldDefinedInClass is taking up nearly 30% of the CPU time. This is because it calls FieldDictionary.field to check if a field exists. If the field does not exist, FieldDictionary.field throws an ObjectAccessException instead of returning null. Unfortunately, throwing exceptions is an inherently expensive operation in the JVM, and PureJavaReflectionProvider.fieldDefinedInClass is called very frequently. The more performant solution would be to have FieldDictionary.field return null, and handle the null-checking at the appropriate call sites. If this is an exposed API method, an alternative solution would be to make a second method which does not throw the exception.

        People

        • Assignee:
          Jörg Schaible
          Reporter:
          Keith Kowalczykowski
        • Votes:
          0 Vote for this issue
          Watchers:
          1 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: