Fixing 'Missing java.lang.ClassValue class' in Android
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
### Description
I successfully modified Lucene 7.3.0 for using in Android: https://github.com/texophen/lucene-android
The modification includes:
+ Add log feature in org.apache.lucene.LucenePackage
+ Add org.apache.lucene.util.ADClassValue to replace java.lang.ClassValue in JDK 8 (but not available in Android)
+ Modify org.apache.lucene.util.AttributeFactory
```
static final MethodHandle findAttributeImplCtor(Class clazz) {
try {
//org.apache.lucene.LucenePackage.writeLog("AttributeFactory.findAttributeImplCtor() - 1: " + lookup.findConstructor(clazz, NO_ARG_CTOR).toString());
MethodHandle mh = null;
if (lookup.findConstructor(clazz, NO_ARG_CTOR).toString().endsWith("PackedTokenAttributeImpl")) {
mh = lookup.findConstructor(clazz, NO_ARG_CTOR).asType(MethodType.methodType(org.apache.lucene.analysis.tokenattributes.PackedTokenAttributeImpl.class));
} else {
mh = lookup.findConstructor(clazz, NO_ARG_CTOR).asType(NO_ARG_RETURNING_ATTRIBUTEIMPL);
}
//org.apache.lucene.LucenePackage.writeLog("AttributeFactory.findAttributeImplCtor() - 2: " + mh.toString());
return mh;
} catch (NoSuchMethodException | IllegalAccessException e) {
throw new IllegalArgumentException("Cannot lookup accessible no-arg constructor for: " + clazz.getName(), e);
}
}
```
Contributor guide
Research direction
Start by reviewing org.apache.lucene.util.ADClassValue and the changes described for org.apache.lucene.util.AttributeFactory, then compare them with the linked lucene-android modification. Reproduce the missing java.lang.ClassValue problem on Android and inspect org.apache.lucene.LucenePackage for the mentioned logging. Done means Lucene 7.3.0 can run on Android without the missing class error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100