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
0
votes
2 answers

How to create dynamic proxy of class with no public constructor using ByteBuddy

I want to create a dynamic proxy of class Sample which has two no public constructor, it's not working and giving the error. But if I make the constructor as Public then it works fine. Is it possible in byte buddy to achieve that? Also is it…
Hemant Singh
  • 1,487
  • 10
  • 15
0
votes
0 answers

superClass's field is null

i'm new bee about cglib , today i write some code by cglib , code show as below public class App { public static void main(String[] args) { //filed UserService userService = new UserService(); RealSubject realSubject =…
shun chen
  • 38
  • 6
0
votes
1 answer

How does CGLIB proxy String or other final classes?

I would like to ask a question regarding Lazy Fetching in Hibernate. As far as I know, in order to implement Lazy Fetching, Hibernate creates a placeholder that is a proxy of the real property. What if my entity includes a String property or other…
Pasha
  • 1,768
  • 6
  • 22
  • 43
0
votes
1 answer

How to exclude the cglib dependencies from an Android(Gradle) app?

I had an issue with using MongoDB Morphia on Android which led me to this post where there is a sugestion to "exclude the cglib dependencies" from my app. How would I do that?
eriel marimon
  • 1,230
  • 1
  • 19
  • 29
0
votes
1 answer

Can't see annotations via reflection despite RetentionPolicy being RUNTIME

I'm trying to find methods in a Spring RestController that are annotated with a given annotation. In order to see what annotations exist on methods for that RestController, I've done the following: Map beans =…
GordyB
  • 179
  • 4
  • 14
0
votes
1 answer

Are Cglib Method Interceptors created per class instance?

I have the following generic cglib method interceptor implementation: public class EntityInterceptor implements MethodInterceptor{ private EntityChangeType changeType; private T entity; private GenericCrudMapper mapper; …
BigONotation
  • 4,406
  • 5
  • 43
  • 72
0
votes
2 answers

CGLib Proxy for Integer (Final class) in Spring MVC

I need such a usage: For each request I want to inject userId into DemoController But because of being a final class without empty constructor I can not inject it. What is the best practice in such cases? A service with request scope is…
Ozgur
  • 137
  • 2
  • 16
0
votes
0 answers

How do I view target_class proxy variable properties in debug mode?

I have a class which has a custom scope, which is injected into a singleton scope object by way of the proxyMode scope setting. When debugging in STS or Eclipse I am typically able to view variables and inspect their contents, but this is not the…
Andrew Cotton
  • 415
  • 3
  • 12
0
votes
0 answers

Spring part of the Service will not be dynamic proxy, leading to the use of @Cacheable

I am using the version of SpringBooot 1.8. Using @Cacheable annotations in the Service layer does not cache the data. Through debugging, it is found that some of the Service objects in the Controller layer are proxied by cglib, but some of them are…
Licoy
  • 1
  • 2
0
votes
1 answer

Integration tests fail - autowiring issue with Grails

For whatever reason, when I try to run any integration test, I'm getting the following: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type …
Stefan Kendall
  • 66,414
  • 68
  • 253
  • 406
0
votes
2 answers

cglib - creating class proxy in OSGi results in NoClassDefFoundError

OK so this is some kind of theoretical question for you guys. I am experimenting with cglib's Enchancer - creating a proxy for a class. My code is running in a Felix OSGi container. The hierarchy looks kind of similar to that: // Bundle A; //…
mdzh
  • 1,030
  • 2
  • 17
  • 34
0
votes
1 answer

org.apache.cxf.interceptor.Fault: Could not initialize class net.sf.cglib.proxy.Enhancer

I am, via SOAPUI, converting a handful of fields into a java object, then using this information to call a webservice for a save functionality. The conversion from SOAPUI to java object seems to work fine. I can view the object in my debugger and it…
0
votes
1 answer

Javassist how to debug modified java method

use Javassist to add some code statically at the beginning of a method right after the class is compiled. For example, public String getFoo() { // add some code here return "foo"; } From Eclipse debug, I can not see the added code. Is…
eastwater
  • 4,624
  • 9
  • 49
  • 118
0
votes
1 answer

bytecode tools: add method interceptor to classes (not proxy)

Javassist proxyFactory can create proxy at runtime with method interceptor. But how to add method interceptor to a class statically by modifying the class file? For example, class Foo has 100 methods, before calling any method on an instance of Foo,…
eastwater
  • 4,624
  • 9
  • 49
  • 118
0
votes
1 answer

what is the alternative for dynamic class loading in java?

I'm using reflection to load the class at run-time but sonar rules are pointing it as vulnerability attack i'm thinking to use ByteBuddy,can bytebuddy library help me on this? ClassLoader classLoader = MyClass.class.getClassLoader(); Class
Tirumalesh
  • 95
  • 1
  • 17