Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Java printer: a nested type prints by simple name when the unit imports another type of that name

オープン
#176 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
57/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java
領域
tooling

調査の方向性

Start at the Java printer and the importComputer call shown in the issue, then trace how it decides whether a nested type can print by its simple name. Reproduce the case with the two Builder types and confirm the printed source resolves to the wrong one. Done when the nested type remains unambiguous in printed output and the example can be reparsed successfully.

索引モデルが issue の本文から書いたものです。

説明

bug

A nested type of an imported type, written Outer.Impl.Builder, prints by its simple name Builder when the unit also imports another type named Builder. The printed unit then means the imported type.

package a.c;
public class Builder { }
package a.d;
public class Outer {
  public static class Impl {
    public static class Builder { public Builder set(int i) { return this; } }
  }
}
package a.b;
import a.c.Builder;
import a.d.Outer;
public class X {
    Builder own;
    Object make() {
        return new Outer.Impl.Builder().set(0);
    }
}

javaInspector.print2(cu, null, javaInspector.importComputer(4, cu.sourceSet())) prints

public class X { Builder own; Object make() { return new Builder().set(0); } }

so new Builder() is a.c.Builder, which has no set. It looks as if the printer takes the simple name as visible because some type of that simple name is imported, without checking it is the same type. (#114 was the converse: a nested type qualified by an outer name the unit had taken.)

Found re-parsing printed sources of jenkins core: hudson.model.Build, Project, hudson.Functions and jenkins.model.Jenkins import hudson.tasks.Builder and use another nested Builder; all four units are dropped (the re-parse then fails with "Unexpected javac type in convert: 'recovery'"). Jenkins alone held 8 of the idiom sites lost in that run.

maddi 0.9.6-alpha.4.

主要言語
Java
スター
1
フォーク
1
平均マージ
1時間 55分
マージ済み PR(30日)
8

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

CodeLaser/maddi のほかの issue

CodeLaser/maddi の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。