Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
c5d977ba
Commit
c5d977ba
authored
Mar 29, 2019
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: always use runtime compiler for build dex (#536)
parent
b5344f45
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
41 deletions
+34
-41
IntegrationTest.java
jadx-core/src/test/java/jadx/tests/api/IntegrationTest.java
+17
-23
TestImportGenericMap.java
...jadx/tests/integration/generics/TestImportGenericMap.java
+17
-17
TestInner2Samples.java
.../java/jadx/tests/integration/inner/TestInner2Samples.java
+0
-1
No files found.
jadx-core/src/test/java/jadx/tests/api/IntegrationTest.java
View file @
c5d977ba
...
@@ -311,21 +311,13 @@ public abstract class IntegrationTest extends TestUtils {
...
@@ -311,21 +311,13 @@ public abstract class IntegrationTest extends TestUtils {
}
}
public
File
getJarForClass
(
Class
<?>
cls
)
throws
IOException
{
public
File
getJarForClass
(
Class
<?>
cls
)
throws
IOException
{
String
path
=
cls
.
getPackage
().
getName
().
replace
(
'.'
,
'/'
);
List
<
File
>
files
=
compileClass
(
cls
);
List
<
File
>
list
;
assertThat
(
"File list is empty"
,
files
,
not
(
empty
()));
if
(!
withDebugInfo
)
{
list
=
compileClass
(
cls
);
}
else
{
list
=
getClassFilesWithInners
(
cls
);
if
(
list
.
isEmpty
())
{
list
=
compileClass
(
cls
);
}
}
assertThat
(
"File list is empty"
,
list
,
not
(
empty
()));
String
path
=
cls
.
getPackage
().
getName
().
replace
(
'.'
,
'/'
);
File
temp
=
createTempFile
(
".jar"
);
File
temp
=
createTempFile
(
".jar"
);
try
(
JarOutputStream
jo
=
new
JarOutputStream
(
new
FileOutputStream
(
temp
)))
{
try
(
JarOutputStream
jo
=
new
JarOutputStream
(
new
FileOutputStream
(
temp
)))
{
for
(
File
file
:
list
)
{
for
(
File
file
:
files
)
{
addFileToJar
(
jo
,
file
,
path
+
'/'
+
file
.
getName
());
addFileToJar
(
jo
,
file
,
path
+
'/'
+
file
.
getName
());
}
}
}
}
...
@@ -382,27 +374,29 @@ public abstract class IntegrationTest extends TestUtils {
...
@@ -382,27 +374,29 @@ public abstract class IntegrationTest extends TestUtils {
}
}
private
List
<
File
>
compileClass
(
Class
<?>
cls
)
throws
IOException
{
private
List
<
File
>
compileClass
(
Class
<?>
cls
)
throws
IOException
{
String
fileName
=
cls
.
getName
();
String
clsFullName
=
cls
.
getName
();
int
end
=
fileName
.
indexOf
(
'$'
);
String
rootClsName
;
int
end
=
clsFullName
.
indexOf
(
'$'
);
if
(
end
!=
-
1
)
{
if
(
end
!=
-
1
)
{
fileName
=
fileName
.
substring
(
0
,
end
);
rootClsName
=
clsFullName
.
substring
(
0
,
end
);
}
else
{
rootClsName
=
clsFullName
;
}
}
fileName
=
file
Name
.
replace
(
'.'
,
'/'
)
+
".java"
;
String
javaFileName
=
rootCls
Name
.
replace
(
'.'
,
'/'
)
+
".java"
;
File
file
=
new
File
(
TEST_DIRECTORY
,
f
ileName
);
File
file
=
new
File
(
TEST_DIRECTORY
,
javaF
ileName
);
if
(!
file
.
exists
())
{
if
(!
file
.
exists
())
{
file
=
new
File
(
TEST_DIRECTORY2
,
f
ileName
);
file
=
new
File
(
TEST_DIRECTORY2
,
javaF
ileName
);
}
}
assertThat
(
"Test source file not found: "
+
f
ileName
,
file
.
exists
(),
is
(
true
));
assertThat
(
"Test source file not found: "
+
javaF
ileName
,
file
.
exists
(),
is
(
true
));
List
<
File
>
compileFileList
=
Collections
.
singletonList
(
file
);
List
<
File
>
compileFileList
=
Collections
.
singletonList
(
file
);
File
outTmp
=
createTempDir
(
"jadx-tmp-classes"
);
File
outTmp
=
createTempDir
(
"jadx-tmp-classes"
);
outTmp
.
deleteOnExit
();
outTmp
.
deleteOnExit
();
List
<
File
>
files
=
StaticCompiler
.
compile
(
compileFileList
,
outTmp
,
withDebugInfo
);
List
<
File
>
files
=
StaticCompiler
.
compile
(
compileFileList
,
outTmp
,
withDebugInfo
);
files
.
forEach
(
File:
:
deleteOnExit
);
// remove classes which are parents for test class
// remove classes which are parents for test class
files
.
removeIf
(
next
->
!
next
.
getName
().
contains
(
cls
.
getSimpleName
()));
String
clsName
=
clsFullName
.
substring
(
clsFullName
.
lastIndexOf
(
'.'
)
+
1
);
for
(
File
clsFile
:
files
)
{
files
.
removeIf
(
next
->
!
next
.
getName
().
contains
(
clsName
));
clsFile
.
deleteOnExit
();
}
return
files
;
return
files
;
}
}
...
...
jadx-core/src/test/java/jadx/tests/integration/generics/TestImportGenericMap.java
View file @
c5d977ba
...
@@ -11,19 +11,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
...
@@ -11,19 +11,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
public
class
TestImportGenericMap
extends
IntegrationTest
{
public
class
TestImportGenericMap
extends
IntegrationTest
{
@Test
public
static
class
SuperClass
<
O
extends
SuperClass
.
ToImport
>
{
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
SuperClass
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsString
(
"import "
+
SuperClass
.
ToImport
.
class
.
getName
().
replace
(
'$'
,
'.'
)
+
';'
));
assertThat
(
code
,
not
(
containsString
(
"import "
+
SuperClass
.
NotToImport
.
class
.
getName
().
replace
(
'$'
,
'.'
)
+
';'
)));
}
}
final
class
SuperClass
<
O
extends
SuperClass
.
ToImport
>
{
interface
ToImport
{
interface
ToImport
{
}
}
...
@@ -36,4 +24,16 @@ final class SuperClass<O extends SuperClass.ToImport> {
...
@@ -36,4 +24,16 @@ final class SuperClass<O extends SuperClass.ToImport> {
public
<
C
extends
NotToImport
>
SuperClass
(
Class1
<
C
>
zzf
)
{
public
<
C
extends
NotToImport
>
SuperClass
(
Class1
<
C
>
zzf
)
{
}
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
SuperClass
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsString
(
"import "
+
SuperClass
.
ToImport
.
class
.
getName
().
replace
(
"$ToImport"
,
".ToImport"
)
+
';'
));
assertThat
(
code
,
not
(
containsString
(
"import "
+
SuperClass
.
NotToImport
.
class
.
getName
().
replace
(
"NotToImport"
,
".NotToImport"
)
+
';'
)));
}
}
}
jadx-core/src/test/java/jadx/tests/integration/inner/TestInner2Samples.java
View file @
c5d977ba
...
@@ -13,7 +13,6 @@ import static org.hamcrest.Matchers.not;
...
@@ -13,7 +13,6 @@ import static org.hamcrest.Matchers.not;
public
class
TestInner2Samples
extends
IntegrationTest
{
public
class
TestInner2Samples
extends
IntegrationTest
{
public
static
class
TestInner2
{
public
static
class
TestInner2
{
private
String
a
;
private
String
a
;
public
class
A
{
public
class
A
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment