Workaround for Hotspot bug that lets tests run without -Xint, from Steven Parkes
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Fri, 13 Aug 2010 03:30:58 +0000 (03:30 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Fri, 13 Aug 2010 03:30:58 +0000 (03:30 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@1526 59b500cc-1b3d-0410-9834-0bbf25fbcc57

core/build.xml
core/src/com/google/zxing/common/reedsolomon/ReedSolomonDecoder.java

index 05e43d7..566ff8c 100644 (file)
       <assertions>
         <enable/>
       </assertions>
       <assertions>
         <enable/>
       </assertions>
-      <jvmarg value="-Xint"/> <!-- works around weird JIT bug in Java 6 -->
       <batchtest>
         <fileset dir="test/src">
           <include name="**/${subdir}/*BlackBox*TestCase.java"/>
       <batchtest>
         <fileset dir="test/src">
           <include name="**/${subdir}/*BlackBox*TestCase.java"/>
index b94a1eb..e7d05de 100644 (file)
@@ -172,8 +172,13 @@ public final class ReedSolomonDecoder {
       int denominator = 1;
       for (int j = 0; j < s; j++) {
         if (i != j) {
       int denominator = 1;
       for (int j = 0; j < s; j++) {
         if (i != j) {
-          denominator = field.multiply(denominator,
-              GF256.addOrSubtract(1, field.multiply(errorLocations[j], xiInverse)));
+          //denominator = field.multiply(denominator,
+          //    GF256.addOrSubtract(1, field.multiply(errorLocations[j], xiInverse)));
+          // Above should work but fails on some Apple and Linux JDKs due to a Hotspot bug.
+          // Below is a funny-looking workaround from Steven Parkes
+          int term = field.multiply(errorLocations[j], xiInverse);
+          int termPlus1 = ((term & 0x1) == 0) ? (term | 1) : (term & ~1);
+          denominator = field.multiply(denominator, termPlus1);
         }
       }
       result[i] = field.multiply(errorEvaluator.evaluateAt(xiInverse),
         }
       }
       result[i] = field.multiply(errorEvaluator.evaluateAt(xiInverse),