Skip to content

Constructor references missing for implicit super() and anonymous subclass creation #1083

Open

Description

@stacknoise

Version: scip-java 0.12.3 (semanticdb-java 0.12.3), JDK 21, Maven 3.9, Linux. Measured against the compiler on a public project (google/gson at a961b0fe088f8558d00cc1b56e506a3656907a91): of 556 uses of constructors that javac reports, 67 are missing from the index (58 implicit super() calls, 9 anonymous subclasses). Everything else (methods, fields, classes, interfaces, enum constants) agrees.

Reproduction

Plain Maven project, maven.compiler.source and target 17. src/main/java/p/A.java:

package p;

public class A {
  static class Base {
    Base() {}
  }

  static class Derived extends Base {}

  static class Explicit extends Base {
    Explicit(int a)
    {
    }
  }

  static class Maker {
    Object make() {
      return new Base() {
        int inner() { return 1; }
      };
    }
  }
}

Run scip-java index --output index.scip in the project folder.

Line What javac resolves What the index has
9 static class Derived extends Base {} the default constructor of Derived calls Base#<init>(). the definition of Derived#<init>(). at the class name, the type Base#; no occurrence of Base#<init>().
11-13 Explicit(int a) with body the implicit super() at the opening brace of the body calls Base#<init>(). the definition of Explicit#<init>().; no occurrence of Base#<init>().
19 return new Base() { the anonymous class calls Base#<init>(). only the type Base#

Expected

  1. A reference occurrence of the superclass constructor at the place where the compiler puts the implicit call (the opening brace of the body, or the class name for a default constructor), like for an explicit super(...), which is written (Base#<init>(). on the keyword).
  2. A reference occurrence of the constructor at the type name of new Base() { ... }, like for new Base() without a body.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions