Skip to content

[jnigen] Fixed an issue with how java.io.File is created #2196

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lucaskimnz
Copy link

@lucaskimnz lucaskimnz commented Apr 12, 2025

[ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: Unable to locate the helper library.

  • dart run jni:setup at the example app is required
  • README.md updated

flutter: Unsupported operation: cannot convert String to jvalue

The issue

flutter: Unsupported operation: cannot convert String to jvalue
flutter: #0      _fillJValue (package:jni/src/jvalues.dart:47)
flutter: #1      toJValues (package:jni/src/jvalues.dart:62)
flutter: #2      JConstructorId.call.<anonymous closure> (package:jni/src/jclass.dart:164)
flutter: #3      using (package:ffi/src/arena.dart:127)
flutter: #4      JConstructorId.call (package:jni/src/jclass.dart:161)
flutter: #5      new PDFFileInfo.usingPDFBox (package:pdfbox_example/main.dart:163)
flutter: #6      PDFInfoAppState.build (package:pdfbox_example/main.dart:125)
flutter: #7      StatefulElement.build (package:flutter/src/widgets/framework.dart:5841)
flutter: #8      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5733)
flutter: #9      StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5892)
flutter: #10     Element.rebuild (package:flutter/src/widgets/framework.dart:5445)
flutter: #11     BuildScope._tryRebuild (package:flutter/src/widgets/framework.dart:2704)
flutter: #12     BuildScope._flushDirtyElements (package:flutter/src/widgets/framework.dart:2762)
flutter: #13     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:3066)
flutter: #14     WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:1229)
flutter: #15     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:482)
flutter: #16     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1442)
flutter: #17     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1355)
flutter: #18     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1208)
flutter: #19     _invoke (dart:ui/hooks.dart:316)
flutter: #20     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:428)
flutter: #21     _drawFrame (dart:ui/hooks.dart:288)

Fixed and tested with a sample pdf that has a title.

  • Excluded the directories when processing pdf files

image


  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.

Copy link

google-cla bot commented Apr 12, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@lucaskimnz lucaskimnz changed the title Fixed an issue with how java.io.File is created [jnigen]Fixed an issue with how java.io.File is created Apr 12, 2025
@lucaskimnz lucaskimnz changed the title [jnigen]Fixed an issue with how java.io.File is created [jnigen] Fixed an issue with how java.io.File is created Apr 12, 2025
@@ -10,6 +10,7 @@ On a Linux machine, following commands can be used to run the example applicatio
cd .. ## From this folder
dart run jnigen --config jnigen.yaml ## Downloads PDFBox JARs and generates bindings.
cd example/
dart run jni:setup
Copy link
Member

Choose a reason for hiding this comment

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

This is not actually required for the Flutter example at /example but is for the Dart-standalone example at /dart_example and the readme there already has it.

Copy link
Author

Choose a reason for hiding this comment

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

Running from IDE wouldn't require it, but running the built executable requires them. Please correct me if I'm wrong. Thanks. If it's too much, I will remove the line.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, not sure what you mean by running it from IDE. Flutter Linux build has a CMake that does the job of jni:setup making it unnecessary.

Yeah I would remove this line.

@@ -67,8 +67,6 @@ class PDFInfoAppState extends State<PDFInfoApp> {
final isDir = (await item.stat()).type == FileSystemEntityType.directory;
if (item.path.endsWith('.pdf') && !isDir) {
pdfs.add(item.path);
} else if (isDir) {
Copy link
Member

Choose a reason for hiding this comment

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

Why remove this?

Copy link
Author

Choose a reason for hiding this comment

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

Currently the example app shows all of directories even if the app aims to show the summary of pdf files found in $HOME directory. I thought better to exclude directories and included only pdf files.

Copy link
Member

Choose a reason for hiding this comment

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

I haven't created this example so I don't know what has been the purpose of this. I'm fine with not removing these lines as it doesn't make the example non-functional.

Feel free to open another PR that deletes this line (and cleans the unused variables as a result of your change) that explains why you are making this change. I'd rather this PR remains focused on solving the bug that you fixed.

Copy link

PR Health

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

API leaks ✔️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbols
License Headers ✔️
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Files
no missing headers

All source files should start with a license header.

Unrelated files missing license headers
Files
pkgs/jni/lib/src/third_party/generated_bindings.dart
pkgs/objective_c/lib/src/ns_input_stream.dart

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

Successfully merging this pull request may close these issues.

3 participants