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
6
votes
3 answers

Spring: Is CGLIB required for injection of a concrete class using @Resource

I have configured Spring 3.0.6 with AspectJ LTW using spring-instrument.jar and: When removing CGLIB from…
Mohsen
  • 3,512
  • 3
  • 38
  • 66
6
votes
1 answer

What are the drawbacks of CGLIB proxy over dynamic proxy in Spring AOP?

As I understand it, Spring AOP generally involves: dynamic proxy for interfaces CGLIB proxy for those without (except for final methods and classes) Why not just use CGLIB proxy all the time? I would expect the following gains: Since its done…
6
votes
1 answer

Self-invocation behaviour in @Configuration vs. @Component classes

My question is about AOP Spring behaviour in case of internal method calls. @Service class Service { @Transactional public void method1() { method2(); } @Transactional public void method2() {} } If we call method1()…
xmen-5
  • 1,806
  • 1
  • 23
  • 44
6
votes
1 answer

Set JVM option for avoid error Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1

I use Spring Boot 2.0.0.RC1, JDK 9.0.4, IntelliJ IDEA 2017.3.4 Ultimate, Gradle 4.5.1 . Spring Boot RC1 version (strictly, Spring Framework 5.0.3.RELEASE) has a known issue: https://jira.spring.io/browse/SPR-15859 , I also see it at here…
Vy Do
  • 46,709
  • 59
  • 215
  • 313
6
votes
2 answers

Create DEEP immutable object in runtime

I need to create immutable copy of an object in runtime with Java. I made use of org.springframework.cglib.beans.ImmutableBean, which can create immutable copy of an object using CGLIB. But the problem is that it provides "first-level"…
Dmytro Titov
  • 2,802
  • 6
  • 38
  • 60
6
votes
1 answer

Javassist failure in hibernate: invalid constant type: 60

I'm creating a cli tool to manage an existing application. Both the application and the tests build fine and run fine but despite that I receive a javassist failure when running my cli tool that exists within the jar: INFO: Bytecode provider name :…
Kaleb Pederson
  • 45,767
  • 19
  • 102
  • 147
6
votes
5 answers

Call method by its name stored in string without reflection API?

I know, using Reflection API, we can call methods by their name stored in a string. But, Reflection API cannot be used in a high performance application. In my application, methods will be invoked at very high rate. So, I cannot use Reflection…
Akshat
  • 720
  • 9
  • 24
6
votes
3 answers

How to force Hibernate 3.3 or 3.5 to use CGLib instead of Javassist?

Is it still possible to force Hibernate 3.3 or 3.5 to use CGLib instead of Javassist? In my properties file, I set hibernate.bytecode.provider = cglib But this doesn't seem to do it. Any thoughts?
mshafrir
  • 5,190
  • 12
  • 43
  • 56
6
votes
3 answers

Serializing a proxy class to file

I have a proxy (generated either as a JDKProxy or a CGLIB one) that is generated at runtime in the JVM. I wanted to know if there is a way to write the contents of this class (which looks like com.sun.proxy$Proxy123.class) to a file so that I may…
Kilokahn
  • 2,281
  • 1
  • 25
  • 50
5
votes
1 answer

How to intercept object creation in Java

I have a little weird requirement.I guess. I'd like to use a custom Proxy I created to decorate all object that implements an specific interface, but I need this to be transparent to the code itself. Something that could be included in the build…
PedroSena
  • 645
  • 6
  • 14
5
votes
5 answers

Java Annotation and Processor to mark a method as so it can be called once and only once?

I need to be able to mark methods so that they throw a RuntimeException if they are called more than once. I am trying to enforce some single assignment semantics and the number of parameters to my class is too large to put in a single constructor…
user177800
5
votes
1 answer

How is the Java Service Provide API supposed to work?

It seems like everybody has had an unpleasant brush with the Java Service Provider, that thing you can do with a file named like META-INF/services/com.example.Interface, but that nobody uses except for trying to load the right XML parser. I'm…
jonathan-stafford
  • 11,647
  • 1
  • 17
  • 11
5
votes
2 answers

Same class invoke NOT effective in Spring AOP cglib

Suppose we have following class @Service class MyClass { public void testA() { testB(); } @Transactional public void testB() { ... } } Now, if we invoke myClass.testA(); in test, then @Transactional on testB will not…
zchen
  • 109
  • 2
  • 7
5
votes
0 answers

spring boot + spring security

A web project that uses the Spring MVC framework is transformed into a springboot project,when I start the project, some custom filter class in the springsecurity XMLconfiguration file is initialized with some error. 2016-12-20 13:31:20.246 INFO…
Quitterie
  • 51
  • 3
5
votes
1 answer

difference between javaassist and cglib

I learning hibernate and I understood that hibernate has stopped using cglib and switched to javaassist. I also understood that javaassist and cglib are used for proxy generation. so I was wondering how these two works and which one is better? What…
user3359405
  • 79
  • 1
  • 3