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

Unified Diff: base/android/jni_generator/jni_generator_tests.py

Issue 23587011: Fix building with Java 7 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Linewrap test case Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/android/jni_generator/jni_generator.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/jni_generator/jni_generator_tests.py
diff --git a/base/android/jni_generator/jni_generator_tests.py b/base/android/jni_generator/jni_generator_tests.py
index f008f394cec95c87d4c6ab5df9ecd036f09504ab..3ce58f1d95a6cde7b26010edad2a9a9b5fce6408 100755
--- a/base/android/jni_generator/jni_generator_tests.py
+++ b/base/android/jni_generator/jni_generator_tests.py
@@ -1566,6 +1566,85 @@ import org.chromium.base.BuildInfo;
datatype='java/lang/String'),],
'java/io/InputStream'))
+ def testFromJavaPGenerics(self):
+ contents = """
+public abstract class java.util.HashSet<T> extends java.util.AbstractSet<E>
+ implements java.util.Set<E>, java.lang.Cloneable, java.io.Serializable {
+ public void dummy();
+}
+"""
+ jni_from_javap = jni_generator.JNIFromJavaP(contents.split('\n'), None)
+ self.assertEquals(1, len(jni_from_javap.called_by_natives))
+ golden_content = """\
+// Copyright (c) 2012 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.
+
+// This file is autogenerated by
+// base/android/jni_generator/jni_generator_tests.py
+// For
+// java/util/HashSet
+
+#ifndef java_util_HashSet_JNI
+#define java_util_HashSet_JNI
+
+#include <jni.h>
+
+#include "base/android/jni_android.h"
+#include "base/android/scoped_java_ref.h"
+#include "base/basictypes.h"
+#include "base/logging.h"
+
+using base::android::ScopedJavaLocalRef;
+
+// Step 1: forward declarations.
+namespace {
+const char kHashSetClassPath[] = "java/util/HashSet";
+// Leaking this jclass as we cannot use LazyInstance from some threads.
+jclass g_HashSet_clazz = NULL;
+} // namespace
+
+namespace JNI_HashSet {
+
+// Step 2: method stubs.
+
+static base::subtle::AtomicWord g_HashSet_dummy = 0;
+static void Java_HashSet_dummy(JNIEnv* env, jobject obj) __attribute__
+ ((unused));
+static void Java_HashSet_dummy(JNIEnv* env, jobject obj) {
+ /* Must call RegisterNativesImpl() */
+ DCHECK(g_HashSet_clazz);
+ jmethodID method_id =
+ base::android::MethodID::LazyGet<
+ base::android::MethodID::TYPE_INSTANCE>(
+ env, g_HashSet_clazz,
+ "dummy",
+
+"("
+")"
+"V",
+ &g_HashSet_dummy);
+
+ env->CallVoidMethod(obj,
+ method_id);
+ base::android::CheckException(env);
+
+}
+
+// Step 3: RegisterNatives.
+
+static bool RegisterNativesImpl(JNIEnv* env) {
+
+ g_HashSet_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
+ base::android::GetClass(env, kHashSetClassPath).obj()));
+ return true;
+}
+} // namespace JNI_HashSet
+
+#endif // java_util_HashSet_JNI
+"""
+ self.assertTextEquals(golden_content, jni_from_javap.GetContent())
+
def testFromJavaP(self):
contents = """
public abstract class java.io.InputStream extends java.lang.Object
« no previous file with comments | « base/android/jni_generator/jni_generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698