{"action":"opened","issue":{"url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/828","labels_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/828/labels{/name}","comments_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/828/comments","events_url":"https://api.github.com/repos/SpongePowered/SpongeAPI/issues/828/events","html_url":"https://github.com/SpongePowered/SpongeAPI/issues/828","id":104133159,"number":828,"title":"Lambda events? (no reflection event calls)","user":{"login":"Soren025","id":3269850,"avatar_url":"https://avatars.githubusercontent.com/u/3269850?v=3","gravatar_id":"","url":"https://api.github.com/users/Soren025","html_url":"https://github.com/Soren025","followers_url":"https://api.github.com/users/Soren025/followers","following_url":"https://api.github.com/users/Soren025/following{/other_user}","gists_url":"https://api.github.com/users/Soren025/gists{/gist_id}","starred_url":"https://api.github.com/users/Soren025/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Soren025/subscriptions","organizations_url":"https://api.github.com/users/Soren025/orgs","repos_url":"https://api.github.com/users/Soren025/repos","events_url":"https://api.github.com/users/Soren025/events{/privacy}","received_events_url":"https://api.github.com/users/Soren025/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-31T20:57:56Z","updated_at":"2015-08-31T20:57:56Z","closed_at":null,"body":"First off this isn't really java 8 specific but the idea came to me when the Java 8 announcement was made.\r\n\r\nEvent's as they are now if I am not mistaken get the method through reflection and call the method through reflection. Something I thought about was instead a method, declare a field of a functional interface (EventHandler<T> just so happens to work) like so\r\n\r\n```Java\r\npublic class Listener {\r\n    \r\n    @Subscribe\r\n    public final EventHandler<PlayerJoinEvent> onPlayerJoin = (event) -> { };\r\n}\r\n```\r\n\r\nor even\r\n```Java\r\npublic class Listener {\r\n    \r\n    @Subscribe\r\n    public final EventHandler<PlayerJoinEvent> onPlayerJoin = this::actualOnPlayerJoin;\r\n\r\n    // This method could be a static method in some utility store of listener implementations\r\n    private void actualOnPlayerJoin(PlayerJoinEvent event) {\r\n\r\n    }\r\n}\r\n```\r\n\r\nThe idea is you reflect the field when registering the listener so when the event is called, it calls the stored event handler interface as a direct call instead of calling a method through reflection.\r\n\r\nThe one thing however is this would require the use of https://github.com/jhalterman/typetools, a lib that is able to resolve generic types at runtime under certain cases, a declared lambda as shown above is one of such cases (tested it with reflected field and works)."}}