jni 1.0.0
jni: ^1.0.0 copied to clipboard
A library to access JNI from Dart and Flutter that acts as a support library for package:jnigen.
1.0.0 #
- Breaking Change: The Flutter specific APIs
Jni.androidApplicationContextandJni.androidActivity(int engineId)have been moved to a new package:jni_flutter. If you are using package:jni on Android you may need to add this new package as a dependency. - Breaking Change: All Java wrapper classes have been migrated to extension
types. The main effects are:
- All collections (
JList,JMapetc) are now direct code generated wrappers around the Java objects, so are less Darty. Instead there are now Darty adapter classes you can access viaasDart(). - No more nullable
JTypeclasses, onlyJTypeclasses, and theJTypeclass is simplified. - It is no longer necessary to pass around the
JTypein many cases where it used to be required.
- All collections (
- Added
Jni.captureStackTraceOnReleasewhich defaults tofalse. When this is set, the stack traces of the release points will be stored forJObjects to help debugDoubleReleaseErrorandUseAfterReleaseErrors. This includes the points whereJObjects have been registered to be released by anarenaviaJObject.releaseBy. - Changed the behavior of
JObject.releasedBy. It now does not throw aDoubleReleaseErrorif the object was manually released before the end of arena. - Added
JThrowableclass which inherits fromJObjectand implementsException. - Breaking Change:
JniExceptionhas been deleted. Java exceptions are now thrown asJThrowableinstead.JThrowableholds an actual Java exception, instead of just holding a string message. It's aJObject, so the usual.isAand.asmethods work to cast theJThrowableto the underlying Java exception. - Breaking Change: Class methods like getFoo, isFoo, and setFoo are now getters and setters in Dart.
- Breaking Change: APIs of
JBoolean,JByte,JCharacter,JDouble,JFloat,JInteger,JLong,JNumber,JShort, andJStringhave changed to be more consistent with other APIs. For example,JBoolean.booleanValueis nowJBoolean.toDartBool. - Fixed bugs that were causing crashes in interfaces after app close and reopen.
- Add compile time version checks to verify consistency of package:jni's versions vs JNIgen's generated code.
0.15.2 #
- Do not fail
flutter buildif JDK is not found for desktop.
0.15.1 #
- Breaking Change: Removed the
engineIdargument fromJni.androidApplicationContextas the application context is not dependant on the engine ID.
0.15.0 #
- Breaking Change: Made
Jni.envinternal. - Breaking Change: Renamed
JObjTypetoJType. - Breaking Change: Made all of the type classes internal.
- Breaking Change: Removed
Jni.getApplicationClassLoader(),Jni.getCurrentActivity(), andJni.getCachedApplicationContext(). Instead useJni.androidApplicationContext(engineId)to access the application context and useJni.androidActivity(engineId)to acccess the activity. - Update to the latest lints.
0.14.2 #
- Fixed a bug where certain method of
JList,JSet, andJMapdid not work with nullable elements. - Fixed a bug in
JList.lastIndexOf.
0.14.1 #
- Updated
bin/setup.dartto use Gradle instead of Maven for building Java sources. Added gradle executables and bootstrap jars #2003 - Added
JObject.isInstanceOfwhich checks whether aJObjectis an instance of a java class. - Fixed a bug where Java interfaces implemented in on the main thread in Dart could deadlock when invoked from the main thread outside the context of a Dart isolate.
0.14.0 #
- Added
DynamicLibraryLoadErrorwhich is thrown when the dynamic library fails to load.HelperNotFoundErrorwill only be thrown when the helper library cannot be found. - Update the README.md to include info about generating bindings for built-in java types.
- Do not require a
dylibDirwhen runningJni.spawnfrom Dart standalone, instead use the default value ofbuild/jni_libs. - Added
JArray.of, which allows aJArrayto be constructed from anIterable. - Added
JObject.isA, which checks whether aJObjectis an instance of a java typeclass. - Do not require JAWT when building for desktop.
- Added
JByteArray.from, which allows aJByteArrayto be constructed from anIterable<int>.
0.13.0 #
-
Breaking Change: Separated primitive arrays from object arrays. Previously, a primitive array like an array of bytes was typed
JArray<jbyte>. NowJArray<T>only acceptsJObjects as types and primitive arrays like arrays of bytes have their own types such asJByteArray.This enables all arrays to implement
Iterablewhich makes it possible to use them in a for-loop or use methods such asmapon them. -
Added nullable type classes for all Java objects.
-
Fixed a problem where interfaces implemented in Dart would crash when calling the default object methods:
equals,hashCode, andtoString.
0.12.2 #
- Added
JniUtils.fromReferenceAddresswhich helps with sendingJObjects through method channels. You can send the address of the pointer aslongand reconstruct the class using the helper method. - Fixed a bug where it would be possible for a type class inference to fail.
- Return 'null' when calling
toStringon a null object.
0.12.0 #
- Breaking Change: Renamed
castTotoas. - Renamed library
internal_helpers_for_jnigento_internal. - Using 16KB page size to support Android 15.
- Added
JImplementerwhich enables building an object that implements multiple Java interfaces.
0.11.0 #
- Breaking Change Removed
Jni.accessors. - Made most
Jni.envmethods into leaf functions to speed up their execution. - Removed the dependency on
kotlin_gradle_plugin.
0.10.1 #
- Fixed an issue with
JObject.castTowhere the type checking could fail in debug mode. - Used
package:dart_flutter_team_lints.
0.9.3 #
- Added lifetime event handling for the thread-local JNI env. Now
jvm.DetachNativeThreadis called when the thread detaches as recommended here. - Removed
JValueChar.fromStringconstructor.
0.9.2 #
- Bumped
minSdkto 21.
0.9.1 #
- Fixed compilation on macOS for consumers that don't use JNI on macOS (which is still not supported) (#1122).
0.9.0 #
- Breaking Change
(#1004): Changed the return
type
operator []ofJArray<jchar>tointinstead ofString. Similarly, change the argument type ofoperator []=to acceptint. - Added
getRangemethod toJArrayof primitive types that returns aTypedDatalist depending on the kind of the array. - Improved the performance of
JArray'ssetRangeandoperator []=.
0.8.0 #
-
Breaking Change (#981):
-
JObject.referencenow returns aJReferenceinstead ofPointer<Void>. -
.fromRefconstructors are now called.fromReferenceand they take aJReferenceinstead ofPointer<Void>. -
JObjectreflective field retrieving and method calling methods are removed. UseJClassAPI instead. -
The following
Jni.accessorsmethods have been removed:getClassOfgetMethodIDOfgetStaticMethodIDOfgetFieldIDOfgetStaticFieldIDOfnewObjectWithArgscallMethodWithArgscallStaticMethodWithArgs
Instead use the
JClassAPI. -
Jni.findJClassis replaced withJClass.forName(String name) -
JClasshas been refactored. Instead of directly calling methods, getting and setting fields, useJClass.instanceMethodId,JClass.staticMethodId,JClass.constructorId,JClass.instanceFieldId, andJClass.staticFieldIdto first get access to the member. -
Renamed
JObject.getClass()toJObject.jClass. -
Removed
Jni.deleteAllRefs.
-
-
Breaking Change (#548): Converted various
Exceptions intoErrors:UseAfterReleaseException->UseAfterReleaseErrorDoubleReleaseException->DoubleReleaseErrorSpawnException->JniError(It's now asealed class)JNullException->JNullErrorInvalidCallTypeException->InvalidCallTypeErrorHelperNotFoundException->HelperNotFoundErrorJvmExistsException->JniVmExistsErrorNoJvmInstanceException->NoJvmInstanceError
-
Breaking Change: Removed
InvalidJStringException. -
Breaking Change:
JTypeis nowsealed. -
Breaking Change: Primitive types and their type classes are now
final. -
Breaking Change:
JArray.fillednow uses the generated type class of thefillobject and not its Java runtime type. -
JObjects now check the types usinginstanceofin debug mode when usingcastTo. -
Breaking Change:
Jni.initDLApi()is removed. -
Added the ability to share
JObjects across isolates.// This now works. final foo = 'foo'.toJString(); Isolate.run(() { // `foo` is usable from another isolate. print(foo); });
0.7.3 #
- Fixed a bug where
get(Static)MethodIDandget(Static)FieldIDcould access null and throw.
0.7.2 #
- Fixed a bug where reading non-null terminated strings would overflow.
- Use
package:dart_flutter_team_lints.
0.7.0 #
- Breaking Change (#563):
Added
JBufferandJByteBufferclasses as default classes forjava.nio.Bufferandjava.nio.ByteBufferrespectively. - Breaking Change: Made the type classes
final. - Fixed a bug where
addAll,removeAllandretainAllinJSetwould run their respective operation twice. - Fixed a bug where
JList.insertAllwould not throw the potentially thrown Java exception.
0.6.1 #
- Depend on the stable version of Dart 3.1.
0.6.0 #
- Breaking Change (#707):
Renamed
delete*torelease*. - Added
PortProxyand related methods used for interface implementation. - Added the missing binding for
java.lang.Character.
0.5.0 #
- Breaking Change (#711):
Java primitive types are now all lowercase like
jint,jshort, ... - The bindings for
java.util.Set,java.util.Map,java.util.Listand the numeric types likejava.lang.Integer,java.lang.Boolean, ... are now included inpackage:jni.
0.4.0 #
- Type classes now have
superCountandsuperTypegetters used for type inference.
0.3.0 #
- Added
PortContinuationused forsuspend funin Kotlin. dartjninow depends ondart_api_dl.h.
0.2.1 #
- Added
.clang-formatto pub.
0.2.0 #
- Added array support
- Added generic support
JniXturned intoJXfor a more terse code.
0.1.1 #
- Windows support for running tests and examples on development machines.
0.1.0 #
- Initial version: Android and Linux support, JObject API