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

refactor: Separated JDK management code into its own module #1874

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

quintesse
Copy link
Contributor

Fixes #1857

@quintesse quintesse changed the title Separated JDK management code into its own module refactor: Separated JDK management code into its own module Nov 27, 2024
private static JdkManager jdkManager = null;

@Nonnull
public static JdkManager jdkManager() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

we seem to call this in many places - but how is going to take into affect jbang provided config of i.e. providers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right now the idea is that the config gets used exactly in that file you're referencing. So the builder will use the config to initialize the jdk manager, including the providers. The jdk manager itself is then completely agnostic where its configuration comes from.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok so in jbang cli we would not call jdkmanger() but have our own instance configured from jbang config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, this JavaUtil class is in the jbang CLI, so this code here is exactly where that instance using jbang config is created.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NB: If you look a bit lower in the createProvider() method you see it references config, which is the jbang config. The missing part I mentioned in our chat is exactly that: tying together the config with the instance creation :-)

@quintesse quintesse force-pushed the jdkman_lib branch 2 times, most recently from 8c7ba7e to 4489268 Compare November 28, 2024 19:44
@quintesse quintesse force-pushed the jdkman_lib branch 2 times, most recently from 2d66e04 to 21e1e5a Compare December 13, 2024 22:05
@quintesse quintesse force-pushed the jdkman_lib branch 5 times, most recently from 260870f to 0f35aa5 Compare January 13, 2025 17:42
@quintesse quintesse force-pushed the jdkman_lib branch 7 times, most recently from e0639c0 to f5e2bb3 Compare January 27, 2025 19:56
@quintesse quintesse force-pushed the jdkman_lib branch 5 times, most recently from 4083f67 to 1d133d2 Compare January 30, 2025 19:39
@maxandersen
Copy link
Collaborator

small thing: how come the package is called .jvm when everything else is named JDK+something ?

//remove this to see all the missing tags/parameters.
options.addStringOption('Xdoclint:none', '-quiet')
}
allprojects {
Copy link
Collaborator

Choose a reason for hiding this comment

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

no matter what I think the changes to enable additional modules in this repo should stay. enable us to split up or add things where it makes the most sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any changes I made to the gradle build file are there only to get things to work, which was already difficult enough. Very likely I made mistakes or did it in an improper way.

* This JUL Formatter is used to format JUL log messages in such a way that they
* look similar to JBang log messages.
*/
public class JBangFormatter extends Formatter {
Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm - originally I explicitly kept "ux output" separate from "logging output" ...is there a reason why we want to redirect all output to JUL ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, you might not want all of the logging output to be confused with UX output, I can understand that.

But there are two things that come to mind:

  1. our output mechanism sure does look like logging (having levels like warn, inifo, error, debug, etc)
  2. to make the new module really independent from JBang I needed a way to generate output that didn't use JBang's system and I didn't want to introduce some new interface

So that's why I decided to switch the module's output to use plain logging but then the output would look different from before, so that's why I decided to capture the logging output and make it look like JBang output.

Now, I thought it would be nice to do the same for anything that could be outputting logging info, but that's just something I decided in the moment and we could easily change that to only work for the module and nothing else.

@@ -0,0 +1,4 @@
handlers=java.util.logging.ConsoleHandler
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need this now? (not against it - just want to understand the rationale)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's just to make any logging appear as if it comes directly from JBang (with our normal "[jbang]" prefix for every line), which was needed to make the logging output from the new module appear exactly the same as it did before.

@quintesse
Copy link
Contributor Author

small thing: how come the package is called .jvm when everything else is named JDK+something ?

Historical reasons, because that was the tool is called that I want to use this module for. But it can of course be anything we want.

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.

Refactor JDK management code into separate module
2 participants