lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r828329 - in /lucene/java/branches/lucene_2_9_back_compat_tests/src: java/org/apache/lucene/util/Constants.java test/org/apache/lucene/index/TestCheckIndex.java test/org/apache/lucene/util/TestParameterToEnumBW.java
Date Thu, 22 Oct 2009 06:48:50 GMT
Author: uschindler
Date: Thu Oct 22 06:48:50 2009
New Revision: 828329

URL: http://svn.apache.org/viewvc?rev=828329&view=rev
Log:
LUCENE-2004: Constants.LUCENE_MAIN_VERSION may not be inlined in code compiled against Lucene
JAR

Modified:
    lucene/java/branches/lucene_2_9_back_compat_tests/src/java/org/apache/lucene/util/Constants.java
    lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestCheckIndex.java
    lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/util/TestParameterToEnumBW.java

Modified: lucene/java/branches/lucene_2_9_back_compat_tests/src/java/org/apache/lucene/util/Constants.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9_back_compat_tests/src/java/org/apache/lucene/util/Constants.java?rev=828329&r1=828328&r2=828329&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9_back_compat_tests/src/java/org/apache/lucene/util/Constants.java
(original)
+++ lucene/java/branches/lucene_2_9_back_compat_tests/src/java/org/apache/lucene/util/Constants.java
Thu Oct 22 06:48:50 2009
@@ -66,8 +66,14 @@
       }
     }
   }
-
-  public static final String LUCENE_MAIN_VERSION = "2.9";
+  
+  // this method prevents inlining the final version constant in compiled classes,
+  // see: http://www.javaworld.com/community/node/3400
+  private static String ident(final String s) {
+    return s.toString();
+  }
+  
+  public static final String LUCENE_MAIN_VERSION = ident("2.9");
 
   public static final String LUCENE_VERSION;
   static {
@@ -78,6 +84,6 @@
     } else if (v.indexOf(LUCENE_MAIN_VERSION) == -1) {
       v = v + " [" + LUCENE_MAIN_VERSION + "]";
     }
-    LUCENE_VERSION = v;
+    LUCENE_VERSION = ident(v);
   }
 }

Modified: lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestCheckIndex.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestCheckIndex.java?rev=828329&r1=828328&r2=828329&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestCheckIndex.java
(original)
+++ lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestCheckIndex.java
Thu Oct 22 06:48:50 2009
@@ -90,7 +90,6 @@
     assertTrue(checker.checkIndex(onlySegments).clean == true);
   }
 
-  /* Does not work, because compilation puts final field from Constants of 2.9 into class
file:
   public void testLuceneConstantVersion() throws IOException {
     // common-build.xml sets lucene.version
     final String version = System.getProperty("lucene.version");
@@ -98,5 +97,5 @@
     assertTrue(version.equals(Constants.LUCENE_MAIN_VERSION+"-dev") ||
                version.equals(Constants.LUCENE_MAIN_VERSION));
     assertTrue(Constants.LUCENE_VERSION.startsWith(version));
-  }*/
+  }
 }

Modified: lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/util/TestParameterToEnumBW.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/util/TestParameterToEnumBW.java?rev=828329&r1=828328&r2=828329&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/util/TestParameterToEnumBW.java
(original)
+++ lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/util/TestParameterToEnumBW.java
Thu Oct 22 06:48:50 2009
@@ -27,11 +27,12 @@
     assertEquals(Field.Store.YES, Field.Store.YES);
     assertEquals("YES", Field.Store.YES.toString());
     assertEquals("NO", Field.Store.NO.toString());
-    
-    if (Constants.LUCENE_VERSION.compareTo("3.0") >= 0) {
-      assertEquals("java.lang.Enum", Field.Store.class.getSuperclass().getName());
+    if (Constants.LUCENE_MAIN_VERSION.startsWith("2.")) {
+      assertEquals("Implementing class should be org.apache.lucene.util.Parameter in version
"+Constants.LUCENE_MAIN_VERSION,
+        "org.apache.lucene.util.Parameter", Field.Store.class.getSuperclass().getName());
   
     } else {
-      assertEquals("org.apache.lucene.util.Parameter", Field.Store.class.getSuperclass().getName());
   
+      assertEquals("Implementing class should be java.lang.Enum in version "+Constants.LUCENE_MAIN_VERSION,
+        "java.lang.Enum", Field.Store.class.getSuperclass().getName());
     }
   }
 



Mime
View raw message