handle field / method name collision#21
Merged
oleavr merged 4 commits intofrida:masterfrom Mar 2, 2017
Merged
Conversation
oleavr
requested changes
Mar 1, 2017
lib/class-factory.js
Outdated
| const fieldName = invokeObjectMethodNoArgs(env.handle, field, fieldGetName); | ||
| try { | ||
| const fieldjsName = env.stringFromJni(fieldName); | ||
| var fieldjsName = env.stringFromJni(fieldName); |
Member
There was a problem hiding this comment.
Use let here to allow re-assigning – var is a legacy keyword from ES5.
lib/class-factory.js
Outdated
| const fieldHandle = env.newGlobalRef(field); | ||
| fieldHandles.push(fieldHandle); | ||
| // If we have a collided method, suffix the fieldName | ||
| if(jsMethods.hasOwnProperty(fieldjsName)){ |
Member
There was a problem hiding this comment.
- Comment can be removed as it's already clear what the code is doing.
- Missing space after
if. - Theoretically there might be a method prefixed with
_having the same name, so usingwhilehere would be better.
|
|
||
| static int Particle2(){ | ||
| return 4; | ||
| } |
Member
There was a problem hiding this comment.
Field- and method-names should follow the coding style, i.e. camelCase, not CamelCase.
Contributor
Author
|
Ok, I have fixed according to your feedback. |
oleavr
requested changes
Mar 1, 2017
lib/class-factory.js
Outdated
| let fieldjsName = env.stringFromJni(fieldName); | ||
| const fieldHandle = env.newGlobalRef(field); | ||
| fieldHandles.push(fieldHandle); | ||
| while (jsMethods.hasOwnProperty(fieldjsName)){ |
Member
There was a problem hiding this comment.
- Let's move these 3 lines to right after the
let, as they belong together. Then put a blank line between that and thefieldHandlestuff (those two lines), and then one blank line before assigning tojsFields. Just to make the code a bit more readable. - Missing a space before
{.
test/re/frida/MethodTest.java
Outdated
| return 3; | ||
| } | ||
|
|
||
| static int particle2(){ |
test/re/frida/MethodTest.java
Outdated
|
|
||
| class Collider { | ||
| static int particle = 1; | ||
|
|
test/re/frida/MethodTest.java
Outdated
| assertEquals("Badger", script.getNextMessage()); | ||
| } | ||
|
|
||
|
|
Member
There was a problem hiding this comment.
There's an extra blank line here.
Contributor
Author
|
Damn I miss stylecop ^^ Should be good now :) |
oleavr
requested changes
Mar 1, 2017
lib/class-factory.js
Outdated
|
|
||
| const fieldHandle = env.newGlobalRef(field); | ||
| fieldHandles.push(fieldHandle); | ||
|
|
Contributor
Author
Member
|
The last blank line isn't blank, it's got spaces before the CRLF. |
oleavr
approved these changes
Mar 2, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Allow interception when a field and a method have the same name.
note : I've added some unit tests that I wasn't able to run (no build env here)
Should fix #20 :)