Skip to content

Commit

Permalink
feat(jvm): add support for Java 23
Browse files Browse the repository at this point in the history
  • Loading branch information
henryhchchc committed Sep 20, 2024
1 parent 78705cb commit 30ebccf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ concurrency:

env:
CARGO_TERM_COLOR: always
JAVA_VERSION: 22
JAVA_VERSION: 23

jobs:
style_rustfmt:
Expand Down
11 changes: 9 additions & 2 deletions src/jvm/class/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub struct ConstantPool {
}

/// The maximum supported major version of a class file.
pub const MAX_MAJOR_VERSION: u16 = 66;
pub const MAX_MAJOR_VERSION: u16 = 67;

/// The version of a class file.
#[derive(Debug, PartialOrd, PartialEq, Eq, Copy, Clone)]
Expand Down Expand Up @@ -144,6 +144,8 @@ pub enum Version {
Jdk21(bool),
/// JDK 22
Jdk22(bool),
/// JDK 23
Jdk23(bool),
}
impl Version {
pub(crate) const fn from_versions(major: u16, minor: u16) -> Result<Self, Error> {
Expand Down Expand Up @@ -181,6 +183,8 @@ impl Version {
(65, 0xFFFF) => Ok(Self::Jdk21(true)),
(66, 0x0000) => Ok(Self::Jdk22(false)),
(66, 0xFFFF) => Ok(Self::Jdk22(true)),
(67, 0x0000) => Ok(Self::Jdk23(false)),
(67, 0xFFFF) => Ok(Self::Jdk23(true)),
(major, _) if major > MAX_MAJOR_VERSION => {
Err(Error::Other("Unsupportted class version"))
}
Expand All @@ -204,6 +208,7 @@ impl Version {
| Self::Jdk20(true)
| Self::Jdk21(true)
| Self::Jdk22(true)
| Self::Jdk23(true)
)
}

Expand Down Expand Up @@ -233,6 +238,7 @@ impl Version {
Self::Jdk20(_) => 64,
Self::Jdk21(_) => 65,
Self::Jdk22(_) => 66,
Self::Jdk23(_) => 67,
}
}

Expand All @@ -254,7 +260,8 @@ impl Version {
| Jdk19(enable_preview)
| Jdk20(enable_preview)
| Jdk21(enable_preview)
| Jdk22(enable_preview) => {
| Jdk22(enable_preview)
| Jdk23(enable_preview) => {
if *enable_preview {
u16::MAX
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ macro_rules! malform {
}

macro_rules! see_jvm_spec {
(__latest_jdk) => { 22 };
(__latest_jdk) => { 23 };
($sec:literal $(, $sub_sec:literal )*) => {
concat!(
"See the [JVM Specification §", $sec, $( ".", $sub_sec, )* "]",
Expand Down

0 comments on commit 30ebccf

Please sign in to comment.