[java-decompiler] unneeded cast around byte/short constants

master
Roman Shevchenko 9 years ago
parent a00952f338
commit b366de8eb4
  1. 2
      src/org/jetbrains/java/decompiler/modules/decompiler/ExprProcessor.java
  2. BIN
      testData/classes/pkg/MoreAnnotations$TestEnum.class
  3. BIN
      testData/classes/pkg/MoreAnnotations.class
  4. 8
      testData/results/MoreAnnotations.dec
  5. 14
      testData/src/pkg/MoreAnnotations.java

@ -891,7 +891,7 @@ public class ExprProcessor implements CodeConstants {
castAlways ||
(!leftType.isSuperset(rightType) && (rightType.equals(VarType.VARTYPE_OBJECT) || leftType.type != CodeConstants.TYPE_OBJECT)) ||
(castNull && rightType.type == CodeConstants.TYPE_NULL && !UNDEFINED_TYPE_STRING.equals(getTypeName(leftType))) ||
(isIntConstant(exprent) && VarType.VARTYPE_INT.isStrictSuperset(leftType));
(isIntConstant(exprent) && rightType.isStrictSuperset(leftType));
boolean quote = cast && exprent.getPrecedence() >= FunctionExprent.getPrecedence(FunctionExprent.FUNCTION_CAST);

@ -33,11 +33,11 @@ public @interface MoreAnnotations {
String annotatedWithEmptyArrays = "";
@MoreAnnotations(
intArray = {1, 0, 2147483647, -2147483648},
byteArray = {(byte)1, (byte)0, (byte)127, (byte)-128},
byteArray = {1, 0, 127, -128, -1},
floatArray = {1.0F, 0.0F, 3.4028235E38F, 1.4E-45F, 0.0F / 0.0, 1.0F / 0.0, -1.0F / 0.0},
doubleArray = {1.0D, 0.0D, 1.7976931348623157E308D, 4.9E-324D, 0.0D / 0.0, 1.0D / 0.0, -1.0D / 0.0},
booleanArray = {true, false},
shortArray = {(short)1, (short)0, (short)32767, (short)-32768},
shortArray = {1, 0, 32767, -32768, -1},
longArray = {1L, 0L, 9223372036854775807L, -9223372036854775808L},
charArray = {'a', '\n', '\u0001', '\u0000', '\uffff', '\u0000'},
enumArray = {MoreAnnotations.TestEnum.FirstValue, MoreAnnotations.TestEnum.SecondValue},
@ -73,7 +73,7 @@ public @interface MoreAnnotations {
int[] intArray() default {1, 0, 2147483647, -2147483648};
byte[] byteArray() default {(byte)1, (byte)0, (byte)127, (byte)-128};
byte[] byteArray() default {1, 0, 127, -128, -1};
float[] floatArray() default {1.0F, 0.0F, 3.4028235E38F, 1.4E-45F, 0.0F / 0.0, 1.0F / 0.0, -1.0F / 0.0};
@ -81,7 +81,7 @@ public @interface MoreAnnotations {
boolean[] booleanArray() default {true, false};
short[] shortArray() default {(short)1, (short)0, (short)32767, (short)-32768};
short[] shortArray() default {1, 0, 32767, -32768, -1};
long[] longArray() default {1L, 0L, 9223372036854775807L, -9223372036854775808L};

@ -16,16 +16,16 @@ public @interface MoreAnnotations {
Class<? extends CharSequence> classValue() default CharSequence.class;
int[] intArray() default { 1, 0, Integer.MAX_VALUE, Integer.MIN_VALUE };
byte[] byteArray() default { 1, 0, Byte.MAX_VALUE, Byte.MIN_VALUE };
byte[] byteArray() default { 1, 0, Byte.MAX_VALUE, Byte.MIN_VALUE, (byte)0xFF };
float[] floatArray() default { 1, 0, Float.MAX_VALUE, Float.MIN_VALUE, Float.NaN, Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY };
double[] doubleArray() default { 1, 0, Double.MAX_VALUE, Double.MIN_VALUE, Double.NaN, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY };
boolean[] booleanArray() default { true, false };
short[] shortArray() default { 1, 0, Short.MAX_VALUE, Short.MIN_VALUE };
short[] shortArray() default { 1, 0, Short.MAX_VALUE, Short.MIN_VALUE, (short)0xFFFF };
long[] longArray() default { 1, 0, Long.MAX_VALUE, Long.MIN_VALUE };
char[] charArray() default { 1, 0, Character.MAX_VALUE, Character.MIN_VALUE };
TestEnum[] enumArray() default { TestEnum.FirstValue };
NestedAnnotation[] annotationArray() default { @NestedAnnotation };
String[] stringArray() default { "first", "second", ""};
String[] stringArray() default { "first", "second", "" };
Class<? extends CharSequence>[] classArray() default { CharSequence.class, String.class, StringBuilder.class };
@interface NestedAnnotation {
@ -66,16 +66,16 @@ public @interface MoreAnnotations {
@MoreAnnotations(
intArray = { 1, 0, Integer.MAX_VALUE, Integer.MIN_VALUE },
byteArray = { 1, 0, Byte.MAX_VALUE, Byte.MIN_VALUE },
byteArray = { 1, 0, Byte.MAX_VALUE, Byte.MIN_VALUE, (byte)0xFF },
floatArray = { 1, 0, Float.MAX_VALUE, Float.MIN_VALUE, Float.NaN, Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY },
doubleArray = { 1, 0, Double.MAX_VALUE, Double.MIN_VALUE, Double.NaN, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY },
booleanArray = { true, false },
shortArray = { 1, 0, Short.MAX_VALUE, Short.MIN_VALUE },
shortArray = { 1, 0, Short.MAX_VALUE, Short.MIN_VALUE, (short)0xFFFF },
longArray = { 1, 0, Long.MAX_VALUE, Long.MIN_VALUE },
charArray = { 'a', '\n', 1, 0, Character.MAX_VALUE, Character.MIN_VALUE },
enumArray = { TestEnum.FirstValue , TestEnum.SecondValue},
enumArray = { TestEnum.FirstValue , TestEnum.SecondValue },
annotationArray = { @NestedAnnotation("a"), @NestedAnnotation("b") },
stringArray = { "first", "second", ""},
stringArray = { "first", "second", "" },
classArray = { CharSequence.class, String.class, StringBuilder.class }
)
String annotatedWithArrays = "";

Loading…
Cancel
Save