JList
, JSet
, and JMap
did not work with nullable elements.JList.lastIndexOf
.bin/setup.dart
to use Gradle instead of Maven for building Java sources. Added gradle executables and bootstrap jars #2003JObject.isInstanceOf
which checks whether a JObject
is an instance of a java class.DynamicLibraryLoadError
which is thrown when the dynamic library fails to load. HelperNotFoundError
will only be thrown when the helper library cannot be found.dylibDir
when running Jni.spawn
from Dart standalone, instead use the default value of build/jni_libs
.JArray.of
, which allows a JArray
to be constructed from an Iterable
.JObject.isA
, which checks whether a JObject
is an instance of a java typeclass.JByteArray.from
, which allows a JByteArray
to be constructed from an Iterable<int>
.Breaking Change: Separated primitive arrays from object arrays. Previously, a primitive array like an array of bytes was typed JArray<jbyte>
. Now JArray<T>
only accepts JObject
s as types and primitive arrays like arrays of bytes have their own types such as JByteArray
.
This enables all arrays to implement Iterable
which makes it possible to use them in a for-loop or use methods such as map
on 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
, and toString
.
JniUtils.fromReferenceAddress
which helps with sending JObject
s through method channels. You can send the address of the pointer as long
and reconstruct the class using the helper method.toString
on a null object.castTo
to as
.internal_helpers_for_jnigen
to _internal
.JImplementer
which enables building an object that implements multiple Java interfaces.Jni.accessors
.Jni.env
methods into leaf functions to speed up their execution.kotlin_gradle_plugin
.JObject.castTo
where the type checking could fail in debug mode.package:dart_flutter_team_lints
.jvm.DetachNativeThread
is called when the thread detaches as recommended here.JValueChar.fromString
constructor.minSdk
to 21.operator []
of JArray<jchar>
to int
instead of String
. Similarly, change the argument type of operator []=
to accept int
.getRange
method to JArray
of primitive types that returns a TypedData
list depending on the kind of the array.JArray
's setRange
and operator []=
.Breaking Change (#981):
JObject.reference
now returns a JReference
instead of Pointer<Void>
.
.fromRef
constructors are now called .fromReference
and they take a JReference
instead of Pointer<Void>
.
JObject
reflective field retrieving and method calling methods are removed. Use JClass
API instead.
The following Jni.accessors
methods have been removed:
getClassOf
getMethodIDOf
getStaticMethodIDOf
getFieldIDOf
getStaticFieldIDOf
newObjectWithArgs
callMethodWithArgs
callStaticMethodWithArgs
Instead use the JClass
API.
Jni.findJClass
is replaced with JClass.forName(String name)
JClass
has been refactored. Instead of directly calling methods, getting and setting fields, use JClass.instanceMethodId
, JClass.staticMethodId
, JClass.constructorId
, JClass.instanceFieldId
, and JClass.staticFieldId
to first get access to the member.
Renamed JObject.getClass()
to JObject.jClass
.
Removed Jni.deleteAllRefs
.
Breaking Change (#548): Converted various Exception
s into Error
s:
UseAfterReleaseException
-> UseAfterReleaseError
DoubleReleaseException
-> DoubleReleaseError
SpawnException
-> JniError
(It's now a sealed class
)JNullException
-> JNullError
InvalidCallTypeException
-> InvalidCallTypeError
HelperNotFoundException
-> HelperNotFoundError
JvmExistsException
-> JniVmExistsError
NoJvmInstanceException
-> NoJvmInstanceError
Breaking Change: Removed InvalidJStringException
.
Breaking Change: JType
is now sealed
.
Breaking Change: Primitive types and their type classes are now final
.
Breaking Change: JArray.filled
now uses the generated type class of the fill
object and not its Java runtime type.
JObject
s now check the types using instanceof
in debug mode when using castTo
.
Breaking Change: Jni.initDLApi()
is removed.
Added the ability to share JObject
s across isolates.
// This now works. final foo = 'foo'.toJString(); Isolate.run(() { // `foo` is usable from another isolate. print(foo); });
get(Static)MethodID
and get(Static)FieldID
could access null and throw.package:dart_flutter_team_lints
.JBuffer
and JByteBuffer
classes as default classes for java.nio.Buffer
and java.nio.ByteBuffer
respectively.final
.addAll
, removeAll
and retainAll
in JSet
would run their respective operation twice.JList.insertAll
would not throw the potentially thrown Java exception.delete*
to release*
.PortProxy
and related methods used for interface implementation.java.lang.Character
.jint
, jshort
, ...java.util.Set
, java.util.Map
, java.util.List
and the numeric types like java.lang.Integer
, java.lang.Boolean
, ... are now included in package:jni
.superCount
and superType
getters used for type inference.PortContinuation
used for suspend fun
in Kotlin.dartjni
now depends on dart_api_dl.h
..clang-format
to pub.JniX
turned into JX
for a more terse code.