Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Quincy379
jadx
提交
c25f918c
J
jadx
项目概览
Quincy379
/
jadx
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
c25f918c
编写于
2月 18, 2018
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
gui: fix some sonar warnings
上级
6fb1c8d3
变更
17
显示空白变更内容
内联
并排
Showing
17 changed file
with
132 addition
and
138 deletion
+132
-138
build.gradle
build.gradle
+4
-0
jadx-core/src/main/java/jadx/core/codegen/ConditionGen.java
jadx-core/src/main/java/jadx/core/codegen/ConditionGen.java
+12
-9
jadx-core/src/main/java/jadx/core/deobf/NameMapper.java
jadx-core/src/main/java/jadx/core/deobf/NameMapper.java
+6
-3
jadx-core/src/main/java/jadx/core/dex/nodes/DexNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/DexNode.java
+8
-10
jadx-core/src/main/java/jadx/core/dex/visitors/DepthTraversal.java
.../src/main/java/jadx/core/dex/visitors/DepthTraversal.java
+2
-2
jadx-core/src/main/java/jadx/core/utils/ErrorsCounter.java
jadx-core/src/main/java/jadx/core/utils/ErrorsCounter.java
+3
-2
jadx-core/src/main/java/jadx/core/utils/files/FileUtils.java
jadx-core/src/main/java/jadx/core/utils/files/FileUtils.java
+2
-2
jadx-core/src/test/java/jadx/tests/functional/TestIfCondition.java
.../src/test/java/jadx/tests/functional/TestIfCondition.java
+24
-18
jadx-core/src/test/java/jadx/tests/integration/TestDuplicateCast.java
...c/test/java/jadx/tests/integration/TestDuplicateCast.java
+5
-4
jadx-gui/src/main/java/jadx/gui/jobs/BackgroundJob.java
jadx-gui/src/main/java/jadx/gui/jobs/BackgroundJob.java
+4
-8
jadx-gui/src/main/java/jadx/gui/ui/CommonSearchDialog.java
jadx-gui/src/main/java/jadx/gui/ui/CommonSearchDialog.java
+13
-10
jadx-gui/src/main/java/jadx/gui/ui/MainWindow.java
jadx-gui/src/main/java/jadx/gui/ui/MainWindow.java
+5
-17
jadx-gui/src/main/java/jadx/gui/ui/SearchDialog.java
jadx-gui/src/main/java/jadx/gui/ui/SearchDialog.java
+8
-18
jadx-gui/src/main/java/jadx/gui/utils/search/CodeIndex.java
jadx-gui/src/main/java/jadx/gui/utils/search/CodeIndex.java
+1
-1
jadx-gui/src/main/java/jadx/gui/utils/search/SimpleIndex.java
...-gui/src/main/java/jadx/gui/utils/search/SimpleIndex.java
+1
-1
jadx-gui/src/main/java/jadx/gui/utils/search/StringRef.java
jadx-gui/src/main/java/jadx/gui/utils/search/StringRef.java
+4
-4
jadx-gui/src/test/java/jadx/gui/treemodel/JSourcesTest.java
jadx-gui/src/test/java/jadx/gui/treemodel/JSourcesTest.java
+30
-29
未找到文件。
build.gradle
浏览文件 @
c25f918c
...
@@ -24,6 +24,10 @@ allprojects {
...
@@ -24,6 +24,10 @@ allprojects {
}
}
}
}
compileJava
{
options
.
encoding
=
"UTF-8"
}
jar
{
jar
{
version
=
jadxVersion
version
=
jadxVersion
manifest
{
manifest
{
...
...
jadx-core/src/main/java/jadx/core/codegen/ConditionGen.java
浏览文件 @
c25f918c
package
jadx.core.codegen
;
package
jadx.core.codegen
;
import
java.util.Iterator
;
import
java.util.LinkedList
;
import
java.util.Queue
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
jadx.core.dex.instructions.ArithNode
;
import
jadx.core.dex.instructions.ArithNode
;
import
jadx.core.dex.instructions.IfOp
;
import
jadx.core.dex.instructions.IfOp
;
import
jadx.core.dex.instructions.InsnType
;
import
jadx.core.dex.instructions.InsnType
;
...
@@ -15,13 +22,6 @@ import jadx.core.utils.ErrorsCounter;
...
@@ -15,13 +22,6 @@ import jadx.core.utils.ErrorsCounter;
import
jadx.core.utils.exceptions.CodegenException
;
import
jadx.core.utils.exceptions.CodegenException
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
import
java.util.Iterator
;
import
java.util.LinkedList
;
import
java.util.Queue
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
public
class
ConditionGen
extends
InsnGen
{
public
class
ConditionGen
extends
InsnGen
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
ConditionGen
.
class
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
ConditionGen
.
class
);
...
@@ -126,7 +126,7 @@ public class ConditionGen extends InsnGen {
...
@@ -126,7 +126,7 @@ public class ConditionGen extends InsnGen {
wrap
(
code
,
firstArg
);
wrap
(
code
,
firstArg
);
return
;
return
;
}
}
LOG
.
warn
(
ErrorsCounter
.
formatErrorMsg
(
mth
,
"Unsupported boolean condition "
+
op
.
getSymbol
()
));
ErrorsCounter
.
methodError
(
mth
,
"Unsupported boolean condition "
+
op
.
getSymbol
(
));
}
}
addArg
(
code
,
firstArg
,
isArgWrapNeeded
(
firstArg
));
addArg
(
code
,
firstArg
,
isArgWrapNeeded
(
firstArg
));
...
@@ -179,6 +179,9 @@ public class ConditionGen extends InsnGen {
...
@@ -179,6 +179,9 @@ public class ConditionGen extends InsnGen {
case
DIV:
case
DIV:
case
REM:
case
REM:
return
false
;
return
false
;
default
:
return
true
;
}
}
}
else
{
}
else
{
switch
(
insnType
)
{
switch
(
insnType
)
{
...
@@ -189,10 +192,10 @@ public class ConditionGen extends InsnGen {
...
@@ -189,10 +192,10 @@ public class ConditionGen extends InsnGen {
case
CONST:
case
CONST:
case
ARRAY_LENGTH:
case
ARRAY_LENGTH:
return
false
;
return
false
;
default
:
default
:
return
true
;
return
true
;
}
}
}
}
return
true
;
}
}
}
}
jadx-core/src/main/java/jadx/core/deobf/NameMapper.java
浏览文件 @
c25f918c
...
@@ -14,7 +14,7 @@ public class NameMapper {
...
@@ -14,7 +14,7 @@ public class NameMapper {
"("
+
VALID_JAVA_IDENTIFIER
+
"\\.)*"
+
VALID_JAVA_IDENTIFIER
);
"("
+
VALID_JAVA_IDENTIFIER
+
"\\.)*"
+
VALID_JAVA_IDENTIFIER
);
private
static
final
Set
<
String
>
RESERVED_NAMES
=
new
HashSet
<>(
private
static
final
Set
<
String
>
RESERVED_NAMES
=
new
HashSet
<>(
Arrays
.
asList
(
new
String
[]{
Arrays
.
asList
(
"abstract"
,
"abstract"
,
"assert"
,
"assert"
,
"boolean"
,
"boolean"
,
...
@@ -67,8 +67,8 @@ public class NameMapper {
...
@@ -67,8 +67,8 @@ public class NameMapper {
"try"
,
"try"
,
"void"
,
"void"
,
"volatile"
,
"volatile"
,
"while"
,
"while"
}
)
)
);
);
public
static
boolean
isReserved
(
String
str
)
{
public
static
boolean
isReserved
(
String
str
)
{
...
@@ -96,4 +96,7 @@ public class NameMapper {
...
@@ -96,4 +96,7 @@ public class NameMapper {
}
}
return
true
;
return
true
;
}
}
private
NameMapper
()
{
}
}
}
jadx-core/src/main/java/jadx/core/dex/nodes/DexNode.java
浏览文件 @
c25f918c
package
jadx.core.dex.nodes
;
package
jadx.core.dex.nodes
;
import
jadx.core.dex.info.ClassInfo
;
import
jadx.core.dex.info.FieldInfo
;
import
jadx.core.dex.info.MethodInfo
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.utils.exceptions.DecodeException
;
import
jadx.core.utils.files.DexFile
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
com.android.dex.ClassData
;
import
com.android.dex.ClassData
;
import
com.android.dex.ClassData.Method
;
import
com.android.dex.ClassData.Method
;
import
com.android.dex.ClassDef
;
import
com.android.dex.ClassDef
;
...
@@ -26,6 +16,14 @@ import com.android.dex.FieldId;
...
@@ -26,6 +16,14 @@ import com.android.dex.FieldId;
import
com.android.dex.MethodId
;
import
com.android.dex.MethodId
;
import
com.android.dex.ProtoId
;
import
com.android.dex.ProtoId
;
import
com.android.dex.TypeList
;
import
com.android.dex.TypeList
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
jadx.core.dex.info.ClassInfo
;
import
jadx.core.dex.info.FieldInfo
;
import
jadx.core.dex.info.MethodInfo
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.utils.files.DexFile
;
public
class
DexNode
implements
IDexNode
{
public
class
DexNode
implements
IDexNode
{
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/DepthTraversal.java
浏览文件 @
c25f918c
...
@@ -17,7 +17,7 @@ public class DepthTraversal {
...
@@ -17,7 +17,7 @@ public class DepthTraversal {
visit
(
visitor
,
mth
);
visit
(
visitor
,
mth
);
}
}
}
}
}
catch
(
Throwable
e
)
{
}
catch
(
Exception
e
)
{
ErrorsCounter
.
classError
(
cls
,
ErrorsCounter
.
classError
(
cls
,
e
.
getClass
().
getSimpleName
()
+
" in pass: "
+
visitor
.
getClass
().
getSimpleName
(),
e
);
e
.
getClass
().
getSimpleName
()
+
" in pass: "
+
visitor
.
getClass
().
getSimpleName
(),
e
);
}
}
...
@@ -29,7 +29,7 @@ public class DepthTraversal {
...
@@ -29,7 +29,7 @@ public class DepthTraversal {
}
}
try
{
try
{
visitor
.
visit
(
mth
);
visitor
.
visit
(
mth
);
}
catch
(
Throwable
e
)
{
}
catch
(
Exception
e
)
{
ErrorsCounter
.
methodError
(
mth
,
ErrorsCounter
.
methodError
(
mth
,
e
.
getClass
().
getSimpleName
()
+
" in pass: "
+
visitor
.
getClass
().
getSimpleName
(),
e
);
e
.
getClass
().
getSimpleName
()
+
" in pass: "
+
visitor
.
getClass
().
getSimpleName
(),
e
);
}
}
...
...
jadx-core/src/main/java/jadx/core/utils/ErrorsCounter.java
浏览文件 @
c25f918c
...
@@ -6,6 +6,7 @@ import java.util.HashSet;
...
@@ -6,6 +6,7 @@ import java.util.HashSet;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Set
;
import
org.jetbrains.annotations.Nullable
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -26,12 +27,12 @@ public class ErrorsCounter {
...
@@ -26,12 +27,12 @@ public class ErrorsCounter {
return
errorsCount
;
return
errorsCount
;
}
}
private
void
addError
(
IAttributeNode
node
,
String
msg
,
Throwable
e
)
{
private
synchronized
void
addError
(
IAttributeNode
node
,
String
msg
,
@Nullable
Throwable
e
)
{
errorNodes
.
add
(
node
);
errorNodes
.
add
(
node
);
errorsCount
++;
errorsCount
++;
if
(
e
!=
null
)
{
if
(
e
!=
null
)
{
if
(
e
.
getClass
()
==
JadxOverflowException
.
class
)
{
if
(
e
instanceof
JadxOverflowException
)
{
// don't print full stack trace
// don't print full stack trace
e
=
new
JadxOverflowException
(
e
.
getMessage
());
e
=
new
JadxOverflowException
(
e
.
getMessage
());
LOG
.
error
(
"{}, message: {}"
,
msg
,
e
.
getMessage
());
LOG
.
error
(
"{}, message: {}"
,
msg
,
e
.
getMessage
());
...
...
jadx-core/src/main/java/jadx/core/utils/files/FileUtils.java
浏览文件 @
c25f918c
...
@@ -195,8 +195,8 @@ public class FileUtils {
...
@@ -195,8 +195,8 @@ public class FileUtils {
makeDirs
(
testDir
);
makeDirs
(
testDir
);
if
(
caseCheckUpper
.
createNewFile
())
{
if
(
caseCheckUpper
.
createNewFile
())
{
boolean
caseSensitive
=
!
caseCheckLow
.
exists
();
boolean
caseSensitive
=
!
caseCheckLow
.
exists
();
LOG
.
debug
(
"Filesystem at {} is {}
case-sensitive"
,
testDir
.
getAbsolutePath
(),
LOG
.
debug
(
"Filesystem at {} is {}case-sensitive"
,
testDir
.
getAbsolutePath
(),
(
caseSensitive
?
""
:
"NOT"
));
(
caseSensitive
?
""
:
"NOT
"
));
return
caseSensitive
;
return
caseSensitive
;
}
else
{
}
else
{
LOG
.
debug
(
"Failed to create file: {}"
,
caseCheckUpper
.
getAbsolutePath
());
LOG
.
debug
(
"Failed to create file: {}"
,
caseCheckUpper
.
getAbsolutePath
());
...
...
jadx-core/src/test/java/jadx/tests/functional/TestIfCondition.java
浏览文件 @
c25f918c
...
@@ -10,11 +10,17 @@ import jadx.core.dex.instructions.args.LiteralArg;
...
@@ -10,11 +10,17 @@ import jadx.core.dex.instructions.args.LiteralArg;
import
jadx.core.dex.regions.conditions.Compare
;
import
jadx.core.dex.regions.conditions.Compare
;
import
jadx.core.dex.regions.conditions.IfCondition
;
import
jadx.core.dex.regions.conditions.IfCondition
;
import
static
jadx
.
core
.
dex
.
instructions
.
args
.
LiteralArg
.
TRUE
;
import
static
jadx
.
core
.
dex
.
regions
.
conditions
.
IfCondition
.
Mode
;
import
static
jadx
.
core
.
dex
.
regions
.
conditions
.
IfCondition
.
Mode
;
import
static
jadx
.
core
.
dex
.
regions
.
conditions
.
IfCondition
.
Mode
.
AND
;
import
static
jadx
.
core
.
dex
.
regions
.
conditions
.
IfCondition
.
Mode
.
COMPARE
;
import
static
jadx
.
core
.
dex
.
regions
.
conditions
.
IfCondition
.
Mode
.
NOT
;
import
static
jadx
.
core
.
dex
.
regions
.
conditions
.
IfCondition
.
Mode
.
OR
;
import
static
jadx
.
core
.
dex
.
regions
.
conditions
.
IfCondition
.
merge
;
import
static
jadx
.
core
.
dex
.
regions
.
conditions
.
IfCondition
.
merge
;
import
static
jadx
.
core
.
dex
.
regions
.
conditions
.
IfCondition
.
not
;
import
static
jadx
.
core
.
dex
.
regions
.
conditions
.
IfCondition
.
not
;
import
static
jadx
.
core
.
dex
.
regions
.
conditions
.
IfCondition
.
simplify
;
import
static
jadx
.
core
.
dex
.
regions
.
conditions
.
IfCondition
.
simplify
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestIfCondition
{
public
class
TestIfCondition
{
...
@@ -41,10 +47,10 @@ public class TestIfCondition {
...
@@ -41,10 +47,10 @@ public class TestIfCondition {
IfCondition
c
=
makeCondition
(
IfOp
.
NE
,
a
,
LiteralArg
.
FALSE
);
IfCondition
c
=
makeCondition
(
IfOp
.
NE
,
a
,
LiteralArg
.
FALSE
);
IfCondition
simp
=
simplify
(
c
);
IfCondition
simp
=
simplify
(
c
);
assert
Equals
(
simp
.
getMode
(),
Mode
.
COMPARE
);
assert
That
(
simp
.
getMode
(),
is
(
COMPARE
)
);
Compare
compare
=
simp
.
getCompare
();
Compare
compare
=
simp
.
getCompare
();
assert
Equals
(
compare
.
getA
(),
a
);
assert
That
(
compare
.
getA
(),
is
(
a
)
);
assert
Equals
(
compare
.
getB
(),
LiteralArg
.
TRUE
);
assert
That
(
compare
.
getB
(),
is
(
TRUE
)
);
}
}
@Test
@Test
...
@@ -53,23 +59,23 @@ public class TestIfCondition {
...
@@ -53,23 +59,23 @@ public class TestIfCondition {
IfCondition
b
=
makeSimpleCondition
();
IfCondition
b
=
makeSimpleCondition
();
IfCondition
c
=
merge
(
Mode
.
OR
,
a
,
b
);
IfCondition
c
=
merge
(
Mode
.
OR
,
a
,
b
);
assert
Equals
(
c
.
getMode
(),
Mode
.
OR
);
assert
That
(
c
.
getMode
(),
is
(
OR
)
);
assert
Equals
(
c
.
first
(),
a
);
assert
That
(
c
.
first
(),
is
(
a
)
);
assert
Equals
(
c
.
second
(),
b
);
assert
That
(
c
.
second
(),
is
(
b
)
);
}
}
@Test
@Test
public
void
testSimplifyNot
()
{
public
void
testSimplifyNot
()
{
// !(!a) => a
// !(!a) => a
IfCondition
a
=
not
(
not
(
makeSimpleCondition
()));
IfCondition
a
=
not
(
not
(
makeSimpleCondition
()));
assert
Equals
(
simplify
(
a
),
a
);
assert
That
(
simplify
(
a
),
is
(
a
)
);
}
}
@Test
@Test
public
void
testSimplifyNot2
()
{
public
void
testSimplifyNot2
()
{
// !(!a) => a
// !(!a) => a
IfCondition
a
=
not
(
makeNegCondition
());
IfCondition
a
=
not
(
makeNegCondition
());
assert
Equals
(
simplify
(
a
),
a
);
assert
That
(
simplify
(
a
),
is
(
a
)
);
}
}
@Test
@Test
...
@@ -80,9 +86,9 @@ public class TestIfCondition {
...
@@ -80,9 +86,9 @@ public class TestIfCondition {
IfCondition
c
=
not
(
merge
(
Mode
.
OR
,
not
(
a
),
not
(
b
)));
IfCondition
c
=
not
(
merge
(
Mode
.
OR
,
not
(
a
),
not
(
b
)));
IfCondition
simp
=
simplify
(
c
);
IfCondition
simp
=
simplify
(
c
);
assert
Equals
(
simp
.
getMode
(),
Mode
.
AND
);
assert
That
(
simp
.
getMode
(),
is
(
AND
)
);
assert
Equals
(
simp
.
first
(),
a
);
assert
That
(
simp
.
first
(),
is
(
a
)
);
assert
Equals
(
simp
.
second
(),
b
);
assert
That
(
simp
.
second
(),
is
(
b
)
);
}
}
@Test
@Test
...
@@ -94,12 +100,12 @@ public class TestIfCondition {
...
@@ -94,12 +100,12 @@ public class TestIfCondition {
IfCondition
cond
=
merge
(
Mode
.
AND
,
merge
(
Mode
.
OR
,
not
(
a
),
not
(
b
)),
not
(
c
));
IfCondition
cond
=
merge
(
Mode
.
AND
,
merge
(
Mode
.
OR
,
not
(
a
),
not
(
b
)),
not
(
c
));
IfCondition
simp
=
simplify
(
cond
);
IfCondition
simp
=
simplify
(
cond
);
assert
Equals
(
simp
.
getMode
(),
Mode
.
NOT
);
assert
That
(
simp
.
getMode
(),
is
(
NOT
)
);
IfCondition
f
=
simp
.
first
();
IfCondition
f
=
simp
.
first
();
assert
Equals
(
f
.
getMode
(),
Mode
.
OR
);
assert
That
(
f
.
getMode
(),
is
(
OR
)
);
assert
Equals
(
f
.
first
().
getMode
(),
Mode
.
AND
);
assert
That
(
f
.
first
().
getMode
(),
is
(
AND
)
);
assert
Equals
(
f
.
first
().
first
(),
a
);
assert
That
(
f
.
first
().
first
(),
is
(
a
)
);
assert
Equals
(
f
.
first
().
second
(),
b
);
assert
That
(
f
.
first
().
second
(),
is
(
b
)
);
assert
Equals
(
f
.
second
(),
c
);
assert
That
(
f
.
second
(),
is
(
c
)
);
}
}
}
}
jadx-core/src/test/java/jadx/tests/integration/TestDuplicateCast.java
浏览文件 @
c25f918c
...
@@ -12,7 +12,8 @@ import jadx.core.dex.nodes.MethodNode;
...
@@ -12,7 +12,8 @@ import jadx.core.dex.nodes.MethodNode;
import
jadx.tests.api.IntegrationTest
;
import
jadx.tests.api.IntegrationTest
;
import
static
org
.
hamcrest
.
CoreMatchers
.
containsString
;
import
static
org
.
hamcrest
.
CoreMatchers
.
containsString
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
hamcrest
.
Matchers
.
hasSize
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
...
@@ -39,12 +40,12 @@ public class TestDuplicateCast extends IntegrationTest {
...
@@ -39,12 +40,12 @@ public class TestDuplicateCast extends IntegrationTest {
assertThat
(
code
,
containsString
(
"return (int[]) o;"
));
assertThat
(
code
,
containsString
(
"return (int[]) o;"
));
List
<
InsnNode
>
insns
=
mth
.
getBasicBlocks
().
get
(
1
).
getInstructions
();
List
<
InsnNode
>
insns
=
mth
.
getBasicBlocks
().
get
(
1
).
getInstructions
();
assert
Equals
(
insns
.
size
(),
1
);
assert
That
(
insns
,
hasSize
(
1
)
);
InsnNode
insnNode
=
insns
.
get
(
0
);
InsnNode
insnNode
=
insns
.
get
(
0
);
assert
Equals
(
InsnType
.
RETURN
,
insnNode
.
getType
(
));
assert
That
(
insnNode
.
getType
(),
is
(
InsnType
.
RETURN
));
assertTrue
(
insnNode
.
getArg
(
0
).
isInsnWrap
());
assertTrue
(
insnNode
.
getArg
(
0
).
isInsnWrap
());
InsnNode
wrapInsn
=
((
InsnWrapArg
)
insnNode
.
getArg
(
0
)).
getWrapInsn
();
InsnNode
wrapInsn
=
((
InsnWrapArg
)
insnNode
.
getArg
(
0
)).
getWrapInsn
();
assert
Equals
(
InsnType
.
CHECK_CAST
,
wrapInsn
.
getType
(
));
assert
That
(
wrapInsn
.
getType
(),
is
(
InsnType
.
CHECK_CAST
));
assertFalse
(
wrapInsn
.
getArg
(
0
).
isInsnWrap
());
assertFalse
(
wrapInsn
.
getArg
(
0
).
isInsnWrap
());
}
}
}
}
jadx-gui/src/main/java/jadx/gui/jobs/BackgroundJob.java
浏览文件 @
c25f918c
package
jadx.gui.jobs
;
package
jadx.gui.jobs
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.Future
;
...
@@ -39,13 +38,10 @@ public abstract class BackgroundJob {
...
@@ -39,13 +38,10 @@ public abstract class BackgroundJob {
private
class
ShutdownTask
extends
FutureTask
<
Boolean
>
{
private
class
ShutdownTask
extends
FutureTask
<
Boolean
>
{
public
ShutdownTask
()
{
public
ShutdownTask
()
{
super
(
new
Callable
<
Boolean
>()
{
super
(()
->
{
@Override
public
Boolean
call
()
throws
Exception
{
runJob
();
runJob
();
executor
.
shutdown
();
executor
.
shutdown
();
return
executor
.
awaitTermination
(
5
,
TimeUnit
.
MINUTES
);
return
executor
.
awaitTermination
(
1
,
TimeUnit
.
HOURS
);
}
});
});
}
}
...
...
jadx-gui/src/main/java/jadx/gui/ui/CommonSearchDialog.java
浏览文件 @
c25f918c
...
@@ -12,8 +12,10 @@ import java.awt.event.MouseAdapter;
...
@@ -12,8 +12,10 @@ import java.awt.event.MouseAdapter;
import
java.awt.event.MouseEvent
;
import
java.awt.event.MouseEvent
;
import
java.awt.event.WindowAdapter
;
import
java.awt.event.WindowAdapter
;
import
java.awt.event.WindowEvent
;
import
java.awt.event.WindowEvent
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.fife.ui.rsyntaxtextarea.RSyntaxTextArea
;
import
org.fife.ui.rsyntaxtextarea.RSyntaxTextArea
;
import
org.fife.ui.rsyntaxtextarea.SyntaxConstants
;
import
org.fife.ui.rsyntaxtextarea.SyntaxConstants
;
...
@@ -143,7 +145,7 @@ public abstract class CommonSearchDialog extends JDialog {
...
@@ -143,7 +145,7 @@ public abstract class CommonSearchDialog extends JDialog {
protected
JPanel
initResultsTable
()
{
protected
JPanel
initResultsTable
()
{
ResultsTableCellRenderer
renderer
=
new
ResultsTableCellRenderer
();
ResultsTableCellRenderer
renderer
=
new
ResultsTableCellRenderer
();
resultsModel
=
new
ResultsModel
(
renderer
);
resultsModel
=
new
ResultsModel
(
renderer
);
resultsModel
.
addTableModelListener
(
(
e
)
->
updateProgressLabel
());
resultsModel
.
addTableModelListener
(
e
->
updateProgressLabel
());
resultsTable
=
new
ResultsTable
(
resultsModel
);
resultsTable
=
new
ResultsTable
(
resultsModel
);
resultsTable
.
setShowHorizontalLines
(
false
);
resultsTable
.
setShowHorizontalLines
(
false
);
resultsTable
.
setDragEnabled
(
false
);
resultsTable
.
setDragEnabled
(
false
);
...
@@ -183,24 +185,24 @@ public abstract class CommonSearchDialog extends JDialog {
...
@@ -183,24 +185,24 @@ public abstract class CommonSearchDialog extends JDialog {
ScrollPaneConstants
.
HORIZONTAL_SCROLLBAR_AS_NEEDED
));
ScrollPaneConstants
.
HORIZONTAL_SCROLLBAR_AS_NEEDED
));
JPanel
paginationPanel
=
new
JPanel
();
JPanel
paginationPanel
=
new
JPanel
();
paginationPanel
.
setAlignmentX
(
Component
.
LEFT_ALIGNMENT
);
paginationPanel
.
setAlignmentX
(
Component
.
LEFT_ALIGNMENT
);
paginationPanel
.
setLayout
(
new
BoxLayout
(
paginationPanel
,
BoxLayout
.
X_AXIS
));
paginationPanel
.
setLayout
(
new
BoxLayout
(
paginationPanel
,
BoxLayout
.
X_AXIS
));
resultsInfoLabel
=
new
JLabel
(
""
);
resultsInfoLabel
=
new
JLabel
(
""
);
JButton
nextPageButton
=
new
JButton
(
"->"
);
JButton
nextPageButton
=
new
JButton
(
"->"
);
nextPageButton
.
setToolTipText
(
NLS
.
str
(
"search_dialog.next_page"
));
nextPageButton
.
setToolTipText
(
NLS
.
str
(
"search_dialog.next_page"
));
nextPageButton
.
addActionListener
(
(
e
)
->
{
nextPageButton
.
addActionListener
(
e
->
{
resultsModel
.
nextPage
();
resultsModel
.
nextPage
();
resultsTable
.
updateTable
();
resultsTable
.
updateTable
();
resultsTable
.
scrollRectToVisible
(
new
Rectangle
(
0
,
0
,
1
,
1
));
resultsTable
.
scrollRectToVisible
(
new
Rectangle
(
0
,
0
,
1
,
1
));
});
});
JButton
prevPageButton
=
new
JButton
(
"<-"
);
JButton
prevPageButton
=
new
JButton
(
"<-"
);
prevPageButton
.
setToolTipText
(
NLS
.
str
(
"search_dialog.prev_page"
));
prevPageButton
.
setToolTipText
(
NLS
.
str
(
"search_dialog.prev_page"
));
prevPageButton
.
addActionListener
(
(
e
)
->
{
prevPageButton
.
addActionListener
(
e
->
{
resultsModel
.
prevPage
();
resultsModel
.
prevPage
();
resultsTable
.
updateTable
();
resultsTable
.
updateTable
();
resultsTable
.
scrollRectToVisible
(
new
Rectangle
(
0
,
0
,
1
,
1
));
resultsTable
.
scrollRectToVisible
(
new
Rectangle
(
0
,
0
,
1
,
1
));
});
});
paginationPanel
.
add
(
prevPageButton
);
paginationPanel
.
add
(
prevPageButton
);
...
@@ -309,8 +311,9 @@ public abstract class CommonSearchDialog extends JDialog {
...
@@ -309,8 +311,9 @@ public abstract class CommonSearchDialog extends JDialog {
}
}
public
int
getDisplayedResultsStart
()
{
public
int
getDisplayedResultsStart
()
{
if
(
rows
.
size
()
==
0
)
if
(
rows
.
isEmpty
())
{
return
0
;
return
0
;
}
return
start
+
1
;
return
start
+
1
;
}
}
...
...
jadx-gui/src/main/java/jadx/gui/ui/MainWindow.java
浏览文件 @
c25f918c
...
@@ -27,8 +27,6 @@ import java.util.Arrays;
...
@@ -27,8 +27,6 @@ import java.util.Arrays;
import
java.util.EnumSet
;
import
java.util.EnumSet
;
import
java.util.Timer
;
import
java.util.Timer
;
import
java.util.TimerTask
;
import
java.util.TimerTask
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -501,12 +499,7 @@ public class MainWindow extends JFrame {
...
@@ -501,12 +499,7 @@ public class MainWindow extends JFrame {
flatPkgButton
=
new
JToggleButton
(
ICON_FLAT_PKG
);
flatPkgButton
=
new
JToggleButton
(
ICON_FLAT_PKG
);
flatPkgButton
.
setSelected
(
isFlattenPackage
);
flatPkgButton
.
setSelected
(
isFlattenPackage
);
ActionListener
flatPkgAction
=
new
ActionListener
()
{
ActionListener
flatPkgAction
=
e
->
toggleFlattenPackage
();
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
toggleFlattenPackage
();
}
};
flatPkgMenuItem
.
addActionListener
(
flatPkgAction
);
flatPkgMenuItem
.
addActionListener
(
flatPkgAction
);
flatPkgButton
.
addActionListener
(
flatPkgAction
);
flatPkgButton
.
addActionListener
(
flatPkgAction
);
flatPkgButton
.
setToolTipText
(
NLS
.
str
(
"menu.flatten"
));
flatPkgButton
.
setToolTipText
(
NLS
.
str
(
"menu.flatten"
));
...
@@ -660,7 +653,7 @@ public class MainWindow extends JFrame {
...
@@ -660,7 +653,7 @@ public class MainWindow extends JFrame {
}
}
@Override
@Override
public
void
menuSelected
(
MenuEvent
e
)
{
public
void
menuSelected
(
MenuEvent
menuEvent
)
{
recentFiles
.
removeAll
();
recentFiles
.
removeAll
();
File
openFile
=
wrapper
.
getOpenFile
();
File
openFile
=
wrapper
.
getOpenFile
();
String
currentFile
=
openFile
==
null
?
""
:
openFile
.
getAbsolutePath
();
String
currentFile
=
openFile
==
null
?
""
:
openFile
.
getAbsolutePath
();
...
@@ -670,12 +663,7 @@ public class MainWindow extends JFrame {
...
@@ -670,12 +663,7 @@ public class MainWindow extends JFrame {
}
}
JMenuItem
menuItem
=
new
JMenuItem
(
file
);
JMenuItem
menuItem
=
new
JMenuItem
(
file
);
recentFiles
.
add
(
menuItem
);
recentFiles
.
add
(
menuItem
);
menuItem
.
addActionListener
(
new
ActionListener
()
{
menuItem
.
addActionListener
(
e
->
openFile
(
new
File
(
file
)));
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
openFile
(
new
File
(
file
));
}
});
}
}
if
(
recentFiles
.
getItemCount
()
==
0
)
{
if
(
recentFiles
.
getItemCount
()
==
0
)
{
recentFiles
.
add
(
new
JMenuItem
(
NLS
.
str
(
"menu.no_recent_files"
)));
recentFiles
.
add
(
new
JMenuItem
(
NLS
.
str
(
"menu.no_recent_files"
)));
...
...
jadx-gui/src/main/java/jadx/gui/ui/SearchDialog.java
浏览文件 @
c25f918c
...
@@ -6,11 +6,8 @@ import javax.swing.event.DocumentListener;
...
@@ -6,11 +6,8 @@ import javax.swing.event.DocumentListener;
import
java.awt.*
;
import
java.awt.*
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
java.awt.event.ActionListener
;
import
java.awt.event.ItemEvent
;
import
java.awt.event.ItemListener
;
import
java.awt.event.KeyAdapter
;
import
java.awt.event.KeyAdapter
;
import
java.awt.event.KeyEvent
;
import
java.awt.event.KeyEvent
;
import
java.util.EnumSet
;
import
java.util.Set
;
import
java.util.Set
;
import
jadx.gui.utils.NLS
;
import
jadx.gui.utils.NLS
;
...
@@ -28,7 +25,7 @@ public class SearchDialog extends CommonSearchDialog {
...
@@ -28,7 +25,7 @@ public class SearchDialog extends CommonSearchDialog {
CODE
CODE
}
}
private
Set
<
SearchOptions
>
options
=
EnumSet
.
allOf
(
SearchOptions
.
class
)
;
private
Set
<
SearchOptions
>
options
;
private
JTextField
searchField
;
private
JTextField
searchField
;
private
JCheckBox
caseChBox
;
private
JCheckBox
caseChBox
;
...
@@ -87,7 +84,6 @@ public class SearchDialog extends CommonSearchDialog {
...
@@ -87,7 +84,6 @@ public class SearchDialog extends CommonSearchDialog {
}
}
private
class
SearchFieldListener
implements
DocumentListener
,
ActionListener
{
private
class
SearchFieldListener
implements
DocumentListener
,
ActionListener
{
private
Timer
timer
;
private
Timer
timer
;
private
synchronized
void
change
()
{
private
synchronized
void
change
()
{
...
@@ -126,11 +122,7 @@ public class SearchDialog extends CommonSearchDialog {
...
@@ -126,11 +122,7 @@ public class SearchDialog extends CommonSearchDialog {
new
TextStandardActions
(
searchField
);
new
TextStandardActions
(
searchField
);
caseChBox
=
new
JCheckBox
(
NLS
.
str
(
"search_dialog.ignorecase"
));
caseChBox
=
new
JCheckBox
(
NLS
.
str
(
"search_dialog.ignorecase"
));
caseChBox
.
addItemListener
(
new
ItemListener
()
{
caseChBox
.
addItemListener
(
e
->
performSearch
());
public
void
itemStateChanged
(
ItemEvent
e
)
{
performSearch
();
}
});
JCheckBox
clsChBox
=
makeOptionsCheckBox
(
NLS
.
str
(
"search_dialog.class"
),
SearchOptions
.
CLASS
);
JCheckBox
clsChBox
=
makeOptionsCheckBox
(
NLS
.
str
(
"search_dialog.class"
),
SearchOptions
.
CLASS
);
JCheckBox
mthChBox
=
makeOptionsCheckBox
(
NLS
.
str
(
"search_dialog.method"
),
SearchOptions
.
METHOD
);
JCheckBox
mthChBox
=
makeOptionsCheckBox
(
NLS
.
str
(
"search_dialog.method"
),
SearchOptions
.
METHOD
);
...
@@ -196,15 +188,13 @@ public class SearchDialog extends CommonSearchDialog {
...
@@ -196,15 +188,13 @@ public class SearchDialog extends CommonSearchDialog {
final
JCheckBox
chBox
=
new
JCheckBox
(
name
);
final
JCheckBox
chBox
=
new
JCheckBox
(
name
);
chBox
.
setAlignmentX
(
LEFT_ALIGNMENT
);
chBox
.
setAlignmentX
(
LEFT_ALIGNMENT
);
chBox
.
setSelected
(
options
.
contains
(
opt
));
chBox
.
setSelected
(
options
.
contains
(
opt
));
chBox
.
addItemListener
(
new
ItemListener
()
{
chBox
.
addItemListener
(
e
->
{
public
void
itemStateChanged
(
ItemEvent
e
)
{
if
(
chBox
.
isSelected
())
{
if
(
chBox
.
isSelected
())
{
options
.
add
(
opt
);
options
.
add
(
opt
);
}
else
{
}
else
{
options
.
remove
(
opt
);
options
.
remove
(
opt
);
}
}
performSearch
();
performSearch
();
}
});
});
return
chBox
;
return
chBox
;
}
}
...
...
jadx-gui/src/main/java/jadx/gui/utils/search/CodeIndex.java
浏览文件 @
c25f918c
...
@@ -7,7 +7,7 @@ import java.util.List;
...
@@ -7,7 +7,7 @@ import java.util.List;
public
class
CodeIndex
<
T
>
implements
SearchIndex
<
T
>
{
public
class
CodeIndex
<
T
>
implements
SearchIndex
<
T
>
{
private
final
List
<
StringRef
>
keys
=
new
ArrayList
<>();
private
final
List
<
StringRef
>
keys
=
new
ArrayList
<>();
private
final
List
<
T
>
values
=
new
ArrayList
<
T
>();
private
final
List
<
T
>
values
=
new
ArrayList
<>();
@Override
@Override
public
void
put
(
String
str
,
T
value
)
{
public
void
put
(
String
str
,
T
value
)
{
...
...
jadx-gui/src/main/java/jadx/gui/utils/search/SimpleIndex.java
浏览文件 @
c25f918c
...
@@ -7,7 +7,7 @@ import java.util.List;
...
@@ -7,7 +7,7 @@ import java.util.List;
public
class
SimpleIndex
<
T
>
implements
SearchIndex
<
T
>
{
public
class
SimpleIndex
<
T
>
implements
SearchIndex
<
T
>
{
private
final
List
<
String
>
keys
=
new
ArrayList
<>();
private
final
List
<
String
>
keys
=
new
ArrayList
<>();
private
final
List
<
T
>
values
=
new
ArrayList
<
T
>();
private
final
List
<
T
>
values
=
new
ArrayList
<>();
@Override
@Override
public
void
put
(
String
str
,
T
value
)
{
public
void
put
(
String
str
,
T
value
)
{
...
...
jadx-gui/src/main/java/jadx/gui/utils/search/StringRef.java
浏览文件 @
c25f918c
package
jadx.gui.utils.search
;
package
jadx.gui.utils.search
;
import
static
jadx
.
gui
.
utils
.
Utils
.
caseChar
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.NotNull
;
import
static
jadx
.
gui
.
utils
.
Utils
.
caseChar
;
public
class
StringRef
implements
CharSequence
{
public
class
StringRef
implements
CharSequence
{
private
final
String
refStr
;
private
final
String
refStr
;
...
@@ -187,5 +188,4 @@ public class StringRef implements CharSequence {
...
@@ -187,5 +188,4 @@ public class StringRef implements CharSequence {
int
offset
=
this
.
offset
;
int
offset
=
this
.
offset
;
return
refStr
.
substring
(
offset
,
offset
+
len
);
return
refStr
.
substring
(
offset
,
offset
+
len
);
}
}
}
}
jadx-gui/src/test/java/jadx/gui/treemodel/JSourcesTest.java
浏览文件 @
c25f918c
package
jadx.gui.treemodel
;
package
jadx.gui.treemodel
;
import
java.util.
Array
s
;
import
java.util.
Collection
s
;
import
java.util.List
;
import
java.util.List
;
import
org.junit.Before
;
import
org.junit.Before
;
...
@@ -12,10 +12,12 @@ import jadx.api.JadxDecompiler;
...
@@ -12,10 +12,12 @@ import jadx.api.JadxDecompiler;
import
jadx.api.JavaClass
;
import
jadx.api.JavaClass
;
import
jadx.api.JavaPackage
;
import
jadx.api.JavaPackage
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.core.utils.exceptions.JadxException
;
import
jadx.gui.JadxWrapper
;
import
jadx.gui.JadxWrapper
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
java
.
util
.
Arrays
.
asList
;
import
static
org
.
hamcrest
.
Matchers
.
hasSize
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
static
org
.
mockito
.
Mockito
.
when
;
...
@@ -25,7 +27,7 @@ public class JSourcesTest {
...
@@ -25,7 +27,7 @@ public class JSourcesTest {
private
JadxDecompiler
decompiler
;
private
JadxDecompiler
decompiler
;
@Before
@Before
public
void
init
()
throws
JadxException
{
public
void
init
()
{
JRoot
root
=
mock
(
JRoot
.
class
);
JRoot
root
=
mock
(
JRoot
.
class
);
when
(
root
.
isFlatPackages
()).
thenReturn
(
false
);
when
(
root
.
isFlatPackages
()).
thenReturn
(
false
);
JadxWrapper
wrapper
=
mock
(
JadxWrapper
.
class
);
JadxWrapper
wrapper
=
mock
(
JadxWrapper
.
class
);
...
@@ -37,50 +39,50 @@ public class JSourcesTest {
...
@@ -37,50 +39,50 @@ public class JSourcesTest {
public
void
testHierarchyPackages
()
{
public
void
testHierarchyPackages
()
{
String
pkgName
=
"a.b.c.d.e"
;
String
pkgName
=
"a.b.c.d.e"
;
List
<
JavaPackage
>
packages
=
Arrays
.
as
List
(
newPkg
(
pkgName
));
List
<
JavaPackage
>
packages
=
Collections
.
singleton
List
(
newPkg
(
pkgName
));
List
<
JPackage
>
out
=
sources
.
getHierarchyPackages
(
packages
);
List
<
JPackage
>
out
=
sources
.
getHierarchyPackages
(
packages
);
assert
Equals
(
out
.
size
(),
1
);
assert
That
(
out
,
hasSize
(
1
)
);
JPackage
j
p
kg
=
out
.
get
(
0
);
JPackage
j
P
kg
=
out
.
get
(
0
);
assert
Equals
(
jpkg
.
getName
(),
pkgName
);
assert
That
(
jPkg
.
getName
(),
is
(
pkgName
)
);
assert
Equals
(
jpkg
.
getClasses
().
size
(),
1
);
assert
That
(
jPkg
.
getClasses
(),
hasSize
(
1
)
);
}
}
@Test
@Test
public
void
testHierarchyPackages2
()
{
public
void
testHierarchyPackages2
()
{
List
<
JavaPackage
>
packages
=
Arrays
.
asList
(
List
<
JavaPackage
>
packages
=
asList
(
newPkg
(
"a.b"
),
newPkg
(
"a.b"
),
newPkg
(
"a.c"
),
newPkg
(
"a.c"
),
newPkg
(
"a.d"
)
newPkg
(
"a.d"
)
);
);
List
<
JPackage
>
out
=
sources
.
getHierarchyPackages
(
packages
);
List
<
JPackage
>
out
=
sources
.
getHierarchyPackages
(
packages
);
assert
Equals
(
out
.
size
(),
1
);
assert
That
(
out
,
hasSize
(
1
)
);
JPackage
j
p
kg
=
out
.
get
(
0
);
JPackage
j
P
kg
=
out
.
get
(
0
);
assert
Equals
(
jpkg
.
getName
(),
"a"
);
assert
That
(
jPkg
.
getName
(),
is
(
"a"
)
);
assert
Equals
(
jpkg
.
getClasses
().
size
(),
0
);
assert
That
(
jPkg
.
getClasses
(),
hasSize
(
0
)
);
assert
Equals
(
jpkg
.
getInnerPackages
().
size
(),
3
);
assert
That
(
jPkg
.
getInnerPackages
(),
hasSize
(
3
)
);
}
}
@Test
@Test
public
void
testHierarchyPackages3
()
{
public
void
testHierarchyPackages3
()
{
List
<
JavaPackage
>
packages
=
Arrays
.
asList
(
List
<
JavaPackage
>
packages
=
asList
(
newPkg
(
"a.b.p1"
),
newPkg
(
"a.b.p1"
),
newPkg
(
"a.b.p2"
),
newPkg
(
"a.b.p2"
),
newPkg
(
"a.b.p3"
)
newPkg
(
"a.b.p3"
)
);
);
List
<
JPackage
>
out
=
sources
.
getHierarchyPackages
(
packages
);
List
<
JPackage
>
out
=
sources
.
getHierarchyPackages
(
packages
);
assert
Equals
(
out
.
size
(),
1
);
assert
That
(
out
,
hasSize
(
1
)
);
JPackage
j
p
kg
=
out
.
get
(
0
);
JPackage
j
P
kg
=
out
.
get
(
0
);
assert
Equals
(
jpkg
.
getName
(),
"a.b"
);
assert
That
(
jPkg
.
getName
(),
is
(
"a.b"
)
);
assert
Equals
(
jpkg
.
getClasses
().
size
(),
0
);
assert
That
(
jPkg
.
getClasses
(),
hasSize
(
0
)
);
assert
Equals
(
jpkg
.
getInnerPackages
().
size
(),
3
);
assert
That
(
jPkg
.
getInnerPackages
(),
hasSize
(
3
)
);
}
}
@Test
@Test
public
void
testHierarchyPackages4
()
{
public
void
testHierarchyPackages4
()
{
List
<
JavaPackage
>
packages
=
Arrays
.
asList
(
List
<
JavaPackage
>
packages
=
asList
(
newPkg
(
"a.p1"
),
newPkg
(
"a.p1"
),
newPkg
(
"a.b.c.p2"
),
newPkg
(
"a.b.c.p2"
),
newPkg
(
"a.b.c.p3"
),
newPkg
(
"a.b.c.p3"
),
...
@@ -89,19 +91,18 @@ public class JSourcesTest {
...
@@ -89,19 +91,18 @@ public class JSourcesTest {
);
);
List
<
JPackage
>
out
=
sources
.
getHierarchyPackages
(
packages
);
List
<
JPackage
>
out
=
sources
.
getHierarchyPackages
(
packages
);
assert
Equals
(
out
.
size
(),
2
);
assert
That
(
out
,
hasSize
(
2
)
);
assert
Equals
(
out
.
get
(
0
).
getName
(),
"a"
);
assert
That
(
out
.
get
(
0
).
getName
(),
is
(
"a"
)
);
assert
Equals
(
out
.
get
(
0
).
getInnerPackages
().
size
(),
2
);
assert
That
(
out
.
get
(
0
).
getInnerPackages
(),
hasSize
(
2
)
);
assert
Equals
(
out
.
get
(
1
).
getName
(),
"d"
);
assert
That
(
out
.
get
(
1
).
getName
(),
is
(
"d"
)
);
assert
Equals
(
out
.
get
(
1
).
getInnerPackages
().
size
(),
2
);
assert
That
(
out
.
get
(
1
).
getInnerPackages
(),
hasSize
(
2
)
);
}
}
private
JavaPackage
newPkg
(
String
name
)
{
private
JavaPackage
newPkg
(
String
name
)
{
return
Factory
.
newPackage
(
name
,
Arrays
.
as
List
(
newClass
()));
return
Factory
.
newPackage
(
name
,
Collections
.
singleton
List
(
newClass
()));
}
}
private
JavaClass
newClass
()
{
private
JavaClass
newClass
()
{
return
Factory
.
newClass
(
decompiler
,
mock
(
ClassNode
.
class
));
return
Factory
.
newClass
(
decompiler
,
mock
(
ClassNode
.
class
));
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录