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

maddi-java-openjdk: type-use annotations on an anonymous class creation's type are dropped

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

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
java, kotlin
Domain
backend, compilers

Research direction

Start by tracing how the OpenJDK front end builds the anonymous class’s parent ParameterizedType and the ConstructorCall type, then compare that path with the named class supertype clause that preserves annotations. The issue names no files or tests, so first locate those entry points and a focused front end test. Done when the anonymous class parent type retains @Nullable and the Kotlin output keeps the annotation consistently with the next() return type.

Written by the indexing model from the issue text.

Description

bug front-end:javac

The OpenJDK front end keeps no type-use annotations on the type of an anonymous class creation. guava's Iterators.partitionImpl:

return new UnmodifiableIterator<List<@Nullable T>>() {
  @Override
  public List<@Nullable T> next() { ... }
};

arrives as UnmodifiableIterator<List<T>>. Neither the anonymous class's parent type nor the ConstructorCall's type carries the @Nullable. The same annotation on a named class's supertype clause is kept; the J2K printer prints that one as T? since 367ca79bc.

Effect: the Kotlin translation prints the anonymous class header as UnmodifiableIterator<MutableList<T>>, while its next(): MutableList<T?> keeps the annotation. kotlinc then reports "return type of 'fun next(): MutableList<T?>' is not a subtype of the return type of the overridden member" (guava Iterators.kt:387, Iterables.kt:177, and Iterators.kt:376/397 downstream).

Expected: the parent ParameterizedType of the anonymous TypeInfo, or the ConstructorCall's parameterizedType(), carries the type-use annotations as written, as for a named class's extends/implements clause.

Found while reducing guava's KotlinConf scoreboard compile errors, together with the printer session.

🤖 Generated with Claude Code

Dominant language
Java
Stars
1
Forks
1
Avg merge
1h 58m
Merged PRs (30d)
5

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.