• <bdo id='9Nosw'></bdo><ul id='9Nosw'></ul>
        <legend id='9Nosw'><style id='9Nosw'><dir id='9Nosw'><q id='9Nosw'></q></dir></style></legend>

        <small id='9Nosw'></small><noframes id='9Nosw'>

        <i id='9Nosw'><tr id='9Nosw'><dt id='9Nosw'><q id='9Nosw'><span id='9Nosw'><b id='9Nosw'><form id='9Nosw'><ins id='9Nosw'></ins><ul id='9Nosw'></ul><sub id='9Nosw'></sub></form><legend id='9Nosw'></legend><bdo id='9Nosw'><pre id='9Nosw'><center id='9Nosw'></center></pre></bdo></b><th id='9Nosw'></th></span></q></dt></tr></i><div id='9Nosw'><tfoot id='9Nosw'></tfoot><dl id='9Nosw'><fieldset id='9Nosw'></fieldset></dl></div>
      1. <tfoot id='9Nosw'></tfoot>

        如何找到已编译类的目标 Java 版本?

        时间:2023-10-15

          <small id='YNwkf'></small><noframes id='YNwkf'>

        1. <tfoot id='YNwkf'></tfoot>

              <i id='YNwkf'><tr id='YNwkf'><dt id='YNwkf'><q id='YNwkf'><span id='YNwkf'><b id='YNwkf'><form id='YNwkf'><ins id='YNwkf'></ins><ul id='YNwkf'></ul><sub id='YNwkf'></sub></form><legend id='YNwkf'></legend><bdo id='YNwkf'><pre id='YNwkf'><center id='YNwkf'></center></pre></bdo></b><th id='YNwkf'></th></span></q></dt></tr></i><div id='YNwkf'><tfoot id='YNwkf'></tfoot><dl id='YNwkf'><fieldset id='YNwkf'></fieldset></dl></div>
                  <bdo id='YNwkf'></bdo><ul id='YNwkf'></ul>

                  <legend id='YNwkf'><style id='YNwkf'><dir id='YNwkf'><q id='YNwkf'></q></dir></style></legend>
                    <tbody id='YNwkf'></tbody>

                  本文介绍了如何找到已编译类的目标 Java 版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  读取和显示 Java .class 版本的工具

                  如果我有一个已编译的 Java 类,有没有办法仅从类文件中判断它的目标版本兼容性是什么?具体来说,我有许多类文件,编译为 Java 6,它们在 Java 5 下运行并给出无法识别的版本".错误.我希望能够在不运行 JVM 的情况下查看类文件并找到其目标版本兼容性.有什么想法吗?

                  If I have a compiled Java class, is there a way to tell from just the class file what its target version compatibility is? Specifically, I have a number of class files, compiled to Java 6, which are running under Java 5 and giving the the "Unrecognized version" error. I want to be able to look at a class file and find what its target version compatibility is without running the JVM. Any ideas?

                  推荐答案

                  我在网上找到了这个,它可以工作.

                  I've found this on the net and it works.

                  每个.class"文件都以以下:

                  Every '.class' file starts off with the following:

                  • 幻数 [4 字节]
                  • 版本信息 [4 字节]

                  已编译的.class"文件的十六进制转储使用以下每个选项揭示:

                  A hexdump of a '.class' file compiled with each of the following options reveals:

                  javac -target 1.1 ==> CA FE BA BE 00 03 00 2D
                  javac -target 1.2 ==> CA FE BA BE 00 00 00 2E
                  javac -target 1.3 ==> CA FE BA BE 00 00 00 2F
                  javac -target 1.4 ==> CA FE BA BE 00 00 00 30

                  javac -target 1.1 ==> CA FE BA BE 00 03 00 2D
                  javac -target 1.2 ==> CA FE BA BE 00 00 00 2E
                  javac -target 1.3 ==> CA FE BA BE 00 00 00 2F
                  javac -target 1.4 ==> CA FE BA BE 00 00 00 30

                  也许您可以使用此信息编写自己的.class"文件版本检查实用程序,使用 Java,或者可能是脚本或外壳语言 ;) !

                  Perhaps you could use this information to write your own '.class' file version checking utility, using Java, or perhaps a scripting or shell language ;) !

                  我希望这会有所帮助.

                  安东尼·博拉

                  来自:http://bytes.com/groups/java/16603-how-determine-java-bytecode-version

                  这篇关于如何找到已编译类的目标 Java 版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 Java 中连接字符串是否总是会导致在内存中创建新字符串? 下一篇:如何在特定文件的基础上禁用 Eclipse 中的编译器警告?

                  相关文章

                  <i id='rUalL'><tr id='rUalL'><dt id='rUalL'><q id='rUalL'><span id='rUalL'><b id='rUalL'><form id='rUalL'><ins id='rUalL'></ins><ul id='rUalL'></ul><sub id='rUalL'></sub></form><legend id='rUalL'></legend><bdo id='rUalL'><pre id='rUalL'><center id='rUalL'></center></pre></bdo></b><th id='rUalL'></th></span></q></dt></tr></i><div id='rUalL'><tfoot id='rUalL'></tfoot><dl id='rUalL'><fieldset id='rUalL'></fieldset></dl></div>

                    <legend id='rUalL'><style id='rUalL'><dir id='rUalL'><q id='rUalL'></q></dir></style></legend>

                    <small id='rUalL'></small><noframes id='rUalL'>

                      <tfoot id='rUalL'></tfoot>
                        <bdo id='rUalL'></bdo><ul id='rUalL'></ul>