typetools / typetools/checker-framework

Handling of anonymous classes in CFG visualization

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

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
1.1k
Forks
440
Avg merge
1d 12h
Merged PRs (30d)
134

Description

Take the following simple example:

class Anon {
  void foo() {
    Object o = new Object() { public String toString() { return "Special"; } };
  }
}

The anonymous object creation is displayed like a normal object creation:
new Object() [ ObjectCreation ] > @Initialized @NonNull <anonymous Anon$1>
(At least the type makes it clear that it is an anonymous object.)

org.checkerframework.dataflow.cfg.CFGBuilder.CFGTranslationPhaseOne.visitNewClass(NewClassTree, Void) should use a more appropriate name.

For the above example, the following dot files are generated when running javac -processor nullness Anon.java -Aflowdotdir=dot:

Anon-foo-KeyForSub.dot
Anon-foo-Nullness.dot
Anon-_init-KeyForSub.dot
Anon-_init-Nullness.dot
-_init-KeyForSub.dot
-_init-Nullness.dot
methods.txt
-toString-KeyForSub.dot
-toString-Nullness.dot

Note how the name for the anonymous class is missing, which makes the result hard to read, in particular if there are multiple anonymous classes, and command-line handling difficult.

Contributor guide

Open the contributing guide

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.

Research direction

Start at org.checkerframework.dataflow.cfg.CFGBuilder.CFGTranslationPhaseOne.visitNewClass(NewClassTree, Void) and reproduce the example with javac -processor nullness Anon.java -Aflowdotdir=dot. Inspect the generated dot filenames and methods.txt, then make the anonymous class name appear consistently so multiple anonymous classes remain distinguishable and command-line handling is not hindered.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.