如何在Eclipse IDE中查看Java的字节码? [英] How to view Java's byte code in eclipse IDE?

查看:311
本文介绍了如何在Eclipse IDE中查看Java的字节码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时,在Eclipse中,我按下了组合键,这些键会将我带到显示我的.class文件(字节码)内容的编辑器页面。我似乎永远无法记住那个组合键是什么。

Sometimes, in Eclipse , i press a combination of keys which take me to the editor page that shows contents of my .class file (bytecode). I never seem to be able to remember what that key combination is.

有人可以让我知道吗?

或者换句话说,怎么能看到自己的字节码?

Or in other words, how can one see own bytecode?

推荐答案

Eclipse的默认类文件查看器显示源(请参阅VonC的答案)(如果它已与二进制文件关联),否则会给出类的类似于javap的视图(可以选择附加源代码)。我猜想它是您要寻找的后者。

Eclipse's default class file viewer shows the source (see VonC's answer) if it has been associated with the binaries, otherwise it gives a javap-like view of the class (with an option to attach source). I'm guessing it's the latter that you are looking for.

我从来没有找到一种方法可以强制Eclipse显示输出而不是链接的源。您可能想要的是一个Eclipse插件,该插件提供类似Javap的功能(或javap的接口)。寻找表明它们反汇编的插件(而不是像jad那样反编译的插件)。

I've never found a way to cleanly force Eclipse to show that output rather than the linked source. What you probably want is an Eclipse plug-in that provides Javap like functionality (or an interface to javap). Look for plugins stating they "disassemble" (as opposed to "decompile," like jad).

如果没有插件,则可以配置外部工具来执行javap,但它可能无法与其他eclipse功能配合使用。

Barring a plug-in, you could probably configure an external tool to perform javap but it might not play nicely with other eclipse features.

编辑:让我对以上内容进行清楚说明:如果您按F3键,则为Eclipse执行以下操作(通常,实际过程可能会略有不同):

Let me be clear about the above: If you hit F3, Eclipse does the following (generally, the actual procedure might be slightly different):


  1. 解析目标(如果选择Java文件,它将将是Java文件本身;如果您正在选择或光标位于类名上方,则它将是类声明,类似于方法声明等)。

  2. 搜索构建路径(首先是同一项目)用于包含目标的Java文件。如果找到,则打开显示该Java源文件的可写编辑器。

  3. 对于类/方法声明,它将继续在构建路径的引用中搜索包含声明的类文件。 。如果找到,则

  1. Resolves the target (if you are selecting a Java file, it will be the Java file itself; if you are selecting or your cursor is over a class name it will be the class declaration, similar for a method declaration, etc).
  2. Searches the build path (same project first) for a Java file containing the target. If found, opens up an writable editor displaying that Java source file.
  3. For class/method declarations, it continues searching references on your build path for a class file that contains the declaration. If it is found, then

a)如果类文件已附加源,则打开链接的Java文件的只读编辑器。

a) If the class file has had source attached to it, open up a read-only editor of the linked Java file.

b)如果类文件没有附加源,则打开一个只读面板,显示已编译的类文件的反汇编(类似Javap的)字节码。 / p>

b) If the class file does not have source attached to it, then open up a read-only panel showing the disassembled (javap-like) bytecode of the compiled class file.

我的猜测是您认为存在3.b的专用键序列,但我不知道认为没有。但是再次,我很想在这里被证明是错误的。

My guess would be that you're thinking there's a dedicated key sequence to 3.b), but I don't think there is. But again, I would love to be proven wrong here.

这篇关于如何在Eclipse IDE中查看Java的字节码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆