mirror of https://github.com/apache/lucene.git
Allow detecting of Java 8
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1366850 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4040721fd0
commit
4a54cc8b16
|
@ -18,6 +18,7 @@ package org.apache.lucene.util;
|
|||
*/
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
import org.apache.lucene.LucenePackage;
|
||||
|
||||
/**
|
||||
|
@ -56,6 +57,7 @@ public final class Constants {
|
|||
new Boolean(true).booleanValue(); // prevent inlining in foreign class files
|
||||
|
||||
public static final boolean JRE_IS_MINIMUM_JAVA7;
|
||||
public static final boolean JRE_IS_MINIMUM_JAVA8;
|
||||
|
||||
/** True iff running on a 64bit JVM */
|
||||
public static final boolean JRE_IS_64BIT;
|
||||
|
@ -93,6 +95,19 @@ public final class Constants {
|
|||
v7 = false;
|
||||
}
|
||||
JRE_IS_MINIMUM_JAVA7 = v7;
|
||||
|
||||
if (JRE_IS_MINIMUM_JAVA7) {
|
||||
// this method only exists in Java 8:
|
||||
boolean v8 = true;
|
||||
try {
|
||||
Collections.class.getMethod("emptySortedSet");
|
||||
} catch (NoSuchMethodException nsme) {
|
||||
v8 = false;
|
||||
}
|
||||
JRE_IS_MINIMUM_JAVA8 = v8;
|
||||
} else {
|
||||
JRE_IS_MINIMUM_JAVA8 = false;
|
||||
}
|
||||
}
|
||||
|
||||
// this method prevents inlining the final version constant in compiled classes,
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.solr.handler.component;
|
|||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.lucene.util.Constants;
|
||||
import org.apache.lucene.util.LuceneTestCase.Slow;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
|
@ -35,7 +36,6 @@ import org.apache.solr.response.SolrQueryResponse;
|
|||
import org.apache.solr.spelling.AbstractLuceneSpellChecker;
|
||||
import org.apache.solr.spelling.SolrSpellChecker;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
@ -99,8 +99,8 @@ public class SpellCheckComponentTest extends SolrTestCaseJ4 {
|
|||
|
||||
|
||||
@Test
|
||||
@Ignore("This test fails in most cases with Java 8+, looks like it depends on order of some HashSet/HashMap whatever")
|
||||
public void testPerDictionary() throws Exception {
|
||||
assumeFalse("This test fails in most cases with Java 8+, looks like it depends on order of some HashSet/HashMap whatever", Constants.JRE_IS_MINIMUM_JAVA8);
|
||||
assertJQ(req("json.nl","map", "qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", SpellingParams.SPELLCHECK_BUILD, "true", "q","documemt"
|
||||
, SpellingParams.SPELLCHECK_DICT, "perDict", SpellingParams.SPELLCHECK_PREFIX + ".perDict.foo", "bar", SpellingParams.SPELLCHECK_PREFIX + ".perDict.bar", "foo")
|
||||
,"/spellcheck/suggestions/bar=={'numFound':1, 'startOffset':0, 'endOffset':1, 'suggestion':['foo']}"
|
||||
|
|
Loading…
Reference in New Issue