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

Abierto
#180 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
java
Área
devtools

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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).

Lenguaje dominante
Java
Estrellas
1
Forks
1
Merge medio
1 h 44 min
PR fusionados (30 d)
6

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de CodeLaser/maddi

Todos los issues de CodeLaser/maddi

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.