了解Java字节代码

编程入门 行业动态 更新时间:2024-10-28 02:30:56
本文介绍了了解Java字节代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我经常遇到一个没有源代码的java类文件,我试图理解我手头的问题。

Often I am stuck with a java class file with no source and I am trying to understand the problem I have at hand.

注意反编译器很有用但不是在所有情况下都足够......

Note a decompiler is useful but not sufficient in all situation...

我有两个问题

  • 什么工具可以查看java字节代码(最好从linux命令行获得)
  • 熟悉java字节代码语法有哪些好的参考资料
  • 推荐答案

    不是直接查看需要熟悉Java虚拟机及其操作的Java字节码,而是可以尝试使用Java反编译实用程序。反编译器将尝试从指定的类文件创建 java 源文件。

    Rather than looking directly at the Java bytecode, which will require familiarity with the Java virtual machine and its operations, one could try to use a Java decompiling utility. A decompiler will attempt to create a java source file from the specified class file.

    如何反编译Java类文件? 是一个相关的问题,可以提供有关如何反编译Java class 文件的信息。

    The How do I "decompile" Java class files? is a related question which would be informative for finding out how to decompile Java class files.

    也就是说,可以使用 javap 命令,该命令是JDK的一部分,用于反汇编Java class 文件。 javap 的输出将是类文件中包含的Java字节码。但请注意,字节码根本不像Java源代码。

    That said, one could use the javap command which is part of the JDK in order to disassemble Java class files. The output of javap will be the Java bytecode contained in the class files. But do be warned that the bytecode does not resemble the Java source code at all.

    了解Java字节码和Java虚拟机本身的明确来源是 Java虚拟机规范,第二版。特别是,第6章:Java虚拟机指令集具有所有字节码指令的索引。

    The definite source for learning about the Java bytecode and the Java Virtual Machine itself would be The Java Virtual Machine Specification, Second Edition. In particular, Chapter 6: The Java Virtual Machine Instruction Set has an index of all the bytecode instructions.

    更多推荐

    了解Java字节代码

    本文发布于:2023-07-30 00:48:02,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1245060.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:字节   代码   Java

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!