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

Running jbang to execute inline code produces a warning about incubator modules #1872

Open
yeurch opened this issue Nov 27, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@yeurch
Copy link

yeurch commented Nov 27, 2024

With a fresh install of Ubuntu 24.04 and JBang, I get the following warning when I execute a simple hello world example using the -c command:

$ jbang -c 'println("Hello, World!")'
WARNING: Using incubator modules: jdk.incubator.foreign, jdk.incubator.vector
Hello, World!

Even though this warning is emitted by JDK (I think), it's frustrating and likely offputting for new users. Can we suppress this in some way?

To Reproduce

Steps to reproduce the behavior:

  1. Start with a fresh installation of Ubuntu 24.04. You could consider running docker run -it ubuntu:24.04 /bin/bash to get this.
  2. Ensure curl is installed: apt update && apt install -y curl
  3. Install jbang and its default JDK 17 ... curl -Ls https://sh.jbang.dev | bash -s - app setup
  4. Run a simple hello world script jbang -c 'println("Hello, World!")'
  5. Note that a warning appears before the program's output.

Expected behavior

No warnings should be visible to the user, particularly during a Hello World scenario.

JBang version

[jbang] [0:122] jbang version 0.121.0
Cache: /root/.jbang/cache
Config: /root/.jbang
Repository: /root/.m2/repository
Java: /root/.jbang/cache/jdks/17 [17.0.13]
OS: linux
Arch: aarch64
Shell: bash
0.121.0

JDK version

This is the default JDK installed by JBang when no JDK is found on the system.

openjdk 17.0.13 2024-10-15
OpenJDK Runtime Environment Temurin-17.0.13+11 (build 17.0.13+11)
OpenJDK 64-Bit Server VM Temurin-17.0.13+11 (build 17.0.13+11, mixed mode, sharing)
@yeurch yeurch added the bug Something isn't working label Nov 27, 2024
@quintesse
Copy link
Contributor

quintesse commented Nov 27, 2024

One way of doing this would be for JBang to switch to --add-modules=ALL-DEFAULT instead of the ALL_SYSTEM it uses now. But I'm not really sure what the effect of that would be (ie what kind of code would stop working). WDYT @maxandersen ? According to the docs ALL-DEFAULT is preferred over ALL-SYSTEM.

Edit: I just tested, if we would switch to ALL-DEFAULT you can still explicitly add -R--add-modules=ALL-SYSTEM if you need it. (You can't do the reverse, it seems you can only add modules, not remove them once added)

@maxandersen
Copy link
Collaborator

I used ALL-SYSTEM in early days to make it as easy as possible to use any java code - if we do "all-default" you won't get access to the incubating ones ....

Like, if we use ALL-DEFAULT then yes, we dont get the warning, but now you need to list -J--add-modules=jdk.incubator.vector to access it and you still get the warning despite you very explicitly already said you know you want to use it.

I guess we could conside making it that we use ALL-DEFAULT by default and when using --enable-preview add ALL-SYSTEM but boy I feel this is tedious.

Ultimately I wish the openjdk would allow us as users to state "yes, we know we are doing it but please don't mess up my console output flag"

@maxandersen
Copy link
Collaborator

the code is here: https://github.com/openjdk/jdk/blob/c88e081a6a0a00d7e7e5f2337f942a1d6c3b5110/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java#L1019

and it just prints directly to System.err.println() ...and it happens before any code is granted access to setup/rewire stderr so can't even do some trickeries.

@maxandersen
Copy link
Collaborator

fyi #992 explains why we added that flag, basically without it you have to get really verbose if you use modules.

@quintesse
Copy link
Contributor

Like, if we use ALL-DEFAULT then yes, we dont get the warning, but now you need to list -J--add-modules=jdk.incubator.vector to access it and you still get the warning despite you very explicitly already said you know you want to use it.

That's true, but you only get that in the case you're using incubator modules, which I don't think is the norm, so defaulting to ALL_DEFAULT would at least get rid of those annoying messages in most cases. In the case you really need them (or any other non-default module) you can still do -J--add-modules=ALL-SYSTEM.

@maxandersen
Copy link
Collaborator

I reckon we could add that --enable-preview adds system instead of default? As inthink you need preview anyway to actually use it ( at least in java)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants