From bd8f7805382e2d1fda5cfa6a37ffa4ae6f1a7c8d Mon Sep 17 00:00:00 2001 From: Taku Kodma <79110363+risu729@users.noreply.github.com> Date: Tue, 19 May 2026 22:08:39 +1000 Subject: [PATCH 1/6] fix(java): include shorthand vendor in lock identity --- src/plugins/core/java.rs | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/plugins/core/java.rs b/src/plugins/core/java.rs index 0e2f220209..c45e5eb732 100644 --- a/src/plugins/core/java.rs +++ b/src/plugins/core/java.rs @@ -64,12 +64,24 @@ impl<'a> JavaOptions<'a> { self.values.str("release_type").unwrap_or("ga") } - fn lockfile_options(&self) -> BTreeMap { + fn lockfile_options( + &self, + requested_version: &str, + shorthand_vendor: &str, + ) -> BTreeMap { let mut opts = BTreeMap::new(); let release_type = self.release_type(); if release_type != "ga" { opts.insert("release_type".to_string(), release_type.to_string()); } + if requested_version + .chars() + .next() + .is_some_and(|c| c.is_ascii_digit()) + && shorthand_vendor != "openjdk" + { + opts.insert("shorthand_vendor".to_string(), shorthand_vendor.to_string()); + } opts } } @@ -480,7 +492,8 @@ impl Backend for JavaPlugin { _target: &PlatformTarget, ) -> BTreeMap { let raw_opts = request.options(); - JavaOptions::new(&raw_opts).lockfile_options() + JavaOptions::new(&raw_opts) + .lockfile_options(&request.version(), &Settings::get().java.shorthand_vendor) } async fn resolve_lock_info( @@ -798,15 +811,30 @@ mod tests { assert_eq!(JavaOptions::new(&default_opts).release_type(), "ga"); assert!( JavaOptions::new(&default_opts) - .lockfile_options() + .lockfile_options("17", "openjdk") .is_empty() ); let opts = opts_with_release_type("ea"); assert_eq!(JavaOptions::new(&opts).release_type(), "ea"); assert_eq!( - JavaOptions::new(&opts).lockfile_options(), + JavaOptions::new(&opts).lockfile_options("17", "openjdk"), BTreeMap::from([("release_type".to_string(), "ea".to_string())]) ); } + + #[test] + fn java_lockfile_options_include_non_default_shorthand_vendor() { + let opts = ToolVersionOptions::default(); + + assert_eq!( + JavaOptions::new(&opts).lockfile_options("17", "temurin"), + BTreeMap::from([("shorthand_vendor".to_string(), "temurin".to_string())]) + ); + assert!( + JavaOptions::new(&opts) + .lockfile_options("temurin-17", "temurin") + .is_empty() + ); + } } From 6438d69a2aa2cb7c998eb7e66326f5b8956dfef4 Mon Sep 17 00:00:00 2001 From: Taku Kodma <79110363+risu729@users.noreply.github.com> Date: Tue, 19 May 2026 22:33:16 +1000 Subject: [PATCH 2/6] fix(java): cover shorthand aliases in lock identity --- src/plugins/core/java.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/plugins/core/java.rs b/src/plugins/core/java.rs index c45e5eb732..2965988df5 100644 --- a/src/plugins/core/java.rs +++ b/src/plugins/core/java.rs @@ -32,6 +32,8 @@ use std::sync::LazyLock as Lazy; use versions::Versioning; use xx::regex; +const DEFAULT_JAVA_SHORTHAND_VENDOR: &str = "openjdk"; + static VERSION_REGEX: Lazy = Lazy::new(|| { Regex::new( r"(?i)(^Available versions:|-src|-dev|-latest|-stm|[-\\.]rc|-milestone|-alpha|-beta|[-\\.]pre|-next|-test|snapshot|SNAPSHOT|master)" @@ -74,11 +76,8 @@ impl<'a> JavaOptions<'a> { if release_type != "ga" { opts.insert("release_type".to_string(), release_type.to_string()); } - if requested_version - .chars() - .next() - .is_some_and(|c| c.is_ascii_digit()) - && shorthand_vendor != "openjdk" + if is_shorthand_java_request(requested_version) + && shorthand_vendor != DEFAULT_JAVA_SHORTHAND_VENDOR { opts.insert("shorthand_vendor".to_string(), shorthand_vendor.to_string()); } @@ -86,6 +85,10 @@ impl<'a> JavaOptions<'a> { } } +fn is_shorthand_java_request(requested_version: &str) -> bool { + !requested_version.contains('-') +} + impl JavaPlugin { pub fn new() -> Self { let settings = Settings::get(); @@ -811,14 +814,14 @@ mod tests { assert_eq!(JavaOptions::new(&default_opts).release_type(), "ga"); assert!( JavaOptions::new(&default_opts) - .lockfile_options("17", "openjdk") + .lockfile_options("17", DEFAULT_JAVA_SHORTHAND_VENDOR) .is_empty() ); let opts = opts_with_release_type("ea"); assert_eq!(JavaOptions::new(&opts).release_type(), "ea"); assert_eq!( - JavaOptions::new(&opts).lockfile_options("17", "openjdk"), + JavaOptions::new(&opts).lockfile_options("17", DEFAULT_JAVA_SHORTHAND_VENDOR), BTreeMap::from([("release_type".to_string(), "ea".to_string())]) ); } @@ -831,6 +834,10 @@ mod tests { JavaOptions::new(&opts).lockfile_options("17", "temurin"), BTreeMap::from([("shorthand_vendor".to_string(), "temurin".to_string())]) ); + assert_eq!( + JavaOptions::new(&opts).lockfile_options("lts", "temurin"), + BTreeMap::from([("shorthand_vendor".to_string(), "temurin".to_string())]) + ); assert!( JavaOptions::new(&opts) .lockfile_options("temurin-17", "temurin") From 454ea9f7fee934d1cf0236009243e74b078eff50 Mon Sep 17 00:00:00 2001 From: Taku Kodma <79110363+risu729@users.noreply.github.com> Date: Mon, 1 Jun 2026 03:35:08 +1000 Subject: [PATCH 3/6] fix(java): source shorthand vendor default from settings --- settings.toml | 2 +- src/config/settings.rs | 14 +++++++++++++- src/plugins/core/java.rs | 34 +++++++++++++++++++++++----------- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/settings.toml b/settings.toml index 1043145675..21603a14d2 100644 --- a/settings.toml +++ b/settings.toml @@ -1138,7 +1138,7 @@ optional = true type = "String" [java.shorthand_vendor] -default = "openjdk" +default_docs = "openjdk" description = "Shorthand for Java. Used when installing Java without a vendor prefix." env = "MISE_JAVA_SHORTHAND_VENDOR" type = "String" diff --git a/src/config/settings.rs b/src/config/settings.rs index f12353317a..2f374e7701 100644 --- a/src/config/settings.rs +++ b/src/config/settings.rs @@ -201,10 +201,13 @@ impl serde::Serialize for PythonUvVenvAuto { pub type SettingsPartial = ::Layer; +pub const DEFAULT_JAVA_SHORTHAND_VENDOR: &str = "openjdk"; + static BASE_SETTINGS: RwLock>> = RwLock::new(None); static CLI_SETTINGS: Mutex> = Mutex::new(None); static DEFAULT_SETTINGS: Lazy = Lazy::new(|| { let mut s = SettingsPartial::empty(); + s.java.shorthand_vendor = Some(DEFAULT_JAVA_SHORTHAND_VENDOR.to_string()); s.python.default_packages_file = Some(env::HOME.join(".default-python-packages")); if let Some("alpine" | "nixos") = env::LINUX_DISTRO.as_ref().map(|s| s.as_str()) && !cfg!(test) @@ -277,7 +280,8 @@ impl Settings { // Initial pass to obtain cd option let mut sb = Self::builder() .preloaded(CLI_SETTINGS.lock().unwrap().clone().unwrap_or_default()) - .env(); + .env() + .preloaded(DEFAULT_SETTINGS.clone()); let mut settings = sb.load()?; if let Some(mut cd) = settings.cd { @@ -1054,6 +1058,14 @@ mod tests { assert!(!settings.prefer_offline); } + #[test] + fn test_java_shorthand_vendor_default() { + assert_eq!( + DEFAULT_SETTINGS.java.shorthand_vendor.as_deref(), + Some(DEFAULT_JAVA_SHORTHAND_VENDOR) + ); + } + #[test] fn test_offline_setting_enables_offline() { let mut partial = SettingsPartial::empty(); diff --git a/src/plugins/core/java.rs b/src/plugins/core/java.rs index 2965988df5..7ed2774fe7 100644 --- a/src/plugins/core/java.rs +++ b/src/plugins/core/java.rs @@ -32,8 +32,6 @@ use std::sync::LazyLock as Lazy; use versions::Versioning; use xx::regex; -const DEFAULT_JAVA_SHORTHAND_VENDOR: &str = "openjdk"; - static VERSION_REGEX: Lazy = Lazy::new(|| { Regex::new( r"(?i)(^Available versions:|-src|-dev|-latest|-stm|[-\\.]rc|-milestone|-alpha|-beta|[-\\.]pre|-next|-test|snapshot|SNAPSHOT|master)" @@ -76,9 +74,7 @@ impl<'a> JavaOptions<'a> { if release_type != "ga" { opts.insert("release_type".to_string(), release_type.to_string()); } - if is_shorthand_java_request(requested_version) - && shorthand_vendor != DEFAULT_JAVA_SHORTHAND_VENDOR - { + if is_shorthand_java_request(requested_version) { opts.insert("shorthand_vendor".to_string(), shorthand_vendor.to_string()); } opts @@ -798,6 +794,7 @@ static JAVA_FEATURES: Lazy> = Lazy::new(|| { #[cfg(test)] mod tests { use super::*; + use crate::config::settings::DEFAULT_JAVA_SHORTHAND_VENDOR; fn opts_with_release_type(release_type: &str) -> ToolVersionOptions { let mut opts = ToolVersionOptions::default(); @@ -812,22 +809,30 @@ mod tests { fn java_options_reads_release_type() { let default_opts = ToolVersionOptions::default(); assert_eq!(JavaOptions::new(&default_opts).release_type(), "ga"); - assert!( - JavaOptions::new(&default_opts) - .lockfile_options("17", DEFAULT_JAVA_SHORTHAND_VENDOR) - .is_empty() + assert_eq!( + JavaOptions::new(&default_opts).lockfile_options("17", DEFAULT_JAVA_SHORTHAND_VENDOR), + BTreeMap::from([( + "shorthand_vendor".to_string(), + DEFAULT_JAVA_SHORTHAND_VENDOR.to_string() + )]) ); let opts = opts_with_release_type("ea"); assert_eq!(JavaOptions::new(&opts).release_type(), "ea"); assert_eq!( JavaOptions::new(&opts).lockfile_options("17", DEFAULT_JAVA_SHORTHAND_VENDOR), - BTreeMap::from([("release_type".to_string(), "ea".to_string())]) + BTreeMap::from([ + ("release_type".to_string(), "ea".to_string()), + ( + "shorthand_vendor".to_string(), + DEFAULT_JAVA_SHORTHAND_VENDOR.to_string() + ) + ]) ); } #[test] - fn java_lockfile_options_include_non_default_shorthand_vendor() { + fn java_lockfile_options_include_shorthand_vendor() { let opts = ToolVersionOptions::default(); assert_eq!( @@ -838,6 +843,13 @@ mod tests { JavaOptions::new(&opts).lockfile_options("lts", "temurin"), BTreeMap::from([("shorthand_vendor".to_string(), "temurin".to_string())]) ); + assert_eq!( + JavaOptions::new(&opts).lockfile_options("17", DEFAULT_JAVA_SHORTHAND_VENDOR), + BTreeMap::from([( + "shorthand_vendor".to_string(), + DEFAULT_JAVA_SHORTHAND_VENDOR.to_string() + )]) + ); assert!( JavaOptions::new(&opts) .lockfile_options("temurin-17", "temurin") From c52d436364afbc268fcf097347922c656eed9576 Mon Sep 17 00:00:00 2001 From: Taku Kodma <79110363+risu729@users.noreply.github.com> Date: Mon, 1 Jun 2026 03:52:41 +1000 Subject: [PATCH 4/6] chore: update generated outputs --- mise.usage.kdl | 1 - schema/mise.json | 1 - 2 files changed, 2 deletions(-) diff --git a/mise.usage.kdl b/mise.usage.kdl index f172d4ef1d..21463fea11 100644 --- a/mise.usage.kdl +++ b/mise.usage.kdl @@ -860,7 +860,6 @@ cmd registry help="List available tools to install" { } arg "[NAME]" help="Show only the specified tool's full name" required=#false } -cmd render-help hide=#true help="internal command to generate markdown from help" cmd reshim help="Creates new shims based on bin paths from currently installed tools." { long_help "Creates new shims based on bin paths from currently installed tools.\n\nThis creates new shims in ~/.local/share/mise/shims for CLIs that have been added.\nmise will try to do this automatically for commands like `npm i -g` but there are\nother ways to install things (like using yarn or pnpm for node) that mise does\nnot know about and so it will be necessary to call this explicitly.\n\nIf you think mise should automatically call this for a particular command, please\nopen an issue on the mise repo. You can also setup a shell function to reshim\nautomatically (it's really fast so you don't need to worry about overhead):\n\n npm() {\n command npm \"$@\"\n mise reshim\n }\n\nNote that this creates shims for _all_ installed tools, not just the ones that are\ncurrently active in mise.toml." after_long_help "Examples:\n\n $ mise reshim\n $ ~/.local/share/mise/shims/node -v\n v20.0.0\n" diff --git a/schema/mise.json b/schema/mise.json index c340a8a46f..0c296f239a 100644 --- a/schema/mise.json +++ b/schema/mise.json @@ -1005,7 +1005,6 @@ "unevaluatedProperties": false, "properties": { "shorthand_vendor": { - "default": "openjdk", "description": "Shorthand for Java. Used when installing Java without a vendor prefix.", "type": "string" } From 2cdcce8828a678d835d7e0a0899a31952145ec21 Mon Sep 17 00:00:00 2001 From: Taku Kodma <79110363+risu729@users.noreply.github.com> Date: Mon, 1 Jun 2026 04:09:31 +1000 Subject: [PATCH 5/6] chore: restore generated usage entry --- mise.usage.kdl | 1 + 1 file changed, 1 insertion(+) diff --git a/mise.usage.kdl b/mise.usage.kdl index 21463fea11..f172d4ef1d 100644 --- a/mise.usage.kdl +++ b/mise.usage.kdl @@ -860,6 +860,7 @@ cmd registry help="List available tools to install" { } arg "[NAME]" help="Show only the specified tool's full name" required=#false } +cmd render-help hide=#true help="internal command to generate markdown from help" cmd reshim help="Creates new shims based on bin paths from currently installed tools." { long_help "Creates new shims based on bin paths from currently installed tools.\n\nThis creates new shims in ~/.local/share/mise/shims for CLIs that have been added.\nmise will try to do this automatically for commands like `npm i -g` but there are\nother ways to install things (like using yarn or pnpm for node) that mise does\nnot know about and so it will be necessary to call this explicitly.\n\nIf you think mise should automatically call this for a particular command, please\nopen an issue on the mise repo. You can also setup a shell function to reshim\nautomatically (it's really fast so you don't need to worry about overhead):\n\n npm() {\n command npm \"$@\"\n mise reshim\n }\n\nNote that this creates shims for _all_ installed tools, not just the ones that are\ncurrently active in mise.toml." after_long_help "Examples:\n\n $ mise reshim\n $ ~/.local/share/mise/shims/node -v\n v20.0.0\n" From 908cb8e9e1130da821f6e25aeecd44b72f1a3904 Mon Sep 17 00:00:00 2001 From: Taku Kodma <79110363+risu729@users.noreply.github.com> Date: Mon, 1 Jun 2026 08:06:16 +1000 Subject: [PATCH 6/6] fix(java): keep shorthand vendor default in settings --- schema/mise.json | 1 + settings.toml | 2 +- src/config/settings.rs | 14 +------------- src/plugins/core/java.rs | 23 +++++++---------------- 4 files changed, 10 insertions(+), 30 deletions(-) diff --git a/schema/mise.json b/schema/mise.json index 0c296f239a..c340a8a46f 100644 --- a/schema/mise.json +++ b/schema/mise.json @@ -1005,6 +1005,7 @@ "unevaluatedProperties": false, "properties": { "shorthand_vendor": { + "default": "openjdk", "description": "Shorthand for Java. Used when installing Java without a vendor prefix.", "type": "string" } diff --git a/settings.toml b/settings.toml index 21603a14d2..1043145675 100644 --- a/settings.toml +++ b/settings.toml @@ -1138,7 +1138,7 @@ optional = true type = "String" [java.shorthand_vendor] -default_docs = "openjdk" +default = "openjdk" description = "Shorthand for Java. Used when installing Java without a vendor prefix." env = "MISE_JAVA_SHORTHAND_VENDOR" type = "String" diff --git a/src/config/settings.rs b/src/config/settings.rs index 2f374e7701..f12353317a 100644 --- a/src/config/settings.rs +++ b/src/config/settings.rs @@ -201,13 +201,10 @@ impl serde::Serialize for PythonUvVenvAuto { pub type SettingsPartial = ::Layer; -pub const DEFAULT_JAVA_SHORTHAND_VENDOR: &str = "openjdk"; - static BASE_SETTINGS: RwLock>> = RwLock::new(None); static CLI_SETTINGS: Mutex> = Mutex::new(None); static DEFAULT_SETTINGS: Lazy = Lazy::new(|| { let mut s = SettingsPartial::empty(); - s.java.shorthand_vendor = Some(DEFAULT_JAVA_SHORTHAND_VENDOR.to_string()); s.python.default_packages_file = Some(env::HOME.join(".default-python-packages")); if let Some("alpine" | "nixos") = env::LINUX_DISTRO.as_ref().map(|s| s.as_str()) && !cfg!(test) @@ -280,8 +277,7 @@ impl Settings { // Initial pass to obtain cd option let mut sb = Self::builder() .preloaded(CLI_SETTINGS.lock().unwrap().clone().unwrap_or_default()) - .env() - .preloaded(DEFAULT_SETTINGS.clone()); + .env(); let mut settings = sb.load()?; if let Some(mut cd) = settings.cd { @@ -1058,14 +1054,6 @@ mod tests { assert!(!settings.prefer_offline); } - #[test] - fn test_java_shorthand_vendor_default() { - assert_eq!( - DEFAULT_SETTINGS.java.shorthand_vendor.as_deref(), - Some(DEFAULT_JAVA_SHORTHAND_VENDOR) - ); - } - #[test] fn test_offline_setting_enables_offline() { let mut partial = SettingsPartial::empty(); diff --git a/src/plugins/core/java.rs b/src/plugins/core/java.rs index 7ed2774fe7..dfb70a2b56 100644 --- a/src/plugins/core/java.rs +++ b/src/plugins/core/java.rs @@ -794,7 +794,6 @@ static JAVA_FEATURES: Lazy> = Lazy::new(|| { #[cfg(test)] mod tests { use super::*; - use crate::config::settings::DEFAULT_JAVA_SHORTHAND_VENDOR; fn opts_with_release_type(release_type: &str) -> ToolVersionOptions { let mut opts = ToolVersionOptions::default(); @@ -807,26 +806,21 @@ mod tests { #[test] fn java_options_reads_release_type() { + let default_vendor = Settings::get().java.shorthand_vendor.clone(); let default_opts = ToolVersionOptions::default(); assert_eq!(JavaOptions::new(&default_opts).release_type(), "ga"); assert_eq!( - JavaOptions::new(&default_opts).lockfile_options("17", DEFAULT_JAVA_SHORTHAND_VENDOR), - BTreeMap::from([( - "shorthand_vendor".to_string(), - DEFAULT_JAVA_SHORTHAND_VENDOR.to_string() - )]) + JavaOptions::new(&default_opts).lockfile_options("17", &default_vendor), + BTreeMap::from([("shorthand_vendor".to_string(), default_vendor.clone())]) ); let opts = opts_with_release_type("ea"); assert_eq!(JavaOptions::new(&opts).release_type(), "ea"); assert_eq!( - JavaOptions::new(&opts).lockfile_options("17", DEFAULT_JAVA_SHORTHAND_VENDOR), + JavaOptions::new(&opts).lockfile_options("17", &default_vendor), BTreeMap::from([ ("release_type".to_string(), "ea".to_string()), - ( - "shorthand_vendor".to_string(), - DEFAULT_JAVA_SHORTHAND_VENDOR.to_string() - ) + ("shorthand_vendor".to_string(), default_vendor.clone()) ]) ); } @@ -844,11 +838,8 @@ mod tests { BTreeMap::from([("shorthand_vendor".to_string(), "temurin".to_string())]) ); assert_eq!( - JavaOptions::new(&opts).lockfile_options("17", DEFAULT_JAVA_SHORTHAND_VENDOR), - BTreeMap::from([( - "shorthand_vendor".to_string(), - DEFAULT_JAVA_SHORTHAND_VENDOR.to_string() - )]) + JavaOptions::new(&opts).lockfile_options("17", "openjdk"), + BTreeMap::from([("shorthand_vendor".to_string(), "openjdk".to_string())]) ); assert!( JavaOptions::new(&opts)