LUCENE-4808: Add workaround for a JDK 8 "class library bug" which is still under discussion and may *not* be fixed

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1451584 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2013-03-01 13:12:16 +00:00
parent ae89bfccb7
commit 202d3af9d0
3 changed files with 10 additions and 4 deletions

View File

@ -252,12 +252,14 @@ public class TestRandomChains extends BaseTokenStreamTestCase {
tokenfilters = new ArrayList<Constructor<? extends TokenFilter>>();
charfilters = new ArrayList<Constructor<? extends CharFilter>>();
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)) {

View File

@ -131,7 +131,9 @@ final class TestRuleSetupAndRestoreClassEnv extends AbstractBeforeAfterRule {
Class<?> targetClass = RandomizedContext.current().getTargetClass();
avoidCodecs = new HashSet<String>();
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()));
}

View File

@ -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));
}