diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/InvocationExprent.java b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/InvocationExprent.java index 4cd7b67..a53576d 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/InvocationExprent.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/InvocationExprent.java @@ -61,6 +61,7 @@ public class InvocationExprent extends Exprent { private String name; private String classname; private boolean isStatic; + private boolean canIgnoreBoxing = true; private int functype = TYP_GENERAL; private Exprent instance; private MethodDescriptor descriptor; @@ -84,7 +85,6 @@ public class InvocationExprent extends Exprent { name = cn.elementname; classname = cn.classname; this.bootstrapArguments = bootstrapArguments; - switch (opcode) { case CodeConstants.opc_invokestatic: invocationTyp = INVOKE_STATIC; @@ -155,6 +155,7 @@ public class InvocationExprent extends Exprent { name = expr.getName(); classname = expr.getClassname(); isStatic = expr.isStatic(); + canIgnoreBoxing = expr.canIgnoreBoxing; functype = expr.getFunctype(); instance = expr.getInstance(); if (instance != null) { @@ -217,8 +218,12 @@ public class InvocationExprent extends Exprent { tracer.addMapping(bytecode); + if (instance instanceof InvocationExprent) { + ((InvocationExprent) instance).markUsingBoxingResult(); + } + if (isStatic) { - if (isBoxingCall()) { + if (isBoxingCall() && canIgnoreBoxing) { // process general "boxing" calls, e.g. 'Object[] data = { true }' or 'Byte b = 123' // here 'byte' and 'short' values do not need an explicit narrowing type cast ExprProcessor.getCastedExprent(lstParameters.get(0), descriptor.params[0], buf, indent, false, false, false, tracer); @@ -441,6 +446,10 @@ public class InvocationExprent extends Exprent { return false; } + public void markUsingBoxingResult() { + canIgnoreBoxing = false; + } + // TODO: move to CodeConstants ??? private static String getClassNameForPrimitiveType(int type) { switch (type) { diff --git a/testData/classes/pkg/TestPrimitives.class b/testData/classes/pkg/TestPrimitives.class index fa6cc59..1dad0d2 100644 Binary files a/testData/classes/pkg/TestPrimitives.class and b/testData/classes/pkg/TestPrimitives.class differ diff --git a/testData/results/TestPrimitives.dec b/testData/results/TestPrimitives.dec index 043ed9f..8809dcc 100644 --- a/testData/results/TestPrimitives.dec +++ b/testData/results/TestPrimitives.dec @@ -157,6 +157,10 @@ public class TestPrimitives { res = c > 255;// 166 return res;// 167 } + + void testAutoBoxingCallRequired(boolean value) { + Boolean.valueOf(value).hashCode();// 171 + }// 172 } class 'pkg/TestPrimitives' { @@ -530,6 +534,12 @@ class 'pkg/TestPrimitives' { 98 156 9a 157 } + + method 'testAutoBoxingCallRequired (Z)V' { + 1 161 + 4 161 + 8 162 + } } Lines mapping: @@ -628,6 +638,8 @@ Lines mapping: 165 <-> 156 166 <-> 157 167 <-> 158 +171 <-> 162 +172 <-> 163 Not mapped: 46 50 diff --git a/testData/src/pkg/TestPrimitives.java b/testData/src/pkg/TestPrimitives.java index 8167339..55bd806 100644 --- a/testData/src/pkg/TestPrimitives.java +++ b/testData/src/pkg/TestPrimitives.java @@ -166,4 +166,9 @@ public class TestPrimitives { res = (c > 255); return res; } + + void testAutoBoxingCallRequired(boolean value) { + Boolean.valueOf(value).hashCode(); + } + }