Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(620)

Issue 1492703003: jni: Allow nullptr to be converted to JavaRef. (Closed)

Created:
5 years ago by Torne
Modified:
5 years ago
Reviewers:
Yaron
CC:
chromium-reviews, vmpstr+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

jni: Allow nullptr to be converted to JavaRef. Allow nullptr to be converted to JavaRef, not just JavaParamRef. This avoids having to declare a ScopedJavaLocalRef just to pass null to a function that takes JavaRef, and makes C++ "nullptr" and Java "null" equivalent. BUG=506850 R=yfriedman@chromium.org Committed: https://crrev.com/8a47be66f340b94662c74544a30d546b49ad0bc3 Cr-Commit-Position: refs/heads/master@{#362966}

Patch Set 1 #

Total comments: 1

Patch Set 2 : fix typo in comment #

Unified diffs Side-by-side diffs Delta from patch set Stats (+13 lines, -5 lines) Patch
M base/android/scoped_java_ref.h View 1 4 chunks +13 lines, -5 lines 0 comments Download

Messages

Total messages: 11 (3 generated)
Torne
Followup to https://codereview.chromium.org/1481033002/ - after thinking about it more and encountering a few more cases, ...
5 years ago (2015-12-02 18:15:51 UTC) #1
Yaron
lgtm - care to do a follow-up pass on current offenders? https://codereview.chromium.org/1492703003/diff/1/base/android/scoped_java_ref.h File base/android/scoped_java_ref.h (right): ...
5 years ago (2015-12-02 19:42:10 UTC) #2
Torne
On 2015/12/02 19:42:10, Yaron wrote: > lgtm - care to do a follow-up pass on ...
5 years ago (2015-12-03 11:58:32 UTC) #3
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1492703003/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1492703003/20001
5 years ago (2015-12-03 11:58:57 UTC) #6
commit-bot: I haz the power
Committed patchset #2 (id:20001)
5 years ago (2015-12-03 13:08:09 UTC) #7
commit-bot: I haz the power
Patchset 2 (id:??) landed as https://crrev.com/8a47be66f340b94662c74544a30d546b49ad0bc3 Cr-Commit-Position: refs/heads/master@{#362966}
5 years ago (2015-12-03 13:09:16 UTC) #9
Torne
On 2015/12/03 11:58:32, Torne wrote: > On 2015/12/02 19:42:10, Yaron wrote: > > lgtm - ...
5 years ago (2015-12-03 14:19:26 UTC) #10
Yaron
5 years ago (2015-12-03 15:30:01 UTC) #11
Message was sent while issue was closed.
On 2015/12/03 14:19:26, Torne wrote:
> On 2015/12/03 11:58:32, Torne wrote:
> > On 2015/12/02 19:42:10, Yaron wrote:
> > > lgtm - care to do a follow-up pass on current offenders?
> > 
> > I'll take a look, I'm not sure if there actually are many right now - the
> reason
> > I made this change was primarily to avoid *introducing* a bunch of cases of
> this
> > in the course of the JavaParamRef migration :)
> 
> D'oh. I had a look, and there are indeed not very many uses of this to pass
null
> to functions (though there are a few, I'll change them): but there are *loads*
> of uses to return null from JNI functions, and those can't be satisfied just
> with this change here, because those specifically return ScopedJavaLocalRef by
> value, which I haven't added a nullptr_t conversion for :)

Right - ok. That's actually the case I was thinking of :(
> 
> I guess there's no reason not to also allow nullptr conversion for
local/global
> refs, since they both already have a default constructor that makes a null
> reference anyway.
> 
> While I'm thinking about this, it would probably also be beneficial if
> ScopedJavaLocalRef (and global as well for symmetry) had move
constructors/move
> assignment operators, to avoid the compiler generating code that calls
> NewLocalRef on one side and immediately DeleteLocalRef on the other side (in
> cases where it can't do RVO for whatever reason).
> 
> I'm going to get the rest of my in-progress changes landed (the parameter
> rewrites, etc), and will then take a long look at scoped_java_ref to see what
> other improvements are possible there.
sgtm

Powered by Google App Engine
This is Rietveld 408576698