Skip to content

Conversation

@google-labs-jules
Copy link
Contributor

Implemented java.io.File in vm/JavaAPI with full native method delegation.
Added native implementation in vm/ByteCodeTranslator/src/nativeMethods.m using Objective-C and NSFileManager for iOS support.
Created vm/tests/src/test/java/com/codename1/tools/translator/FileClassIntegrationTest.java to 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.m to include stubs for getUsableSpace etc. on iOS as requested.


PR created automatically by Jules for task 10208213905050889515 started by @shai-almog

…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.
@google-labs-jules
Copy link
Contributor Author

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!


For security, I will only act on instructions from the user who triggered this task.

New to Jules? Learn more at jules.google/docs.

@github-actions
Copy link

github-actions bot commented Dec 20, 2025

✅ Continuous Quality Report

Test & Coverage

Static Analysis

Generated automatically by the PR CI workflow.

@shai-almog
Copy link
Collaborator

shai-almog commented Dec 20, 2025

iOS screenshot updates

Compared 30 screenshots: 23 matched, 6 updated, 1 missing reference.

  • BrowserComponent — updated screenshot. Screenshot differs (1206x2622 px, bit depth 8).

    BrowserComponent
    Preview info: Preview provided by instrumentation.
    Full-resolution PNG saved as BrowserComponent.png in workflow artifacts.

  • graphics-draw-arc — updated screenshot. Screenshot differs (1206x2622 px, bit depth 8).

    graphics-draw-arc
    Preview info: JPEG preview quality 20; JPEG preview quality 20; downscaled to 603x1311.
    Full-resolution PNG saved as graphics-draw-arc.png in workflow artifacts.

  • graphics-draw-gradient — updated screenshot. Screenshot differs (1206x2622 px, bit depth 8).

    graphics-draw-gradient
    Preview info: JPEG preview quality 10; JPEG preview quality 10; downscaled to 844x1835.
    Full-resolution PNG saved as graphics-draw-gradient.png in workflow artifacts.

  • graphics-draw-round-rect — missing reference. Reference screenshot missing at /Users/runner/work/CodenameOne/CodenameOne/scripts/ios/screenshots/graphics-draw-round-rect.png.

    graphics-draw-round-rect
    Preview info: JPEG preview quality 10; JPEG preview quality 10; downscaled to 844x1835.
    Full-resolution PNG saved as graphics-draw-round-rect.png in workflow artifacts.

  • graphics-draw-string — updated screenshot. Screenshot differs (1206x2622 px, bit depth 8).

    graphics-draw-string
    Preview info: JPEG preview quality 10; JPEG preview quality 10; downscaled to 422x918.
    Full-resolution PNG saved as graphics-draw-string.png in workflow artifacts.

  • graphics-draw-string-decorated — updated screenshot. Screenshot differs (1206x2622 px, bit depth 8).

    graphics-draw-string-decorated
    Preview info: JPEG preview quality 10; JPEG preview quality 10; downscaled to 603x1311.
    Full-resolution PNG saved as graphics-draw-string-decorated.png in workflow artifacts.

  • kotlin — updated screenshot. Screenshot differs (1206x2622 px, bit depth 8).

    kotlin
    Preview info: Preview provided by instrumentation.
    Full-resolution PNG saved as kotlin.png in workflow artifacts.

Benchmark Results

  • VM Translation Time: 296 seconds
  • Compilation Time: 61 seconds

Detailed Performance Metrics

Metric Duration
Build Time Statistics
Setup & Unzip 26703 ms
Extract Extensions 16 ms
Google Services Setup 2 ms
Scan Classes 520 ms
Extract Libs 982 ms
Inject Build Hints 31 ms
Generate Unit Tests 5 ms
Generate Stubs 821 ms
Compile Stubs 2062 ms
Generate Icons 809 ms
Prepare ParparVM 163 ms
ParparVM Execution 174131 ms
Post-VM Setup 118 ms
CocoaPods 5724 ms
Finalize 46 ms
Total Time 212134 msMaven Overhead : 84000 ms
CocoaPods Install (Script) 2000 ms
Simulator Boot (Run) 54000 ms
App Install 12000 ms
App Launch 13000 ms
Test Execution 153000 ms

- 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`.
@github-actions
Copy link

github-actions bot commented Dec 21, 2025

✅ ByteCodeTranslator Quality Report

Test & Coverage

  • Tests: 119 total, 0 failed, 0 skipped

Benchmark Results

  • Execution Time: 10398 ms

  • Hotspots (Top 20 sampled methods):

    • 21.63% java.lang.String.indexOf (382 samples)
    • 19.65% com.codename1.tools.translator.Parser.isMethodUsed (347 samples)
    • 14.61% com.codename1.tools.translator.Parser.addToConstantPool (258 samples)
    • 11.16% java.util.ArrayList.indexOf (197 samples)
    • 5.49% java.lang.Object.hashCode (97 samples)
    • 3.34% com.codename1.tools.translator.ByteCodeClass.calcUsedByNative (59 samples)
    • 2.89% java.lang.System.identityHashCode (51 samples)
    • 2.55% com.codename1.tools.translator.ByteCodeClass.fillVirtualMethodTable (45 samples)
    • 1.93% com.codename1.tools.translator.BytecodeMethod.optimize (34 samples)
    • 1.02% java.io.FileOutputStream.writeBytes (18 samples)
    • 0.96% java.lang.Integer.getChars (17 samples)
    • 0.74% com.codename1.tools.translator.Parser.cullMethods (13 samples)
    • 0.68% com.codename1.tools.translator.BytecodeMethod.appendCMethodPrefix (12 samples)
    • 0.68% java.lang.StringCoding$StringEncoder.encode (12 samples)
    • 0.68% java.lang.StringBuilder.append (12 samples)
    • 0.62% java.io.FileOutputStream.open0 (11 samples)
    • 0.62% com.codename1.tools.translator.BytecodeMethod.equals (11 samples)
    • 0.62% com.codename1.tools.translator.Parser.generateClassAndMethodIndexHeader (11 samples)
    • 0.57% com.codename1.tools.translator.ByteCodeClass.markDependent (10 samples)
    • 0.51% java.io.FileInputStream.open0 (9 samples)
  • ⚠️ Coverage report not generated.

Static Analysis

  • ✅ SpotBugs: no findings (report was not generated by the build).
  • ⚠️ PMD report not generated.
  • ⚠️ Checkstyle report not generated.

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`.
@shai-almog shai-almog marked this pull request as ready for review December 21, 2025 17:22
@shai-almog shai-almog merged commit a5c39f0 into master Dec 21, 2025
11 checks passed
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a 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".

Comment on lines +144 to +148
public boolean createNewFile() throws IOException {
return createNewFileImpl(path);
}

public String getParent() {
return null;
private native boolean createNewFileImpl(String path);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants