Android: List.of() (API 30+) used in core since 0.24.0 contradicts the README's "minimum API level is 19"
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 74/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Bereich
- mobile-dev
Rechercherichtung
Beginne mit der Überprüfung der aufgeführten List.of-, Set.of- und Map.of-Vorkommen im commonmark-Modul und der Android-Testkonfiguration in .github/workflows/ci.yml. Reproduziere den Fehler für API 24–29 ohne core library desugaring und überprüfe anschließend, dass die gewählte Lösung README, Laufzeitverhalten und die Erwartungen an die Android-Unterstützung konsistent hält.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
Since 0.24.0 the core commonmark module uses java.util.List.of(...) (and a few Set.of/Map.of). On Android these methods exist only from API 30 (Android 11). The README still says:
It works on Android too, but that is on a best-effort basis, please report problems. For Android the minimum API level is 19
An app with minSdk < 30 that does not enable core library desugaring crashes on the first parse on API < 30 devices:
java.lang.NoSuchMethodError: No static method of(Ljava/lang/Object;)Ljava/util/List;
at org.commonmark.internal.InlineParserImpl.parse(InlineParserImpl.java)
This is the same class of problem as #366 / #373 (Objects.requireNonNullElseGet, fixed by #369). The List.of usages were introduced deliberately in #322 as a Java 11 clean-up, so this is a report that the clean-up and the Android support statement now disagree — not a claim that the change was wrong.
Steps to reproduce
Android app, minSdk 24, no coreLibraryDesugaring, org.commonmark:commonmark:0.30.0, run on an API 24–29 emulator:
Parser.builder().build().parse("*a*") // NoSuchMethodError: List.of
With isCoreLibraryDesugaringEnabled = true + com.android.tools:desugar_jdk_libs:2.1.5 the same code works on API 24 (verified on an API 24 emulator).
Where the API 30+ calls live (0.30.0, commonmark module)
List.of / Set.of / Map.of occurrences by file:
| File | Count |
|---|---|
internal/InlineParserImpl.java |
8 |
renderer/markdown/CoreMarkdownNodeRenderer.java |
3 |
renderer/html/CoreHtmlNodeRenderer.java |
3 |
parser/Parser.java |
3 (incl. Javadoc example) |
internal/ParagraphParser.java |
2 |
internal/IndentedCodeBlockParser.java |
2 |
renderer/text/CoreTextContentNodeRenderer.java, renderer/markdown/MarkdownRenderer.java, renderer/html/HtmlWriter.java, renderer/html/DefaultUrlSanitizer.java, parser/block/AbstractBlockParser.java, node/SourceSpans.java |
1 each |
0.22.0 had none; 0.24.0 introduced 8 in InlineParserImpl.
Why CI did not catch it
commonmark-android-test is only run through ./gradlew :app:lint in .github/workflows/ci.yml (minSdk 19, no emulator run), so a runtime NoSuchMethodError never surfaces there.
Possible resolutions
Either would be fine from a consumer's point of view — the important part is that the README and the code agree:
- Keep API 19 support — replace the factory calls with Java 8 equivalents (
Collections.emptyList()/singletonList(x)/unmodifiableList(Arrays.asList(a, b)), same forSet/Map). Mechanical, ~26 sites, keeps immutability. I can send a PR if you want this. - Document the new requirement — state in the README that Android needs API 30+ or core library desugaring, and ideally have
commonmark-android-testrun on an emulator (or fail lint onNewApi) so future regressions are visible.
Context: I hit this while building an Android Markdown renderer on top of commonmark-java (https://github.com/Jimmy-Jung/RichMarkdown-Android). We chose minSdk 30 for now, so this is not blocking us — reporting because the README statement is likely to mislead other Android users.
- Vorherrschende Sprache
- Java
- Sterne
- 2.7k
- Forks
- 336
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus commonmark/commonmark-java
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
commonmark/commonmark-java#460 ·
-
Second code span not recognised after an unclosed backtick string and another code spanEvtl. vergeben @TanbirRamim hat das vor 14 Tagen übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
commonmark/commonmark-java#458 ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 48/100
commonmark/commonmark-java#443 · 4 Kommentare ·
-
Option to define custom flanking/canOpen/canClose rules for delimitersEvtl. wieder frei @abhiramaab hat das vor 58 Tagen übernommen, und es ist kein Pull Request offen. Offenenhancement
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
commonmark/commonmark-java#428 · 4 Kommentare ·
-
enhancement
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
commonmark/commonmark-java#414 · 1 Kommentar · 1 Reaktion ·
Alle Issues in commonmark/commonmark-java
Ähnliche Issues
-
backend
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
bcgov/nr-forest-client#2524 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 74/100
Maintainer antworten meist innerhalb von 1 Tag
-
team:Lumberjack
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
OpenLiberty/open-liberty#35998 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[BUG] SQS SendMessageBatch accepts more than 10 entries instead of TooManyEntriesInBatchRequestEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
floci-io/floci#5319 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag