-
-
Notifications
You must be signed in to change notification settings - Fork 7
Replace runtime panics with the matching Java exceptions #174
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
java_runtime/src/classes/java/lang/class_not_found_exception.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| use alloc::vec; | ||
|
|
||
| use java_class_proto::JavaMethodProto; | ||
| use jvm::{ClassInstanceRef, Jvm, Result}; | ||
|
|
||
| use crate::{RuntimeClassProto, RuntimeContext, classes::java::lang::String}; | ||
|
|
||
| // class java.lang.ClassNotFoundException | ||
| pub struct ClassNotFoundException; | ||
|
|
||
| impl ClassNotFoundException { | ||
| pub fn as_proto() -> RuntimeClassProto { | ||
| RuntimeClassProto { | ||
| name: "java/lang/ClassNotFoundException", | ||
| parent_class: Some("java/lang/Exception"), | ||
| interfaces: vec![], | ||
| methods: vec![ | ||
| JavaMethodProto::new("<init>", "()V", Self::init, Default::default()), | ||
| JavaMethodProto::new("<init>", "(Ljava/lang/String;)V", Self::init_with_message, Default::default()), | ||
| ], | ||
| fields: vec![], | ||
| access_flags: Default::default(), | ||
| } | ||
| } | ||
|
|
||
| async fn init(jvm: &Jvm, _: &mut RuntimeContext, this: ClassInstanceRef<Self>) -> Result<()> { | ||
| tracing::debug!("java.lang.ClassNotFoundException::<init>({this:?})"); | ||
|
|
||
| let _: () = jvm.invoke_special(&this, "java/lang/Exception", "<init>", "()V", ()).await?; | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| async fn init_with_message(jvm: &Jvm, _: &mut RuntimeContext, this: ClassInstanceRef<Self>, message: ClassInstanceRef<String>) -> Result<()> { | ||
| tracing::debug!("java.lang.ClassNotFoundException::<init>({this:?}, {message:?})"); | ||
|
|
||
| let _: () = jvm | ||
| .invoke_special(&this, "java/lang/Exception", "<init>", "(Ljava/lang/String;)V", (message,)) | ||
| .await?; | ||
|
|
||
| Ok(()) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| mod zip_entry; | ||
| mod zip_exception; | ||
| mod zip_file; | ||
| mod zip_file_entries; | ||
|
|
||
| pub use {zip_entry::ZipEntry, zip_file::ZipFile, zip_file_entries::ZipFileEntries}; | ||
| pub use {zip_entry::ZipEntry, zip_exception::ZipException, zip_file::ZipFile, zip_file_entries::ZipFileEntries}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the requested class file is present but resolving one of its superclasses or interfaces fails,
resolve_classpropagates that Java error (for exampleNoClassDefFoundErrorfromjvm/src/jvm.rswhen a dependency is missing). This blanketErr(_)converts those linkage failures intoClassNotFoundException, so Java code can incorrectly catch them as CNFE instead of seeing the linkage error thatClass.forNameshould propagate. Only the actual “requested class not found” case should be remapped here; otherresolve_classerrors should be returned unchanged.Useful? React with 👍 / 👎.