Skip to content

Commit

Permalink
Fix InvokeExpr subclasses even more
Browse files Browse the repository at this point in the history
Maybe this fix is superfluous, but well... Why not? :)
  • Loading branch information
ThexXTURBOXx committed Sep 5, 2021
1 parent 9c6cde4 commit 9c0db1d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
3 changes: 3 additions & 0 deletions dex-ir/src/main/java/com/googlecode/dex2jar/ir/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ public static void appendString(final StringBuffer buf, final String s) {
}

public static String toShortClassName(String desc) {
if (desc == null || desc.isEmpty()) {
return "";
}
switch (desc.charAt(0)) {
case 'Z':
return "boolean";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.googlecode.d2j.Proto;
import com.googlecode.dex2jar.ir.LabelAndLocalMapper;

public class InvokeCustomExpr extends AbstractInvokeExpr {
public class InvokeCustomExpr extends InvokeExpr {

public String name;

Expand All @@ -30,20 +30,20 @@ public Proto getProto() {

public InvokeCustomExpr(VT type, Value[] args, String methodName, Proto proto, MethodHandle handle,
Object[] bsmArgs) {
super(type, args);
super(type, args, handle == null ? null : handle.getMethod());
this.proto = proto;
this.name = methodName;
this.handle = handle;
this.bsmArgs = bsmArgs;
}

@Override
public Value clone() {
public InvokeCustomExpr clone() {
return new InvokeCustomExpr(vt, cloneOps(), name, proto, handle, bsmArgs);
}

@Override
public Value clone(LabelAndLocalMapper mapper) {
public InvokeCustomExpr clone(LabelAndLocalMapper mapper) {
return new InvokeCustomExpr(vt, cloneOps(mapper), name, proto, handle, bsmArgs);
}

Expand Down
29 changes: 14 additions & 15 deletions dex-ir/src/main/java/com/googlecode/dex2jar/ir/expr/InvokeExpr.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ protected void releaseMemory() {

@Override
public Proto getProto() {
return method.getProto();
return method == null ? null : method.getProto();
}

public InvokeExpr(VT type, Value[] args, String ownerType, String methodName, String[] argmentTypes,
String returnType) {
super(type, args);
this.method = new Method(ownerType, methodName, argmentTypes, returnType);
this(type, args, new Method(ownerType, methodName, argmentTypes, returnType));
}

public InvokeExpr(VT type, Value[] args, Method method) {
Expand All @@ -45,12 +44,12 @@ public InvokeExpr(VT type, Value[] args, Method method) {
}

@Override
public Value clone() {
public InvokeExpr clone() {
return new InvokeExpr(vt, cloneOps(), method);
}

@Override
public Value clone(LabelAndLocalMapper mapper) {
public InvokeExpr clone(LabelAndLocalMapper mapper) {
return new InvokeExpr(vt, cloneOps(mapper), method);
}

Expand All @@ -59,13 +58,13 @@ public String toString0() {
StringBuilder sb = new StringBuilder();

int i = 0;
if (super.vt == VT.INVOKE_NEW) {
sb.append("new ").append(Util.toShortClassName(method.getOwner()));
} else if (super.vt == VT.INVOKE_STATIC) {
sb.append(Util.toShortClassName(method.getOwner())).append('.')
.append(this.method.getName());
if (vt == VT.INVOKE_NEW) {
sb.append("new ").append(Util.toShortClassName(getOwner()));
} else if (vt == VT.INVOKE_STATIC) {
sb.append(Util.toShortClassName(getOwner())).append('.')
.append(getName());
} else {
sb.append(ops[i++]).append('.').append(this.method.getName());
sb.append(ops[i++]).append('.').append(getName());
}
sb.append('(');
boolean first = true;
Expand All @@ -82,19 +81,19 @@ public String toString0() {
}

public String getOwner() {
return method.getOwner();
return method == null ? null : method.getOwner();
}

public String getRet() {
return method.getReturnType();
return method == null ? null : method.getReturnType();
}

public String getName() {
return method.getName();
return method == null ? null : method.getName();
}

public String[] getArgs() {
return method.getParameterTypes();
return method == null ? null : method.getParameterTypes();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public class InvokePolymorphicExpr extends InvokeExpr {

@Override
protected void releaseMemory() {
method = null;
proto = null;
super.releaseMemory();
}
Expand All @@ -27,12 +26,12 @@ public InvokePolymorphicExpr(VT type, Value[] args, Proto proto, Method method)
}

@Override
public Value clone() {
public InvokePolymorphicExpr clone() {
return new InvokePolymorphicExpr(vt, cloneOps(), proto, method);
}

@Override
public Value clone(LabelAndLocalMapper mapper) {
public InvokePolymorphicExpr clone(LabelAndLocalMapper mapper) {
return new InvokePolymorphicExpr(vt, cloneOps(mapper), proto, method);
}

Expand Down

0 comments on commit 9c0db1d

Please sign in to comment.