diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestRandomChains.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestRandomChains.java index b100b8d6752..26f550dd064 100644 --- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestRandomChains.java +++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/core/TestRandomChains.java @@ -252,12 +252,14 @@ public class TestRandomChains extends BaseTokenStreamTestCase { tokenfilters = new ArrayList>(); charfilters = new ArrayList>(); for (final Class c : analysisClasses) { + // TODO: Fix below code to use c.isAnnotationPresent(). It was changed + // to the null check to work around a bug in JDK 8 b78 (see LUCENE-4808). final int modifiers = c.getModifiers(); if ( // don't waste time with abstract classes or deprecated known-buggy ones Modifier.isAbstract(modifiers) || !Modifier.isPublic(modifiers) || c.isSynthetic() || c.isAnonymousClass() || c.isMemberClass() || c.isInterface() - || c.isAnnotationPresent(Deprecated.class) + || c.getAnnotation(Deprecated.class) != null || !(Tokenizer.class.isAssignableFrom(c) || TokenFilter.class.isAssignableFrom(c) || CharFilter.class.isAssignableFrom(c)) ) { continue; @@ -265,7 +267,7 @@ public class TestRandomChains extends BaseTokenStreamTestCase { for (final Constructor ctor : c.getConstructors()) { // don't test synthetic or deprecated ctors, they likely have known bugs: - if (ctor.isSynthetic() || ctor.isAnnotationPresent(Deprecated.class) || brokenConstructors.get(ctor) == ALWAYS) { + if (ctor.isSynthetic() || ctor.getAnnotation(Deprecated.class) != null || brokenConstructors.get(ctor) == ALWAYS) { continue; } if (Tokenizer.class.isAssignableFrom(c)) { diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java b/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java index fddb55011d6..7ae72338e87 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java +++ b/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java @@ -131,7 +131,9 @@ final class TestRuleSetupAndRestoreClassEnv extends AbstractBeforeAfterRule { Class targetClass = RandomizedContext.current().getTargetClass(); avoidCodecs = new HashSet(); - if (targetClass.isAnnotationPresent(SuppressCodecs.class)) { + // TODO: Fix below code to use c.isAnnotationPresent(). It was changed + // to the null check to work around a bug in JDK 8 b78 (see LUCENE-4808). + if (targetClass.getAnnotation(SuppressCodecs.class) != null) { SuppressCodecs a = targetClass.getAnnotation(SuppressCodecs.class); avoidCodecs.addAll(Arrays.asList(a.value())); } diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java b/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java index b772ea04bad..ca84edbf335 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java @@ -114,7 +114,9 @@ public class DocumentObjectBinder { } for (AccessibleObject member : members) { - if (member.isAnnotationPresent(Field.class)) { + // TODO: Fix below code to use c.isAnnotationPresent(). It was changed + // to the null check to work around a bug in JDK 8 b78 (see LUCENE-4808). + if (member.getAnnotation(Field.class) != null) { member.setAccessible(true); fields.add(new DocField(member)); }