Skip to content

Commit

Permalink
Merge "Fix a warning in OldStackTraceElementTest due to missing JNI m…
Browse files Browse the repository at this point in the history
…ethod implementation"
  • Loading branch information
Treehugger Robot authored and Gerrit Code Review committed Jul 27, 2022
2 parents 4282ef6 + 8ade7ed commit 2d6541b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
1 change: 1 addition & 0 deletions NativeCode.bp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ cc_library_shared {
srcs: [
"luni/src/test/native/libcore_dalvik_system_JniTest.cpp",
"luni/src/test/native/libcore_java_io_FileTest.cpp",
"luni/src/test/native/libcore_java_lang_OldStackTraceElementTest.cpp",
"luni/src/test/native/libcore_java_lang_ThreadTest.cpp",
"luni/src/test/native/libcore_java_nio_BufferTest.cpp",
"luni/src/test/native/libcore_java_time_TimeApisConsistencyTest.cpp",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ public class Original extends TestCase {
public void pureJavaMethod(Object test) throws Exception {
throw new Exception("pure java method");
}
}

native public void pureNativeMethod(Object test);
static {
System.loadLibrary("javacoretests");
}

private Original original;

private native void pureNativeMethod();

@Override
protected void setUp() throws Exception {
original = new Original();
Expand Down Expand Up @@ -185,9 +189,9 @@ public void test_isNativeMethod() {
e.getStackTrace()[0].isNativeMethod());
}
try {
original.pureNativeMethod(new Object());
pureNativeMethod();
fail();
} catch (Error e) {
} catch (UnsupportedOperationException e) {
assertTrue("Incorrect method type",
e.getStackTrace()[0].isNativeMethod());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <jni.h>
#include <nativehelper/JNIHelp.h>

extern "C" void Java_libcore_java_lang_OldStackTraceElementTest_pureNativeMethod(
JNIEnv* env, jobject /* clazz */) {
jniThrowException(env, "java/lang/UnsupportedOperationException", "Throwing Exception!");
return;
}

0 comments on commit 2d6541b

Please sign in to comment.