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

Add a preference to ignore the unnamed module for split packages #424

Merged
merged 6 commits into from
Oct 13, 2022

Conversation

jdneo
Copy link
Contributor

@jdneo jdneo commented Sep 20, 2022

Signed-off-by: Sheng Chen [email protected]

Hi team! 👋

I was trying to make a draft to illustrate the idea mentioned in #415. It will be great and helpful if anyone from the team can take a look and let me know if this idea is acceptable, thanks!

What it does

Add a preference to control whether the unnamed module should be ignored when it comes to a split package.

In https://openjdk.org/projects/jigsaw/spec/sotms/#the-unnamed-module says

If a package is defined in both a named module and the unnamed module then
the package in the unnamed module is ignored. This preserves reliable configuration
even in the face of the chaos of the class path, ensuring that every module still reads
at most one module defining a given package.

How to test

Sample: test1.zip

In .settings/org.eclipse.jdt.core.prefs, if org.eclipse.jdt.core.compiler.ignoreUnnamedModuleForSplitPackage is set to enabled. After import the sample project, everything looks fine. If the preference is set to disabled, The package xxx is accessible from more than one module can be observed.

Author checklist

This is to control whether the error 'The package xxx is accessible from
more than one module' will be reported.

In https://openjdk.org/projects/jigsaw/spec/sotms/#the-unnamed-module says

If a package is defined in both a named module and the unnamed module then
the package in the unnamed module is ignored. This preserves reliable configuration
even in the face of the chaos of the class path, ensuring that every module still reads
at most one module defining a given package.

Signed-off-by: Sheng Chen <[email protected]>
@jdneo jdneo marked this pull request as ready for review September 28, 2022 08:05
Copy link
Contributor

@stephan-herrmann stephan-herrmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please find some nitpicks inline.

jdneo added a commit to jdneo/eclipse.platform.common that referenced this pull request Sep 30, 2022
@jdneo jdneo changed the title Allow disable module system for unmodular project Add a preference to ignore the unnamed module for split packages Sep 30, 2022
Copy link
Contributor

@stephan-herrmann stephan-herrmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're getting closer, great!

With more diligence applied, here's the next round of comments

@jdneo
Copy link
Contributor Author

jdneo commented Oct 11, 2022

Hi @stephan-herrmann, I've updated the PR, would you have time to take a look? :)

Copy link
Contributor

@stephan-herrmann stephan-herrmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks well now. Thanks!

@stephan-herrmann stephan-herrmann merged commit 9b329b0 into eclipse-jdt:master Oct 13, 2022
@jdneo jdneo deleted the cs/issue-415 branch October 14, 2022 01:41
@jdneo
Copy link
Contributor Author

jdneo commented Oct 14, 2022

Thank you @stephan-herrmann :)

jdneo added a commit to jdneo/eclipse.platform.common that referenced this pull request Oct 14, 2022
akurtakov pushed a commit to eclipse-platform/eclipse.platform.common that referenced this pull request Nov 8, 2022
robstryker pushed a commit to robstryker/eclipse.jdt.core that referenced this pull request Jul 18, 2024
…ipse-jdt#424)

* Add a preference to ignore unnamed module for split package

This is to control whether the error 'The package xxx is accessible from
more than one module' will be reported, if the conflict goes away when the
unnamed module is ignored.

In https://openjdk.org/projects/jigsaw/spec/sotms/#the-unnamed-module says

If a package is defined in both a named module and the unnamed module then
the package in the unnamed module is ignored. This preserves reliable configuration
even in the face of the chaos of the class path, ensuring that every module still reads
at most one module defining a given package.

Signed-off-by: Sheng Chen <[email protected]>
@laeubi
Copy link
Contributor

laeubi commented Dec 3, 2024

@stephan-herrmann @jdneo I just came across the preference

org.eclipse.jdt.core.compiler.ignoreUnnamedModuleForSplitPackage=enabled

but it is quite hard to discover and I was not aware about this only after some google-search with a lot of unhelpful results.

Do you think it would be useful to enhance the error message with a hint to the property? e.g

The package xxx is accessible from more than one module, if you want to allow this use org.eclipse.jdt.core.compiler.ignoreUnnamedModuleForSplitPackage=enabled in your org.eclipse.jdt.core preferences.

@xnhp
Copy link

xnhp commented Feb 13, 2025

Can this option also be set when using eclipsec the Eclipse compiler but not the Eclipse IDE? For instance, IntelliJ comes with it. I've tried putting some variations in the compiler CLI arguments in IntelliJ but none were recognised.

@stephan-herrmann
Copy link
Contributor

Can this option also be set when using eclipsec but not the Eclipse IDE? For instance, IntelliJ comes with eclipsec. I've tried putting some variations in the compiler CLI arguments in IntelliJ but none were recognised.

I've never heard the name "eclipsec" 😄 but ecj should understand the option via -properties <file> (haven't tried it myself, though).

@xnhp
Copy link

xnhp commented Feb 13, 2025

Thank you 🙏 It does not complain about some unknown option, but it does not seem to help with the split package error either. I think I'm having the same issue as here.

@laeubi
Copy link
Contributor

laeubi commented Feb 13, 2025

@xnhp You should ask at the supportforum of your tool (IntelliJ) how to set compiler settings for the Eclipse Compiler there.

@stephan-herrmann
Copy link
Contributor

public class Test {
	javax.xml.transform.Transformer transformer;
}

Here's a transcript of how to make the error appear and then disappear again:

$ ecj -23 Test.java
$ ecj -23 -classpath xml-apis-1.4.01.jar Test.java
----------
1. ERROR in /tmp/Test.java (at line 2)
        javax.xml.transform.Transformer transformer;
        ^^^^^^^^^^^^^^^^^^^
The package javax.xml.transform is accessible from more than one module: <unnamed>, java.xml
----------
1 problem (1 error)
$ cat > ecj.prefs
org.eclipse.jdt.core.compiler.ignoreUnnamedModuleForSplitPackage=enabled
^D
$ ecj -23 -classpath xml-apis-1.4.01.jar -properties ecj.prefs Test.java
$

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

Successfully merging this pull request may close these issues.

4 participants