Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-2004: Constants.LUCENE_MAIN_VERSION may not be inlined in code compiled against Lucene JAR

Uwe Schindlerabf2f86302ce
diff --git a/CHANGES.txt b/CHANGES.txt
index cb582e0866b..bbbc11d8cd7 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -122,6 +122,9 @@ Bug fixes
cannot exceed 2048 MB, and throw IllegalArgumentException if it
does. (Aaron McKee, Yonik Seeley, Mike McCandless)
+* LUCENE-2004: Fix Constants.LUCENE_MAIN_VERSION to not be inlined
+ by client code. (Uwe Schindler)
+
New features
* LUCENE-1933: Provide a convenience AttributeFactory that creates a
diff --git a/common-build.xml b/common-build.xml
index dc5cbdc4495..38c45bb2e21 100644
--- a/common-build.xml
+++ b/common-build.xml
@@ -42,7 +42,7 @@
<property name="Name" value="Lucene"/>
<property name="dev.version" value="3.0-dev"/>
<property name="version" value="${dev.version}"/>
- <property name="compatibility.tag" value="lucene_2_9_back_compat_tests_20091021a"/>
+ <property name="compatibility.tag" value="lucene_2_9_back_compat_tests_20091022"/>
<property name="spec.version" value="${version}"/>
<property name="year" value="2000-${current.year}"/>
<property name="final.name" value="lucene-${name}-${version}"/>
diff --git a/src/java/org/apache/lucene/util/Constants.java b/src/java/org/apache/lucene/util/Constants.java
index cb51affbaf5..dde5886d1f9 100644
--- a/src/java/org/apache/lucene/util/Constants.java
+++ b/src/java/org/apache/lucene/util/Constants.java
@@ -64,7 +64,13 @@ public final class Constants {
}
}
- public static final String LUCENE_MAIN_VERSION = "3.0";
+ // 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("3.0");
public static final String LUCENE_VERSION;
static {
@@ -75,6 +81,6 @@ public final class Constants {
} else if (v.indexOf(LUCENE_MAIN_VERSION) == -1) {
v = v + " [" + LUCENE_MAIN_VERSION + "]";
}
- LUCENE_VERSION = v;
+ LUCENE_VERSION = ident(v);
}
}