Closed Bug 1343027 Opened 7 years ago Closed 7 years ago

Add JNI wrappers for casting and locking

Categories

(Core Graveyard :: Widget: Android, defect)

All
Android
defect
Not set
normal

Tracking

(firefox55 fixed)

RESOLVED FIXED
mozilla55
Tracking Status
firefox55 --- fixed

People

(Reporter: jchen, Assigned: jchen)

Details

Attachments

(2 files)

Add wrappers for casting one type to another type, and for locking an object.
Add a Cast function to jni::Ref to cast a reference to a different type
(e.g. if ref is a jni::Object::Ref referring to a String instance, use |
ref.Cast<jni::String>()->Length() | to get the length of the string).

In MOZ_CHECK_JNI builds, Cast() checks that an instance of the source
class can indeed be cast to the target class.
Attachment #8842204 - Flags: review?(snorp)
Add a Lock function to jni::Ref to lock the referenced object akin to
the synchronized keyword in Java. It returns a Locked RAII object that
automatically unlocks the object when going out of scope.
Attachment #8842205 - Flags: review?(snorp)
Comment on attachment 8842204 [details] [diff] [review]
1. Add jni::Ref::Cast function (v1)

Review of attachment 8842204 [details] [diff] [review]:
-----------------------------------------------------------------

This is super nice.
Attachment #8842204 - Flags: review?(snorp) → review+
Comment on attachment 8842205 [details] [diff] [review]
2. Add jni::Ref::Lock function (v1)

Review of attachment 8842205 [details] [diff] [review]:
-----------------------------------------------------------------

::: widget/android/jni/Refs.h
@@ +78,5 @@
>  
>  public:
>      using JNIType = Type;
>  
> +    class Locked

AutoLock? AutoMonitor? AutoMutex? It should have Auto in it.
Attachment #8842205 - Flags: review?(snorp) → review+
https://hg.mozilla.org/mozilla-central/rev/a97e11f9a6e2
https://hg.mozilla.org/mozilla-central/rev/1af35d88e88b
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: