IDEA 14.反编译我自己的类(从输出目录)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了IDEA 14.反编译我自己的类(从输出目录)相关的知识,希望对你有一定的参考价值。

我想查看从我自己的源代码生成的代码,但似乎IDEA没有使用IntelliJ API Decompiler使用新的fernflower插件反编译它们。

至少我有标题评论

// IntelliJ API Decompiler stub source generated from a class file
// Implementation of methods is not available

和那样的方法:public void update() { /* compiled code */ }

同时,在外部库(例如JDK)中,我看到了正常的头文件和反编译代码。

// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)

我可以使反编译工作,如果我将代码编译为jar并将其添加到某个模块,但它看起来不像一个普通的解决方案。

我可以使用fernflower使IDEA反编译任何类文件吗?

编辑:打开文件时,我在IDEA日志文件中得到一个异常。请参阅片段。

<pre>
2015-02-13 19:16:29,991 [119281666]   WARN - l.compiled.ClassFileDecompiler - decompiler: class org.jetbrains.java.decompiler.IdeaDecompiler
com.intellij.psi.compiled.ClassFileDecompilers$Light$CannotDecompileException: org.jetbrains.java.decompiler.IdeaLogger$InternalException: Method <init> (Ljava/util/HashMap;)V couldn't be decompiled.
	at org.jetbrains.java.decompiler.IdeaDecompiler.getText(IdeaDecompiler.java:162)
	at com.intellij.psi.impl.compiled.ClassFileDecompiler.decompile(ClassFileDecompiler.java:57)
	at com.intellij.openapi.fileEditor.impl.LoadTextUtil.loadText(LoadTextUtil.java:364)
	at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.getDocument(FileDocumentManagerImpl.java:167)
	at com.intellij.openapi.fileEditor.impl.text.PsiAwareTextEditorProvider.createEditorAsync(PsiAwareTextEditorProvider.java:58)
	at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.openFileImpl4(FileEditorManagerImpl.java:778)
	at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.openFileImpl3(FileEditorManagerImpl.java:736)
	at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl$8.run(FileEditorManagerImpl.java:716)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:117)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:99)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:85)
	at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.openFileImpl2(FileEditorManagerImpl.java:713)
	at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.openFileWithProviders(FileEditorManagerImpl.java:654)
	at com.intellij.openapi.fileEditor.ex.FileEditorManagerEx.openFile(FileEditorManagerEx.java:146)
	at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl$14.run(FileEditorManagerImpl.java:1071)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:124)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:99)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:85)
	at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.openEditor(FileEditorManagerImpl.java:1067)
	at com.intellij.openapi.fileEditor.OpenFileDescriptor.navigateInAnyFileEditor(OpenFileDescriptor.java:152)
	at com.intellij.openapi.fileEditor.OpenFileDescriptor.navigateInEditor(OpenFileDescriptor.java:138)
	at com.intellij.openapi.fileEditor.OpenFileDescriptor.navigateInEditorOrNativeApp(OpenFileDescriptor.java:134)
	at com.intellij.openapi.fileEditor.OpenFileDescriptor.navigate(OpenFileDescriptor.java:121)
	at com.intellij.psi.impl.PsiElementBase.navigate(PsiElementBase.java:197)
	at com.intellij.codeInsight.navigation.NavigationUtil.openFileWithPsiElement(NavigationUtil.java:167)
	at com.intellij.ide.projectView.impl.nodes.AbstractPsiBasedNode.navigate(AbstractPsiBasedNode.java:207)
	at com.intellij.ide.projectView.impl.nodes.AbstractPsiBasedNode.navigate(AbstractPsiBasedNode.java:217)
	at com.intellij.ide.projectView.impl.nodes.PsiFileNode.navigate(PsiFileNode.java:132)
	at com.intellij.util.OpenSourceUtil.navigate(OpenSourceUtil.java:53)
	at com.intellij.util.OpenSourceUtil.openSourcesFrom(OpenSourceUtil.java:31)
	at com.intellij.util.EditSourceOnDoubleClickHandler$TreeMouseListener.processDoubleClick(EditSourceOnDoubleClickHandler.java:130)
	at com.intellij.util.EditSourceOnDoubleClickHandler$TreeMouseListener.onDoubleClick(EditSourceOnDoubleClickHandler.java:122)
	at com.intellij.ui.DoubleClickListener.onClick(DoubleClickListener.java:30)
	at com.intellij.ui.ClickListener$1.mouseReleased(ClickListener.java:73)
	at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:273)
	at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
	at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
	at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
	at java.awt.Component.processMouseEvent(Component.java:6414)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3275)
	at com.intellij.ui.treeStructure.Tree.processMouseEvent(Tree.java:421)
	at com.intellij.ide.dnd.aware.DnDAwareTree.processMouseEvent(DnDAwareTree.java:53)
	at java.awt.Component.processEvent(Component.java:6179)
	at java.awt.Container.processEvent(Container.java:2084)
	at java.awt.Component.dispatchEventImpl(Component.java:4776)
	at java.awt.Container.dispatchEventImpl(Container.java:2142)
	at java.awt.Component.dispatchEvent(Component.java:4604)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4618)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4279)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4209)
	at java.awt.Container.dispatchEventImpl(Container.java:2128)
	at java.awt.Window.dispatchEventImpl(Window.java:2492)
	at java.awt.Component.dispatchEvent(Component.java:4604)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:717)
	at java.awt.EventQueue.access$400(EventQueue.java:82)
	at java.awt.EventQueue$2.run(EventQueue.java:676)
	at java.awt.EventQueue$2.run(EventQueue.java:674)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:690)
	at java.awt.EventQueue$3.run(EventQueue.java:688)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:687)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:748)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:573)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:384)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: org.jetbrains.java.decompiler.IdeaLogger$InternalException: Method <init> (Ljava/util/HashMap;)V couldn't be decompiled.
	at org.jetbrains.java.decompiler.IdeaLogger.writeMessage(IdeaLogger.java:44)
	at org.jetbrains.java.decompiler.main.rels.ClassWrapper.init(ClassWrapper.java:151)
	at org.jetbrains.java.decompiler.main.ClassesProcessor.initWrappers(ClassesProcessor.java:305)
	at org.jetbrains.java.decompiler.main.ClassesProcessor.writeClass(ClassesProcessor.java:252)
	at org.jetbrains.java.decompiler.main.Fernflower.getClassContent(Fernflower.java:86)
	at org.jetbrains.java.decompiler.struct.ContextUnit.save(ContextUnit.java:113)
	at org.jetbrains.java.decompiler.struct.StructContext.saveContext(StructContext.java:72)
	at org.jetbrains.java.decompiler.main.Fernflower.decompileContext(Fernflower.java:54)
	at org.jetbrains.java.decompiler.main.decompiler.BaseDecompiler.decompileContext(BaseDecompiler.java:41)
	at org.jetbrains.java.decompiler.IdeaDecompiler.getText(IdeaDecompiler.java:151)
	... 73 more
Caused by: java.lang.ClassCastException: org.jetbrains.java.decompiler.struct.consts.PrimitiveConstant cannot be cast to org.jetbrains.java.decompiler.struct.consts.LinkConstant
	at org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor.processBlock(ExprProcessor.java:563)
	at org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor.processStatement(ExprProcessor.java:202)
	at org.jetbrains.java.decompiler.main.rels.MethodProcessorThread.codeToJava(MethodProcessorThread.java:162)
	at org.jetbrains.java.decompiler.main.rels.ClassWrapper.init(ClassWrapper.java:92)
	... 81 more
</pre>
答案

在我的情况下,问题是我安装了“Java Decompiler IntelliJ Plugin”。 Unistall它可以完成这项工作。

以上是关于IDEA 14.反编译我自己的类(从输出目录)的主要内容,如果未能解决你的问题,请参考以下文章

Android proguard代码混淆

idea导入maven项目cotroller报错注解无用

反编译动态创建的类/类型

class文件反编译后,怎么编译回去!

apk文件反编译后,添加引用jar.再回编.这个想法可以实现么。

C++从0到14.程序的注释