diff options
Diffstat (limited to 'base/android/java/src/org/chromium/base/JNIUtils.java')
-rw-r--r-- | base/android/java/src/org/chromium/base/JNIUtils.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/base/android/java/src/org/chromium/base/JNIUtils.java b/base/android/java/src/org/chromium/base/JNIUtils.java new file mode 100644 index 0000000000..3fcec91316 --- /dev/null +++ b/base/android/java/src/org/chromium/base/JNIUtils.java @@ -0,0 +1,46 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.base; + +import org.chromium.base.annotations.CalledByNative; +import org.chromium.base.annotations.MainDex; + +/** + * This class provides JNI-related methods to the native library. + */ +@MainDex +public class JNIUtils { + private static Boolean sSelectiveJniRegistrationEnabled; + + /** + * This returns a ClassLoader that is capable of loading Chromium Java code. Such a ClassLoader + * is needed for the few cases where the JNI mechanism is unable to automatically determine the + * appropriate ClassLoader instance. + */ + @CalledByNative + public static Object getClassLoader() { + return JNIUtils.class.getClassLoader(); + } + + /** + * @return whether or not the current process supports selective JNI registration. + */ + @CalledByNative + public static boolean isSelectiveJniRegistrationEnabled() { + if (sSelectiveJniRegistrationEnabled == null) { + sSelectiveJniRegistrationEnabled = false; + } + return sSelectiveJniRegistrationEnabled; + } + + /** + * Allow this process to selectively perform JNI registration. This must be called before + * loading native libraries or it will have no effect. + */ + public static void enableSelectiveJniRegistration() { + assert sSelectiveJniRegistrationEnabled == null; + sSelectiveJniRegistrationEnabled = true; + } +} |