Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't use XmirPackage in package-info.java #3671

Open
yegor256 opened this issue Dec 15, 2024 · 2 comments
Open

can't use XmirPackage in package-info.java #3671

yegor256 opened this issue Dec 15, 2024 · 2 comments

Comments

@yegor256
Copy link
Member

At this line, in TranspileMojo, if we remove //, the build fails with internal Javac error (at least for me, with OpenJDK 23.0.1). Let's find out what's wrong and enable the usage of XmirPackage.

@Suban05
Copy link
Contributor

Suban05 commented Feb 17, 2025

@yegor256 If I understand correctly, the issue is that package-info.java files are defined twice. When the compiler crashes with an internal error, the logs show something like this:

[ERROR] /home/user/eolang/eo/eo-runtime/target/generated-sources/E0org/EOeoLang/EOfs/package-info.java: [6,23] a package-info.java file has already been seen for package E0org.EOeolang.EOfs
[ERROR] /home/user/eolang/eo/eo-runtime/target/generated-sources/EOorg/EOeolang/EOmath/package-info.java: [6,23] a package-info.java file has already been seen for package Eorg.EOeolang.EOmath
[ERROR] /home/user/eolang/eo/eo-runtime/target/generated-sources/EOorg/EOeolang/EOsys/package-info.java: [6,23] a package-info.java file has already been seen for package EOrg.EOeolang.EOsys
[ERROR] /home/user/eolang/eo/eo-runtime/target/generated-sources/E0org/EOeolang/EOtxt/package-info.java: [6,23] a package-info.java file has already been seen for package EOorg.EOeolang.EOtxt
[ERROR] /home/user/eolang/eo/eo-runtime/target/generated-sources/E0org/EOeolang/package-info.java: [6,14] a package-info.java file has already been seen for package EOorg.EOeolang

The first time package-info.java is defined is here https://github.com/objectionary/eo/blob/master/eo-runtime/src/main/java/EOorg/package-info.java
and in the nested folders.

Then, TranspileMojo generates them again but with different content, adding the @org.eolang.XmirPackage annotation. This causes the error.

Workarounds:

  1. Removing this setting in the pom.xml:

    eo/pom.xml

    Line 387 in 1aaeb2a

    <arg>-Xpkginfo:always</arg>

    This way, as far as I understand, package-info.java is regenerated with the new content.

  2. Deleting the predefined package-info.java files from https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg and its nested folders also helps. Then, TranspileMojo generates package-info.java files, and they are compiled only once.

Alternatively, we need to find a way to avoid generating or modifying package-info.java unnecessarily, and we should annotate the predefined package-info.java files in advance.

@yegor256
Copy link
Member Author

@Suban05 I don't think this is the problem. It's perfectly legit to have multiple package-info.java files in the same package. We have that in many libraries. The bug is related to something else inside Javac.

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

No branches or pull requests

2 participants