New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 629103 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Jul 2016
Cc:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug

Blocking:
issue 519562



Sign in to add a comment

JNI generator doesn't work for inner classes with native methods that don't have any CalledByNative methods

Project Member Reported by torne@chromium.org, Jul 18 2016

Issue description

If you have an inner class with at least one native method, but no CalledByNative methods, the JNI generator generates output that doesn't compile, because it doesn't define or initialise a class global for the inner class.

This has always been broken but nobody was relying on it. There's also no example in the sample java class of how to declare native methods on an inner class in the first place, which would have probably caught this when compiled :)
 

Comment 1 by torne@chromium.org, Jul 18 2016

Cc: siev...@chromium.org
Project Member

Comment 2 by bugdroid1@chromium.org, Jul 19 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/2eb44e80e1216124ced411b369a254d103d00cc3

commit 2eb44e80e1216124ced411b369a254d103d00cc3
Author: Torne (Richard Coles) <torne@chromium.org>
Date: Tue Jul 19 11:36:09 2016

jni_generator: handle inner class natives properly.

Inner classes with native methods but no @CalledByNative methods were
generating incorrect code that doesn't compile, but there was no example
of this in the sample class and so it wasn't noticed. Several of the
non-compiled test headers were doing this and the header was just
un-compilable as a result.

Fix this by including the class global's declaration and initialisation
in all the appropriate cases, and adding an example to the sample.

BUG= 629103 
R=rmcilroy@chromium.org

Review URL: https://codereview.chromium.org/2154293002 .

Cr-Commit-Position: refs/heads/master@{#406249}

[modify] https://crrev.com/2eb44e80e1216124ced411b369a254d103d00cc3/base/android/jni_generator/golden_sample_for_tests_jni.h
[modify] https://crrev.com/2eb44e80e1216124ced411b369a254d103d00cc3/base/android/jni_generator/java/src/org/chromium/example/jni_generator/SampleForTests.java
[modify] https://crrev.com/2eb44e80e1216124ced411b369a254d103d00cc3/base/android/jni_generator/jni_generator.py
[modify] https://crrev.com/2eb44e80e1216124ced411b369a254d103d00cc3/base/android/jni_generator/sample_for_tests.cc
[modify] https://crrev.com/2eb44e80e1216124ced411b369a254d103d00cc3/base/android/jni_generator/testInnerClassNatives.golden
[modify] https://crrev.com/2eb44e80e1216124ced411b369a254d103d00cc3/base/android/jni_generator/testInnerClassNativesBothInnerAndOuter.golden
[modify] https://crrev.com/2eb44e80e1216124ced411b369a254d103d00cc3/base/android/jni_generator/testInnerClassNativesMultiple.golden
[modify] https://crrev.com/2eb44e80e1216124ced411b369a254d103d00cc3/base/android/jni_generator/testNativeExportsOptionalOption.golden

Comment 3 by torne@chromium.org, Jul 19 2016

Status: Fixed (was: Started)

Sign in to add a comment