Java源代码由Intellij中的反编译文件替换 [英] Java sources replaced by decompiled files in Intellij

查看:1757
本文介绍了Java源代码由Intellij中的反编译文件替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 ctrl +右键单击打开一个特定的类时,我应该被重定向到一个包含所有行和相应注释的java源窗口。但是我得到了一个带有反编译的.class文件的窗口。



我试图停用反编译器插件但它不起作用。



如果我添加



如果未列出或为红色,运行下载源或下载源和文档。如果源为红色,则可能意味着它不可用于maven存储库中的该工件。使用



IDEA应该在您添加JDK时自动设置,但如果没有,请添加它。



2。确保源JAR / ZIP文件没有损坏



导航到资源管理器/查找程序中的存档,并确保可以打开和查看它。



3。刷新IDEA的缓存



IDEA的缓存/索引可能已损坏。因此,IDEA没有看到类和源代码之间的链接。转到文件>使缓存无效/重新启动... 。使缓存无效并重新启动IDEA。等待IDEA完成对项目和库的重新索引(观察IDEA右下角的进度)窗口)。



以上其中一项应解决问题。



仅供参考,如果你不想要IDEA根据我的知识(并且基于其帮助页面),唯一的方法是禁用插件列表中的Java字节码反编译器。


When I'm opening a specific class using ctrl + right click I should be redirected to a window with the java sources which contains all the lines and the appropriate comments. But instead I get a window with the decompiled .class file.

I have tried to deactivate the decompiler plugin but it does not work.

If I add http://docs.oracle.com/javase/8/docs/api to Project Structure -> SDKs -> Documentation Paths I can get an overview of the class or method's I'm rolling over, but still can't open the right source file.

Any ideas?

解决方案

When navigting to sources, IDEA will first go to attached sources. If not present, it will decompile the class and display it.

Try the following troubleshooting to track down the issue:

1. Make sure the sources are properly attached.

For libraries, Open the Project Structure dialog (Ctrl+Alt+Shift+S or ;) and sel4ct "Libraries" on the left under "Project Settings". Find the library in question, and select it. It will show if the source is attached. You mentioned you have Maven's "Automatically download" sources/documentation both checked. So for any maven libraries that have source available, it should be listed.

If it is not listed or is in red, run "Download Sources" or "Download Sources and Documentation" from the Maven tool window. If the source is till in red, it likely means it is not available for that artifact in the maven repository. Use Maven Search to verify such.

For the JDK, select "SDKs" in the Project Structure dialog, find the JDK, and then select the "Sourcepath" tab. Make sure the {jdk-home}/src.zip file is listed.

IDEA should automatically set this when you add the JDK, but if not, add it.

2. Make sure the source JAR/ZIP file is not corrupt

Navigate to the archive in explorer/finder and make sure it can be opened and viewed.

3. Refresh IDEA's Caches

It's possible that IDEA's caches/indexes are corrupted. As such, IDEA is not "seeing" the link between the class and the source code. Go to File > Invalidate Caches / Restart...". Invalidate the caches and restart IDEA. Wait for IDEA to finish re-indexing the project and libraries (watch the progress in the bottom right of the IDEA window).

One of the above should resolve the issue.

FYI, If you do not want IDEA to decompile code(as a backup to no source being present), to the best of my knowledge (and based on the its help page), the only way to do such is to disable the "Java Bytecode Decompiler" in the Plugins list.

这篇关于Java源代码由Intellij中的反编译文件替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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