Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Merge pull request #60 from rakuco/backport-jdk7-commits
Browse files Browse the repository at this point in the history
JDK7-related fixes.



I've been trying to build Crosswalk for Android using JDK7, as these days it
looks like downloading JDK6 from Oracle's website requires an oracle.com
account.

The two patches in this series bring in some commits in Chromium trunk that
have not been backported to branches yet that fix the build with JDK7.
  • Loading branch information
Raphael Kubo da Costa committed Sep 6, 2013
2 parents 30efd9a + 77531e5 commit d845fd7
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 3 deletions.
3 changes: 3 additions & 0 deletions base/android/jni_generator/jni_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@ def __init__(self, contents, namespace):
'.*?(class|interface) (?P<class_name>.*?)( |{)',
contents[1]).group('class_name')
self.fully_qualified_class = self.fully_qualified_class.replace('.', '/')
# Java 7's javap includes type parameters in output, like HashSet<T>. Strip
# away the <...> and use the raw class name that Java 6 would've given us.
self.fully_qualified_class = self.fully_qualified_class.split('<', 1)[0]
JniParams.SetFullyQualifiedClass(self.fully_qualified_class)
self.java_class_name = self.fully_qualified_class.split('/')[-1]
if not self.namespace:
Expand Down
79 changes: 79 additions & 0 deletions base/android/jni_generator/jni_generator_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1566,6 +1566,85 @@ def testMethodNameMangling(self):
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
Expand Down
4 changes: 1 addition & 3 deletions build/android/gyp/jar_toc.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ def GetClassesInZipFile(zip_file):
def CallJavap(classpath, classes):
javap_cmd = [
'javap',
'-public',
'-protected',
'-protected', # In reality both public & protected.
# -verbose is required to get constant values (which can be inlined in
# dependents).
'-verbose',
Expand Down Expand Up @@ -109,4 +108,3 @@ def main(argv):

if __name__ == '__main__':
sys.exit(main(sys.argv))

0 comments on commit d845fd7

Please sign in to comment.