{"action":"created","issue":{"url":"https://api.github.com/repos/raphw/byte-buddy/issues/19","labels_url":"https://api.github.com/repos/raphw/byte-buddy/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/raphw/byte-buddy/issues/19/comments","events_url":"https://api.github.com/repos/raphw/byte-buddy/issues/19/events","html_url":"https://github.com/raphw/byte-buddy/issues/19","id":54769616,"number":19,"title":"Can I create an abstract class with byte buddy?","user":{"login":"uvwild","id":825210,"avatar_url":"https://avatars.githubusercontent.com/u/825210?v=3","gravatar_id":"","url":"https://api.github.com/users/uvwild","html_url":"https://github.com/uvwild","followers_url":"https://api.github.com/users/uvwild/followers","following_url":"https://api.github.com/users/uvwild/following{/other_user}","gists_url":"https://api.github.com/users/uvwild/gists{/gist_id}","starred_url":"https://api.github.com/users/uvwild/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uvwild/subscriptions","organizations_url":"https://api.github.com/users/uvwild/orgs","repos_url":"https://api.github.com/users/uvwild/repos","events_url":"https://api.github.com/users/uvwild/events{/privacy}","received_events_url":"https://api.github.com/users/uvwild/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/raphw/byte-buddy/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/raphw/byte-buddy/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":{"login":"raphw","id":4489328,"avatar_url":"https://avatars.githubusercontent.com/u/4489328?v=3","gravatar_id":"","url":"https://api.github.com/users/raphw","html_url":"https://github.com/raphw","followers_url":"https://api.github.com/users/raphw/followers","following_url":"https://api.github.com/users/raphw/following{/other_user}","gists_url":"https://api.github.com/users/raphw/gists{/gist_id}","starred_url":"https://api.github.com/users/raphw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raphw/subscriptions","organizations_url":"https://api.github.com/users/raphw/orgs","repos_url":"https://api.github.com/users/raphw/repos","events_url":"https://api.github.com/users/raphw/events{/privacy}","received_events_url":"https://api.github.com/users/raphw/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/raphw/byte-buddy/milestones/7","labels_url":"https://api.github.com/repos/raphw/byte-buddy/milestones/7/labels","id":942212,"number":7,"title":"0.5.3","description":null,"creator":{"login":"raphw","id":4489328,"avatar_url":"https://avatars.githubusercontent.com/u/4489328?v=3","gravatar_id":"","url":"https://api.github.com/users/raphw","html_url":"https://github.com/raphw","followers_url":"https://api.github.com/users/raphw/followers","following_url":"https://api.github.com/users/raphw/following{/other_user}","gists_url":"https://api.github.com/users/raphw/gists{/gist_id}","starred_url":"https://api.github.com/users/raphw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raphw/subscriptions","organizations_url":"https://api.github.com/users/raphw/orgs","repos_url":"https://api.github.com/users/raphw/repos","events_url":"https://api.github.com/users/raphw/events{/privacy}","received_events_url":"https://api.github.com/users/raphw/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":1,"state":"open","created_at":"2015-01-19T17:18:30Z","updated_at":"2015-02-09T09:16:38Z","due_on":null,"closed_at":null},"comments":6,"created_at":"2015-01-19T14:22:32Z","updated_at":"2015-02-09T09:16:38Z","closed_at":"2015-02-09T09:16:38Z","body":"I need to create some abstract  Mixin classes for a package of our framework persistent objects so I can use the jackson framework to serialize them. Are there any examples about how to create an abstract class so I can reference it in the JacksonObjectMapper as a Mixin Class?\r\n`objectMapper.addMixInAnnotations(POJO.class, POJOMixin.class);`\r\n\r\nOr am I screwed due to classloader issues?\r\nSample Class:\r\n\r\n    public abstract class JacksonItemMixin {\r\n        @JsonCreator\r\n        protected JacksonItemMixin(@JsonProperty(\"objId\") final Long objId) {\r\n        }\r\n    }\r\n\r\nThe code I have so far:\r\n\r\n            Annotation methodAnnotation = JacksonItemMixin.class.getDeclaredConstructor(Long.class).getAnnotation(JsonCreator.class);\r\n            Annotation parameterAnnotation = JacksonItemMixin.class.getDeclaredConstructor(Long.class).getParameterAnnotations()[0][0];\r\n            Class<?> dynamicType = new ByteBuddy().withModifiers(TypeManifestation.ABSTRACT)\r\n                                                  .subclass(Object.class, ConstructorStrategy.Default.NO_CONSTRUCTORS)\r\n                                                  .name(declaringClass.getCanonicalName().concat(\"MixIn\"))\r\n                                                  .defineConstructor(Arrays.<Class<?>>asList(Long.class), Visibility.PROTECTED)\r\n                                                  .withoutCode()\r\n                                                  .annotateMethod(methodAnnotation)\r\n                                                  .annotateParameter(0, parameterAnnotation)\r\n                                                  .make()\r\n                                                  .load(getClass().getClassLoader(), ClassLoadingStrategy.Default.INJECTION)\r\n                                                  .getLoaded();\r\n            dynamicType.newInstance();\r\n        } catch (NoSuchMethodException e) {\r\n            e.printStackTrace();\r\n            assert (false);\r\n        } catch (InstantiationException e) {\r\n            e.printStackTrace();\r\n            assert (true);\r\n        } catch (IllegalAccessException e) {\r\n            e.printStackTrace();\r\n            assert (false);\r\n        }\r\n\r\nHowever this thows this Exception:\r\n\r\n    java.lang.IllegalStateException: Exception on invoking loader method\r\n    \tat    net.bytebuddy.dynamic.loading.ClassLoaderByteArrayInjector.inject(ClassLoaderByteArrayInjector.java:142)\r\n\tat net.bytebuddy.dynamic.loading.ClassLoaderByteArrayInjector.inject(ClassLoaderByteArrayInjector.java:107)\r\n\tat net.bytebuddy.dynamic.ClassLoadingStrategy$Default$5.load(ClassLoadingStrategy.java:144)\r\n\tat net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:2944)\r\n\tat de.idealo.core.factory.CachingItemFactoryTest.createMixinFor(CachingItemFactoryTest.java:293)\r\n\tat de.idealo.core.factory.CachingItemFactoryTest.testClassScanning(CachingItemFactoryTest.java:277)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)\r\n\tat org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)\r\n\tat org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)\r\n\tat org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)\r\n\tat org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)\r\n\tat org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)\r\n\tat org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)\r\n\tat org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)\r\n\tat org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)\r\n\tat org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)\r\n\tat org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)\r\n\tat org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)\r\n\tat org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)\r\n\tat org.junit.runners.ParentRunner.run(ParentRunner.java:363)\r\n\tat org.junit.runner.JUnitCore.run(JUnitCore.java:137)\r\n\tat com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)\r\n\tat com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)\r\n\tat com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)\r\n\tat com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)\r\nCaused by: java.lang.ClassFormatError: Method <init> in class de/pinuts/core/CatalogItemMixIn has illegal modifiers: 0x404\r\n\tat java.lang.ClassLoader.defineClass1(Native Method)\r\n\tat java.lang.ClassLoader.defineClass(ClassLoader.java:800)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat net.bytebuddy.dynamic.loading.ClassLoaderByteArrayInjector$ClassLoadingAction.run(ClassLoaderByteArrayInjector.java:320)\r\n\tat net.bytebuddy.dynamic.loading.ClassLoaderByteArrayInjector$ClassLoadingAction.run(ClassLoaderByteArrayInjector.java:290)\r\n\tat java.security.AccessController.doPrivileged(Native Method)\r\n\tat net.bytebuddy.dynamic.loading.ClassLoaderByteArrayInjector.inject(ClassLoaderByteArrayInjector.java:127)\r\n\t... 32 more\r\n`"},"comment":{"url":"https://api.github.com/repos/raphw/byte-buddy/issues/comments/73477831","html_url":"https://github.com/raphw/byte-buddy/issues/19#issuecomment-73477831","issue_url":"https://api.github.com/repos/raphw/byte-buddy/issues/19","id":73477831,"user":{"login":"raphw","id":4489328,"avatar_url":"https://avatars.githubusercontent.com/u/4489328?v=3","gravatar_id":"","url":"https://api.github.com/users/raphw","html_url":"https://github.com/raphw","followers_url":"https://api.github.com/users/raphw/followers","following_url":"https://api.github.com/users/raphw/following{/other_user}","gists_url":"https://api.github.com/users/raphw/gists{/gist_id}","starred_url":"https://api.github.com/users/raphw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raphw/subscriptions","organizations_url":"https://api.github.com/users/raphw/orgs","repos_url":"https://api.github.com/users/raphw/repos","events_url":"https://api.github.com/users/raphw/events{/privacy}","received_events_url":"https://api.github.com/users/raphw/received_events","type":"User","site_admin":false},"created_at":"2015-02-09T09:16:38Z","updated_at":"2015-02-09T09:16:38Z","body":"I implemented a `MethodCall` instrumentation that is included in the next version of Byte Buddy. You can then create the instrumentation by:\r\n\r\n```java\r\nMethodCall.invoke(Object.class.getDeclaredConstructor())\r\n```\r\n\r\nThis instrumentation also allows you to hand over parameters if you wanted to call a constructor that takes parameters."}}