Bypass method access checks for event handlers

This commit is contained in:
Kai S. K. Engelbart 2020-09-07 10:38:38 +02:00
parent 70bcfd5125
commit f407021cea
Signed by: kske
GPG Key ID: 8BEB13EC5DF7EF13
2 changed files with 3 additions and 2 deletions

View File

@ -27,6 +27,7 @@ final class EventHandler implements Comparable<EventHandler> {
this.listener = listener; this.listener = listener;
this.method = method; this.method = method;
this.annotation = annotation; this.annotation = annotation;
method.setAccessible(true);
} }
/** /**

View File

@ -26,13 +26,13 @@ class EventBusTest implements EventListener {
} }
@Event(priority = 50) @Event(priority = 50)
public void onSimpleEventSecond(SimpleEvent event) { private void onSimpleEventSecond(SimpleEvent event) {
++hits; ++hits;
assertEquals(2, hits); assertEquals(2, hits);
} }
@Event(priority = 150) @Event(priority = 150)
public void onSimpleEventFirst(SimpleEvent event) { private void onSimpleEventFirst(SimpleEvent event) {
++hits; ++hits;
assertEquals(1, hits); assertEquals(1, hits);
} }