@dzaima i recommend reading the jvm spec. it's unusually well written for something in the java ecosystem (guy steele was involved in the early editions!). the
bcel library used to be the most popular way to generate bytecode, but things might have changed in the last decades. (unfortunately bcel wasn't available when i started, it appeared later, so i'm not very familiar with it)