Annotated JDK: Collections.sort's list, StringBuilder.indexOf, Throwable.printStackTrace(PrintWriter) have wrong or missing modification verdicts
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
Direzione di ricerca
Start in the annotated JDK under maddi-aapi-archive for JavaUtil.java around the Collections.sort stubs (lines 1628 and 1631) and JavaLang.java for StringBuilder/AbstractStringBuilder query methods and Throwable.printStackTrace(PrintWriter). Match existing @Modified / @NotModified / @IgnoreModifications patterns on sibling methods. Add a small analyzer test per item so Collections.sort(l) is a decided modification of l and indexOf / printStackTrace(PrintWriter) leave the receiver unmodified.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Three gaps in the annotated JDK (maddi-aapi-archive/.../jdk), found while building diagnostics on the modification analysis downstream (equals/toString/compare that change state, loops that modify their collection). Each makes the analysis read a method as modifying something it does not, or leaves a real modification undecided.
1. Collections.sort — the list parameter has no verdict
JavaUtil.java:1628 and :1631:
static <T extends Comparable<? super T>> void sort(/*@Independent[M]*/ List<T> list) { }
static <T> void sort(...)
The list parameter carries no modification annotation, so UNMODIFIED_PARAMETER is absent and a caller gets the shallow default. Collections.sort(x) does modify x: it should be marked @Modified, like List.sort's receiver effectively is.
2. StringBuilder.indexOf (and siblings) — not marked non-modifying
JavaLang.java:2461, :2464 (the StringBuilder$ overrides from AbstractStringBuilder; compare :1853–:1859 and :2246–:2249):
int indexOf(String str) { return 0; }
int indexOf(String str, int fromIndex) { return 0; }
In the annotated API a method without @NotModified is modifying, so sb.indexOf(sep) modifies sb. These are reads. The same probably holds for other query methods of AbstractStringBuilder / StringBuilder / StringBuffer (lastIndexOf, charAt, length, substring, codePointAt, …) — worth a pass over the class.
3. Throwable.printStackTrace(PrintWriter) — not marked non-modifying
JavaLang.java, in Throwable$:
@IgnoreModifications void printStackTrace() { }
@NotModified void printStackTrace(/*@Independent[M]*/ PrintStream s) { }
void printStackTrace(PrintWriter s) { }
The PrintStream overload is @NotModified; the PrintWriter one is not, so t.printStackTrace(new PrintWriter(sw)) modifies t. It should match its sibling (the writer is what changes, not the throwable).
How it shows
Downstream, jenkins' WorkspaceList.Entry.toString() → Functions.printThrowable(source) → t.printStackTrace(new PrintWriter(sw)) read as "toString modifies source"; fernflower's TextBuffer.toString() → myStringBuilder.indexOf(...) read as "toString modifies myStringBuilder"; a Comparator.compare doing Collections.sort(x) could not be shown to modify x. The consumer now works around these (it distrusts a missing verdict outside containers and builders, and query-named methods), but the verdicts themselves are what should be right.
Suggested check
A small analyzer test per item: Collections.sort(l) leaves l modified with a decided verdict; sb.indexOf("x") and t.printStackTrace(pw) leave sb / t unmodified.
- Lingua principale
- Java
- Stelle
- 1
- Fork
- 1
- Merge medio
- 1h 58m
- PR unite (30g)
- 5
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di CodeLaser/maddi
-
build/ci good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
bug front-end:javac
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
CodeLaser/maddi#145 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
C# printer: an inner class of a generic class needs the outer type's arguments (Outer<A>.Inner)Apertafront-end:csharp
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 10/100
CodeLaser/maddi#140 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Java → C# translation: an idiomatic C# printer driven by the modification and nullability analysesApertaenhancement extension front-end:csharp
Difficoltà 5/5 Più di una settimana Idoneità per principianti 8/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di CodeLaser/maddi
Issue simili
-
status: waiting-for-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
spring-projects/spring-ai#7206 ·
I maintainer di solito rispondono entro 2 giorni
-
area/cli
Difficoltà 2/5 Mezza giornata Idoneità per principianti 78/100
quarkusio/quarkus#57623 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
jhipster/prettier-java#1113 ·
I maintainer di solito rispondono entro 2 giorni
-
bug follow-up lane:backlog
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
Sanne/incus-spawn#1576 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Pasting code into a comment adds imports for the pasted codeForse già presa @ravnskjaer l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
eclipse-jdt/eclipse.jdt.ui#3275 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno