Mixing Java 1.4 and 1.6 bytecode in a class hierarchy

后端 未结 5 2079
被撕碎了的回忆
被撕碎了的回忆 2021-01-07 11:27

The question first, the story will follow:

Is it safe to mix different bytecode version in a class hierarchy? What are the risks?

For a case, Class C extends

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-07 12:14

    The JVM byte code is not siginificantly different between Java 1.0 and Java 6. In Java 7 they add one new instruction. Woohoo.

    There are so little changes in how the byte code works that

    • The JVM doesn't support nested classes accessing private members of outer classes, this works through generated code.
    • The JVM doesn't support runtime checks for generics e.g you cannot new T() where T is a generic.

    Basically, they make the JVM smarter and faster but until recently changing the model of how the byte code works has been avoided at all costs.

提交回复
热议问题