Skip to content

Commit d90d4df

Browse files
author
emmanue1
committed
Remove all reflection 'invoke' method calls
1 parent 16619db commit d90d4df

File tree

7 files changed

+365
-247
lines changed

7 files changed

+365
-247
lines changed

src/main/java/org/jd/core/v1/service/converter/classfiletojavasyntax/util/LoopStatementMaker.java

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import java.util.ListIterator;
2424

2525
import static org.jd.core.v1.model.javasyntax.statement.ContinueStatement.CONTINUE;
26-
import static org.jd.core.v1.service.converter.classfiletojavasyntax.util.ReflectionUtil.getExpression;
27-
import static org.jd.core.v1.service.converter.classfiletojavasyntax.util.ReflectionUtil.invokeGetter;
2826

2927
public class LoopStatementMaker {
3028
protected static final RemoveLastContinueStatementVisitor REMOVE_LAST_CONTINUE_STATEMENT_VISITOR = new RemoveLastContinueStatementVisitor();
@@ -378,7 +376,19 @@ protected static Statement makeForEachArray(LocalVariableMaker localVariableMake
378376
}
379377

380378
// String s = arr$[i$];
381-
boe = invokeGetter(subStatements.get(0), getExpression, BinaryOperatorExpression.class);
379+
statement = subStatements.getFirst();
380+
381+
if (statement.getClass() != ExpressionStatement.class) {
382+
return null;
383+
}
384+
385+
expression = ((ExpressionStatement)statement).getExpression();
386+
387+
if (expression.getClass() != BinaryOperatorExpression.class) {
388+
return null;
389+
}
390+
391+
boe = (BinaryOperatorExpression)expression;
382392

383393
if ((boe.getRightExpression().getClass() != ArrayExpression.class) || (boe.getLeftExpression().getClass() != ClassFileLocalVariableReferenceExpression.class) || (boe.getLineNumber() != condition.getLineNumber())) {
384394
return null;
@@ -401,7 +411,19 @@ protected static Statement makeForEachArray(LocalVariableMaker localVariableMake
401411
}
402412

403413
// arr$ = array;
404-
boe = invokeGetter(statements.get(statementsSize-3), getExpression, BinaryOperatorExpression.class);
414+
statement = statements.get(statementsSize-3);
415+
416+
if (statement.getClass() != ExpressionStatement.class) {
417+
return null;
418+
}
419+
420+
expression = ((ExpressionStatement)statement).getExpression();
421+
422+
if (expression.getClass() != BinaryOperatorExpression.class) {
423+
return null;
424+
}
425+
426+
boe = (BinaryOperatorExpression)expression;
405427

406428
if (boe.getLeftExpression().getClass() != ClassFileLocalVariableReferenceExpression.class) {
407429
return null;
@@ -413,9 +435,21 @@ protected static Statement makeForEachArray(LocalVariableMaker localVariableMake
413435
Expression array = boe.getRightExpression();
414436

415437
// i$ = 0;
416-
boe = invokeGetter(statements.get(statementsSize-1), getExpression, BinaryOperatorExpression.class);
438+
statement = statements.get(statementsSize-1);
439+
440+
if (statement.getClass() != ExpressionStatement.class) {
441+
return null;
442+
}
443+
444+
expression = ((ExpressionStatement)statement).getExpression();
445+
446+
if (expression.getClass() != BinaryOperatorExpression.class) {
447+
return null;
448+
}
449+
450+
boe = (BinaryOperatorExpression)expression;
417451

418-
if ((boe == null) || (boe.getLineNumber() != lineNumber) || (boe.getLeftExpression().getClass() != ClassFileLocalVariableReferenceExpression.class) || (boe.getRightExpression().getClass() != IntegerConstantExpression.class)) {
452+
if ((boe.getLineNumber() != lineNumber) || (boe.getLeftExpression().getClass() != ClassFileLocalVariableReferenceExpression.class) || (boe.getRightExpression().getClass() != IntegerConstantExpression.class)) {
419453
return null;
420454
}
421455
if ((((IntegerConstantExpression)boe.getRightExpression()).getValue() != 0) || (((ClassFileLocalVariableReferenceExpression)boe.getLeftExpression()).getLocalVariable() != syntheticIndex)) {

src/main/java/org/jd/core/v1/service/converter/classfiletojavasyntax/util/ObjectTypeMaker.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,16 @@ private boolean recursiveIsAssignable(String parentInternalName, String childInt
227227
}
228228
}
229229

230-
for (String name : superClassAndInterfaceNames) {
231-
if (parentInternalName.equals(name))
232-
return true;
233-
}
230+
if (superClassAndInterfaceNames != null) {
231+
for (String name : superClassAndInterfaceNames) {
232+
if (parentInternalName.equals(name))
233+
return true;
234+
}
234235

235-
for (String name : superClassAndInterfaceNames) {
236-
if (recursiveIsAssignable(parentInternalName, name))
237-
return true;
236+
for (String name : superClassAndInterfaceNames) {
237+
if (recursiveIsAssignable(parentInternalName, name))
238+
return true;
239+
}
238240
}
239241

240242
return false;

src/main/java/org/jd/core/v1/service/converter/classfiletojavasyntax/util/ReflectionUtil.java

Lines changed: 0 additions & 135 deletions
This file was deleted.

0 commit comments

Comments
 (0)