eo icon indicating copy to clipboard operation
eo copied to clipboard

can't use `XmirPackage` in package-info.java

Open yegor256 opened this issue 1 year ago • 2 comments

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.

yegor256 avatar Dec 15 '24 20:12 yegor256

@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: https://github.com/objectionary/eo/blob/1aaeb2a6113c4e82121a2185a6157990a45dc8b3/pom.xml#L387 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.

Suban05 avatar Feb 17 '25 08:02 Suban05

@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.

yegor256 avatar Feb 17 '25 09:02 yegor256