Questions tagged [cglib]

CGLib (Code Generation Library) is a run time code generation library for the Java platform licensed under the Apache 2.0 license.

CGLib (Code Generation Library) is mainly used the generation of class proxies. This is achieved by creating subclasses at run time where method invocations are intercepted by user defined methods. Additionally, cglib offers different extension such as for example bean utilities. cglib is built on top of ASM.

Alternative code generation libraries for the JVM that are still under active development are:

401 questions
14
votes
5 answers

Slow to start after upgraded to Spring 3

I use Struts2 and my application has thousands of action classes managed by Spring. I used Spring 2.5.6 before and my application starts quickly. But when I changed Spring to 3.0. I got a extremely slow start up of Tomcat. For each action class, I…
Matt
  • 1,671
  • 5
  • 23
  • 34
13
votes
3 answers

How can I create a dynamic proxy in java that retains parameter annotations on methods?

I currently am trying to proxy some existing JAX/RS resources, in order to allow me to use the Hibernate Validator's method validation support. However, when I proxy my class (currently using cglib 2.2), the FormParam annotation is not present on…
Peter Hart
  • 4,955
  • 2
  • 25
  • 30
13
votes
1 answer

Using Groovy on Android

With the advent of ASMDEX (ASM for dex files) and dexmaker, shouldn't it be possible to port Groovy to Android? Both frameworks allow the generation of dex bytecode at runtime. As I understand it, it is impossible to modify dex classes from the APK…
Dirk Jäckel
  • 2,979
  • 3
  • 29
  • 47
11
votes
2 answers

If reflection in Java slows down execution by orders, why do so many frameworks use it ?

As per my understanding, use of Java reflection API slows down code execution by orders. But then I see it being used in so many places in Java universe. To name a few : Annotations Spring framework (AOP) Hibernate MyBatis Which implies that…
Amit Sharma
  • 5,844
  • 5
  • 25
  • 34
10
votes
1 answer

Spring + lombok + @SneakyThrows

I'm using @SneakyThrows Lombok feature in my SpringBoot project. I have problems with this feature when CGLIB proxies implementation it throws java.lang.Exception: Unexpected exception, expected but…
Volodymyr Roman
  • 101
  • 1
  • 5
10
votes
3 answers

How to prevent false positive null pointer warnings, when using CGLIB / Spring AOP?

I'm using Spring AOP and therefore indirectly CGLIB in my Spring MVC controller. Since CGLIB needs an default constructor I included one and my controller now looks like this: @Controller public class ExampleController { private final…
Tim Büthe
  • 62,884
  • 17
  • 92
  • 129
10
votes
1 answer

Spring async doesn't work when implements AsyncConfigurer

Having a Spring configuration class for async methods as: @Configuration @EnableAsync(proxyTargetClass = true) @EnableScheduling public class AsyncConfiguration { @Autowired private ApplicationContext applicationContext; @Bean public…
Ignasi
  • 5,887
  • 7
  • 45
  • 81
10
votes
1 answer

Grails 2.4.4 UNRESOLVED DEPENDENCIES cglib 2.2.2

I am trying to upgrade a project to grails version 2.4.4 but it keep failing with the following error message: :: problems summary :: :::: WARNINGS :::::::::::::::::::::::::::::::::::::::::::::: :: UNRESOLVED DEPENDENCIES …
hertog
  • 219
  • 2
  • 5
10
votes
1 answer

spring - forcing cglib proxies for @Autowired fields

I have mixed stack: EJB and Spring. For autowiring Spring to EJBs I use SpringBeanAutowiringInterceptor (not sure if that could affect the problem I have). Whlie trying to autowire beans in a following…
Peter Butkovic
  • 11,143
  • 10
  • 57
  • 81
10
votes
2 answers

CGLIB not able to intercept methods in a superclass/superinterface

May be I'm not thinking hard enough or the answer is really elusive. Quick scenario (Try the code out. It compiles). Consider a legacy interface public interface LegacyInterfaceNoCodeAvailable{ void logInfo(String message); } The consider a…
mainas
  • 754
  • 1
  • 6
  • 15
10
votes
3 answers

Java - creating a subclass dynamically

I'd like to create a subclass programatically. I guess I have few options - Javassist, CGLib, BCEL, or ASM. The use case is that one app's internals are class-oriented, and extensions are class-based. Therefore I can't have a single class as a base…
Ondra Žižka
  • 43,948
  • 41
  • 217
  • 277
10
votes
2 answers

How can I create dynamic proxy for final Class?

In short: 1. I have some final class that I want to create dynamic proxy for it. How can I do it? 2. Can I convert MethodHandle to Method? Details First of all, does exists any API to convert MethodHandle to Method? Something like in…
alexsmail
  • 5,661
  • 7
  • 37
  • 57
9
votes
2 answers

method annotations null when proxying via CGLIB

I'm experiencing a strange behaviour when looking via reflection for annotations on a method belonging to a class proxied via CGLIB. We use CGLIB in Spring, and if I annotate a method only with an annotation it works well (I'm able to retrieve the…
manub
  • 3,990
  • 2
  • 24
  • 33
9
votes
3 answers

Performance problems when using lots of AOP request scoped beans

I'm working on a semi-large application using Spring 3 and am running into performance problems when throwing hundreds of users at it at once. I'm using several request scoped beans using Spring's AOP proxy and I can see that every time I call any…
Cameron
  • 1,868
  • 3
  • 21
  • 38
9
votes
4 answers

What's the difference between Spring CGLIB and CGLIB?

Spring doesn't contains cglib dependency, both cglib and spring cglib has the Enhancer class, one is net.sf.cglib.proxy.Enhancer while the another is org.springframework.cglib.proxy, what's the difference between them?
zyl
  • 197
  • 1
  • 2
  • 12
1
2
3
26 27