Return-Path: Delivered-To: apmail-lucene-java-commits-archive@www.apache.org Received: (qmail 91986 invoked from network); 22 Oct 2009 06:49:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 22 Oct 2009 06:49:24 -0000 Received: (qmail 88778 invoked by uid 500); 22 Oct 2009 06:49:24 -0000 Delivered-To: apmail-lucene-java-commits-archive@lucene.apache.org Received: (qmail 88724 invoked by uid 500); 22 Oct 2009 06:49:24 -0000 Mailing-List: contact java-commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-dev@lucene.apache.org Delivered-To: mailing list java-commits@lucene.apache.org Received: (qmail 88712 invoked by uid 99); 22 Oct 2009 06:49:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Oct 2009 06:49:24 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Oct 2009 06:49:12 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id EAC20238888A; Thu, 22 Oct 2009 06:48:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: java-commits@lucene.apache.org From: uschindler@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091022064850.EAC20238888A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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()); } }