diff options
author | bulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-02 16:23:35 +0000 |
---|---|---|
committer | bulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-02 16:23:35 +0000 |
commit | f24cf72db9f4f5eecffed8ef2659214890e8fac0 (patch) | |
tree | 051423dd63296670e87cf9a03088d3ef3d467308 /base/android | |
parent | 842372ee45318357a553cd8428dc120e83f54b90 (diff) | |
download | chromium_src-f24cf72db9f4f5eecffed8ef2659214890e8fac0.zip chromium_src-f24cf72db9f4f5eecffed8ef2659214890e8fac0.tar.gz chromium_src-f24cf72db9f4f5eecffed8ef2659214890e8fac0.tar.bz2 |
Android JNI generator: raises an error when there are no JNI methods.
Minor sanity check to avoid parsing files without JNI methods.
BUG=
TEST=testRaisesOnNonJNIMethod
Review URL: https://chromiumcodereview.appspot.com/10636049
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145150 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/android')
-rwxr-xr-x | base/android/jni_generator/jni_generator.py | 3 | ||||
-rwxr-xr-x | base/android/jni_generator/jni_generator_tests.py | 11 |
2 files changed, 14 insertions, 0 deletions
diff --git a/base/android/jni_generator/jni_generator.py b/base/android/jni_generator/jni_generator.py index 131d7ee..5da57ae 100755 --- a/base/android/jni_generator/jni_generator.py +++ b/base/android/jni_generator/jni_generator.py @@ -443,6 +443,9 @@ class JNIFromJavaSource(object): jni_namespace = ExtractJNINamespace(contents) natives = ExtractNatives(contents) called_by_natives = ExtractCalledByNatives(contents) + if len(natives) == 0 and len(called_by_natives) == 0: + raise SyntaxError('Unable to find any JNI methods for %s.' % + fully_qualified_class) inl_header_file_generator = InlHeaderFileGenerator( jni_namespace, fully_qualified_class, natives, called_by_natives) self.content = inl_header_file_generator.GetContent() diff --git a/base/android/jni_generator/jni_generator_tests.py b/base/android/jni_generator/jni_generator_tests.py index aa820c5..f0f68f9 100755 --- a/base/android/jni_generator/jni_generator_tests.py +++ b/base/android/jni_generator/jni_generator_tests.py @@ -1470,6 +1470,17 @@ static bool RegisterNativesImpl(JNIEnv* env) { jni_generator.JNIFromJavaSource, test_data, 'foo/bar') + def testRaisesOnNonJNIMethod(self): + test_data = """ + class MyInnerClass { + private int Foo(int p0) { + } + } + """ + self.assertRaises(SyntaxError, + jni_generator.JNIFromJavaSource, + test_data, 'foo/bar') + def testJniSelfDocumentingExample(self): script_dir = os.path.dirname(sys.argv[0]) content = file(os.path.join(script_dir, 'SampleForTests.java')).read() |