-
-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
handle field / method name collision #21
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,62 @@ public void genericsCanBeUsed() { | |
assertEquals("Badger", script.getNextMessage()); | ||
} | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's an extra blank line here. |
||
@Test | ||
public void fieldsThatCollideWithMethodsGetSuffixed() { | ||
loadScript("var Collider = Java.use('re.frida.Collider');" + | ||
"var collider = Collider.$new();" + | ||
"send(collider._particle);"); | ||
assertEquals("1", script.getNextMessage()); | ||
} | ||
|
||
@Test | ||
public void methodsThatCollideWithFieldsKeepName() { | ||
loadScript("var Collider = Java.use('re.frida.Collider');" + | ||
"var collider = Collider.$new();" + | ||
"send(collider.particle());"); | ||
assertEquals("3", script.getNextMessage()); | ||
} | ||
|
||
@Test | ||
public void fieldsThatCollideWithMethodsGetSuffixed2() { | ||
loadScript("var Collider = Java.use('re.frida.Collider');" + | ||
"var collider = Collider.$new();" + | ||
"send(collider._particle2);"); | ||
assertEquals("2", script.getNextMessage()); | ||
} | ||
|
||
@Test | ||
public void methodsThatCollideWithFieldsKeepName2() { | ||
loadScript("var Collider = Java.use('re.frida.Collider');" + | ||
"var collider = Collider.$new();" + | ||
"send(collider.particle2());"); | ||
assertEquals("4", script.getNextMessage()); | ||
} | ||
|
||
@Test | ||
public void collidedMethodsFieldsCanStillBeInstrumented() { | ||
loadScript("var Collider = Java.use('re.frida.Collider');" + | ||
"Collider._particle.implementation = function () {" + | ||
"return 11;" + | ||
"};" + | ||
"Collider._particle2.implementation = function () {" + | ||
"return 22;" + | ||
"};" + | ||
"Collider.particle.implementation = function () {" + | ||
"return 33;" + | ||
"};" + | ||
"Collider.particle2.implementation = function () {" + | ||
"return 44;" + | ||
"};"); | ||
|
||
Collider collider = new Collider(); | ||
assertEquals(11, Collider.particle); | ||
assertEquals(22, collider.particle2); | ||
assertEquals(33, collider.particle()); | ||
assertEquals(44, Collider.particle2()); | ||
} | ||
|
||
// @Test | ||
public void interfaceCanBeImplemented() { | ||
loadScript("var X509TrustManager = Java.use('javax.net.ssl.X509TrustManager');" + | ||
|
@@ -118,3 +174,17 @@ public int returnZero() { | |
return 0; | ||
} | ||
} | ||
|
||
class Collider { | ||
static int particle = 1; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing whitespace. |
||
int particle2 = 2; | ||
|
||
int particle() { | ||
return 3; | ||
} | ||
|
||
static int particle2(){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing space before |
||
return 4; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Field- and method-names should follow the coding style, i.e. |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let
, as they belong together. Then put a blank line between that and thefieldHandle
stuff (those two lines), and then one blank line before assigning tojsFields
. Just to make the code a bit more readable.{
.