{"action":"created","issue":{"url":"https://api.github.com/repos/qos-ch/slf4j/issues/115","labels_url":"https://api.github.com/repos/qos-ch/slf4j/issues/115/labels{/name}","comments_url":"https://api.github.com/repos/qos-ch/slf4j/issues/115/comments","events_url":"https://api.github.com/repos/qos-ch/slf4j/issues/115/events","html_url":"https://github.com/qos-ch/slf4j/pull/115","id":70972418,"number":115,"title":"Allow the logger name mismatch detector to work even if security manager creation is disabled.","user":{"login":"adorokhine","id":2999402,"avatar_url":"https://avatars.githubusercontent.com/u/2999402?v=3","gravatar_id":"","url":"https://api.github.com/users/adorokhine","html_url":"https://github.com/adorokhine","followers_url":"https://api.github.com/users/adorokhine/followers","following_url":"https://api.github.com/users/adorokhine/following{/other_user}","gists_url":"https://api.github.com/users/adorokhine/gists{/gist_id}","starred_url":"https://api.github.com/users/adorokhine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adorokhine/subscriptions","organizations_url":"https://api.github.com/users/adorokhine/orgs","repos_url":"https://api.github.com/users/adorokhine/repos","events_url":"https://api.github.com/users/adorokhine/events{/privacy}","received_events_url":"https://api.github.com/users/adorokhine/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-25T21:51:40Z","updated_at":"2015-04-25T22:09:15Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/qos-ch/slf4j/pulls/115","html_url":"https://github.com/qos-ch/slf4j/pull/115","diff_url":"https://github.com/qos-ch/slf4j/pull/115.diff","patch_url":"https://github.com/qos-ch/slf4j/pull/115.patch"},"body":"Implemented by falling back to slower exception-based method if this happens.\r\n\r\nFixes bug SLF4J-324."},"comment":{"url":"https://api.github.com/repos/qos-ch/slf4j/issues/comments/96286437","html_url":"https://github.com/qos-ch/slf4j/pull/115#issuecomment-96286437","issue_url":"https://api.github.com/repos/qos-ch/slf4j/issues/115","id":96286437,"user":{"login":"adorokhine","id":2999402,"avatar_url":"https://avatars.githubusercontent.com/u/2999402?v=3","gravatar_id":"","url":"https://api.github.com/users/adorokhine","html_url":"https://github.com/adorokhine","followers_url":"https://api.github.com/users/adorokhine/followers","following_url":"https://api.github.com/users/adorokhine/following{/other_user}","gists_url":"https://api.github.com/users/adorokhine/gists{/gist_id}","starred_url":"https://api.github.com/users/adorokhine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adorokhine/subscriptions","organizations_url":"https://api.github.com/users/adorokhine/orgs","repos_url":"https://api.github.com/users/adorokhine/repos","events_url":"https://api.github.com/users/adorokhine/events{/privacy}","received_events_url":"https://api.github.com/users/adorokhine/received_events","type":"User","site_admin":false},"created_at":"2015-04-25T22:09:15Z","updated_at":"2015-04-25T22:09:15Z","body":"@mattbishop @ceki \r\n\r\nI don't think there's any other efficient way to get a backtrace if we can't construct a SecurityManager.\r\n\r\nFundamentally, all we need is to call SecurityManager#getClassContext, but we can't do that without constructing a class in SecurityManager's inheritance hierarchy because it's protected. SecurityManager construction might be disabled by an existing SecurityManager:\r\nhttp://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/lang/SecurityManager.java#299\r\n\r\nUnder the hood, SecurityManager simply calls JVM_GetClassContext in JNI:\r\nhttps://code.openhub.net/file?fid=DvdXh1aTTWSBu1zKlsh5SA_JEnQ&cid=9CbxgfzUr7o&s=JVM_GetClassContext&fp=309993&mp,=1&ml=1&me=1&md=1&projSelected=true#L77\r\n\r\nBut there's no other public callers of that function in hotspot, and I definitely don't want to start adding JNI to slf4j.\r\n\r\nThe functionality of getting the class of the caller is directly implemented in sun.reflection.Reflection#getCallerClass:\r\nhttp://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/sun/reflect/Reflection.java#64\r\n\r\nSadly, the sun.* packages are not meant for public use and won't help us when running under other JVMs.\r\n\r\nSo I don't see any other solutions than to fall back to exception-based stack traces.\r\n\r\nTesting on my machine with a stack depth of ~17 frames and 100,000 calls, I get 12.3 microseconds per trace with the new exception implementation, and 2.2 microseconds per trace with the SecurityManager approach. I can't find any better solutions to fall back to though, so I hope this is okay."}}