diff --git a/Cargo.lock b/Cargo.lock index b3c05328..104f6fe9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -92,6 +92,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" +[[package]] +name = "cfg_aliases" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" + [[package]] name = "chrono" version = "0.4.45" @@ -446,6 +452,18 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d" +[[package]] +name = "nix" +version = "0.31.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d" +dependencies = [ + "bitflags", + "cfg-if", + "cfg_aliases", + "libc", +] + [[package]] name = "nom" version = "8.0.0" @@ -713,9 +731,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.54.0" +version = "1.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c168a474b95bfecfe908a65d4bdffc523144b649a74c09c286afb35d53e0bc" +checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" dependencies = [ "pin-project-lite", "tokio-macros", @@ -928,14 +946,15 @@ dependencies = [ [[package]] name = "zip" -version = "8.6.0" +version = "9.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d04a6b5381502aa6087c94c669499eb1602eb9c5e8198e534de571f7154809b" +checksum = "6e04976da629d3b04204ba8105b396a193af8ad2583b2c79bfb3ab8af580a11e" dependencies = [ "crc32fast", "flate2", "indexmap", "memchr", + "nix", "typed-path", "zopfli", ] diff --git a/Cargo.toml b/Cargo.toml index 48b9a310..92835a9b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ nom = { version = "^8.0", default-features = false, features = ["alloc"] } parking_lot = { version = "^0.12", default-features = false } tracing = { version = "^0.1", default-features = false, features = ["attributes"] } -tokio = { version = "^1.52", features = ["macros"] } +tokio = { version = "^1.54.1", features = ["macros"] } classfile = { path = "classfile", version = "0.3.2" } jvm = { path = "jvm", version = "0.3.2" } diff --git a/rustjava-runtime/Cargo.toml b/rustjava-runtime/Cargo.toml index 7fc1572d..53077479 100644 --- a/rustjava-runtime/Cargo.toml +++ b/rustjava-runtime/Cargo.toml @@ -20,7 +20,7 @@ chrono = { version = "^0.4", default-features = false } encoding_rs = { version = "^0.8", features = ["alloc"], default-features = false } tracing-attributes = { version = "<0.1.29" } # Pin this to avoid compile error with no-std https://github.com/tokio-rs/tracing/issues/3388 url = { version = "^2.5", default-features = false } -zip = { version = "^8.6", features = ["deflate"], default-features = false } +zip = { version = "^9.0.5", features = ["deflate"], default-features = false } jvm = { workspace = true } jvm-class-proto = { workspace = true } diff --git a/rustjava-runtime/src/classes/java/util/jar/jar_file.rs b/rustjava-runtime/src/classes/java/util/jar/jar_file.rs index 9e6322c0..eb717ad0 100644 --- a/rustjava-runtime/src/classes/java/util/jar/jar_file.rs +++ b/rustjava-runtime/src/classes/java/util/jar/jar_file.rs @@ -125,9 +125,18 @@ impl JarFile { if manifest_file.is_null() { let name = { let zip = ZipFile::get_zip_archive(jvm, &ClassInstanceRef::from(this.instance.clone())).await?; - zip.file_names() - .find(|name| name.eq_ignore_ascii_case("META-INF/MANIFEST.MF")) - .map(ToString::to_string) + let mut manifest_name = None; + for name in zip.file_names() { + let name = match name { + Ok(name) => name, + Err(err) => return Err(jvm.exception("java/util/zip/ZipException", &err.to_string()).await), + }; + if name.eq_ignore_ascii_case("META-INF/MANIFEST.MF") { + manifest_name = Some(name.into_owned()); + break; + } + } + manifest_name }; let Some(name) = name else { return Ok(None.into()); diff --git a/rustjava-runtime/src/classes/java/util/zip/zip_file.rs b/rustjava-runtime/src/classes/java/util/zip/zip_file.rs index 11745a6e..71109d5a 100644 --- a/rustjava-runtime/src/classes/java/util/zip/zip_file.rs +++ b/rustjava-runtime/src/classes/java/util/zip/zip_file.rs @@ -110,7 +110,10 @@ impl ZipFile { tracing::debug!("java.util.zip.ZipFile::entries({this:?})"); let zip = Self::get_zip_archive(jvm, &this).await?; - let names = zip.file_names().map(|x| x.to_string()).collect::>(); + let names = match zip.file_names().collect::, _>>() { + Ok(names) => names, + Err(err) => return Err(jvm.exception("java/util/zip/ZipException", &err.to_string()).await), + }; let mut name_array = jvm.instantiate_array("Ljava/lang/String;", names.len() as _).await?; for (i, name) in names.iter().enumerate() {