Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #2720: Use StackWalker on Java 9+ to create Locations #2723

Merged
merged 7 commits into from Aug 13, 2022

Commits on Aug 5, 2022

  1. Fixes mockito#2720 Use StackWalker on Java 9+ to create Locations

    In terms of memory allocations, this reduces the overall memory
    allocations of creating a location by an order of magnitude in
    Java 9, and as compared to Java 8.
    
    The implementation is somewhat involved due to these desires:
    
    - Minimize the amount of work done if the Location is never used. This
      is done by not converting the StackFrame into a StackTraceElement,
      instead wrapping in an intermediate state. The StackTraceElement conversion
      will only occur (internally) if the .getFileName() method is called.
    - Ensure the implementation is still Serializable. This is ensured with
      a .writeReplace method.
    - Minimize the number of allocations, which is basically an exercise in
      lambda caching.
    - Ensuring the old mechanism still works on Java 8.
    
    Presently on Java 9+, on a stack depth of 1000 the old mechanism will allocate
    40kB of RAM per call. The new one will allocate 1.5kB of RAM per call,
    which is a huge improvement.
    
    This is still sadly not the 'close-to-no-overhead' solution I was
    looking for. I therefore also added a system property that can be used
    to fully disable Location creation. I'm aware that this is likely not
    the right approach given Mockito has plugins and settings - mostly
    looking for guidance here given I'm not sure what would be idiomatic
    here.
    j-baker committed Aug 5, 2022
    Copy the full SHA
    0391e26 View commit details
    Browse the repository at this point in the history

Commits on Aug 8, 2022

  1. Copy the full SHA
    a5c573f View commit details
    Browse the repository at this point in the history

Commits on Aug 13, 2022

  1. PR comments

    j-baker committed Aug 13, 2022
    Copy the full SHA
    46b4033 View commit details
    Browse the repository at this point in the history
  2. Refactor test organization

    j-baker committed Aug 13, 2022
    Copy the full SHA
    b403d8c View commit details
    Browse the repository at this point in the history
  3. ./gradlew check works now

    j-baker committed Aug 13, 2022
    Copy the full SHA
    8dc8978 View commit details
    Browse the repository at this point in the history
  4. Linkage Error

    j-baker committed Aug 13, 2022
    Copy the full SHA
    60fd2cb View commit details
    Browse the repository at this point in the history
  5. Remove unused constructors

    j-baker committed Aug 13, 2022
    Copy the full SHA
    af8454e View commit details
    Browse the repository at this point in the history