Write byte code changes to class file

20 views
Skip to first unread message

Manoel Campos

unread,
Mar 2, 2025, 10:08:59 AMMar 2
to Byte Buddy
Hello everyone,

I'm creating a library using ByteBuddy that intercepts access to public attributes in JPA entity classes and replaces by respective getters/setters. The project uses byte-buddy-maven-plugin to apply the byte code changes during build time.

I added the library to a sample project and the changes in classes are applied. I can see the getters/setters being called.

However, I can't see those changes in the class files or jar files, that made me confuse. If the byte-buddy-maven-plugin makes the byte code changes during build time, I expected to see those changes in class files.

I'm wondering if somebody can explain how exactly the plugin works.

Best regards,
Manoel Campos

Vishal Pandya

unread,
Mar 2, 2025, 10:54:14 AMMar 2
to Byte Buddy
You first need to understand javaagent option in "java -javaagent" in java runtime.

Manoel Campos

unread,
Mar 2, 2025, 11:48:51 AMMar 2
to Vishal Pandya, Byte Buddy
I know what a Java agent is, and in fact, my first approach was to create one, so that the byte code manipulation happened during runtime.

But the byte buddy maven README states:

The Byte Buddy Maven Plugin enables you to apply bytecode enhancements during the build process”


This way, I would expect the class files were changed during build time.


Manoel Campos da Silva Filho, Ph.D 

Software Architect, Professor at Federal Institute of Education, Science and Technology of Tocantins - Brazil

 about.me



--
You received this message because you are subscribed to a topic in the Google Groups "Byte Buddy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/byte-buddy/diAACatb8tc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to byte-buddy+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/byte-buddy/eb0e0994-f130-4856-b47d-4d7facba70d4n%40googlegroups.com.

Vishal Pandya

unread,
Mar 2, 2025, 1:00:41 PMMar 2
to Byte Buddy
what is the plugin configuration? I believe class changes are applied at runtime only. What is the transformation applied?  People generally write reflection test in the code to check if the new/altered methods are called or not in a class.

Vishal Pandya

unread,
Mar 2, 2025, 1:02:59 PMMar 2
to Byte Buddy
In the config one can check with ClassFileLocator tag value

On Sunday, March 2, 2025 at 11:48:51 AM UTC-5 manoel...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages