I recently came across the term "Bytecode manipulation" (what made to look into this, by chance I saw bytecode provider while seeing the logs in an application which used Hibernate) . I also know (a bit) about Java Reflection API.
Are these two concepts similar? What are the difference between them? When to use which?
Reflection API allows you to access the information about the members (fields, methods, interfaces, e.t.c.) of classes which are already loaded to the JVM. This API doesn't allow to modify the behaviour of the class except for some basic stuff like calling private methods.
Some examples where Reflection API is applicable
ByteCode manipulation on the contrary allows you to make any changes you want either to some .class files on your disk or also to the classes which are already loaded to the JVM using Java Agent API
A few examples where bytecode manipulations are applicable:
Here's how it might look