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 8d53711..19f913e 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/InvocationExprent.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/InvocationExprent.java @@ -409,6 +409,15 @@ public class InvocationExprent extends Exprent { // special handling for ambiguous types if (lstParameters.get(0).type == Exprent.EXPRENT_CONST) { + // 'Integer.valueOf(1)' has '1' type detected as TYPE_BYTECHAR + if (lstParameters.get(0).getExprType().typeFamily == CodeConstants.TYPE_FAMILY_INTEGER) { + if (classname.equals("java/lang/Integer")) { + // 'Integer.valueOf(40_000)' will change to '40_000' and that will be interpreted as 'char' type + ((ConstExprent) lstParameters.get(0)).setConstType(VarType.VARTYPE_INT); + return true; + } + } + if (paramType == CodeConstants.TYPE_BYTECHAR || paramType == CodeConstants.TYPE_SHORTCHAR) { if (classname.equals("java/lang/Character")) { return true; diff --git a/testData/classes/pkg/TestPrimitives.class b/testData/classes/pkg/TestPrimitives.class index be15ee5..022c8c1 100644 Binary files a/testData/classes/pkg/TestPrimitives.class and b/testData/classes/pkg/TestPrimitives.class differ diff --git a/testData/results/TestClassLambda.dec b/testData/results/TestClassLambda.dec index 609928c..7133344 100644 --- a/testData/results/TestClassLambda.dec +++ b/testData/results/TestClassLambda.dec @@ -15,7 +15,7 @@ public class TestClassLambda { public int field = 0; public void testLambda() { - List var1 = Arrays.asList(Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3), Integer.valueOf(4), Integer.valueOf(5), Integer.valueOf(6), Integer.valueOf(7));// 29 + List var1 = Arrays.asList(new Integer[]{1, 2, 3, 4, 5, 6, 7});// 29 int var2 = (int)Math.random();// 30 var1.forEach((var2x) -> {// 32 int var3 = 2 * var2x.intValue();// 33 diff --git a/testData/results/TestPrimitives.dec b/testData/results/TestPrimitives.dec index eae376a..1cc23bc 100644 --- a/testData/results/TestPrimitives.dec +++ b/testData/results/TestPrimitives.dec @@ -10,55 +10,56 @@ public class TestPrimitives { this.printFloat(1.23F);// 11 this.printDouble(1.23D);// 12 this.printChar('Z');// 13 - System.out.println(String.format("%b, %d, %d, %d", this.getBoolean(), this.getByte(), this.getShort(), this.getInt()));// 15 - }// 16 + String.format("%b, %d, %d, %d, %c", new Object[]{true, 1, 213, 40000, 'c', 42L});// 15 + System.out.println(String.format("%b, %d, %d, %d", this.getBoolean(), this.getByte(), this.getShort(), this.getInt()));// 16 + }// 17 public void printBoolean(boolean b) { - System.out.println(String.format("%b", b));// 19 - }// 20 + System.out.println(String.format("%b", b));// 20 + }// 21 public void printByte(byte b) { - System.out.println(String.format("%d", b));// 23 - }// 24 + System.out.println(String.format("%d", b));// 24 + }// 25 public void printShort(short s) { - System.out.println(String.format("%d", s));// 27 - }// 28 + System.out.println(String.format("%d", s));// 28 + }// 29 public void printInt(int i) { - System.out.println(String.format("%d", i));// 31 - }// 32 + System.out.println(String.format("%d", i));// 32 + }// 33 public void printLong(long l) { - System.out.println(String.format("%d", l));// 35 - }// 36 + System.out.println(String.format("%d", l));// 36 + }// 37 public void printFloat(float f) { - System.out.println(String.format("%f", f));// 39 - }// 40 + System.out.println(String.format("%f", f));// 40 + }// 41 public void printDouble(double d) { - System.out.println(String.format("%f", d));// 43 - }// 44 + System.out.println(String.format("%f", d));// 44 + }// 45 public void printChar(char c) { - System.out.println(String.format("%c", c));// 47 - }// 48 + System.out.println(String.format("%c", c));// 48 + }// 49 public boolean getBoolean() { - return false;// 52 + return false;// 53 } public byte getByte() { - return -128;// 56 + return -128;// 57 } public short getShort() { - return -32768;// 60 + return -32768;// 61 } public int getInt() { - return 42;// 64 + return 42;// 65 } public void printNarrowed() { @@ -107,120 +108,134 @@ class 'pkg/TestPrimitives' { 2d 11 2f 11 32 12 - 35 12 - 3e 12 - 41 12 - 48 12 - 4b 12 + 3b 12 + 3c 12 + 42 12 + 43 12 + 49 12 + 4c 12 52 12 - 55 12 + 54 12 + 5a 12 5c 12 - 5f 12 - 63 12 - 66 12 - 69 13 + 62 12 + 65 12 + 69 12 + 6d 13 + 70 13 + 79 13 + 7c 13 + 83 13 + 86 13 + 8d 13 + 90 13 + 97 13 + 9a 13 + 9e 13 + a1 13 + a4 14 } method 'printBoolean (Z)V' { - 0 16 - 3 16 - c 16 - 10 16 - 13 16 - 16 17 + 0 17 + 3 17 + c 17 + 10 17 + 13 17 + 16 18 } method 'printByte (B)V' { - 0 20 - 3 20 - c 20 - 10 20 - 13 20 - 16 21 + 0 21 + 3 21 + c 21 + 10 21 + 13 21 + 16 22 } method 'printShort (S)V' { - 0 24 - 3 24 - c 24 - 10 24 - 13 24 - 16 25 + 0 25 + 3 25 + c 25 + 10 25 + 13 25 + 16 26 } method 'printInt (I)V' { - 0 28 - 3 28 - c 28 - 10 28 - 13 28 - 16 29 + 0 29 + 3 29 + c 29 + 10 29 + 13 29 + 16 30 } method 'printLong (J)V' { - 0 32 - 3 32 - c 32 - 10 32 - 13 32 - 16 33 + 0 33 + 3 33 + c 33 + 10 33 + 13 33 + 16 34 } method 'printFloat (F)V' { - 0 36 - 3 36 - c 36 - 10 36 - 13 36 - 16 37 + 0 37 + 3 37 + c 37 + 10 37 + 13 37 + 16 38 } method 'printDouble (D)V' { - 0 40 - 3 40 - c 40 - 10 40 - 13 40 - 16 41 + 0 41 + 3 41 + c 41 + 10 41 + 13 41 + 16 42 } method 'printChar (C)V' { - 0 44 - 3 44 - c 44 - 10 44 - 13 44 - 16 45 + 0 45 + 3 45 + c 45 + 10 45 + 13 45 + 16 46 } method 'getBoolean ()Z' { - 0 48 - 1 48 + 0 49 + 1 49 } method 'getByte ()B' { - 0 52 - 2 52 + 0 53 + 2 53 } method 'getShort ()S' { - 0 56 - 3 56 + 0 57 + 3 57 } method 'getInt ()I' { - 0 60 - 2 60 + 0 61 + 2 61 } method 'printNarrowed ()V' { - 2 64 - 5 64 - 6 64 - b 65 - e 65 - f 65 - 12 66 + 2 65 + 5 65 + 6 65 + b 66 + e 66 + f 66 + 12 67 } method 'constructor ()V' { @@ -282,27 +297,27 @@ Lines mapping: 13 <-> 12 15 <-> 13 16 <-> 14 -19 <-> 17 +17 <-> 15 20 <-> 18 -23 <-> 21 +21 <-> 19 24 <-> 22 -27 <-> 25 +25 <-> 23 28 <-> 26 -31 <-> 29 +29 <-> 27 32 <-> 30 -35 <-> 33 +33 <-> 31 36 <-> 34 -39 <-> 37 +37 <-> 35 40 <-> 38 -43 <-> 41 +41 <-> 39 44 <-> 42 -47 <-> 45 +45 <-> 43 48 <-> 46 -52 <-> 49 -56 <-> 53 -60 <-> 57 -64 <-> 61 -68 <-> 65 +49 <-> 47 +53 <-> 50 +57 <-> 54 +61 <-> 58 +65 <-> 62 69 <-> 66 70 <-> 67 73 <-> 70 diff --git a/testData/src/pkg/TestPrimitives.java b/testData/src/pkg/TestPrimitives.java index 39041ef..484eb84 100644 --- a/testData/src/pkg/TestPrimitives.java +++ b/testData/src/pkg/TestPrimitives.java @@ -12,6 +12,7 @@ public class TestPrimitives { printDouble(1.23); printChar('Z'); + String.format("%b, %d, %d, %d, %c", true, 1, 213, 40_000, 'c', 42L); System.out.println(String.format("%b, %d, %d, %d", getBoolean(), getByte(), getShort(), getInt())); }