mobile/android/base/mozglue/generatorannotations/WrapElementForJNI.java

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mobile/android/base/mozglue/generatorannotations/WrapElementForJNI.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,47 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +package org.mozilla.gecko.mozglue.generatorannotations;
     1.9 +
    1.10 +import java.lang.annotation.Retention;
    1.11 +import java.lang.annotation.RetentionPolicy;
    1.12 +
    1.13 +/**
    1.14 + * This annotation is used to tag methods that are to have wrapper methods generated in the android
    1.15 + * bridge. Such methods will be protected from destruction by Proguard, and allow us to avoid writing
    1.16 + * by hand large amounts of boring boilerplate.
    1.17 + * An annotated Java method will have a corresponding method generated in the android bridge.
    1.18 + * By default, the name of the generated method will be the same as the name of the Java method, with
    1.19 + * the first letter in upper case. The stubName property may be used to specify a custom name for the
    1.20 + * generated method stub.
    1.21 + *
    1.22 + * allowMultithreaded should be used as sparingly as possible - the resulting code will allow the
    1.23 + * Java method to be invoked from the C side from multiple threads. Often, this isn't what is wanted
    1.24 + * and may lead to subtle bugs.
    1.25 + */
    1.26 +@Retention(RetentionPolicy.RUNTIME)
    1.27 +public @interface WrapElementForJNI {
    1.28 +    // Optional parameter specifying the name of the generated method stub. If omitted, the name
    1.29 +    // of the Java method will be used.
    1.30 +    String stubName() default "";
    1.31 +
    1.32 +    // Optional parameter specifying if the generated method should be a static member of AndroidBridge
    1.33 +    // By default, an instance member is produced. This is almost always what is wanted.
    1.34 +    boolean generateStatic() default false;
    1.35 +
    1.36 +    /**
    1.37 +     * If set, the generated method stub will support being called from any thread via the use of
    1.38 +     * GetJNIForThread. This is rarely useful, at time of writing, as well as possibly risky.
    1.39 +     * See information in AndroidBridge.cpp regarding GetJNIForThread.
    1.40 +     *
    1.41 +     * Did I mention use of this function is discouraged?
    1.42 +     */
    1.43 +    boolean allowMultithread() default false;
    1.44 +
    1.45 +    /**
    1.46 +     * If set, the generated stub will not handle uncaught exceptions.
    1.47 +     * Any exception must be handled or cleared by the code calling the stub.
    1.48 +     */
    1.49 +    boolean noThrow() default false;
    1.50 +}

mercurial