Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): check for inner-class and field name collision #346

Merged
merged 5 commits into from
Oct 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions android/hooks/metabase/templates/class.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ if (classDefinition.innerClasses) {
for (var ic = 0; ic < classDefinition.innerClasses.length; ic++) {
var innerClassName = classDefinition.innerClasses[ic];
var baseInnerClassName = innerClassName.slice(innerClassName.lastIndexOf('$') + 1);
if (classDefinition.properties[baseInnerClassName]) {
// Class has a field with same name as inner class.
continue;
}
-%>
Object.defineProperty(<%= sanitizedName %>, '<%= baseInnerClassName %>', {
get: function() {
Expand Down
1 change: 0 additions & 1 deletion android/src/hyperloop/BaseProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ protected BaseProxy(Class<?> clazz, String className) {
*/
public abstract Object getReceiver();

@Kroll.method
@Kroll.getProperty
@Override
public String getApiName() {
Expand Down
2 changes: 1 addition & 1 deletion android/src/hyperloop/InstanceProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ protected Object invokeMethod(Method m, Object receiver, Object[] convertedArgs)
return super.invokeMethod(m, receiver, convertedArgs);
}

@Kroll.getProperty @Kroll.method
@Kroll.getProperty
public InstanceProxy getSuper() {
if (!ProxyBuilder.isProxyClass(this.clazz)) {
return this;
Expand Down