Skip to content

Identical static methods in parent/child classes are mistakenly marked as overrides in java resulting in a compilation error #2358

@iliapolo

Description

@iliapolo

🐛 Bug Report

Affected Languages

  • TypeScript or Javascript
  • Python
  • Java
  • .NET (C#, F#, ...) [Probably]

General Information

  • JSII Version: 1.15.0 (build 585166b), typescript 3.9.7
  • Platform: MacOS, CodeBuild (jsii/superchain)

What is the problem?

We encountered a scenario in aws-cdk that generates illegal java code, annotating static methods with the @Override annotation.

This happens when a child class has the same static method as its parent.

export class Parent {
  public static hello() {}
}

export class Child extends Parent {
  public static hello() {}
}

This code will generate a JSII assembly that marks the Child.hello function both as static and as overrides of Parent.hello.
The generated java code will look like:

public class Child extends Parent {

  @Override
  public static hello() {}

}

Resulting in a compilation error: method does not override or implement a method from a supertype

See aws/aws-cdk#12091 for the full scenario.

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.effort/smallSmall work item – less than a day of effortlanguage/dotnetRelated to .NET bindings (C#, F#, ...)language/javaRelated to Java bindingsmodule/pacmakIssues affecting the `jsii-pacmak` modulep1

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions