{"action":"created","issue":{"url":"https://api.github.com/repos/cglib/cglib/issues/48","labels_url":"https://api.github.com/repos/cglib/cglib/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/cglib/cglib/issues/48/comments","events_url":"https://api.github.com/repos/cglib/cglib/issues/48/events","html_url":"https://github.com/cglib/cglib/issues/48","id":113822098,"number":48,"title":"VerifyError on attempt to load class generated by cglib","user":{"login":"nd","id":38202,"avatar_url":"https://avatars.githubusercontent.com/u/38202?v=3","gravatar_id":"","url":"https://api.github.com/users/nd","html_url":"https://github.com/nd","followers_url":"https://api.github.com/users/nd/followers","following_url":"https://api.github.com/users/nd/following{/other_user}","gists_url":"https://api.github.com/users/nd/gists{/gist_id}","starred_url":"https://api.github.com/users/nd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nd/subscriptions","organizations_url":"https://api.github.com/users/nd/orgs","repos_url":"https://api.github.com/users/nd/repos","events_url":"https://api.github.com/users/nd/events{/privacy}","received_events_url":"https://api.github.com/users/nd/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-28T13:34:42Z","updated_at":"2015-10-28T13:58:31Z","closed_at":null,"body":"Hi,\r\n\r\nI've got a ```VerifyError: Must call initializers using invokespecial``` during load of the class generated by cglib. It seems like cglib doesn't handle the case when bridge methods generated by javac contain arbitrary code. In my project I use @NotNull annotation by jetbrains which adds check if the returned value is null and throw an exception in this case. It adds this code both to original method and to bridge method generated by javac. The generated byte code looks like this:\r\n\r\n```\r\n  public java.lang.Object getValue();\r\n    descriptor: ()Ljava/lang/Object;\r\n    flags: ACC_PUBLIC, ACC_BRIDGE, ACC_SYNTHETIC\r\n    Code:\r\n      stack=8, locals=1, args_size=1\r\n         0: aload_0\r\n         1: invokevirtual #43                 // Method getValue:()Ljava/lang/String;\r\n         4: dup\r\n         5: ifnonnull     38\r\n         8: new           #25                 // class java/lang/IllegalStateException\r\n        11: dup\r\n        12: ldc           #27                 // String @NotNull method %s.%s must not return null\r\n        14: ldc           #28                 // int 2\r\n        16: anewarray     #4                  // class java/lang/Object\r\n        19: dup\r\n        20: ldc           #29                 // int 0\r\n        22: ldc           #30                 // String TestImpl\r\n        24: aastore\r\n        25: dup\r\n        26: ldc           #31                 // int 1\r\n        28: ldc           #32                 // String getValue\r\n        30: aastore\r\n        31: invokestatic  #38                 // Method java/lang/String.format:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;\r\n        34: invokespecial #40                 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\r\n        37: athrow\r\n        38: areturn\r\n      LocalVariableTable:\r\n        Start  Length  Slot  Name   Signature\r\n            0      39     0  this   LTestImpl;\r\n      LineNumberTable:\r\n        line 4: 0\r\n      StackMapTable: number_of_entries = 1\r\n        frame_type = 102 /* same_locals_1_stack_item */\r\n          stack = [ class java/lang/String ]\r\n    RuntimeInvisibleAnnotations:\r\n      0: #23()\r\n```\r\n\r\nThe [BridgeMethodResolver code](https://github.com/cglib/cglib/blob/master/cglib/src/main/java/net/sf/cglib/proxy/BridgeMethodResolver.java#L93) is triggered by ```34: invokespecial #40``` as a result in generated code by cglib invokestatic is replaced by invokevirtual which results in VerifyError.\r\n"},"comment":{"url":"https://api.github.com/repos/cglib/cglib/issues/comments/151853963","html_url":"https://github.com/cglib/cglib/issues/48#issuecomment-151853963","issue_url":"https://api.github.com/repos/cglib/cglib/issues/48","id":151853963,"user":{"login":"sameb","id":2145042,"avatar_url":"https://avatars.githubusercontent.com/u/2145042?v=3","gravatar_id":"","url":"https://api.github.com/users/sameb","html_url":"https://github.com/sameb","followers_url":"https://api.github.com/users/sameb/followers","following_url":"https://api.github.com/users/sameb/following{/other_user}","gists_url":"https://api.github.com/users/sameb/gists{/gist_id}","starred_url":"https://api.github.com/users/sameb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sameb/subscriptions","organizations_url":"https://api.github.com/users/sameb/orgs","repos_url":"https://api.github.com/users/sameb/repos","events_url":"https://api.github.com/users/sameb/events{/privacy}","received_events_url":"https://api.github.com/users/sameb/received_events","type":"User","site_admin":false},"created_at":"2015-10-28T13:58:31Z","updated_at":"2015-10-28T13:58:31Z","body":"Patches gladly accepted."}}