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

Possibly bogus warning for public exported types when the export target contains those types #3067

Open
nlisker opened this issue Oct 10, 2024 · 3 comments
Labels
enhancement New feature or request jpms

Comments

@nlisker
Copy link

nlisker commented Oct 10, 2024

Suppose a module dep that exports package dep with class dep.D. And suppose another module:

module App {
    requires dep;

    exports app to dep;
}

then

package app;

public class A {
    public dep.D d;
}

emits a warning:

The type D from module dep may not be accessible to clients due to missing 'requires transitive'

While it's true that it may not be accessible, since the module exposes the package (and class) to the module that defines that class, we can know that it will be accessible.

Can the compiler be smarter and check if the targets of an export have access to the exposed types?

@jukzi jukzi added the enhancement New feature or request label Oct 10, 2024
@jukzi
Copy link
Contributor

jukzi commented Oct 10, 2024

I guess as long as you don't contribute such improvement nothing will happen.

@stephan-herrmann
Copy link
Contributor

I believe one thing is missing from the problem description:

see:

Suppose a module dep that exports package dep with class dep.D.

and:

exports app to dep;

In order for that export to take effect module dep would also need to require module App, right?

Thus we have a cyclic dependency, which brings us back to #2122 (comment)

LMK if I missed something.

@nlisker
Copy link
Author

nlisker commented Oct 10, 2024

In order for that export to take effect module dep would also need to require module App, right?

I don't think so because it can be accessed reflectively. See https://stackoverflow.com/questions/53035454/javafx-module-javafx-graphics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request jpms
Projects
None yet
Development

No branches or pull requests

3 participants