Repository: getsentry/sentry

Issue:
Stack traces not grouping because of jdk.internal.reflect.GeneratedMethodAccessor
<!--

Do you want to ask a question? Are you looking for support? The Sentry message
board is the best place for getting support: https://forum.sentry.io
-->

## Important Details

How are you running Sentry?

* [x] On-Premise docker [Version 9.0.0]
* [ ] Saas (sentry.io)
* [ ] Other [briefly describe your environment]

## Description

Stack traces that should be grouped together, aren't, and the major difference I can see is that they have a stack trace element with the class `jdk.internal.reflect.GeneratedMethodAccessor{effectively random number}`. This class moved from `sun.reflect` to `jdk.internal.reflect` so the fix made in #11145 / e4c6600  doesn't help users of JDK11 (possibly earlier, too). 

## Steps to Reproduce

1. Use JDK 11 with some code that uses 
2. Capture an exception that uses Method#invoke somewhere in its call stack. 
3. The captured stack trace will have something like this in it: 

```    
    at jdk.internal.reflect.GeneratedMethodAccessor261.invoke
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:566)
 ```

### What you expected to happen

Ignore the trailing number from the generated method accessor when calculating the grouping for the stacktrace. 




Discussion:

Resolving patch:
diff --git a/src/sentry/grouping/strategies/legacy.py b/src/sentry/grouping/strategies/legacy.py
--- a/src/sentry/grouping/strategies/legacy.py
+++ b/src/sentry/grouping/strategies/legacy.py
@@ -88,6 +88,8 @@ def remove_module_outliers_legacy(module, platform):
     if platform == 'java':
         if module[:35] == 'sun.reflect.GeneratedMethodAccessor':
             return 'sun.reflect.GeneratedMethodAccessor', 'removed reflection marker'
+        if module[:44] == 'jdk.internal.reflect.GeneratedMethodAccessor':
+            return 'jdk.internal.reflect.GeneratedMethodAccessor', 'removed reflection marker'
         old_module = module
         module = _java_reflect_enhancer_re.sub(r'\1<auto>', module)
         module = _java_cglib_enhancer_re.sub(r'\1<auto>', module)
diff --git a/src/sentry/grouping/strategies/newstyle.py b/src/sentry/grouping/strategies/newstyle.py
--- a/src/sentry/grouping/strategies/newstyle.py
+++ b/src/sentry/grouping/strategies/newstyle.py
@@ -130,6 +130,11 @@ def get_module_component_v1(abs_path, module, platform):
                 values=['sun.reflect.GeneratedMethodAccessor'],
                 hint='removed reflection marker',
             )
+        elif module[:44] == 'jdk.internal.reflect.GeneratedMethodAccessor':
+            module_component.update(
+                values=['jdk.internal.reflect.GeneratedMethodAccessor'],
+                hint='removed reflection marker',
+            )
         else:
             old_module = module
             module = _java_reflect_enhancer_re.sub(r'\1<auto>', module)


Test patch:
diff --git a/tests/sentry/grouping/grouping_inputs/frame-ignores-sun-java-generated-methods.json b/tests/sentry/grouping/grouping_inputs/frame-ignores-sun-java-generated-methods.json
--- a/tests/sentry/grouping/grouping_inputs/frame-ignores-sun-java-generated-methods.json
+++ b/tests/sentry/grouping/grouping_inputs/frame-ignores-sun-java-generated-methods.json
@@ -4,6 +4,10 @@
       {
         "function": "invoke",
         "module": "sun.reflect.GeneratedMethodAccessor12345"
+      },
+      {
+        "function": "invoke",
+        "module": "jdk.internal.reflect.GeneratedMethodAccessor12345"
       }
     ]
   },
diff --git a/tests/sentry/grouping/snapshots/test_variants/test_event_hash_variant/combined:2019_04_07/frame_ignores_sun_java_generated_methods.pysnap b/tests/sentry/grouping/snapshots/test_variants/test_event_hash_variant/combined:2019_04_07/frame_ignores_sun_java_generated_methods.pysnap
--- a/tests/sentry/grouping/snapshots/test_variants/test_event_hash_variant/combined:2019_04_07/frame_ignores_sun_java_generated_methods.pysnap
+++ b/tests/sentry/grouping/snapshots/test_variants/test_event_hash_variant/combined:2019_04_07/frame_ignores_sun_java_generated_methods.pysnap
@@ -1,5 +1,5 @@
 ---
-created: '2019-04-07T10:03:31.262050Z'
+created: '2019-05-21T19:16:08.166809Z'
 creator: sentry
 source: tests/sentry/grouping/test_variants.py
 ---
@@ -13,9 +13,14 @@ app:
             'sun.reflect.GeneratedMethodAccessor'
           function*
             u'invoke'
+        frame* (frame considered in-app because no frame is in-app)
+          module* (removed reflection marker)
+            'jdk.internal.reflect.GeneratedMethodAccessor'
+          function*
+            u'invoke'
 --------------------------------------------------------------------------
 system:
-  hash: 'df0a8233b314c542a0b98a4e8865c7b5'
+  hash: '9bc326575875422d0d4ced3c35d9f916'
   component:
     system*
       stacktrace*
@@ -24,3 +29,8 @@ system:
             'sun.reflect.GeneratedMethodAccessor'
           function*
             u'invoke'
+        frame*
+          module* (removed reflection marker)
+            'jdk.internal.reflect.GeneratedMethodAccessor'
+          function*
+            u'invoke'
diff --git a/tests/sentry/grouping/snapshots/test_variants/test_event_hash_variant/legacy:2019_03_12/frame_ignores_sun_java_generated_methods.pysnap b/tests/sentry/grouping/snapshots/test_variants/test_event_hash_variant/legacy:2019_03_12/frame_ignores_sun_java_generated_methods.pysnap
--- a/tests/sentry/grouping/snapshots/test_variants/test_event_hash_variant/legacy:2019_03_12/frame_ignores_sun_java_generated_methods.pysnap
+++ b/tests/sentry/grouping/snapshots/test_variants/test_event_hash_variant/legacy:2019_03_12/frame_ignores_sun_java_generated_methods.pysnap
@@ -1,5 +1,5 @@
 ---
-created: '2019-03-14T17:12:37.195959Z'
+created: '2019-05-21T19:16:09.511284Z'
 creator: sentry
 source: tests/sentry/grouping/test_variants.py
 ---
@@ -13,9 +13,14 @@ app:
             'sun.reflect.GeneratedMethodAccessor'
           function*
             u'invoke'
+        frame* (frame considered in-app because no frame is in-app)
+          module* (removed reflection marker)
+            'jdk.internal.reflect.GeneratedMethodAccessor'
+          function*
+            u'invoke'
 --------------------------------------------------------------------------
 system:
-  hash: 'df0a8233b314c542a0b98a4e8865c7b5'
+  hash: '9bc326575875422d0d4ced3c35d9f916'
   component:
     system*
       stacktrace*
@@ -24,3 +29,8 @@ system:
             'sun.reflect.GeneratedMethodAccessor'
           function*
             u'invoke'
+        frame*
+          module* (removed reflection marker)
+            'jdk.internal.reflect.GeneratedMethodAccessor'
+          function*
+            u'invoke'
diff --git a/tests/sentry/grouping/snapshots/test_variants/test_event_hash_variant/newstyle:2019_04_05/frame_ignores_sun_java_generated_methods.pysnap b/tests/sentry/grouping/snapshots/test_variants/test_event_hash_variant/newstyle:2019_04_05/frame_ignores_sun_java_generated_methods.pysnap
--- a/tests/sentry/grouping/snapshots/test_variants/test_event_hash_variant/newstyle:2019_04_05/frame_ignores_sun_java_generated_methods.pysnap
+++ b/tests/sentry/grouping/snapshots/test_variants/test_event_hash_variant/newstyle:2019_04_05/frame_ignores_sun_java_generated_methods.pysnap
@@ -1,5 +1,5 @@
 ---
-created: '2019-03-15T11:58:33.017753Z'
+created: '2019-05-21T19:16:10.811034Z'
 creator: sentry
 source: tests/sentry/grouping/test_variants.py
 ---
@@ -13,9 +13,14 @@ app:
             'sun.reflect.GeneratedMethodAccessor'
           function*
             u'invoke'
+        frame (non app frame)
+          module* (removed reflection marker)
+            'jdk.internal.reflect.GeneratedMethodAccessor'
+          function*
+            u'invoke'
 --------------------------------------------------------------------------
 system:
-  hash: 'df0a8233b314c542a0b98a4e8865c7b5'
+  hash: '9bc326575875422d0d4ced3c35d9f916'
   component:
     system*
       stacktrace*
@@ -24,3 +29,8 @@ system:
             'sun.reflect.GeneratedMethodAccessor'
           function*
             u'invoke'
+        frame*
+          module* (removed reflection marker)
+            'jdk.internal.reflect.GeneratedMethodAccessor'
+          function*
+            u'invoke'
diff --git a/tests/sentry/grouping/snapshots/test_variants/test_event_hash_variant/newstyle:2019_04_17/frame_ignores_sun_java_generated_methods.pysnap b/tests/sentry/grouping/snapshots/test_variants/test_event_hash_variant/newstyle:2019_04_17/frame_ignores_sun_java_generated_methods.pysnap
--- a/tests/sentry/grouping/snapshots/test_variants/test_event_hash_variant/newstyle:2019_04_17/frame_ignores_sun_java_generated_methods.pysnap
+++ b/tests/sentry/grouping/snapshots/test_variants/test_event_hash_variant/newstyle:2019_04_17/frame_ignores_sun_java_generated_methods.pysnap
@@ -1,5 +1,5 @@
 ---
-created: '2019-04-17T20:07:50.420285Z'
+created: '2019-05-21T19:16:12.157909Z'
 creator: sentry
 source: tests/sentry/grouping/test_variants.py
 ---
@@ -13,9 +13,14 @@ app:
             'sun.reflect.GeneratedMethodAccessor'
           function*
             u'invoke'
+        frame (non app frame)
+          module* (removed reflection marker)
+            'jdk.internal.reflect.GeneratedMethodAccessor'
+          function*
+            u'invoke'
 --------------------------------------------------------------------------
 system:
-  hash: 'df0a8233b314c542a0b98a4e8865c7b5'
+  hash: '9bc326575875422d0d4ced3c35d9f916'
   component:
     system*
       stacktrace*
@@ -24,3 +29,8 @@ system:
             'sun.reflect.GeneratedMethodAccessor'
           function*
             u'invoke'
+        frame*
+          module* (removed reflection marker)
+            'jdk.internal.reflect.GeneratedMethodAccessor'
+          function*
+            u'invoke'
diff --git a/tests/sentry/grouping/snapshots/test_variants/test_event_hash_variant/newstyle:2019_05_08/frame_ignores_sun_java_generated_methods.pysnap b/tests/sentry/grouping/snapshots/test_variants/test_event_hash_variant/newstyle:2019_05_08/frame_ignores_sun_java_generated_methods.pysnap
--- a/tests/sentry/grouping/snapshots/test_variants/test_event_hash_variant/newstyle:2019_05_08/frame_ignores_sun_java_generated_methods.pysnap
+++ b/tests/sentry/grouping/snapshots/test_variants/test_event_hash_variant/newstyle:2019_05_08/frame_ignores_sun_java_generated_methods.pysnap
@@ -1,5 +1,5 @@
 ---
-created: '2019-05-08T07:29:42.288933Z'
+created: '2019-05-21T19:16:13.403893Z'
 creator: sentry
 source: tests/sentry/grouping/test_variants.py
 ---
@@ -13,9 +13,14 @@ app:
             'sun.reflect.GeneratedMethodAccessor'
           function*
             u'invoke'
+        frame (non app frame)
+          module* (removed reflection marker)
+            'jdk.internal.reflect.GeneratedMethodAccessor'
+          function*
+            u'invoke'
 --------------------------------------------------------------------------
 system:
-  hash: 'df0a8233b314c542a0b98a4e8865c7b5'
+  hash: '9bc326575875422d0d4ced3c35d9f916'
   component:
     system*
       stacktrace*
@@ -24,3 +29,8 @@ system:
             'sun.reflect.GeneratedMethodAccessor'
           function*
             u'invoke'
+        frame*
+          module* (removed reflection marker)
+            'jdk.internal.reflect.GeneratedMethodAccessor'
+          function*
+            u'invoke'