manifold-systems / manifold

Manifold is a Java compiler plugin, its features include Metaprogramming, Properties, Extension Methods, Operator Overloading, Templates, a Preprocessor, and more.
http://manifold.systems/
Apache License 2.0
2.43k stars 125 forks source link

Manifold-json: java compiler complaining about interface beeing already defined #509

Closed ltanguy closed 8 months ago

ltanguy commented 1 year ago

Describe the bug When using Manifold-json on a JSON Schema, Java throws an error at compile time about an interface being already defined.

To Reproduce Import the attached file (renamed with a .txt extension to make Github happy) in a project JiraIssuesResponse.json.txt

The Java compiler throws the following error:

java: interface JiraIssuesResponse.issues.issuesItem.fields is already defined in interface JiraIssuesResponse.issues.issuesItem

Already tried to clean the project, reload the maven project and rebuild the project without success.

Expected behavior The code compiles.

Screenshots If applicable, add screenshots to help explain your problem (drag/drop them here).

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

Stack trace Please include a stack trace if applicable

rsmckinney commented 1 year ago

This is due to a limitation in Java where a nested class can't have the same name as any of its outer classes. The following is illegal.

public class A {
    public class B {
        public class A {  // compile error: duplicate class
        }
    }
}

There is a fields interface nested inside another fields interface in the type projected for the JSON file. Apologies for not accounting for this. It will be fixed in next week's build.

Thanks for reporting this!

CC007 commented 1 year ago

I looked at the implementation and found that the solution might not fully fix the issue. See my comment here: https://github.com/manifold-systems/manifold/commit/32ba7fdd186195752926b16a1dbade909ed93f05#r128939227

rsmckinney commented 8 months ago

Fix available with release 2024.1.5