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

Java printer: a static interface method called from an implementing class prints unqualified

Open
#168 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

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

Research direction

Start by tracing how javaInspector.print2 decides whether a static call can omit its owner qualifier, then inspect the implicit-scope logic for static methods declared on interfaces. Reproduce the issue with the Item and Use.Impl example in the report, including the fully qualified call. Done when printing preserves the interface type and the printed source compiles; the payload names no test file.

Written by the indexing model from the issue text.

Description

bug

A call to a static method of an interface prints without its type when the caller's class implements that interface. Static interface methods are not inherited (JLS 8.4.8), so the bare call does not compile.

package proj.v1;
public interface Item {
    static Item from(Object o) { return null; }
    String name();
}
package proj;
import proj.v1.Item;
public class Use {
    public static final class Impl implements Item {
        private final Object delegate;
        public Impl(Object delegate) { this.delegate = delegate; }
        @Override public String name() { return Item.from(delegate).name(); }
    }
}

javaInspector.print2(cu, null, javaInspector.importComputer(Integer.MAX_VALUE, cu.sourceSet())) prints the body as

@Override public String name() { return from(delegate).name(); }

and javac rejects it: cannot find symbol: method from(Object), location: class Impl. The same happens when the source writes the type fully qualified (proj.v1.Item.from(delegate), with a homonym proj.v2.Item imported): the qualifier is dropped all the same.

Found re-parsing printed sources of jenkins core: FileParameterValue.FileItemImpl implements org.apache.commons.fileupload.FileItem calls org.apache.commons.fileupload.FileItem.fromFileUpload2FileItem(delegate), printed as fromFileUpload2FileItem(delegate). The re-parse drops the unit, 42 units in that run (two passes) for this reason.

Probably the "implicit scope" decision for a static call: a static method of a superclass may be called unqualified from a subclass, but a static method of a superinterface may not. Keep the type qualifier when the method's owner is an interface (unless the call is inside that interface itself).

maddi 0.9.5-alpha.36.

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

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.