{"action":"created","issue":{"url":"https://api.github.com/repos/cglib/cglib/issues/75","repository_url":"https://api.github.com/repos/cglib/cglib","labels_url":"https://api.github.com/repos/cglib/cglib/issues/75/labels{/name}","comments_url":"https://api.github.com/repos/cglib/cglib/issues/75/comments","events_url":"https://api.github.com/repos/cglib/cglib/issues/75/events","html_url":"https://github.com/cglib/cglib/issues/75","id":160357706,"number":75,"title":"Cache related issue with class definitions","user":{"login":"martin-g","id":232002,"avatar_url":"https://avatars.githubusercontent.com/u/232002?v=3","gravatar_id":"","url":"https://api.github.com/users/martin-g","html_url":"https://github.com/martin-g","followers_url":"https://api.github.com/users/martin-g/followers","following_url":"https://api.github.com/users/martin-g/following{/other_user}","gists_url":"https://api.github.com/users/martin-g/gists{/gist_id}","starred_url":"https://api.github.com/users/martin-g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martin-g/subscriptions","organizations_url":"https://api.github.com/users/martin-g/orgs","repos_url":"https://api.github.com/users/martin-g/repos","events_url":"https://api.github.com/users/martin-g/events{/privacy}","received_events_url":"https://api.github.com/users/martin-g/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":39,"created_at":"2016-06-15T07:41:46Z","updated_at":"2016-06-16T06:30:13Z","closed_at":null,"body":"Hi,\r\n\r\nSince CGLIB 3.2.1+ (including 3.2.3) I experience the following error:\r\n\r\n```\r\nnet.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null\r\n\tat net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:332)\r\n\tat net.sf.cglib.proxy.Enhancer.generate(Enhancer.java:445)\r\n\tat net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:85)\r\n\tat net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:83)\r\n\tat net.sf.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54)\r\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\r\n\tat net.sf.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)\r\n\tat net.sf.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)\r\n\tat net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:108)\r\n\tat net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:282)\r\n\tat net.sf.cglib.proxy.Enhancer.nextInstance(Enhancer.java:643)\r\n\tat net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:286)\r\n\tat net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:433)\r\n\tat net.sf.cglib.proxy.Enhancer.create(Enhancer.java:304)\r\n\tat org.apache.wicket.jmx.Initializer.createProxy(Initializer.java:295)\r\n\tat org.apache.wicket.jmx.Initializer.register(Initializer.java:249)\r\n\tat org.apache.wicket.jmx.Initializer.init(Initializer.java:192)\r\n\tat org.apache.wicket.Application.initInitializers(Application.java:568)\r\n\tat org.apache.wicket.Application.initApplication(Application.java:776)\r\n\tat org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:431)\r\n\tat org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:355)\r\n\tat org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:137)\r\n\tat org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:856)\r\n\tat org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:346)\r\n\tat org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1380)\r\n\tat org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1342)\r\n\tat org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:772)\r\n\tat org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:259)\r\n\tat org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:518)\r\n\tat org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)\r\n\tat org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)\r\n\tat org.eclipse.jetty.server.Server.start(Server.java:405)\r\n\tat org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:106)\r\n\tat org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)\r\n\tat org.eclipse.jetty.server.Server.doStart(Server.java:372)\r\n\tat org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)\r\n\tat org.apache.wicket.examples.StartExamples.main(StartExamples.java:110)\r\nCaused by: java.lang.reflect.InvocationTargetException\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:498)\r\n\tat net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:409)\r\n\tat net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:323)\r\n\t... 36 more\r\nCaused by: java.lang.LinkageError: loader (instance of  org/eclipse/jetty/webapp/WebAppClassLoader): attempted  duplicate class definition for name: \"org/apache/wicket/jmx/Application\"\r\n\tat java.lang.ClassLoader.defineClass1(Native Method)\r\n\tat java.lang.ClassLoader.defineClass(ClassLoader.java:763)\r\n\t... 42 more\r\n```\r\n\r\nThere is no such error with 3.2.0.\r\nThe CGLIB related code that is involved is https://github.com/apache/wicket/blob/7973959f169a1c44c1de18a6acde21c8b926d64c/wicket-jmx/src/main/java/org/apache/wicket/jmx/Initializer.java#L256-L294\r\n\r\nAny idea what could be the reason ?"},"comment":{"url":"https://api.github.com/repos/cglib/cglib/issues/comments/226399345","html_url":"https://github.com/cglib/cglib/issues/75#issuecomment-226399345","issue_url":"https://api.github.com/repos/cglib/cglib/issues/75","id":226399345,"user":{"login":"vlsi","id":213894,"avatar_url":"https://avatars.githubusercontent.com/u/213894?v=3","gravatar_id":"","url":"https://api.github.com/users/vlsi","html_url":"https://github.com/vlsi","followers_url":"https://api.github.com/users/vlsi/followers","following_url":"https://api.github.com/users/vlsi/following{/other_user}","gists_url":"https://api.github.com/users/vlsi/gists{/gist_id}","starred_url":"https://api.github.com/users/vlsi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vlsi/subscriptions","organizations_url":"https://api.github.com/users/vlsi/orgs","repos_url":"https://api.github.com/users/vlsi/repos","events_url":"https://api.github.com/users/vlsi/events{/privacy}","received_events_url":"https://api.github.com/users/vlsi/received_events","type":"User","site_admin":false},"created_at":"2016-06-16T06:30:13Z","updated_at":"2016-06-16T06:30:13Z","body":">so the first generated instance would be the factory for creating every next instance.\r\n\r\nThis behavior was reverted here:  https://github.com/cglib/cglib/commit/880f7b3cbe40c0a069e5bf03f630ae4f2f57bd2a#diff-13ef5fff6889a608d911b20abda8e76fL220.\r\n\r\nStoring a stateful proxy object in cglib cache might introduce memory leaks (e.g. unwanted strong references to callbacks, etc). In my point of view that was the driver to remove `firstInstance` cache.\r\n\r\nThat was the main driver to \"always generate factory class\".\r\n\r\n> forcing 2 code-gen'd classes for each Enhanced class seems bad to me\r\n\r\nWhat is bad? Can you elaborate?\r\nIf cglib manages to `defineClass` for proxy-class, then it will almost likely to succeed loading a factory class.\r\n\r\nFor one-use proxy class performance does not matter. For hot-used proxy classes, factory speeds up execution dramatically.\r\n\r\nWe can explore `MethodHandle` way of instantiating, however that is not available on older JVMs.\r\n\r\nEven if reflection is used for instantiation, it will end up generating accessor class by the JVM itself. Hot reflection objects are generated into classes, thus the number of classes would still be \"at least 2 per proxy class\"."}}
{"actor":{"display_login":"vlsi"}}