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
123ba2ba
Commit
123ba2ba
authored
May 25, 2019
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: workaround for primitive values if type resolved incorrectly (#671)
parent
f2f8936c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
15 deletions
+54
-15
TypeGen.java
jadx-core/src/main/java/jadx/core/codegen/TypeGen.java
+15
-15
TestTypeResolver9.java
.../java/jadx/tests/integration/types/TestTypeResolver9.java
+39
-0
No files found.
jadx-core/src/main/java/jadx/core/codegen/TypeGen.java
View file @
123ba2ba
...
...
@@ -65,11 +65,11 @@ public class TypeGen {
}
return
stringUtils
.
unescapeChar
(
ch
);
case
BYTE:
return
formatByte
(
(
byte
)
lit
);
return
formatByte
(
lit
);
case
SHORT:
return
formatShort
(
(
short
)
lit
);
return
formatShort
(
lit
);
case
INT:
return
formatInteger
(
(
int
)
lit
);
return
formatInteger
(
lit
);
case
LONG:
return
formatLong
(
lit
);
case
FLOAT:
...
...
@@ -90,34 +90,34 @@ public class TypeGen {
}
}
public
static
String
formatShort
(
short
s
)
{
if
(
s
==
Short
.
MAX_VALUE
)
{
public
static
String
formatShort
(
long
l
)
{
if
(
l
==
Short
.
MAX_VALUE
)
{
return
"Short.MAX_VALUE"
;
}
if
(
s
==
Short
.
MIN_VALUE
)
{
if
(
l
==
Short
.
MIN_VALUE
)
{
return
"Short.MIN_VALUE"
;
}
return
Short
.
toString
(
s
);
return
Long
.
toString
(
l
);
}
public
static
String
formatByte
(
byte
b
)
{
if
(
b
==
Byte
.
MAX_VALUE
)
{
public
static
String
formatByte
(
long
l
)
{
if
(
l
==
Byte
.
MAX_VALUE
)
{
return
"Byte.MAX_VALUE"
;
}
if
(
b
==
Byte
.
MIN_VALUE
)
{
if
(
l
==
Byte
.
MIN_VALUE
)
{
return
"Byte.MIN_VALUE"
;
}
return
Byte
.
toString
(
b
);
return
Long
.
toString
(
l
);
}
public
static
String
formatInteger
(
int
i
)
{
if
(
i
==
Integer
.
MAX_VALUE
)
{
public
static
String
formatInteger
(
long
l
)
{
if
(
l
==
Integer
.
MAX_VALUE
)
{
return
"Integer.MAX_VALUE"
;
}
if
(
i
==
Integer
.
MIN_VALUE
)
{
if
(
l
==
Integer
.
MIN_VALUE
)
{
return
"Integer.MIN_VALUE"
;
}
return
Integer
.
toString
(
i
);
return
Long
.
toString
(
l
);
}
public
static
String
formatLong
(
long
l
)
{
...
...
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver9.java
0 → 100644
View file @
123ba2ba
package
jadx
.
tests
.
integration
.
types
;
import
org.junit.jupiter.api.Test
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.tests.api.IntegrationTest
;
import
static
jadx
.
tests
.
api
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
hamcrest
.
Matchers
.
containsString
;
import
static
org
.
hamcrest
.
Matchers
.
not
;
public
class
TestTypeResolver9
extends
IntegrationTest
{
public
static
class
TestCls
{
public
int
test
(
byte
b
)
{
return
16777216
*
b
;
}
public
int
test2
(
byte
[]
array
,
int
offset
)
{
return
(
array
[
offset
]
*
128
)
+
(
array
[
offset
+
1
]
&
0xFF
);
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsOne
(
"return 16777216 * b;"
));
assertThat
(
code
,
not
(
containsString
(
"Byte.MIN_VALUE"
)));
}
@Test
public
void
testNoDebug
()
{
noDebugInfo
();
getClassNode
(
TestCls
.
class
);
}
}
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