Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Java printer: a fully qualified package annotation prints by simple name without an import

Closed
#109 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
java
Domain
compilers

Research direction

The bug is in how Formatter2Impl prints annotations on a package declaration, and how the import computer treats them. Start by finding the annotation printing path for package-info.java units, then check why a fully qualified package annotation is shortened to its simple name without an import. There is no small reproducer yet, so first build one from the gson package-info.java example. Done means the printed output either keeps the qualified name or adds a matching import, and the gson package-info units compile again.

Written by the indexing model from the issue text.

Description

bug

Problem

An annotation on a package declaration (package-info.java) that is written fully qualified is printed by its simple name, and no import is added. The printed file fails to resolve: Type 'CheckReturnValue' not found.

gson's com/google/gson/package-info.java:

@com.google.errorprone.annotations.CheckReturnValue
package com.google.gson;

prints as

@CheckReturnValue
package com.google.gson;

Expected

Either keep the qualified name on a package annotation, or add the import. A package-info.java may have imports after the package declaration, so either works, but keeping the qualified name is the simpler of the two.

Seen on

Printing parsed sources with Formatter2Impl (imports computed by the import computer) on maddi 0.9.5-alpha.5. gson loses 5 package-info units this way. I haven't reduced it further: package-info units don't go through the same small round-trip harness as the other reports.

Dominant language
Java
Stars
1
Forks
1
Avg merge
2h 51m
Merged PRs (30d)
3

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from CodeLaser/maddi

All issues in CodeLaser/maddi

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.