IsolateClass: a group isolate doesn't compile: interfaces become classes, annotation stubs lack @Target

Aperta
#180 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java
Ambito
devtools

Direzione di ricerca

Start with util/IsolateClass.java, especially phase 0 around line 324, and reproduce using the fernflower steps in the issue: isolate DomHelper with the types from reachedPerType(), then print and parse the result with failFast(true). Check the emitted nature of isolated interfaces and how annotation stubs preserve @Target; the issue also lists four remaining compile errors that are not yet analyzed. Done means the isolated tree compiles in the described reproduction.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

IsolateClass.isolate(List<TypeInfo>) (maddi-mod, maddi-modification-common, util/IsolateClass.java) produces trees that don't compile once the group holds an interface or the code uses type-use annotations. Found isolating fernflower's DomHelper together with the 33 fernflower types it reaches.

1. An isolated interface is emitted as a class

Phase 0 builds every isolated type with .setTypeNature(runtime.typeNatureClass()) (line 324), and nothing later restores the original's nature. With org.jetbrains.java.decompiler.struct.match.IMatchable in the group:

public abstract class IMatchable {        // the original is an interface

so every implements IMatchable fails ("interface expected here"; 4 of 55 errors, plus their follow-ups). The single-type isolate doesn't hit this when the isolated type is a class, and as a stub an interface comes out right. Only an interface that is itself isolated is affected. Enums, records and annotation types are probably affected the same way (not checked).

2. Annotation stubs are not usable in type-use positions

org.jetbrains.annotations.Nullable and NotNull are stubbed without @Target, so a verbatim body using them in a type position (@Nullable String[], a type argument) fails with "annotation @org.jetbrains.annotations.Nullable not applicable in this type context" (8 of the remaining 12 errors). A stub annotation needs its original's @Target, or failing that one that includes TYPE_USE.

3. Remaining

With interfaces kept out of the group and the two annotation stubs replaced by hand, four errors remain, not yet analyzed:

  • StructClass is not abstract and does not override abstract method getType() in a stubbed supertype;
  • constructor DataInputStream in class java.io.DataInputStream cannot be applied to given types;
  • two more.

The parse then drops StructClass and DataInputFullStream.

Reproduce

Parse fernflower (JavaToKotlinRatchet.parse("fernflower")), isolate DomHelper alone, take the corpus types in reachedPerType(), isolate [DomHelper] + those, print with the members' verbatim sources and parse the tree back with failFast(true).

Lingua principale
Java
Stelle
1
Fork
1
Merge medio
1h 44m
PR unite (30g)
6

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di CodeLaser/maddi

Tutte le issue di CodeLaser/maddi

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.