From: Greg Woolsey Date: Tue, 14 Feb 2017 22:00:05 +0000 (+0000) Subject: Change logic to avoid a 1.6 compiler bug that doesn't properly handle generics. ... X-Git-Tag: REL_3_16_FINAL~83 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3c2c45daa7bb2ecd6d8444116724e6b109df6026;p=poi.git Change logic to avoid a 1.6 compiler bug that doesn't properly handle generics. Eclipse compiler and JDK > 1.6 work properly, even with target runtime = 1.6, so I didn't see it locally. had to compile with the same version of the JDK as the build machine to see the problem. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1783035 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/ss/formula/EvaluationConditionalFormatRule.java b/src/java/org/apache/poi/ss/formula/EvaluationConditionalFormatRule.java index 9ccb5bd5ea..b01a7fbf85 100644 --- a/src/java/org/apache/poi/ss/formula/EvaluationConditionalFormatRule.java +++ b/src/java/org/apache/poi/ss/formula/EvaluationConditionalFormatRule.java @@ -594,16 +594,18 @@ public class EvaluationConditionalFormatRule implements Comparable> boolean isValid(C cellValue, C v1, C v2) { - if (cellValue instanceof String) { - return ((String) cellValue).compareToIgnoreCase((String) v1) == 0; + // need to avoid instanceof, to work around a 1.6 compiler bug + if (cellValue.getClass() == String.class) { + return cellValue.toString().compareToIgnoreCase(v1.toString()) == 0; } return cellValue.compareTo(v1) == 0; } }, NOT_EQUAL { public > boolean isValid(C cellValue, C v1, C v2) { - if (cellValue instanceof String) { - return ((String) cellValue).compareToIgnoreCase((String) v1) != 0; + // need to avoid instanceof, to work around a 1.6 compiler bug + if (cellValue.getClass() == String.class) { + return cellValue.toString().compareToIgnoreCase(v1.toString()) == 0; } return cellValue.compareTo(v1) != 0; }