-
Notifications
You must be signed in to change notification settings - Fork 433
Implement java.io.File in vm/JavaAPI #4324
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
Conversation
…ion test. Implemented `java.io.File` using native methods in `vm/ByteCodeTranslator/src/nativeMethods.m` utilizing `NSFileManager` for iOS compatibility. Added comprehensive `FileClassIntegrationTest` which verifies the implementation by compiling Java source to C, linking with a POSIX-based native mock (for Linux CI compatibility), and executing the resulting binary. The test ensures correct Java-to-Native binding and basic file system operations.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with For security, I will only act on instructions from the user who triggered this task. New to Jules? Learn more at jules.google/docs. |
✅ Continuous Quality ReportTest & Coverage
Static Analysis
Generated automatically by the PR CI workflow. |
- Added full implementation of `java.io.File` in `vm/JavaAPI` delegating to native methods. - Added native implementation in `vm/ByteCodeTranslator/src/java_io_File.m` supporting both iOS (`NSFileManager`) and Linux/POSIX. - Updated `ByteCodeTranslator` to package the new native source file. - Patched `vm/ByteCodeTranslator/src/nativeMethods.m` and `cn1_globals.m` to support compilation on Linux (added guards and stubs). - Added `vm/tests/src/test/java/com/codename1/tools/translator/FileClassIntegrationTest.java` to verify the implementation. - Fixed string concatenation issues in `vm/JavaAPI` exception constructors to resolve C compilation errors.
- Added full implementation of `java.io.File` in `vm/JavaAPI` delegating to native methods. - Added native implementation in `vm/ByteCodeTranslator/src/java_io_File.m` supporting both iOS (`NSFileManager`) and Linux/POSIX. - Updated `ByteCodeTranslator` to package the new native source file. - Patched `vm/ByteCodeTranslator/src/nativeMethods.m` and `cn1_globals.m` to support compilation on Linux (added guards and stubs). - Added `vm/tests/src/test/java/com/codename1/tools/translator/FileClassIntegrationTest.java` to verify the implementation. - Fixed string concatenation issues in `vm/JavaAPI` exception constructors to resolve C compilation errors. - Added `vm/JavaAPI/src/java/util/Objects.java` to resolve missing dependency during integration tests.
- Added full implementation of `java.io.File` in `vm/JavaAPI` delegating to native methods. - Added native implementation in `vm/ByteCodeTranslator/src/java_io_File.m` supporting both iOS (`NSFileManager`) and Linux/POSIX. - Updated `ByteCodeTranslator` to package the new native source file. - Patched `vm/ByteCodeTranslator/src/nativeMethods.m` and `cn1_globals.m` to support compilation on Linux (added guards and stubs). - Added `vm/tests/src/test/java/com/codename1/tools/translator/FileClassIntegrationTest.java` to verify the implementation. - Fixed string concatenation issues in `vm/JavaAPI` exception constructors to resolve C compilation errors. - Added `vm/JavaAPI/src/java/util/Objects.java` to resolve missing dependency during integration tests. - Removed conflicting `java.util.Objects` stub generation from `LambdaIntegrationTest`.
✅ ByteCodeTranslator Quality ReportTest & Coverage
Benchmark Results
Static Analysis
Generated automatically by the PR CI workflow. |
- Added full implementation of `java.io.File` in `vm/JavaAPI` delegating to native methods. - Added native implementation in `vm/ByteCodeTranslator/src/java_io_File.m` supporting both iOS (`NSFileManager`) and Linux/POSIX. - Updated `ByteCodeTranslator` to package the new native source file. - Patched `vm/ByteCodeTranslator/src/nativeMethods.m` and `cn1_globals.m` to support compilation on Linux (added guards and stubs). - Refactored common native definitions (NSString helpers, NSLog) to `cn1_globals.h`. - Guarded privacy-sensitive file system APIs with `CN1_ENABLE_FILE_SYSTEM_STATS`. - Updated POSIX UTF-8 decoding in `nativeMethods.m` to use the DFA decoder. - Added `vm/tests/src/test/java/com/codename1/tools/translator/FileClassIntegrationTest.java` to verify the implementation. - Fixed string concatenation issues in `vm/JavaAPI` exception constructors to resolve C compilation errors. - Added `vm/JavaAPI/src/java/util/Objects.java` to resolve missing dependency during integration tests. - Removed conflicting `java.util.Objects` stub generation from `LambdaIntegrationTest`.
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| public boolean createNewFile() throws IOException { | ||
| return createNewFileImpl(path); | ||
| } | ||
|
|
||
| public String getParent() { | ||
| return null; | ||
| private native boolean createNewFileImpl(String path); |
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.
createNewFile swallows I/O failures
The new implementation of createNewFile() simply returns the boolean from createNewFileImpl and never throws, even though the signature declares throws IOException. The POSIX implementation returns false for any failure (e.g., parent directory missing or permission denied), so callers now get false instead of an exception and cannot distinguish “file already exists” from real I/O errors, diverging from the Java File contract.
Useful? React with 👍 / 👎.







Implemented
java.io.Fileinvm/JavaAPIwith full native method delegation.Added native implementation in
vm/ByteCodeTranslator/src/nativeMethods.musing Objective-C andNSFileManagerfor iOS support.Created
vm/tests/src/test/java/com/codename1/tools/translator/FileClassIntegrationTest.javato integration test the new class by translating it to C code and running it. The test uses a POSIX-based native implementation (native_test.c) to verify behavior on Linux CI environments where Foundation is unavailable, ensuring the Java logic correctly invokes native methods.Updated
nativeMethods.mto include stubs forgetUsableSpaceetc. on iOS as requested.PR created automatically by Jules for task 10208213905050889515 started by @shai-almog