You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2017/10/30 15:56:10 UTC

svn commit: r1813787 - /uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/impl/OptimizeStringsTest.java

Author: schor
Date: Mon Oct 30 15:56:10 2017
New Revision: 1813787

URL: http://svn.apache.org/viewvc?rev=1813787&view=rev
Log:
no Jira - remove part of Optimized String test that depended on internals of String impl - not reliable across various java implementations.  (gave wrong test for IBM Java 1.8 for instance)

Modified:
    uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/impl/OptimizeStringsTest.java

Modified: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/impl/OptimizeStringsTest.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/impl/OptimizeStringsTest.java?rev=1813787&r1=1813786&r2=1813787&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/impl/OptimizeStringsTest.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/impl/OptimizeStringsTest.java Mon Oct 30 15:56:10 2017
@@ -25,30 +25,38 @@ import junit.framework.TestCase;
 
 public class OptimizeStringsTest extends TestCase {
 
-  private static Field STRING_OFFSET;
-  static {
-    try {
-      STRING_OFFSET = String.class.getDeclaredField("offset");
-      STRING_OFFSET.setAccessible(true);
-    } catch (SecurityException e) {
-      throw new RuntimeException(e);
-    } catch (NoSuchFieldException e) {
-      System.err.println("OptimizeStringsTest could not find the String offset field, skipping that part of the test.");
-      STRING_OFFSET = null;
-    }
-  }
+  // modern Javas do this in various ways, can't depend on internal impl
+//  private static Field STRING_OFFSET;
+//  static {
+//    try {
+//   // Found that IBM Java 8 version 8.0.4.2 returns a value for the field "offset", but it's 0
+//      // and there doesn't seem to be an offset field in that class.
+//      if (System.getProperty("java.version").startsWith("1.8")) {
+//        STRING_OFFSET = null;
+//      } else {
+//        STRING_OFFSET =  String.class.getDeclaredField("offset");
+//        STRING_OFFSET.setAccessible(true);
+//      }
+//    } catch (SecurityException e) {
+//      throw new RuntimeException(e);
+//    } catch (NoSuchFieldException e) {
+//      System.err.println("OptimizeStringsTest could not find the String offset field, skipping that part of the test.");
+//      STRING_OFFSET = null;
+//    }
+//  }
     
   public static int getStringOffset(String s) {
-    try {
-      if (STRING_OFFSET != null) {
-        return STRING_OFFSET.getInt(s);
-      }
-      return -1;
-    } catch (IllegalArgumentException e) {
-      throw new RuntimeException(e);
-    } catch (IllegalAccessException e) {
-      throw new RuntimeException(e);
-    }
+    return -1;  // disabled
+//    try {
+//      if (STRING_OFFSET != null) {
+//        return STRING_OFFSET.getInt(s);
+//      }
+//      return -1;
+//    } catch (IllegalArgumentException e) {
+//      throw new RuntimeException(e);
+//    } catch (IllegalAccessException e) {
+//      throw new RuntimeException(e);
+//    }
   }
    
   public void testOpStr() {