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

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Feb 7
Cc:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug

Blocked on:
issue 898660

Blocking:
issue 929661
issue 929682



Sign in to add a comment
link

Issue 898261: Hide JNI native methods behind interfaces so that they can be mocked in tests

Reported by agrieve@chromium.org, Oct 23 Project Member

Issue description

Primary goal: Allow JNI to be mocked in robolectric tests
Secondary goal: Obfuscate JNI symbols for small binary size savings.
More details in Googler-only doc: https://goto.google.com/mockable-jni

============= For Static JNI that has no mNativePointer ==========

public interface org.chromium.base.JniStaticTestMocker<T> {
    void setInstanceForTesting(T instance);
}

final class ExampleUtils_NativesJni {
    // ... Existing methods as above, plus:
    private static ExampleUtils_NativesJni sTestInstance;


    public static final JniStaticTestMocker<Natives> TEST_HOOKS = new JniTestMocker<> {
        public void setInstanceForTesting(Natives instance) {
            sTestInstance = instance;
        }    
    };

    static Natives get() {
        if (GEN_JNI.IS_TESTING_ENABLED && sTestInstance != null) {
            return sTestInstance;
        }
        return new ExampleUtils_NativesJni();
    }
}


Generated code:

// All native methods declared here so that we don't have to mark
// ExampleUtils_NativesJni as -keep.
public final class GEN_JNI {
    public static boolean IS_TESTING_ENABLED;
    public static final native boolean ExampleUtils_NativesJni_someMethod(String value);
}


final class ExampleUtils_NativesJni {
    private boolean someMethod(String value) {
        return GEN_JNI.ExampleUtils_NativesJni_someMethod(value);
    }

    static Natives get() {
        return new ExampleUtils_NativesJni();
    }
}


Sample Test:

class MyTest {
    // Rule will reset mocks back to null in tearDown().
    @Rule JniMocker mocker = new JniMocker();
    @Mock ExampleUtils.Natives mock1;

    @SetUp
    public void setUp() {
        mocker.mock(ExampleUtils_NativesJni.TEST_HOOKS, mock1);
    }
}



============= For Non-static JNI that has no mNativePointer ==========

Still TBD. Right now there seems to be no design that r8 can fully optimize away the overhead.
 

Comment 1 by bugdroid1@chromium.org, Oct 23

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/a4bf09f98174e106204841beaf7adf77f6bd3cef

commit a4bf09f98174e106204841beaf7adf77f6bd3cef
Author: Aiden Benner <abenner@google.com>
Date: Tue Oct 23 20:07:41 2018

Generate javadoc comments in GEN_JNI

When the generated jni methods are hashed it's difficult
to debug jni headers. This change adds javadoc comments
to the generated jni methods with type information.

e.g.
class GEN_JNI {
  /**
   * org.chromium.example.jni_generator.SampleForAnnotationProcessor.bar
   * @param sample (org.chromium.example.jni_generator.SampleForAnnotationProcessor)
   * @return (org.chromium.example.jni_generator.SampleForAnnotationProcessor)
   */
  public static final native Object MYz$E75A(Object sample);
}

Change-Id: Ia0ffa2f36de9f20aae8841c1e25e9d02517f861f
Bug:  898261 
Reviewed-on: https://chromium-review.googlesource.com/c/1296989
Commit-Queue: agrieve <agrieve@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602069}
[modify] https://crrev.com/a4bf09f98174e106204841beaf7adf77f6bd3cef/base/android/jni_generator/java/src/org/chromium/jni_generator/JniProcessor.java

Comment 2 by bugdroid1@chromium.org, Oct 23

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/467713a30ed3a53ad2780ba7b30422eefcd27ec6

commit 467713a30ed3a53ad2780ba7b30422eefcd27ec6
Author: Aiden Benner <abenner@google.com>
Date: Tue Oct 23 21:00:54 2018

Properly escape underscores in generated native method descriptors

Previously the generated jni method name for org.chormium.jni_example.foo()
would collide with the name org.chromium.jni.example.foo() because . would be
replaced with _, but _ in class/package/method names were not escaped.

Change-Id: I3911a278c1b5d67269e4c746e114262c4fb36629
Bug:  898261 
Reviewed-on: https://chromium-review.googlesource.com/c/1297075
Reviewed-by: agrieve <agrieve@chromium.org>
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Commit-Queue: Aiden Benner <abenner@google.com>
Cr-Commit-Position: refs/heads/master@{#602086}
[modify] https://crrev.com/467713a30ed3a53ad2780ba7b30422eefcd27ec6/base/android/jni_generator/java/src/org/chromium/jni_generator/JniProcessor.java

Comment 3 by bugdroid1@chromium.org, Oct 24

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/f08cbfefb876faf50966e5554484c1a35eded73c

commit f08cbfefb876faf50966e5554484c1a35eded73c
Author: Aiden Benner <abenner@google.com>
Date: Wed Oct 24 02:50:57 2018

Add array support and type exceptions to generated native method object casting

Even though String is an object (and so being casted to jobject across
the jni boundary would make sense), the JNI spec gives special treatment for java
string types and they're casted to jstrings instead of jobjects. This
change makes sure Strings stay as Strings in the native method declaration.
Previously all non-primitive types would be casted to objects.

Also fixed a bug where void was being cast to object (this happened because
void is non-primitive).

Also adds better array support. Arrays with a primitive component type
will stay as primitive arrays but arrays with a non-primitive component type
will be casted to an object array.

Change-Id: If795bcddf7a38f051d0c6fb515e1dd320dd3f30d
Bug:  898261 
Reviewed-on: https://chromium-review.googlesource.com/c/1297083
Commit-Queue: Aiden Benner <abenner@google.com>
Reviewed-by: agrieve <agrieve@chromium.org>
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602230}
[modify] https://crrev.com/f08cbfefb876faf50966e5554484c1a35eded73c/base/android/jni_generator/java/src/org/chromium/jni_generator/JniProcessor.java

Comment 4 by estevenson@chromium.org, Oct 24

Cc: abenner@google.com
 Issue 898258  has been merged into this issue.

Comment 5 by estevenson@chromium.org, Oct 24

Blockedon: 898660

Comment 6 by bugdroid1@chromium.org, Oct 30

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/0a7cb79a7f041ff1130595ab6f51f4eb3223f5cf

commit 0a7cb79a7f041ff1130595ab6f51f4eb3223f5cf
Author: Aiden Benner <abenner@google.com>
Date: Tue Oct 30 15:17:00 2018

Add support for generation of header files and registration of proxy native methods.

'Proxy' native methods are declared in an @JniStaticNatives interface without a native
qualifier and indicate that the JNI annotation processor should generate code
to link between the equivalent native method as if it were declare statically.
Under the hood the annotation processor generates the actual native
method declaration in another another class (org.chromium.base.natives.GEN_JNI)
but generates wrapper code so it can be called through the declaring class.

This CL adds support to the python header generator to generate header files and
registration header files for native methods declared in an @JniStaticNatives
annotated interface which uses the JNI annotation processor.

Change-Id: I7a1c10f67d6b7c7dad3423634bdb995e76e751a4
Bug:  898261 
Reviewed-on: https://chromium-review.googlesource.com/c/1297184
Commit-Queue: Aiden Benner <abenner@google.com>
Reviewed-by: agrieve <agrieve@chromium.org>
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603900}
[modify] https://crrev.com/0a7cb79a7f041ff1130595ab6f51f4eb3223f5cf/base/android/jni_generator/BUILD.gn
[add] https://crrev.com/0a7cb79a7f041ff1130595ab6f51f4eb3223f5cf/base/android/jni_generator/HashedSampleForAnnotationProcessor_jni.golden
[add] https://crrev.com/0a7cb79a7f041ff1130595ab6f51f4eb3223f5cf/base/android/jni_generator/SampleForAnnotationProcessor_jni.golden
[modify] https://crrev.com/0a7cb79a7f041ff1130595ab6f51f4eb3223f5cf/base/android/jni_generator/java/src/org/chromium/example/jni_generator/SampleForAnnotationProcessor.java
[modify] https://crrev.com/0a7cb79a7f041ff1130595ab6f51f4eb3223f5cf/base/android/jni_generator/java/src/org/chromium/jni_generator/JniProcessor.java
[modify] https://crrev.com/0a7cb79a7f041ff1130595ab6f51f4eb3223f5cf/base/android/jni_generator/jni_generator.py
[modify] https://crrev.com/0a7cb79a7f041ff1130595ab6f51f4eb3223f5cf/base/android/jni_generator/jni_generator_tests.py
[modify] https://crrev.com/0a7cb79a7f041ff1130595ab6f51f4eb3223f5cf/base/android/jni_generator/jni_registration_generator.py
[modify] https://crrev.com/0a7cb79a7f041ff1130595ab6f51f4eb3223f5cf/base/android/jni_generator/sample_for_tests.cc
[add] https://crrev.com/0a7cb79a7f041ff1130595ab6f51f4eb3223f5cf/base/android/jni_generator/testProxyNatives.golden
[add] https://crrev.com/0a7cb79a7f041ff1130595ab6f51f4eb3223f5cf/base/android/jni_generator/testProxyNativesRegistrations.golden
[add] https://crrev.com/0a7cb79a7f041ff1130595ab6f51f4eb3223f5cf/base/android/jni_generator/testProxyNativesWithNatives.golden

Comment 7 by bugdroid1@chromium.org, Oct 30

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/eee073530f9424438a87dfbc3b717038fe655126

commit eee073530f9424438a87dfbc3b717038fe655126
Author: Aiden Benner <abenner@google.com>
Date: Tue Oct 30 21:12:19 2018

Register proxy natives declared in @MainDex properly

Previously the @MainDex annotation would not be processed by
the jni_generator for proxy natives. So method registrations
that should be in main dex were incorrectly registered.

This CL processes @MainDex annotations for proxy natives
and properly splits up their declaration in generated
registration headers.

Bug:  898261 
Change-Id: Iad9d3b3121085ef1427b958dcefc1acfb255312c
Reviewed-on: https://chromium-review.googlesource.com/c/1303394
Commit-Queue: Aiden Benner <abenner@google.com>
Reviewed-by: agrieve <agrieve@chromium.org>
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604014}
[modify] https://crrev.com/eee073530f9424438a87dfbc3b717038fe655126/base/android/jni_generator/jni_generator.py
[modify] https://crrev.com/eee073530f9424438a87dfbc3b717038fe655126/base/android/jni_generator/jni_generator_tests.py
[modify] https://crrev.com/eee073530f9424438a87dfbc3b717038fe655126/base/android/jni_generator/jni_registration_generator.py
[add] https://crrev.com/eee073530f9424438a87dfbc3b717038fe655126/base/android/jni_generator/testProxyNativesMainDex.golden
[add] https://crrev.com/eee073530f9424438a87dfbc3b717038fe655126/base/android/jni_generator/testProxyNativesMainDexAndNonMainDex.golden
[modify] https://crrev.com/eee073530f9424438a87dfbc3b717038fe655126/base/android/jni_generator/testProxyNativesRegistrations.golden

Comment 8 by estevenson@chromium.org, Oct 31

Description: Show this description

Comment 9 by bugdroid1@chromium.org, Oct 31

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/684b74b9007d405ef2db8dd05b207cba1dc4f5a6

commit 684b74b9007d405ef2db8dd05b207cba1dc4f5a6
Author: Aiden Benner <abenner@google.com>
Date: Wed Oct 31 17:35:18 2018

Add Throwable and Class as JNI type exceptions to annotation processor

Throwable and Class have special JNI types jclass and jthrowable.
Converting these types to object breaks the function bindings,
This CL adds Class and Throwable to the list of types not to cast to objects
when creating the JNI bindings

Bug:  898261 
Change-Id: I84f008a8aa6d3505a975f5989482ffb5f6bba237
Reviewed-on: https://chromium-review.googlesource.com/c/1307774
Reviewed-by: agrieve <agrieve@chromium.org>
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Commit-Queue: Aiden Benner <abenner@google.com>
Cr-Commit-Position: refs/heads/master@{#604316}
[modify] https://crrev.com/684b74b9007d405ef2db8dd05b207cba1dc4f5a6/base/android/jni_generator/java/src/org/chromium/jni_generator/JniProcessor.java

Comment 10 by bugdroid1@chromium.org, Oct 31

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/f1ebefaf786c08d353c8ee4952bcb218e515ff9a

commit f1ebefaf786c08d353c8ee4952bcb218e515ff9a
Author: Aiden Benner <abenner@google.com>
Date: Wed Oct 31 18:12:04 2018

Fix multiline-params being ignored by proxy natives

Multiline parameters in proxy natives would be ignored by the jni_generator
because the .* in the params portion of the proxy natives regex was not
matching on newlines. This CL adds the flag re.DOTALL so that dot matches
on newline which fixes the issue, and adds test coverage for this case.

Bug:  898261 
Change-Id: I28f1fb3c57b39daff4d8bb1eb2bfba4a2f4d7adc
Reviewed-on: https://chromium-review.googlesource.com/c/1306694
Reviewed-by: agrieve <agrieve@chromium.org>
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Commit-Queue: Aiden Benner <abenner@google.com>
Cr-Commit-Position: refs/heads/master@{#604331}
[modify] https://crrev.com/f1ebefaf786c08d353c8ee4952bcb218e515ff9a/base/android/jni_generator/jni_generator.py
[modify] https://crrev.com/f1ebefaf786c08d353c8ee4952bcb218e515ff9a/base/android/jni_generator/jni_generator_tests.py

Comment 11 by bugdroid1@chromium.org, Oct 31

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/8deb13e43c8972b3d60bba710d72dddc88554e29

commit 8deb13e43c8972b3d60bba710d72dddc88554e29
Author: Aiden Benner <abenner@google.com>
Date: Wed Oct 31 20:15:14 2018

Add testing setter in generated JNI classes

Updates JNI wrapper to use the version that optimizes the
best with R8, and includes a testing flag/setter.

Bug:  898261 
Change-Id: I343dd1a4f470fb8067dfd4cdb31d7c545b5f3717
Reviewed-on: https://chromium-review.googlesource.com/c/1308098
Commit-Queue: Aiden Benner <abenner@google.com>
Reviewed-by: agrieve <agrieve@chromium.org>
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604369}
[modify] https://crrev.com/8deb13e43c8972b3d60bba710d72dddc88554e29/base/android/jni_generator/java/src/org/chromium/jni_generator/JniProcessor.java

Comment 12 by agrieve@chromium.org, Nov 5

Description: Show this description

Comment 13 by bugdroid1@chromium.org, Nov 5

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/ce2ed51a2723d95dc3a0289961f9ae95568d51fa

commit ce2ed51a2723d95dc3a0289961f9ae95568d51fa
Author: Andrew Grieve <agrieve@chromium.org>
Date: Mon Nov 05 15:54:52 2018

Android: Switch ContentShell to use implicit JNI registration

Explicit registration is needed only when using the custom linker.
Content shell doesn't use the custom linker, so has no need to jump
through the extra hoops involved with explicit registration.

Change motivated by JNI refactorings, which are made simpler by having
fewer targets use manual JNI registration.

Bug:  898261 
Change-Id: Ia38529c1df92264781ba64235a7aea749ef0356a
Reviewed-on: https://chromium-review.googlesource.com/c/1317338
Reviewed-by: Yaron Friedman <yfriedman@chromium.org>
Commit-Queue: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605344}
[modify] https://crrev.com/ce2ed51a2723d95dc3a0289961f9ae95568d51fa/content/shell/android/BUILD.gn
[modify] https://crrev.com/ce2ed51a2723d95dc3a0289961f9ae95568d51fa/content/shell/android/shell_library_loader.cc
[modify] https://crrev.com/ce2ed51a2723d95dc3a0289961f9ae95568d51fa/content/shell/android/shell_test_library_loader.cc

Comment 14 by bugdroid1@chromium.org, Nov 5

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/69d9e273c683fec0e1b39d8fd0f6ae1cf2983dfd

commit 69d9e273c683fec0e1b39d8fd0f6ae1cf2983dfd
Author: Andrew Grieve <agrieve@chromium.org>
Date: Mon Nov 05 19:05:45 2018

Android: Switch Remoting to use implicit JNI registration

Explicit registration is needed only when using the custom linker.
Remoting doesn't use the custom linker, so has no need to jump
through the extra hoops involved with explicit registration.

Change motivated by JNI refactorings, which are made simpler by having
fewer targets use manual JNI registration.

Bug:  898261 
Change-Id: I0b03afdd421f8c806886cbf7a6650ec1ca5d7f9c
Reviewed-on: https://chromium-review.googlesource.com/c/1317339
Reviewed-by: Lambros Lambrou <lambroslambrou@chromium.org>
Commit-Queue: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605404}
[modify] https://crrev.com/69d9e273c683fec0e1b39d8fd0f6ae1cf2983dfd/remoting/android/BUILD.gn
[modify] https://crrev.com/69d9e273c683fec0e1b39d8fd0f6ae1cf2983dfd/remoting/client/jni/BUILD.gn
[modify] https://crrev.com/69d9e273c683fec0e1b39d8fd0f6ae1cf2983dfd/remoting/client/jni/remoting_jni_onload.cc

Comment 15 by bugdroid1@chromium.org, Nov 5

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/f1854090df71901e50c22e793daa0ffc91b6ae6e

commit f1854090df71901e50c22e793daa0ffc91b6ae6e
Author: Andrew Grieve <agrieve@chromium.org>
Date: Mon Nov 05 20:38:23 2018

Android: Switch cast_shell to use implicit JNI registration

Explicit registration is needed only when using the custom linker.
Cast shell doesn't use the custom linker, so has no need to jump
through the extra hoops involved with explicit registration.

Change motivated by JNI refactorings, which are made simpler by having
fewer targets use manual JNI registration.

Bug:  898261 
Change-Id: I88e92480d355fc0a19ffdd4c816efbf749dd9964
Reviewed-on: https://chromium-review.googlesource.com/c/1317340
Reviewed-by: Luke Halliwell <halliwell@chromium.org>
Commit-Queue: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605446}
[modify] https://crrev.com/f1854090df71901e50c22e793daa0ffc91b6ae6e/chromecast/BUILD.gn
[modify] https://crrev.com/f1854090df71901e50c22e793daa0ffc91b6ae6e/chromecast/android/BUILD.gn
[modify] https://crrev.com/f1854090df71901e50c22e793daa0ffc91b6ae6e/chromecast/app/android/cast_jni_loader.cc

Comment 16 by bugdroid1@chromium.org, Nov 6

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/4756a23a1e56e8da0e21f790a508a05c9d242f07

commit 4756a23a1e56e8da0e21f790a508a05c9d242f07
Author: Andrew Grieve <agrieve@chromium.org>
Date: Tue Nov 06 19:20:13 2018

generate_jni_registrations: Use @JniIgnoreNatives rather a GN blacklist

Change motivated by JNI refactorings, which are made simpler by not
having to specify this blacklist in GN.

TBR=agrieve  # Trivial build refactor

Bug:  898261 
Change-Id: Ic81e99a460f54e5c02fedfd9f8467390045ee21c
Reviewed-on: https://chromium-review.googlesource.com/c/1317341
Commit-Queue: agrieve <agrieve@chromium.org>
Reviewed-by: Tibor Goldschwendt <tiborg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605778}
[modify] https://crrev.com/4756a23a1e56e8da0e21f790a508a05c9d242f07/base/BUILD.gn
[add] https://crrev.com/4756a23a1e56e8da0e21f790a508a05c9d242f07/base/android/java/src/org/chromium/base/annotations/JniIgnoreNatives.java
[modify] https://crrev.com/4756a23a1e56e8da0e21f790a508a05c9d242f07/base/android/java/src/org/chromium/base/library_loader/Linker.java
[modify] https://crrev.com/4756a23a1e56e8da0e21f790a508a05c9d242f07/base/android/jni_generator/BUILD.gn
[delete] https://crrev.com/dc44b72a95879b70fc9e0843585eaa04920f8556/base/android/jni_generator/jni_exception_list.gni
[modify] https://crrev.com/4756a23a1e56e8da0e21f790a508a05c9d242f07/base/android/jni_generator/jni_registration_generator.py
[modify] https://crrev.com/4756a23a1e56e8da0e21f790a508a05c9d242f07/chrome/android/BUILD.gn
[modify] https://crrev.com/4756a23a1e56e8da0e21f790a508a05c9d242f07/components/cronet/android/BUILD.gn
[modify] https://crrev.com/4756a23a1e56e8da0e21f790a508a05c9d242f07/content/shell/android/BUILD.gn

Comment 17 by mef@google.com, Nov 8

Cc: pauljensen@chromium.org mef@chromium.org
This may have interesting implications for Cronet.

Comment 18 by bugdroid1@chromium.org, Nov 16

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/38d5b1dee89f30f272c738f12af8c02ed638eca1

commit 38d5b1dee89f30f272c738f12af8c02ed638eca1
Author: Eric Stevenson <estevenson@chromium.org>
Date: Fri Nov 16 01:15:12 2018

Generate GEN_JNI.java for every .apk

This is part of a better scheme for calling Java->Native
where all native methods are hidden behind interfaces,
and exist within a single "GEN_JNI.java" generated file.
See bug for more details.

Bug:  898261 
Change-Id: I1fd7a9f162cb2853a2dfcd62ffcdebe909cb40e1
Reviewed-on: https://chromium-review.googlesource.com/c/1315808
Commit-Queue: Eric Stevenson <estevenson@chromium.org>
Reviewed-by: Misha Efimov <mef@chromium.org>
Reviewed-by: Tibor Goldschwendt <tiborg@chromium.org>
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608614}
[modify] https://crrev.com/38d5b1dee89f30f272c738f12af8c02ed638eca1/base/android/jni_generator/BUILD.gn
[modify] https://crrev.com/38d5b1dee89f30f272c738f12af8c02ed638eca1/base/android/jni_generator/jni_generator.py
[modify] https://crrev.com/38d5b1dee89f30f272c738f12af8c02ed638eca1/base/android/jni_generator/jni_registration_generator.py
[modify] https://crrev.com/38d5b1dee89f30f272c738f12af8c02ed638eca1/build/android/gyp/write_build_config.py
[modify] https://crrev.com/38d5b1dee89f30f272c738f12af8c02ed638eca1/build/config/android/rules.gni
[modify] https://crrev.com/38d5b1dee89f30f272c738f12af8c02ed638eca1/chrome/android/BUILD.gn
[modify] https://crrev.com/38d5b1dee89f30f272c738f12af8c02ed638eca1/chrome/browser/android/vr/BUILD.gn
[modify] https://crrev.com/38d5b1dee89f30f272c738f12af8c02ed638eca1/components/cronet/android/BUILD.gn
[modify] https://crrev.com/38d5b1dee89f30f272c738f12af8c02ed638eca1/content/shell/android/BUILD.gn

Comment 19 by bugdroid1@chromium.org, Nov 16

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/60d72c0b63123eb70057a9353b16dbabff723e9f

commit 60d72c0b63123eb70057a9353b16dbabff723e9f
Author: Aiden Benner <abenner@google.com>
Date: Fri Nov 16 22:08:34 2018

Add helpers to generate GEN_JNI.java during JNI registration

GEN_JNI contains the actual native method declaration
that corresponds to a method in an @JniNatives annotation.
This change adds helpers to generate GEN_JNI with all
proxy natives that are being registered in a generated
registration header file.

- Also fixes bug where hashed method names were escaped
one too many times.
- Adds better tests for special JNI type cases.

Change-Id: Ie705d0cf55233c513ad4bc32024212454115bcba
Bug:  898261 
Reviewed-on: https://chromium-review.googlesource.com/c/1315687
Commit-Queue: Aiden Benner <abenner@google.com>
Reviewed-by: agrieve <agrieve@chromium.org>
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608974}
[add] https://crrev.com/60d72c0b63123eb70057a9353b16dbabff723e9f/base/android/jni_generator/HashedSampleForAnnotationProcessorGenJni.golden
[modify] https://crrev.com/60d72c0b63123eb70057a9353b16dbabff723e9f/base/android/jni_generator/HashedSampleForAnnotationProcessor_jni.golden
[modify] https://crrev.com/60d72c0b63123eb70057a9353b16dbabff723e9f/base/android/jni_generator/SampleForAnnotationProcessor_jni.golden
[modify] https://crrev.com/60d72c0b63123eb70057a9353b16dbabff723e9f/base/android/jni_generator/java/src/org/chromium/example/jni_generator/SampleForAnnotationProcessor.java
[modify] https://crrev.com/60d72c0b63123eb70057a9353b16dbabff723e9f/base/android/jni_generator/jni_generator.py
[modify] https://crrev.com/60d72c0b63123eb70057a9353b16dbabff723e9f/base/android/jni_generator/jni_generator_tests.py
[modify] https://crrev.com/60d72c0b63123eb70057a9353b16dbabff723e9f/base/android/jni_generator/jni_registration_generator.py
[modify] https://crrev.com/60d72c0b63123eb70057a9353b16dbabff723e9f/base/android/jni_generator/sample_for_tests.cc
[add] https://crrev.com/60d72c0b63123eb70057a9353b16dbabff723e9f/base/android/jni_generator/testProxyNativesJava.golden

Comment 20 by bugdroid1@chromium.org, Nov 20

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/68548c418a375bffddd6e4a8eee3c065c7411ce5

commit 68548c418a375bffddd6e4a8eee3c065c7411ce5
Author: Aiden Benner <abenner@google.com>
Date: Tue Nov 20 23:47:25 2018

Add testing hooks to classes generated by the JniProcessor

Adds an interface JniStaticTestMocker and an anonymous implementation
in each generated class created by the JniProcessor. The TEST_HOOKS
field contains a method that will set the mock that is used when
testing is enabled.

When testing is disabled, TEST_HOOKS will never be called and
should be optimized away by proguard/R8.

This should allow for generic JUnit rules that work with all
static mockable 'proxy' natives.

Bug:  898261 
Change-Id: I026858957e7f98cbbe16da0772dc3e68d38717bb
Reviewed-on: https://chromium-review.googlesource.com/c/1342805
Commit-Queue: Aiden Benner <abenner@google.com>
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609855}
[modify] https://crrev.com/68548c418a375bffddd6e4a8eee3c065c7411ce5/base/BUILD.gn
[add] https://crrev.com/68548c418a375bffddd6e4a8eee3c065c7411ce5/base/android/java/src/org/chromium/base/JniStaticTestMocker.java
[modify] https://crrev.com/68548c418a375bffddd6e4a8eee3c065c7411ce5/base/android/jni_generator/BUILD.gn
[modify] https://crrev.com/68548c418a375bffddd6e4a8eee3c065c7411ce5/base/android/jni_generator/java/src/org/chromium/jni_generator/JniProcessor.java

Comment 21 by bugdroid1@chromium.org, Nov 21

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/dc538afe841988d422c9427308b0104053660c72

commit dc538afe841988d422c9427308b0104053660c72
Author: Aiden Benner <abenner@google.com>
Date: Wed Nov 21 19:36:54 2018

Fix presubmit warnings for javadocs in the JNI processor

Can't use @JniStaticNatives in comments because it's not a
valid javadoc tag. Use {@link JniStaticNatives} instead.

Also renames instances of JNINatives -> JniStaticNatives
in comments.

Bug:  898261 
Change-Id: I62d0dda735559af92473052f4856466308cd14a4
Reviewed-on: https://chromium-review.googlesource.com/c/1345231
Commit-Queue: Aiden Benner <abenner@google.com>
Reviewed-by: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610167}
[modify] https://crrev.com/dc538afe841988d422c9427308b0104053660c72/base/android/java/src/org/chromium/base/JniStaticTestMocker.java
[modify] https://crrev.com/dc538afe841988d422c9427308b0104053660c72/base/android/jni_generator/java/src/org/chromium/jni_generator/JniProcessor.java

Comment 22 by bugdroid1@chromium.org, Nov 21

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d0d0a00bf1faaea1edb957ac87e64eac9753962f

commit d0d0a00bf1faaea1edb957ac87e64eac9753962f
Author: Aiden Benner <abenner@google.com>
Date: Wed Nov 21 23:36:49 2018

JNI: Add flags to enable/disable/require mocks in GEN_JNI

Adds the REQUIRE_MOCKS flag to GEN_JNI. If both the REQUIRE_MOCKS and
TESTING_ENABLED flags are set, calls to native implementations must
have had a mock instance set first through TEST_HOOKS,
otherwise an UnsupportedOperationException will be thrown.

If only TESTING_ENABLED is set, calls to the native implementation
will use a test mock if it is provided, and otherwise fallback to the
native implementation. This is used for instrumentation tests that
may want to mock out some native implementations but not all.

In the annotation processor version of GEN_JNI both these flags are
mutable and so they can be set by a JNI test rule for unit tests.

Instrumentation tests that want to mock a native implementation
can pass flags to JNI registration generator to set the corresponding
GEN_JNI flags.

Bug:  898261 
Change-Id: I6a90e91a29368df692d458f35c9ea92f8898064b
Reviewed-on: https://chromium-review.googlesource.com/c/1344554
Commit-Queue: Aiden Benner <abenner@google.com>
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610263}
[modify] https://crrev.com/d0d0a00bf1faaea1edb957ac87e64eac9753962f/base/android/jni_generator/HashedSampleForAnnotationProcessorGenJni.golden
[modify] https://crrev.com/d0d0a00bf1faaea1edb957ac87e64eac9753962f/base/android/jni_generator/java/src/org/chromium/jni_generator/JniProcessor.java
[modify] https://crrev.com/d0d0a00bf1faaea1edb957ac87e64eac9753962f/base/android/jni_generator/jni_generator_tests.py
[modify] https://crrev.com/d0d0a00bf1faaea1edb957ac87e64eac9753962f/base/android/jni_generator/jni_registration_generator.py
[modify] https://crrev.com/d0d0a00bf1faaea1edb957ac87e64eac9753962f/base/android/jni_generator/testProxyNativesJava.golden

Comment 23 by bugdroid1@chromium.org, Nov 21

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/742d3f18ff3be8832577537167a6980c81b00cb5

commit 742d3f18ff3be8832577537167a6980c81b00cb5
Author: Aiden Benner <abenner@google.com>
Date: Wed Nov 21 23:43:43 2018

jni_generator: Refactor/clean up tests

- Move golden/javap files to jni_generator/golden/
- Make method capitalization more consistent with jni_generator py files
- Split proxy native tests to a different test suite
- Decouple utility functions from TestGenerator into a base test class
- Fix bug where tests would fail if ran from a different directory
- Adds tests for enable/disable/require mock flags

Bug:  898261 
Change-Id: Ieae930c73539b00653dfcf32c89d9a79a3ceecf6
Reviewed-on: https://chromium-review.googlesource.com/c/1345239
Commit-Queue: Aiden Benner <abenner@google.com>
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610266}
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/HashedSampleForAnnotationProcessorGenJni.golden
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/HashedSampleForAnnotationProcessor_jni.golden
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/SampleForAnnotationProcessor_jni.golden
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/SampleForTests_jni.golden
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testCalledByNatives.golden
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testConstantsFromJavaP.golden
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testFromJavaP.golden
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testFromJavaPGenerics.golden
[copy] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testGenJniFlagsDisabled.golden
[add] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testGenJniFlagsMocksEnabled.golden
[add] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testGenJniFlagsMocksRequired.golden
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testInnerClassNatives.golden
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testInnerClassNativesBothInnerAndOuter.golden
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testInnerClassNativesBothInnerAndOuterRegistrations.golden
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testInnerClassNativesMultiple.golden
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testInputStream.javap
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testMotionEvent.javap
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testMotionEvent.javap7
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testMultipleJNIAdditionalImport.golden
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testNativeExportsOnlyOption.golden
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testNatives.golden
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testNativesLong.golden
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testNativesRegistrations.golden
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testProxyNatives.golden
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testProxyNativesJava.golden
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testProxyNativesMainDex.golden
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testProxyNativesMainDexAndNonMainDex.golden
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testProxyNativesRegistrations.golden
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testProxyNativesWithNatives.golden
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testSingleJNIAdditionalImport.golden
[rename] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/golden/testTracing.golden
[modify] https://crrev.com/742d3f18ff3be8832577537167a6980c81b00cb5/base/android/jni_generator/jni_generator_tests.py

Comment 24 by bugdroid1@chromium.org, Nov 22

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/b419dc55bb81b1804c84129bda1e05035eb4f9f8

commit b419dc55bb81b1804c84129bda1e05035eb4f9f8
Author: Aiden Benner <abenner@google.com>
Date: Thu Nov 22 03:11:26 2018

jni_generator: Use shortened name for GEN_JNI when !is_java_debug

To save space in release, instead of using org.chromium.base.natives.GEN_JNI
use a short package/class name, J.N. Proguard won't do this for us because
we can't obfuscate any class that contains native methods.

Bug:  898261 
Change-Id: I84ad6914912b5b0e0d390d53a88dbcf41633edbf
Reviewed-on: https://chromium-review.googlesource.com/c/1347034
Reviewed-by: agrieve <agrieve@chromium.org>
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Commit-Queue: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610288}
[modify] https://crrev.com/b419dc55bb81b1804c84129bda1e05035eb4f9f8/base/android/jni_generator/golden/HashedSampleForAnnotationProcessor_jni.golden
[modify] https://crrev.com/b419dc55bb81b1804c84129bda1e05035eb4f9f8/base/android/jni_generator/java/src/org/chromium/jni_generator/JniProcessor.java
[modify] https://crrev.com/b419dc55bb81b1804c84129bda1e05035eb4f9f8/base/android/jni_generator/jni_generator.py
[modify] https://crrev.com/b419dc55bb81b1804c84129bda1e05035eb4f9f8/base/android/jni_generator/jni_generator_tests.py
[modify] https://crrev.com/b419dc55bb81b1804c84129bda1e05035eb4f9f8/base/android/jni_generator/jni_registration_generator.py
[modify] https://crrev.com/b419dc55bb81b1804c84129bda1e05035eb4f9f8/build/config/android/rules.gni

Comment 25 by bugdroid1@chromium.org, Nov 23

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d958e2ee016ae16b32a9cc0f4a4d21331c471213

commit d958e2ee016ae16b32a9cc0f4a4d21331c471213
Author: Aiden Benner <abenner@google.com>
Date: Fri Nov 23 02:08:29 2018

Refactor AnimationFrameTimeHistogram to use mockable static natives

This CL adds the necessary dependencies to use the JNI annotation
processor in base/java and converts AnimationFrameTimeHistogram to
use mockable static methods.

This abstraction should have little overhead once R8 is used instead
of proguard but for now it still adds methods.

Bug:  898261 
Change-Id: I73141dfeb5916c40aafc3c58ae606fe0af7a392e
Reviewed-on: https://chromium-review.googlesource.com/c/1347202
Reviewed-by: agrieve <agrieve@chromium.org>
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Commit-Queue: Aiden Benner <abenner@google.com>
Cr-Commit-Position: refs/heads/master@{#610514}
[modify] https://crrev.com/d958e2ee016ae16b32a9cc0f4a4d21331c471213/base/BUILD.gn
[modify] https://crrev.com/d958e2ee016ae16b32a9cc0f4a4d21331c471213/base/android/animation_frame_time_histogram.cc
[modify] https://crrev.com/d958e2ee016ae16b32a9cc0f4a4d21331c471213/base/android/java/src/org/chromium/base/AnimationFrameTimeHistogram.java
[modify] https://crrev.com/d958e2ee016ae16b32a9cc0f4a4d21331c471213/base/android/jni_generator/BUILD.gn

Comment 26 by bugdroid1@chromium.org, Nov 23

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/dac8daaa421b26aea9aeee23421869ad7aba72ec

commit dac8daaa421b26aea9aeee23421869ad7aba72ec
Author: Sam McNally <sammc@chromium.org>
Date: Fri Nov 23 02:32:08 2018

Revert "Refactor AnimationFrameTimeHistogram to use mockable static natives"

This reverts commit d958e2ee016ae16b32a9cc0f4a4d21331c471213.

Reason for revert: Looks responsible for causing android-rel compile failure: https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/android-rel/4748

Original change's description:
> Refactor AnimationFrameTimeHistogram to use mockable static natives
> 
> This CL adds the necessary dependencies to use the JNI annotation
> processor in base/java and converts AnimationFrameTimeHistogram to
> use mockable static methods.
> 
> This abstraction should have little overhead once R8 is used instead
> of proguard but for now it still adds methods.
> 
> Bug:  898261 
> Change-Id: I73141dfeb5916c40aafc3c58ae606fe0af7a392e
> Reviewed-on: https://chromium-review.googlesource.com/c/1347202
> Reviewed-by: agrieve <agrieve@chromium.org>
> Reviewed-by: Eric Stevenson <estevenson@chromium.org>
> Commit-Queue: Aiden Benner <abenner@google.com>
> Cr-Commit-Position: refs/heads/master@{#610514}

TBR=agrieve@chromium.org,estevenson@chromium.org,abenner@google.com

Change-Id: I3731924e03a3ab084bc761ae441f6bf71970ab27
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug:  898261 
Reviewed-on: https://chromium-review.googlesource.com/c/1348886
Reviewed-by: Sam McNally <sammc@chromium.org>
Commit-Queue: Sam McNally <sammc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610517}
[modify] https://crrev.com/dac8daaa421b26aea9aeee23421869ad7aba72ec/base/BUILD.gn
[modify] https://crrev.com/dac8daaa421b26aea9aeee23421869ad7aba72ec/base/android/animation_frame_time_histogram.cc
[modify] https://crrev.com/dac8daaa421b26aea9aeee23421869ad7aba72ec/base/android/java/src/org/chromium/base/AnimationFrameTimeHistogram.java
[modify] https://crrev.com/dac8daaa421b26aea9aeee23421869ad7aba72ec/base/android/jni_generator/BUILD.gn

Comment 27 by bugdroid1@chromium.org, Nov 30

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/104459dbd6e3bab6fea41c00beae46f23775f153

commit 104459dbd6e3bab6fea41c00beae46f23775f153
Author: Andrew Grieve <agrieve@chromium.org>
Date: Fri Nov 30 21:26:40 2018

Cronet: Merge apk_under_test into instrumentation_test_apk targets

Except for sample_apk, which looks like it's a valid app on its own.

Motivation:
 * Trying to add a new JNI generator, and these targets were being
 difficult due to the tests having (unused) native methods that the
 under_test apk did not have.
 * The under_test apks didn't really make sense on their own anyways, so
 it's more efficent to just combine them.

Bug:  898261 
Change-Id: I23571ea61230daefccb8e0e14689d3f872080136
Reviewed-on: https://chromium-review.googlesource.com/c/1352853
Reviewed-by: Paul Jensen <pauljensen@chromium.org>
Commit-Queue: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612791}
[modify] https://crrev.com/104459dbd6e3bab6fea41c00beae46f23775f153/BUILD.gn
[modify] https://crrev.com/104459dbd6e3bab6fea41c00beae46f23775f153/components/cronet/android/BUILD.gn
[delete] https://crrev.com/ba4d92c9af1699712c6dfa5ca5f7bfa5606c60e0/components/cronet/android/test/AndroidManifest.xml
[modify] https://crrev.com/104459dbd6e3bab6fea41c00beae46f23775f153/components/cronet/android/test/javatests/AndroidManifest.xml

Comment 28 by bugdroid1@chromium.org, Dec 4

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/11c1167818777a4c3e0e5e17dbd10c8e09a65bd9

commit 11c1167818777a4c3e0e5e17dbd10c8e09a65bd9
Author: Aiden Benner <abenner@google.com>
Date: Tue Dec 04 19:40:38 2018

JNI: Add docs for mockable static natives

Bug:  898261 
Change-Id: I52eb3c883118b90a074542d5123557c491244ff9
Reviewed-on: https://chromium-review.googlesource.com/c/1348951
Commit-Queue: Aiden Benner <abenner@google.com>
Reviewed-by: agrieve <agrieve@chromium.org>
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#613650}
[modify] https://crrev.com/11c1167818777a4c3e0e5e17dbd10c8e09a65bd9/base/android/jni_generator/README.md

Comment 29 by bugdroid1@chromium.org, Dec 4

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/f5500c51183843aaf4c60a6f2e614256226a0bbb

commit f5500c51183843aaf4c60a6f2e614256226a0bbb
Author: Aiden Benner <abenner@google.com>
Date: Tue Dec 04 19:42:23 2018

JNI: Add @JCaller annotation

@JCaller is used on a parameter in a static native method to indicate
that a native binding should be generated as if that parameter
was calling a non-static function with the same signature.

This allows for easy conversion from non-static methods to static methods
without also modifying native method signatures.

This change is motivated by an impending refactor to the new JNI
interface (which will use all static methods).

(cherry picked from commit 914bfe613854337d097db9402765fd14e51ddcd5)

Bug:  898261 
Change-Id: I37b2bb5ecf2da9ef33a34a61a35a43b8e2cdb838
Reviewed-on: https://chromium-review.googlesource.com/c/1358003
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Commit-Queue: Aiden Benner <abenner@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/1361642
Cr-Commit-Position: refs/heads/master@{#613652}
[modify] https://crrev.com/f5500c51183843aaf4c60a6f2e614256226a0bbb/base/BUILD.gn
[add] https://crrev.com/f5500c51183843aaf4c60a6f2e614256226a0bbb/base/android/java/src/org/chromium/base/annotations/JCaller.java
[add] https://crrev.com/f5500c51183843aaf4c60a6f2e614256226a0bbb/base/android/jni_generator/golden/testStaticBindingCaller.golden
[modify] https://crrev.com/f5500c51183843aaf4c60a6f2e614256226a0bbb/base/android/jni_generator/jni_generator.py
[modify] https://crrev.com/f5500c51183843aaf4c60a6f2e614256226a0bbb/base/android/jni_generator/jni_generator_tests.py

Comment 30 by bugdroid1@chromium.org, Dec 4

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/00323b7c03a2f3eb4c53bd2286ddf4b5044b5fb2

commit 00323b7c03a2f3eb4c53bd2286ddf4b5044b5fb2
Author: Aiden Benner <abenner@google.com>
Date: Tue Dec 04 19:55:45 2018

JNI: Remove @NativeCall

In preparation of a refactor to use the JNI annotation processor,
the @NativeCall annotation is now deprecated. (Since when using the
annotation processor all native functions will need to be declared
on the top level class)

This CL refactors the remaining uses.

TBR=agrieve@chromium.org

Bug:  898261 
Change-Id: Iead176a271774be58d06de27e35fa5d605f6ffc4
Reviewed-on: https://chromium-review.googlesource.com/c/1361584
Commit-Queue: Aiden Benner <abenner@google.com>
Reviewed-by: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#613662}
[modify] https://crrev.com/00323b7c03a2f3eb4c53bd2286ddf4b5044b5fb2/base/BUILD.gn
[delete] https://crrev.com/4ae291d41792e0084797999bb4aba2817b080f85/base/android/java/src/org/chromium/base/annotations/NativeCall.java
[modify] https://crrev.com/00323b7c03a2f3eb4c53bd2286ddf4b5044b5fb2/base/android/jni_generator/golden/SampleForTests_jni.golden
[modify] https://crrev.com/00323b7c03a2f3eb4c53bd2286ddf4b5044b5fb2/base/android/jni_generator/java/src/org/chromium/example/jni_generator/SampleForTests.java
[modify] https://crrev.com/00323b7c03a2f3eb4c53bd2286ddf4b5044b5fb2/base/android/jni_generator/sample_for_tests.cc
[modify] https://crrev.com/00323b7c03a2f3eb4c53bd2286ddf4b5044b5fb2/chrome/android/java/src/org/chromium/chrome/browser/IntentHeadersRecorder.java
[modify] https://crrev.com/00323b7c03a2f3eb4c53bd2286ddf4b5044b5fb2/chrome/android/java/src/org/chromium/chrome/browser/browserservices/UkmRecorder.java
[modify] https://crrev.com/00323b7c03a2f3eb4c53bd2286ddf4b5044b5fb2/chrome/browser/android/browserservices/ukm_recorder.cc
[modify] https://crrev.com/00323b7c03a2f3eb4c53bd2286ddf4b5044b5fb2/chrome/browser/android/headers_classifier.cc
[modify] https://crrev.com/00323b7c03a2f3eb4c53bd2286ddf4b5044b5fb2/components/dom_distiller/core/android/java/src/org/chromium/components/dom_distiller/core/DistilledPagePrefs.java
[modify] https://crrev.com/00323b7c03a2f3eb4c53bd2286ddf4b5044b5fb2/components/dom_distiller/core/distilled_page_prefs_android.cc
[modify] https://crrev.com/00323b7c03a2f3eb4c53bd2286ddf4b5044b5fb2/components/feature_engagement/internal/android/java/src/org/chromium/components/feature_engagement/internal/TrackerImpl.java

Comment 31 by bugdroid1@chromium.org, Dec 4

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/a34bd14cba588b0c0d55b4f5b3096ef92e69332a

commit a34bd14cba588b0c0d55b4f5b3096ef92e69332a
Author: Aiden Benner <abenner@google.com>
Date: Tue Dec 04 23:25:09 2018

Reland "Refactor AnimationFrameTimeHistogram to use mockable static natives"

This is a reland of d958e2ee016ae16b32a9cc0f4a4d21331c471213

Original change's description:
> Refactor AnimationFrameTimeHistogram to use mockable static natives
> 
> This CL adds the necessary dependencies to use the JNI annotation
> processor in base/java and converts AnimationFrameTimeHistogram to
> use mockable static methods.
> 
> This abstraction should have little overhead once R8 is used instead
> of proguard but for now it still adds methods.
> 
> Bug:  898261 
> Change-Id: I73141dfeb5916c40aafc3c58ae606fe0af7a392e
> Reviewed-on: https://chromium-review.googlesource.com/c/1347202
> Reviewed-by: agrieve <agrieve@chromium.org>
> Reviewed-by: Eric Stevenson <estevenson@chromium.org>
> Commit-Queue: Aiden Benner <abenner@google.com>
> Cr-Commit-Position: refs/heads/master@{#610514}

Bug:  898261 
Change-Id: I3c0d32da9e72e103cea229f03cf80e93fbe9eb64
Reviewed-on: https://chromium-review.googlesource.com/c/1349855
Commit-Queue: Aiden Benner <abenner@google.com>
Reviewed-by: Paul Jensen <pauljensen@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#613751}
[modify] https://crrev.com/a34bd14cba588b0c0d55b4f5b3096ef92e69332a/base/BUILD.gn
[modify] https://crrev.com/a34bd14cba588b0c0d55b4f5b3096ef92e69332a/base/android/animation_frame_time_histogram.cc
[modify] https://crrev.com/a34bd14cba588b0c0d55b4f5b3096ef92e69332a/base/android/java/src/org/chromium/base/AnimationFrameTimeHistogram.java
[modify] https://crrev.com/a34bd14cba588b0c0d55b4f5b3096ef92e69332a/base/android/jni_generator/BUILD.gn
[modify] https://crrev.com/a34bd14cba588b0c0d55b4f5b3096ef92e69332a/components/cronet/android/BUILD.gn

Comment 33 by bugdroid1@chromium.org, Dec 7

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/0c63af8a49b2ab722520c4641931b8d6a80ca857

commit 0c63af8a49b2ab722520c4641931b8d6a80ca857
Author: Aiden Benner <abenner@google.com>
Date: Fri Dec 07 21:58:48 2018

JNI: Rename @JniStaticNatives -> @NativeMethods

This name makes more sense given that this interface will also
contain non-static natives.

Bug:  898261 
Change-Id: Icc3e2bb9c863cb722047accd3e699e9b4511a5ff
Reviewed-on: https://chromium-review.googlesource.com/c/1366224
Commit-Queue: Aiden Benner <abenner@google.com>
Reviewed-by: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#614831}
[modify] https://crrev.com/0c63af8a49b2ab722520c4641931b8d6a80ca857/base/BUILD.gn
[modify] https://crrev.com/0c63af8a49b2ab722520c4641931b8d6a80ca857/base/android/java/src/org/chromium/base/AnimationFrameTimeHistogram.java
[modify] https://crrev.com/0c63af8a49b2ab722520c4641931b8d6a80ca857/base/android/java/src/org/chromium/base/JniStaticTestMocker.java
[modify] https://crrev.com/0c63af8a49b2ab722520c4641931b8d6a80ca857/base/android/java/src/org/chromium/base/annotations/JCaller.java
[rename] https://crrev.com/0c63af8a49b2ab722520c4641931b8d6a80ca857/base/android/java/src/org/chromium/base/annotations/NativeMethods.java
[modify] https://crrev.com/0c63af8a49b2ab722520c4641931b8d6a80ca857/base/android/jni_generator/README.md
[modify] https://crrev.com/0c63af8a49b2ab722520c4641931b8d6a80ca857/base/android/jni_generator/java/src/org/chromium/example/jni_generator/SampleForAnnotationProcessor.java
[modify] https://crrev.com/0c63af8a49b2ab722520c4641931b8d6a80ca857/base/android/jni_generator/java/src/org/chromium/jni_generator/JniProcessor.java
[modify] https://crrev.com/0c63af8a49b2ab722520c4641931b8d6a80ca857/base/android/jni_generator/jni_generator.py
[modify] https://crrev.com/0c63af8a49b2ab722520c4641931b8d6a80ca857/base/android/jni_generator/jni_generator_tests.py
[modify] https://crrev.com/0c63af8a49b2ab722520c4641931b8d6a80ca857/base/test/android/javatests/src/org/chromium/base/test/util/JniMocker.java

Comment 34 by bugdroid1@chromium.org, Dec 11

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/98ea933514779a84a747a2fa4dd8c280d602b7c1

commit 98ea933514779a84a747a2fa4dd8c280d602b7c1
Author: Aiden Benner <abenner@google.com>
Date: Tue Dec 11 18:01:24 2018

JNI: Mockable JNI refactor tool

Adds script for refactoring non-static native methods
to static native methods using @JCaller and for refactoring
static native methods that to use mockable natives.

Bug:  898261 
Change-Id: I5188a99c55bba028c375a9bf43d029a2c6752b08
Reviewed-on: https://chromium-review.googlesource.com/c/1361782
Commit-Queue: Aiden Benner <abenner@google.com>
Reviewed-by: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615580}
[add] https://crrev.com/98ea933514779a84a747a2fa4dd8c280d602b7c1/base/android/jni_generator/jni_refactorer.py

Comment 35 by bugdroid1@chromium.org, Dec 12

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/97395ba755411e497499c1ca7122cc251b3757b0

commit 97395ba755411e497499c1ca7122cc251b3757b0
Author: agrieve <agrieve@chromium.org>
Date: Wed Dec 12 20:06:54 2018

Update JNI Generator docs to mention JCaller.

Bug:  898261 
Change-Id: Idc5d040a535be7b03b326ed30a902166b63d9b48
Reviewed-on: https://chromium-review.googlesource.com/c/1374138
Commit-Queue: agrieve <agrieve@chromium.org>
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#616009}
[modify] https://crrev.com/97395ba755411e497499c1ca7122cc251b3757b0/base/android/jni_generator/README.md

Comment 36 by bugdroid1@chromium.org, Dec 19

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/ad57a9e02ae2ab3f0a4723e6b26190fda4aaeb13

commit ad57a9e02ae2ab3f0a4723e6b26190fda4aaeb13
Author: Andrew Grieve <agrieve@chromium.org>
Date: Wed Dec 19 04:09:53 2018

Android: Add explicit GN arg to control JNI generator class name

use_hashed_jni_names = !is_java_debug

Cronet needs to have this so that they can build native lib in debug,
but use the release version of java code.

Bug:  898261 
Change-Id: Ic554feacb2f6426a611cfad08dc1e14554e30c80
Reviewed-on: https://chromium-review.googlesource.com/c/1383122
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Commit-Queue: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#617722}
[modify] https://crrev.com/ad57a9e02ae2ab3f0a4723e6b26190fda4aaeb13/base/android/jni_generator/BUILD.gn
[modify] https://crrev.com/ad57a9e02ae2ab3f0a4723e6b26190fda4aaeb13/base/android/jni_generator/ProcessorArgs.template
[modify] https://crrev.com/ad57a9e02ae2ab3f0a4723e6b26190fda4aaeb13/base/android/jni_generator/java/src/org/chromium/jni_generator/JniProcessor.java
[modify] https://crrev.com/ad57a9e02ae2ab3f0a4723e6b26190fda4aaeb13/build/config/android/config.gni
[modify] https://crrev.com/ad57a9e02ae2ab3f0a4723e6b26190fda4aaeb13/build/config/android/rules.gni

Comment 37 by bugdroid1@chromium.org, Dec 19

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e1625b15959c99568c62612bfed58e6072758d99

commit e1625b15959c99568c62612bfed58e6072758d99
Author: Paul Jensen <pauljensen@chromium.org>
Date: Wed Dec 19 20:34:10 2018

Replace an addition use of !is_java_debug with use_hashed_jni_names

I think this was missed in crrev.com/617722.

Bug:  898261 
Change-Id: Ia1ffca4fadbbe0816f161a1cbbd4e8b5c43c9497
Reviewed-on: https://chromium-review.googlesource.com/c/1384631
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Commit-Queue: Paul Jensen <pauljensen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#617935}
[modify] https://crrev.com/e1625b15959c99568c62612bfed58e6072758d99/build/config/android/rules.gni

Comment 38 by estevenson@chromium.org, Feb 7

Blocking: 929661

Comment 39 by estevenson@chromium.org, Feb 7

Blocking: 929682

Comment 40 by estevenson@chromium.org, Feb 7

Status: Fixed (was: Assigned)

Sign in to add a comment