Learning about Java bytecode and the JVM

前端 未结 6 488
孤独总比滥情好
孤独总比滥情好 2021-01-29 19:15

In a recent question asked recently my simple minded answer highlighted many of my misconceptions about Java, the JVM, and how the code gets compiled and run. This has created

相关标签:
6条回答
  • 2021-01-29 19:52

    Suggested reading: the JVM spec.

    You might also want to play with BCEL - there are other libraries around for manipulating bytecode, but that's probably the best known one.

    0 讨论(0)
  • 2021-01-29 19:53

    The Apache BCEL will allow you to analyse and hand craft .class files from bytecode.

    javap will allow you to disassemble existing .class files. It's particularly useful for knocking up quick test classes to understand what is really going on underneath the covers.

    0 讨论(0)
  • 2021-01-29 19:56

    Programming for the Java Virtual Machine is a good book for this topic. (Disclosure: I work with the author.)

    0 讨论(0)
  • 2021-01-29 20:02

    I learned by reading the ASM tutorial and mucking about with the library itself.

    IMHO, ASM is better than BECL.

    BCEL is already being used successfully in several projects such as compilers, optimizers, obsfuscators, code generators and analysis tools. Unfortunately there hasn't been much development going on over the past few years. Feel free to help out or you might want to have a look into the ASM project at objectweb. - http://jakarta.apache.org/bcel/

    0 讨论(0)
  • 2021-01-29 20:02

    For understanding Java/the JVM's architecture: read Wikipedia, the specs and the source code.

    For understanding how object-orientated code is done on a low level: try and emulate features like inheritance/polymorphism/encapsulation in a lower-level language like C.

    In C you can achieve the above through, for example, a combination of function pointers and nested structures.

    0 讨论(0)
  • 2021-01-29 20:03

    There is only one reliable source for JVM understanding

    The Java® Virtual Machine Specification Java SE 7 Edition

    http://docs.oracle.com/javase/specs/jvms/se7/html/index.html

    0 讨论(0)
提交回复
热议问题