Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
colcode
jadx
提交
ebf06fde
J
jadx
项目概览
colcode
/
jadx
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jadx
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ebf06fde
编写于
12月 27, 2013
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
gui: remove not generated elements from class node tree
上级
438b3b50
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
132 addition
and
53 deletion
+132
-53
jadx-core/src/main/java/jadx/api/JavaClass.java
jadx-core/src/main/java/jadx/api/JavaClass.java
+21
-17
jadx-core/src/main/java/jadx/api/JavaMethod.java
jadx-core/src/main/java/jadx/api/JavaMethod.java
+8
-9
jadx-core/src/main/java/jadx/core/codegen/ClassGen.java
jadx-core/src/main/java/jadx/core/codegen/ClassGen.java
+4
-7
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
+1
-0
jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java
+2
-3
jadx-gui/src/main/java/jadx/gui/MainWindow.java
jadx-gui/src/main/java/jadx/gui/MainWindow.java
+21
-0
jadx-gui/src/main/java/jadx/gui/treemodel/JClass.java
jadx-gui/src/main/java/jadx/gui/treemodel/JClass.java
+26
-12
jadx-gui/src/main/java/jadx/gui/treemodel/JMethod.java
jadx-gui/src/main/java/jadx/gui/treemodel/JMethod.java
+13
-5
jadx-gui/src/main/java/jadx/gui/treemodel/TextNode.java
jadx-gui/src/main/java/jadx/gui/treemodel/TextNode.java
+35
-0
jadx-gui/src/main/resources/i18n/Messages_en_US.properties
jadx-gui/src/main/resources/i18n/Messages_en_US.properties
+1
-0
未找到文件。
jadx-core/src/main/java/jadx/api/JavaClass.java
浏览文件 @
ebf06fde
package
jadx.api
;
import
jadx.core.codegen.CodeWriter
;
import
jadx.core.dex.attributes.AttributeFlag
;
import
jadx.core.dex.info.AccessInfo
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.core.dex.nodes.FieldNode
;
...
...
@@ -15,44 +16,47 @@ public final class JavaClass {
private
final
Decompiler
decompiler
;
private
final
ClassNode
cls
;
private
final
List
<
JavaClass
>
innerClasses
;
private
final
List
<
JavaField
>
fields
;
private
final
List
<
JavaMethod
>
methods
;
private
List
<
JavaClass
>
innerClasses
=
Collections
.
emptyList
();
private
List
<
JavaField
>
fields
=
Collections
.
emptyList
();
private
List
<
JavaMethod
>
methods
=
Collections
.
emptyList
();
JavaClass
(
Decompiler
decompiler
,
ClassNode
classNode
)
{
this
.
decompiler
=
decompiler
;
this
.
cls
=
classNode
;
}
public
void
decompile
()
{
decompiler
.
processClass
(
cls
);
int
inClsCount
=
cls
.
getInnerClasses
().
size
();
if
(
inClsCount
==
0
)
{
this
.
innerClasses
=
Collections
.
emptyList
();
}
else
{
if
(
inClsCount
!=
0
)
{
List
<
JavaClass
>
list
=
new
ArrayList
<
JavaClass
>(
inClsCount
);
for
(
ClassNode
inner
:
cls
.
getInnerClasses
())
{
list
.
add
(
new
JavaClass
(
decompiler
,
inner
));
if
(!
inner
.
getAttributes
().
contains
(
AttributeFlag
.
DONT_GENERATE
))
{
list
.
add
(
new
JavaClass
(
decompiler
,
inner
));
}
}
this
.
innerClasses
=
Collections
.
unmodifiableList
(
list
);
}
int
fieldsCount
=
cls
.
getFields
().
size
();
if
(
fieldsCount
==
0
)
{
this
.
fields
=
Collections
.
emptyList
();
}
else
{
if
(
fieldsCount
!=
0
)
{
List
<
JavaField
>
flds
=
new
ArrayList
<
JavaField
>(
fieldsCount
);
for
(
FieldNode
f
:
cls
.
getFields
())
{
flds
.
add
(
new
JavaField
(
f
));
if
(!
f
.
getAttributes
().
contains
(
AttributeFlag
.
DONT_GENERATE
))
{
flds
.
add
(
new
JavaField
(
f
));
}
}
this
.
fields
=
Collections
.
unmodifiableList
(
flds
);
}
int
methodsCount
=
cls
.
getMethods
().
size
();
if
(
methodsCount
==
0
)
{
this
.
methods
=
Collections
.
emptyList
();
}
else
{
if
(
methodsCount
!=
0
)
{
List
<
JavaMethod
>
mths
=
new
ArrayList
<
JavaMethod
>(
methodsCount
);
for
(
MethodNode
m
:
cls
.
getMethods
())
{
if
(!
m
.
getA
ccessFlags
().
isSynthetic
(
))
{
mths
.
add
(
new
JavaMethod
(
m
));
if
(!
m
.
getA
ttributes
().
contains
(
AttributeFlag
.
DONT_GENERATE
))
{
mths
.
add
(
new
JavaMethod
(
this
,
m
));
}
}
Collections
.
sort
(
mths
,
new
Comparator
<
JavaMethod
>()
{
...
...
@@ -68,7 +72,7 @@ public final class JavaClass {
public
String
getCode
()
{
CodeWriter
code
=
cls
.
getCode
();
if
(
code
==
null
)
{
decompile
r
.
processClass
(
cls
);
decompile
(
);
code
=
cls
.
getCode
();
}
return
code
!=
null
?
code
.
toString
()
:
"error processing class"
;
...
...
jadx-core/src/main/java/jadx/api/JavaMethod.java
浏览文件 @
ebf06fde
package
jadx.api
;
import
jadx.core.dex.info.AccessInfo
;
import
jadx.core.dex.info.MethodInfo
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.dex.nodes.MethodNode
;
...
...
@@ -9,19 +8,19 @@ import java.util.List;
public
final
class
JavaMethod
{
private
final
MethodNode
mth
;
private
final
JavaClass
parent
;
public
JavaMethod
(
MethodNode
m
)
{
public
JavaMethod
(
JavaClass
cls
,
MethodNode
m
)
{
this
.
parent
=
cls
;
this
.
mth
=
m
;
}
public
String
getName
()
{
MethodInfo
mi
=
mth
.
getMethodInfo
();
if
(
mi
.
isConstructor
())
{
return
mth
.
getParentClass
().
getShortName
();
}
else
if
(
mi
.
isClassInit
())
{
return
"static"
;
}
return
mi
.
getName
();
return
mth
.
getMethodInfo
().
getName
();
}
public
JavaClass
getDeclaringClass
()
{
return
parent
;
}
public
AccessInfo
getAccessFlags
()
{
...
...
jadx-core/src/main/java/jadx/core/codegen/ClassGen.java
浏览文件 @
ebf06fde
...
...
@@ -216,9 +216,9 @@ public class ClassGen {
CodeWriter
code
=
new
CodeWriter
(
clsCode
.
getIndent
()
+
1
);
for
(
Iterator
<
MethodNode
>
it
=
mthList
.
iterator
();
it
.
hasNext
();
)
{
MethodNode
mth
=
it
.
next
();
if
(
mth
.
getAttributes
().
contains
(
AttributeFlag
.
DONT_GENERATE
))
if
(
mth
.
getAttributes
().
contains
(
AttributeFlag
.
DONT_GENERATE
))
{
continue
;
}
try
{
if
(
mth
.
getAccessFlags
().
isAbstract
()
||
mth
.
getAccessFlags
().
isNative
())
{
MethodGen
mthGen
=
new
MethodGen
(
this
,
mth
);
...
...
@@ -232,9 +232,6 @@ public class ClassGen {
}
code
.
add
(
';'
);
}
else
{
if
(
mth
.
isNoCode
())
continue
;
MethodGen
mthGen
=
new
MethodGen
(
this
,
mth
);
if
(
mth
.
getAttributes
().
contains
(
AttributeFlag
.
INCONSISTENT_CODE
))
{
code
.
startLine
(
"/* JADX WARNING: inconsistent code */"
);
...
...
@@ -253,9 +250,9 @@ public class ClassGen {
String
msg
=
ErrorsCounter
.
methodError
(
mth
,
"Method generation error"
,
e
);
code
.
startLine
(
"/* "
+
msg
+
CodeWriter
.
NL
+
Utils
.
getStackTrace
(
e
)
+
" */"
);
}
if
(
it
.
hasNext
())
if
(
it
.
hasNext
())
{
code
.
newLine
();
}
}
return
code
;
}
...
...
jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
浏览文件 @
ebf06fde
...
...
@@ -533,6 +533,7 @@ public class InsnGen {
}
else
{
parent
=
cls
.
getSuperClass
();
}
cls
.
getAttributes
().
add
(
AttributeFlag
.
DONT_GENERATE
);
MethodNode
defCtr
=
cls
.
getDefaultConstructor
();
if
(
RegionUtils
.
notEmpty
(
defCtr
.
getRegion
()))
{
defCtr
.
getAttributes
().
add
(
AttributeFlag
.
ANONYMOUS_CONSTRUCTOR
);
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java
浏览文件 @
ebf06fde
...
...
@@ -124,14 +124,13 @@ public class MethodNode extends LineAttrNode implements ILoadable {
@Override
public
void
unload
()
{
if
(
noCode
)
if
(
noCode
)
{
return
;
}
if
(
instructions
!=
null
)
instructions
.
clear
();
blocks
=
null
;
exitBlocks
=
null
;
if
(
exceptionHandlers
!=
null
)
exceptionHandlers
.
clear
();
getAttributes
().
clear
();
noCode
=
true
;
}
...
...
jadx-gui/src/main/java/jadx/gui/MainWindow.java
浏览文件 @
ebf06fde
...
...
@@ -26,14 +26,18 @@ import javax.swing.JToolBar;
import
javax.swing.JTree
;
import
javax.swing.KeyStroke
;
import
javax.swing.ProgressMonitor
;
import
javax.swing.event.TreeExpansionEvent
;
import
javax.swing.event.TreeSelectionEvent
;
import
javax.swing.event.TreeSelectionListener
;
import
javax.swing.event.TreeWillExpandListener
;
import
javax.swing.filechooser.FileNameExtensionFilter
;
import
javax.swing.plaf.basic.BasicButtonUI
;
import
javax.swing.text.BadLocationException
;
import
javax.swing.tree.DefaultMutableTreeNode
;
import
javax.swing.tree.DefaultTreeCellRenderer
;
import
javax.swing.tree.DefaultTreeModel
;
import
javax.swing.tree.ExpandVetoException
;
import
javax.swing.tree.TreePath
;
import
javax.swing.tree.TreeSelectionModel
;
import
java.awt.BorderLayout
;
import
java.awt.Color
;
...
...
@@ -192,6 +196,7 @@ public class MainWindow extends JFrame {
}
private
void
showCode
(
JClass
cls
,
int
line
)
{
cls
.
load
();
JPanel
panel
=
(
JPanel
)
openTabs
.
get
(
cls
);
if
(
panel
!=
null
)
{
panel
=
(
JPanel
)
openTabs
.
get
(
cls
);
...
...
@@ -379,6 +384,22 @@ public class MainWindow extends JFrame {
return
c
;
}
});
tree
.
addTreeWillExpandListener
(
new
TreeWillExpandListener
()
{
@Override
public
void
treeWillExpand
(
TreeExpansionEvent
event
)
throws
ExpandVetoException
{
TreePath
path
=
event
.
getPath
();
Object
node
=
path
.
getLastPathComponent
();
if
(
node
instanceof
JClass
)
{
JClass
cls
=
(
JClass
)
node
;
cls
.
load
();
}
}
@Override
public
void
treeWillCollapse
(
TreeExpansionEvent
event
)
throws
ExpandVetoException
{
}
});
JScrollPane
treeScrollPane
=
new
JScrollPane
(
tree
);
splitPane
.
setLeftComponent
(
treeScrollPane
);
...
...
jadx-gui/src/main/java/jadx/gui/treemodel/JClass.java
浏览文件 @
ebf06fde
...
...
@@ -4,6 +4,7 @@ import jadx.api.JavaClass;
import
jadx.api.JavaField
;
import
jadx.api.JavaMethod
;
import
jadx.core.dex.info.AccessInfo
;
import
jadx.gui.utils.NLS
;
import
jadx.gui.utils.Utils
;
import
javax.swing.Icon
;
...
...
@@ -22,6 +23,7 @@ public class JClass extends JNode {
private
final
JavaClass
cls
;
private
JClass
jParrent
;
private
boolean
loaded
;
public
JClass
(
JavaClass
cls
)
{
this
.
cls
=
cls
;
...
...
@@ -31,21 +33,33 @@ public class JClass extends JNode {
return
cls
;
}
public
synchronized
void
load
()
{
if
(!
loaded
)
{
cls
.
decompile
();
loaded
=
true
;
updateChilds
();
}
}
@Override
public
void
updateChilds
()
{
removeAllChildren
();
JClass
currentParent
=
jParrent
==
null
?
this
:
jParrent
;
for
(
JavaClass
javaClass
:
cls
.
getInnerClasses
())
{
JClass
child
=
new
JClass
(
javaClass
);
child
.
setJParent
(
currentParent
);
child
.
updateChilds
();
add
(
child
);
}
for
(
JavaField
f
:
cls
.
getFields
())
{
add
(
new
JField
(
f
,
currentParent
));
}
for
(
JavaMethod
m
:
cls
.
getMethods
())
{
add
(
new
JMethod
(
m
,
currentParent
));
if
(!
loaded
)
{
add
(
new
TextNode
(
NLS
.
str
(
"tree.loading"
)));
}
else
{
JClass
currentParent
=
jParrent
==
null
?
this
:
jParrent
;
for
(
JavaClass
javaClass
:
cls
.
getInnerClasses
())
{
JClass
child
=
new
JClass
(
javaClass
);
child
.
setJParent
(
currentParent
);
child
.
updateChilds
();
add
(
child
);
}
for
(
JavaField
f
:
cls
.
getFields
())
{
add
(
new
JField
(
f
,
currentParent
));
}
for
(
JavaMethod
m
:
cls
.
getMethods
())
{
add
(
new
JMethod
(
m
,
currentParent
));
}
}
}
...
...
jadx-gui/src/main/java/jadx/gui/treemodel/JMethod.java
浏览文件 @
ebf06fde
...
...
@@ -47,8 +47,12 @@ public class JMethod extends JNode {
public
Icon
getIcon
()
{
AccessInfo
accessFlags
=
mth
.
getAccessFlags
();
OverlayIcon
icon
=
Utils
.
makeIcon
(
accessFlags
,
ICON_MTH_PUB
,
ICON_MTH_PRI
,
ICON_MTH_PRO
,
ICON_MTH_DEF
);
if
(
accessFlags
.
isConstructor
())
icon
.
add
(
ICON_CONSTRUCTOR
);
if
(
accessFlags
.
isSynchronized
())
icon
.
add
(
ICON_SYNC
);
if
(
accessFlags
.
isConstructor
())
{
icon
.
add
(
ICON_CONSTRUCTOR
);
}
if
(
accessFlags
.
isSynchronized
())
{
icon
.
add
(
ICON_SYNC
);
}
return
icon
;
}
...
...
@@ -57,14 +61,18 @@ public class JMethod extends JNode {
if
(
mth
.
isClassInit
())
{
return
"{...}"
;
}
StringBuilder
base
=
new
StringBuilder
();
base
.
append
(
mth
.
getName
());
if
(
mth
.
isConstructor
())
{
base
.
append
(
mth
.
getDeclaringClass
().
getShortName
());
}
else
{
base
.
append
(
mth
.
getName
());
}
base
.
append
(
'('
);
for
(
Iterator
<
ArgType
>
it
=
mth
.
getArguments
().
iterator
();
it
.
hasNext
();
)
{
base
.
append
(
Utils
.
typeStr
(
it
.
next
()));
if
(
it
.
hasNext
())
if
(
it
.
hasNext
())
{
base
.
append
(
", "
);
}
}
base
.
append
(
')'
);
return
Utils
.
typeFormat
(
base
.
toString
(),
mth
.
getReturnType
());
...
...
jadx-gui/src/main/java/jadx/gui/treemodel/TextNode.java
0 → 100644
浏览文件 @
ebf06fde
package
jadx.gui.treemodel
;
import
javax.swing.Icon
;
public
class
TextNode
extends
JNode
{
private
final
String
label
;
public
TextNode
(
String
str
)
{
this
.
label
=
str
;
}
@Override
public
JClass
getJParent
()
{
return
null
;
}
@Override
public
int
getLine
()
{
return
0
;
}
@Override
public
void
updateChilds
()
{
}
@Override
public
Icon
getIcon
()
{
return
null
;
}
@Override
public
String
toString
()
{
return
label
;
}
}
jadx-gui/src/main/resources/i18n/Messages_en_US.properties
浏览文件 @
ebf06fde
...
...
@@ -6,6 +6,7 @@ file.select=Select
file.exit
=
Exit
tree.flatten
=
Flatten packages
tree.loading
=
Loading...
search
=
Search
search.previous
=
Previous
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录