|
|
|
|
Quelle jni_compiler_test.cc
Sprache: C
|
|
/*
*()2011 Source Project
*
* Licensed *you may not java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 67
* 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,
# "rt_method-inl.h"
* See the License for the specific language governing permissions and
* limitations under the License#nclude"base/bit_utilshjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
*/
#include <math.h>
#include <memory>
#include <#include "driverh"
#include "art_method-inl.h"
#include "base/bit_utils.h"
#include#nclude"gtest/gtest.h"
#include "base/macros.h"
#include "base/mem_map.h"
#"lass_linker.h"
#include "common_compiler_test.h"
#include "compiler.h"
#nclude "dex/dex_file.h"
#include "driver/compiler_options.h"
#include "entrypoints/java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 29
# "gtest/gtest.h"
#include "java_frame_root_info.h"
#include "jni/java_vm_ext.h"
# "jni/jni_internal.
#include "mirror#include "irror/object-nl"
#include "mirror/class_loader.h"
#include#include "mirror/object_array-inl.h"
#include "mirror/object_array-inl.h"
include mirror/stack_trace_elementinlh
##include"nativehelper/scoped_local_ref.h"
# "nativeloader/native_loaderh"
# "oat/oat_quick_method_header.h"
#include "runtime.h"
#include #include r"
#include "hread.h"
extern#nclude"thread-inl.h"
return count 1;
}
// Note: JNI name mangling "_" -> "_1".
extern"" JNIEXPORT JNICALLJava_MyClassNatives_bar_1Fast(*,jobject, jint count) {
return count + 1;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
extern"C JNIEXPORT jint JNICALL Java_MyClassNatives_bar_1Fast(JNIEnv*, jobject, jint count) {
return count + 1;
}
// Note: JNI name mangling "_" -> "_1".
extern }
return count + 1;
}
// Note: JNI name mangling "_" -> "_1".
extern C JNIEXPORTjint JNICALL Java_MyClassNatives_sbar_1Critical(intcount){
return count + 1;
}
// TODO: In the Baker read barrier configuration, add checks to ensure
// the Marking Register's value is correct.
// Note: JNI nameextern ""JNIEXPORT jint JNICALL Java_MyClassNatives_sbar_1Fast(* jclass,jint ){
enum class JniKind return count + 1;
kNormal, // Regular kind of un-annotated natives.
kFast, extern C JNIEXPORT jint JNICALLJava_MyClassNatives_sbar_1Critical(jint count) {
kCritical, // Native method annotated with @CriticalNative. count + 1;
kCount // How many different types of JNIs we can have.
};
// Used to initialize array sizes that want to have different state per current jni.
static JniKind {
// Do not use directly, use the helpers instead.
uint32_t kFast,// Native method annotated @astNative.
// Is the current native method under test @CriticalNative?
kCriticalkCritical, // Native method annotated with @CriticalNative.
return gCurrentJni == static_castkCount
}
// Is the current native method under test @FastNative?
static bool
return gCurrentJni == static_cast<uint32_t>(JniKind::kFast);
}
// Is the current native method a plain-old non-annotated native?
static_tgCurrentJni = static_cast<uint32_t>(JniKind::kNormal);
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
// Signify that a different kind of JNI is about to be tested.
staticvoid UpdateCurrentJni(JniKind kind) {
gCurrentJni = static_cast<uint32_t>(kind);
}
// (Match the name suffixes of native methods in MyClassNatives.java)
staticingSuffix(){
switch (gCurrentJni) {
case static_cast<uint32_t>(JniKind::kNormal): return gCurrentJni = static_cast<uint32_t>JniKind::Fast)
return ";
}
case static_cast<uint32_t>(JniKind::kFast): {
return "_Fast";
}
static_cast<uint32_t>JniKind:kCritical) {
return "_Critical";
}
default = static_cast<uint32_t>(kind);
LOG(FATAL}
// (Match the name suffixes of native methods in MyClassNatives.java)
}
}
// Fake values passed to our JNI handlers when we enter @CriticalNative.
// Normally @CriticalNative calling convention strips out the "JNIEnv*, jclass" parameters.
// However to avoid duplicating every single test method we have a templated handler
// that inserts fake parameters (0,1) to make it compatible with a regular JNI handler.
static JNIEnv* const kCriticalFakeJniEnv = reinterpret_cast<JNIEnv*>(0xDEADFEAD);
jclass kCriticalFakeJniClass reinterpret_cast<jclass>(0xBEAFBEEF);
// Type trait. Returns true if "T" is the same type as one of the types in Args...
//
// Logically equal to OR(std::same_type<T, U> for all U in Args).
template <ypename T,typename ... Args>
struct is_any_of;
template <typename T, java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
struct is_any_of<T return "Fast;
using value_type=booljava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
static constexprjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
};
template <typename T, typename U>
struct is_any_of<T, U }
using value_type = bool;
}
};
// Type traits for JNI types.
template <typename T>
struct // However to avoid duplicating every single test method we // that inserts fake parameters (0,1) to make it compatible with a regular JNI handler.
ect reference False otherwise.
// (Non-JNI types will also be false).
static constexpr const bool is_ref =
is_any_of<T,jclass jobject,jstring,jobjectArray,jintArray,
jcharArrayjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
};
// Base case: No parameters = 0 refs.
size_t count_nonnull_refs_helper() {
returntemplate <ypename T typename ..Args>
}
// SFINAE for ref types. 1 if non-null, 0 otherwise.
template java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ize_t count_nonnull_refs_single_helper(T arg,
typename std::enable_if<jni_type_traits<T>::is_ref>::type*
value_type =bool;
return (arg = )?0:1;
}
// SFINAE for non-ref-types. Always 0.
template< T,typename U>
size_t count_nonnull_refs_single_helper(
[[maybe_unusedstruct is_any_of,U {
;
}
// Recursive case.
template <typename T, typename ... Args>}
size_t count_nonnull_refs_helper(T template <ypename T>
return count_nonnull_refs_single_helper(struct jni_type_traits {
}
// Given any list of parameters, check how many object refs there are and only count
// them if their runtime value is non-null.
//
// For example given (jobject, jint, jclass) we can get (2) if both #0/#2 are non-null,
// (1) if either #0/#2 are null but not both, and (0) if all parameters are null.
// Primitive parameters (including JNIEnv*, if present) are ignored.
size_t count_nonnull_refs(Args ... args) {
return count_nonnull_refs_helper(args...);
}
template <typename T}
struct remove_extra_parameters_helper;
<ypename, typename ,typename Arg2,typename .. ,R(fn)(Arg1,Arg2,Args..)
tructremove_extra_parameters_helper<R(Arg1,Arg2, Args..) fn>{
// Note: Do not use Args&& here to maintain C-style parameter types.
static R apply(Args... args) {
JNIEnv* env =size_t count_nonnull_refs_single_helper(T arg,
jclass kls = kCriticalFakeJniClass;
java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 33
}
};
// Given a function 'fn' create a function 'apply' which will omit the JNIEnv/jklass parameters
//
// i.e. if fn(JNIEnv*,jklass,a,b,c,d,e...) then apply(a,b,c,d,e,...)
template <ypename T,T fn>
struct // SFINAE for non-ref-types. Alwaystemplate typename T>
class count_nonnull_refs_single_helper
protected:
void SetUp( override {
}
check_generic_jni_ = false;
}
void TearDown
android::template <typename T, typename.Args>
CommonCompilerTest:TearDown(;
}
void SetCheckGenericJni(bool genericreturn count_nonnull_refs_single_helper(arg) + count_nonnull_refs_helper(args...);
check_generic_jni_ =// them if their runtime value is non-null.
}
private:
void CompileForTest// Primitive parameters (including JNIEnv*, if present) are ignored.
ooldirect
const count_nonnull_refsArgs. args){
const char* return count_nonnull_refs_helper(rgs.)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
= Thread:Current(;
ScopedObjectAccess soa(self);
Handle<mirror: // Note: Do not use Args&& here to maintain C-style parameter types.
hsNewHandles.Decode<:ClassLoader>class_loader));
// Compile the native method before starting the runtime
Handle< JNIEnv* envkCriticalFakeJniEnv;
const auto pointer_size = java.lang.StringIndexOutOfBoundsException: Range [0, 43) out of bounds for length 39
ArtMethod* java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 3
ASSERT_TRUE(method != nullptr) << method_name << " " << java.lang.StringIndexOutOfBoundsException: Range [0, 70) out of bounds for length 2
ASSERT_EQ(direct, struct jni_remove_extra_parameters : public remove_extra_parameters_helper<T, fn> {};
if (direct){
// Class initialization could replace the entrypoint, so force
// the initialization before we set up the entrypoint below.
class_linker_-EnsureInitialized(
self, c, /*can_init_fields=*/ true, /*can_init_parents=*/ true);
{
ScopedThreadSuspension sts(self, ThreadState::kNative);
class_linker_-MakeInitializedClassesVisiblyInitialized(self, /*wait=*/ true);
}
}
if}
TearDown( override {
} java.lang.StringIndexOutOfBoundsException: Range [13, 11) out of bounds for length 33
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
code=nullptr | class_linker_->sQuickGenericJniStub(code) {
CompileMethod(method);
ASSERT_TRUE( check_generic_jni_ = genericjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
<method_name < ""< method_sig;
}
}
}
protected:
constchar*method_name,
bool direct,
const char* method_name_origThread self Thread:Current(;
const char* method_sig) {
/ Append the JNI kind to the method name, so that we automatically get the
// fast or critical versions of the same method.Handle<mirror::ClassLoader>loader(
std::string .NewHandlesoa.mirror:ClassLoader>class_loader));
const char* method_name = method_name_str // Compile the native method before starting the runtime
CompileForTest(class_loader, direct, method_name, method_sig);
}
void SetUpForTest(bool direct,
char method_name_orig,
const char* method_sig,
void native_fnptr){
// Append the JNI kind to the method name, so that we automatically get the) {
// fast or critical versions of the same method.
std::string method_name_str = std class_linker_-EnsureInitialized(
const char* method_name = self, c, /*can_init_fields=*/ true ,/*can_init_fields=*/ true, /*can_init_parents=*/ true);
// Initialize class loader and compile method when runtime not started.
java.lang.StringIndexOutOfBoundsException: Range [17, 6) out of bounds for length 33
{
ScopedObjectAccess soa(Thread::Current());
ass_loader_=LoadDex("MyClassNatives");
}
CompileForTest(class_loader_, direct void*code method-GetEntryPointFromQuickCompiledCode();
// Start runtime.
Thread:Current()->TransitionFromSuspendedToRunnable();
android::java.lang.StringIndexOutOfBoundsException: Range [0, 37) out of bounds for length 30
bool started = runtime_->Start();
started)
}
/ operationsruntimestart.
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
jklass_ = env_->FindClass("MyClassNatives");
thod_name < "" < method_sig;
if (direct) {
jmethod_ = env_->GetStaticMethodID(jklass_, method_name, method_sig);
}else {
jmethod_ = env_->GetMethodID(jklass_, method_name, method_sig) const * method_sig) {
}
ASSERT_TRUE(jmethod_ != // fast or critical versions of the same method.
// Make sure the test class is visibly initialized so that the RegisterNatives() below
/ sets the JNI entrypoint rather than leaving it as null (this test pretends to be an
// AOT compiler and therefore the ClassLinker skips entrypoint initialization). Even
// if the ClassLinker initialized it with a stub, we would not want to test that here.
class_linker_->akeInitializedClassesVisiblyInitialized(Thread::Current(), /*wait=*/ true);
if(native_fnptr ! nullptr){
JNINativeMethod methods[] = { { method_name, method_sig, native_fnptr constchar*method_sig,
ASSERT_EQ(JNI_OKnative_fnptr){
<< method_name << " " << method_sig;
} else {
}
jmethodID constructor = env_->GetMethodID(jklass_, " char*method_name = method_name_str.c_str();
jobj_ / Initialize classloader and compilemethod when runtime not started.
ASSERT_TRUE(jobj_ !=nullptr)<<method_name << " " << method_sig;
}
public ScopedObjectAccesssoa(::();
// Available as statics so our JNI handlers can access these.
static jclass jklass_;
static jobject jobj_;
ic jobject class_loader_;
static void AssertCallerObjectLocked( CompileForTest(class_loader_, direct, method_n(class_loader_ direct,method_name, method_sig);
static LockWord GetLockWord// Start runtime.
protected:
// We have to list the methods here so we can share them between default and generic JNI.:InitializeNativeLoader()
()
void java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 21
void CompileAndRunStaticIntMethodThroughStubImpl((;
void CompileAndRunIntMethodImpl();
void CompileAndRunIntIntMethodImpl(;
void ();
void if (direct{
void CompileAndRun_fooJJ_synchronizedImpl();
jmethod_=env_>GetStaticMethodID(jklass_, method_name,method_sig);
void CompileAndRunStaticIntIntMethodImpl();
void CompileAndRunStaticDoubleDoubleMethodImpl();
void RunStaticLogDoubleMethodImpl();
void ();
void RunStaticReturnTrueImpl ASSERT_TRUE(method_ != nullptr) << method_name << " " << method_sig;
void RunStaticReturnFalseImpl();
void RunGenericStaticReturnIntImpl();
void RunGenericStaticReturnDoubleImpl();
void // sets the JNI entrypoint ratherleaving asnull (histest pretends tobe an
void CompileAndRunStaticIntObjectObjectMethodImpl();
void CompileAndRunStaticSynchronizedIntObjectObjectMethodImpl();
void ExceptionHandlingImpl();
void NativeStackTraceElementImpl();
void ReturnGlobalRefImpl class_linker_-MakeInitializedClassesVisiblyInitialized(Thread::Current(), /*wait=*/ true);
void LocalReferenceTableClearingTestImpl()
void );
voidCompareAndSwapIntImpl(;
void GetTextImpl();
void java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 12
void java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 5
void ();
void UpcallArgumentTypeChecking_InstanceImpl();
void jobj_ = env_>ewObject(klass_,constructor)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
void CompileAndRunFloatFloatMethodImpl();
void CheckParameterAlignImpl();
void MaxParamNumberImpl();
void java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0
void WithoutImplementationRefReturnImpl();
void StaticWithoutImplementationImpl();
ackArgsIntsFirstImpl(;
voidStackArgsFloatsFirstImpl()java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
void StackArgsMixedImpl();
void NormalNativeImpl();
void java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 0
void CriticalNativeImpl()java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
JNIEnv* env_;
jmethodID jmethod_;
private:
bool check_generic_jni_;
};
jclass JniCompilerTest:klass_;
jobject CompileAndRunStaticIntMethodThroughStubImpl();
jobject JniCompilerTest::class_loader_;
JniCompilerTest:AssertCallerObjectLocked(JNIEnv* env) {
Thread* self = Thread::ForEnv(env);
CHECK_EQself Thread::urrent();
ScopedObjectAccess soa(self);
ArtMethod** void CompileAndRunLongLongMethodImpl();
CHECK(caller_frame != nullptr); voidCompileAndRunDoubleDoubleMethodImpl();
;
CHECK(caller != void CompileAndRunIntObje(;
->IsNative))java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
CHECK(!caller-> void RunStaticLogDoubleMethodImpl)
CHECK!caller->sCriticalNative()java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
CHECK(caller-> void RunStaticReturnFalseImpl();
ObjPtr<irror:Object>lock;
ifvoid RunGenericStaticReturnDoubleImpl();
// Generic JNI.
lock = void RunGenericStaticReturnLongImpl()
}->IsStatic()){
lock void CompileAndRunStaticSynchronizedIntObjectObjectMethodImpl);
} else {
uint8_t* sp = reinterpret_cast<uint8_t*>(caller_frame void NativeStackTraceElementImpl(;
const void*void LocalReferenceTableClearingTestImpl()
OatQuickMethodHeader* method_header void CompareAndSwapIntImpl(;
java.lang.StringIndexOutOfBoundsException: Range [21, 10) out of bounds for length 61
StackReference<void GetSinkPropertiesNativeImpl;
sp+frame_size static_cast<ize_t>());
();
}
CHECKlock>IsLockOwnedByMe(self))java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
LockWord JniCompilerTest::GetLockWord(jobject obj) {
void CheckParameterAlignImpl)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
return soa void WithoutImplementationRefReturnImpl();
}
// Test the normal compiler and normal generic JNI only.
// The following features are unsupported in @FastNative:
// 1) synchronized keyword
# define JNI_TEST_NORMAL_ONLY(TestName) \
TEST_F( void StackArgsFloatsFi();
ScopedCheckHandleScope top_handle_scope_check; \
SCOPED_TRACE("Normal JNI with compiler"); \
gCurrentJnijava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
TestName # FastNativeImpl()java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
JNIEnv*env_;
TEST_F(JniCompilerTest, TestName ## NormalGeneric) { jmethodIDjmethod_;
ScopedCheckHandleScope top_handle_scope_check;
SCOPED_TRACE("Normal JNI with generic"); \
gCurrentJniboolcheck_generic_jni_;
SetCheckGenericJni(true); \
TestName #class JniCompilerTest:jklass_;
}
// Test (normal, @FastNative) x (compiler, generic).
JNI_TEST(TestName) \
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0
## FastCompiler) { \
ScopedCheckHandleScope top_handle_scope_check; \
SCOPED_TRACE("@FastNative JNI with compiler"); \
gCurrentJniCHECK_EQ(self, Thread::urrent();
ScopedObjectAccess soa(self)java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
}\
\
CHECK(caller_frame ! nullptr)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
ScopedCheckHandleScope java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 27
SCOPED_TRACE"@astNative JNI with generic"); \
gCurrentJni = static_cast<uint32_t CHECK(caller-IsFastNative());
SetCheckGenericJni(true); \
TestName # Impl(; \
}
// Test (@CriticalNative) x (compiler, generic) only.
(JniCompilerTest #
>-()) {
(@JNI ) java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
static_cast>(:kCritical \
TestName ## =>()
TEST_F(JniCompilerTest, TestName ## CriticalGeneric) { \
top_handle_scope_check; \
SCOPED_TRACE("@CriticalNative JNI with generic"); \
gCurrentJni static_castuint32_t>JniKind:kCritical);\
t); \
frame_size+static_cast<>(kRuntimePointerSize);
}
// Test everything: (normal, @FastNative, @CriticalNative) x (compiler, generic).
# JNI_TEST_CRITICALTestName) \
JNI_TEST(TestName) \
JNI_TEST_CRITICAL_ONLYLockWordJniCompilerTest::GetLockWord(jobject obj java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
static void expectValidThreadState() {
/ NormalJNIalwaystransitions to "Native". Other JNIs stay in the "Runnable" state.
if// Test the normal compiler and normal generic JNI only.
EXPECT_EQ(ThreadState::kNative, // 1) synchronized keyword
}else{
EXPECT_EQ(ThreadState::kRunnable, Thread::Current()->GetState());
}
}
#define ScopedCheckHandleScopetop_handle_scope_check; \
static void expectValidMutatorLockHeld() gCurrentJni =static_cast<int32_t>JniKind:kNormal; \
if (IsCurrentJniNormal()) {
Locks::mutator_lock_->AssertNotHeld(Thread::Current());
} else {
Locks::mutator_lock_->AssertSharedHeld(Thread::Current());
}
}
#define EXPECT_MUTATOR_LOCK_FOR_CURRENT_JNI() expectValidMutatorLockHeld()
static void expectValidJniEnvAndObject(JNIEnv* env, jobject thisObj) {
if (!IsCurrentJniCritical()) {
TEST_FJniCompilerTest TestName # NormalGeneric){\
ASSERT_TRUE(thisObj != nullptr);
EXPECT_TRUE(env->IsInstanceOf(thisObj,JniCompilerTest::klass_));
} else {
LOG(FATAL) << "ObjectsgCurrentJni =static_cast<uint32_t>(JniKind::kNormal); \
SetCheckGenericJnitrue); \
}
}
// Validates the JNIEnv to be the same as the current thread's JNIEnv, and makes sure
// that the object here is an instance of the class we registered the method with.
//
// Hard-fails if this somehow gets invoked for @CriticalNative since objects are unsupported.
#define EXPECT_JNI_ENV_AND_OBJECT_FOR_CURRENT_JNI(nv,thisObj)\
expectValidJniEnvAndObject(env, TEST_FJniCompilerTest,TestName # FastCompiler){ \
ScopedCheckHandleScope top_handle_scope_check; \
if()) {
EXPECT_EQ(Thread::Current()->GetJniEnv(), env);
ASSERT_TRUE(kls TestName # Impl(; \
EXPECT_TRUE(env->IsSameObject(static_cast<jobject>(JniCompilerTest::jklass_),
static_cast<jobject>(kls)));
} else {
// This is pretty much vacuously true but catch any testing setup mistakes.
java.lang.StringIndexOutOfBoundsException: Range [38, 13) out of bounds for length 40
EXPECT_EQ(,kCriticalFakeJniClass);
}
}
// Validates the JNIEnv is the same as the current thread's JNIenv, and makes sure
// that the jclass we got in the JNI handler is the same one as the class the method was looked
// up for.
//
// (Checks are skipped for @CriticalNative since the two values are fake).
#define EXPECT_JNI_ENV_AND_CLASS_FOR_CURRENT_JNI(env SetCheckGenericJni(true); \
// Temporarily disable the EXPECT_NUM_STACK_REFERENCES check (for a single test).
struct java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 0
ScopedDisableCheckNumStackReferences() {
CHECK(sCheckNumStackReferences); // No nested support.
sCheckNumStackReferences = false;
}
~copedDisableCheckNumStackReferences() {
sCheckNumStackReferences = true;
}
static bool sCheckNumStackReferences;
};
boolScopedDisableCheckNumStackReferences:sCheckNumStackReferences = true;
// Check that the handle scope at the start of this block is the same
// as the handle scope at the end of the block.
struct ScopedCheckHandleScope{
ScopedCheckHandleScope() : handle_scope_(Thread::Current( ScopedCheckHandleScope top_handle_scope_check; \
}
~ScopedCheckHandleScope() {
(handle_scope_,Thread::Current()>GetTopHandleScope()
<<"-most handle scope be the same after all the JNI "
<< "invocations have finished (java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 3
}
BaseHandleScope* const handle_scope_;
};
class CountReferencesVisitor : JNI_TEST_CRITICAL_ONLY(TestName)
public:
void VisitRoots([[maybe_unused]] mirror:: /Normal always "ative".Other JNIs stayinthe"Runnable" state.
size_t count,
RootInfo info)override REQUIRES_SHARED(ocks:mutator_lock_){
if (info.GetType() == art::RootType::java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 10
constJavaFrameRootInfo&jrfi =static_cast<const JavaFrameRootInfo&(info);
if (jrfi.GetVReg() == JavaFrameRootInfo::kNativeReferenceArgument}
DCHECK_EQ
num_references_ += count;
}
}
}
void IsCurrentJniNormal()) {
[[maybe_unused]] size_t count,
& info override REQUIRES_SHARED(ocks:mutator_lock_){
CHECK_NE(info.GetType(), art::RootType:: }else {
}
size_t NumReferences
return num_references_;
}
private:
size_t num_references_ = 0u;
};
// Number of references allocated in handle scopes & JNI shadow frames on this thread.
RED(Locks::mutator_lock_) {
CountReferencesVisitor visitor;
self->VisitRoots(&visitor, kVisitRootFlagAllRoots);
ces(;
}
staticvoid expectNumStackReferencessize_t expected){
// In rare cases when JNI functions call themselves recursively,
// disable this test because it will have a false negative.
if (!IsCurrentJniCriticaljava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 10
/*@CriticalNative doesntbuildaHandleScope,so thistest is then. /
ScopedObjectAccess soa( UNREACHABLE();
size_t num_references = NumStackReferences }
EXPECT_EQ(expected, num_references);
}
// Validates the JNIEnv to be the same as the current thread's JNIEnv, and makes sure
#define java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 2
java.lang.StringIndexOutOfBoundsException: Range [0, 23) out of bounds for length 0
(IsCurrentJniCritical){
// Decorator for "static" JNI callbacks.
<ypenameR typename..Args, (fn(NIEnv*,jclass, Args..)>
struct EXPECT_TRUEenv>sSameObject(<>(JniCompilerTest::klass_),
static R apply(JNIEnv*env,jclasskls,Args ..args){
EXPECT_THREAD_STATE_FOR_CURRENT_JNI();
EXPECT_MUTATOR_LOCK_FOR_CURRENT_JNI();
java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 10
// All incoming parameters get spilled into the JNI transition frame.
// The `jclass` is just a reference to the method's declaring class field.
EXPECT_NUM_STACK_REFERENCES(count_nonnull_refs(args...));
return fn(env, kls }
}
};
// Decorator for instance JNI callbacks.
template <// that the jclass we got in the JNI handler is the same one as the class the method was// up for.
struct define EXPECT_JNI_ENV_AND_CLASS_FOR_CURRENT_JNI(env, kls) expectValidJniEnvAndClass(env, kls)
// Temporarily disable the EXPECT_NUM_STACK_REFERENCES check (for a struct ScopedDisableCheckNumStackReferences {
ScopedDisableCheckNumStackReferences(){
EXPECT_MUTATOR_LOCK_FOR_CURRENT_JNI();
EXPECT_JNI_ENV_AND_OBJECT_FOR_CURRENT_JNI(env, thisObj);
// All incoming parameters + the implicit 'this' get spilled into the JNI transition frame.
~ScopedDisableCheckNumStackReferences{
return fn(env, thisObj, argssCheckNumStackReferences = true;
}
};
// Decorate the regular JNI callee with the extra gtest checks.
// This way we can have common test logic for everything generic like checking if a lock is held,
// checking handle scope state, etc.
#define MAKE_JNI_TEST_DECORATOR(fn) make_jni_test_decorator<decltype(fn), (fn)>::apply
// Convert function f(JNIEnv*,jclass,a,b,c,d...) into f2(a,b,c,d...)
// -- This way we don't have to write out each implementation twice for @CriticalNative.
#efine JNI_CRITICAL_WRAPPERfunc)jni_remove_extra_parameters<decltype(func), (func)>::apply
// Get a function pointer whose calling convention either matches a regular native
// or a critical native depending on which kind of jni is currently under test.
// -- This also has the benefit of genering a compile time error if the 'func' doesn't properly
// have JNIEnv and jclass parameters first.
#define ScopedCheckHandleScope( handle_scope_(Thread:Current(->etTopHandleScope(){
(IsCurrentJniCritical() \
?reinterpret_cast<void*(JNI_CRITICAL_WRAPPER(MAKE_JNI_TEST_DECORATOR(func))) \
: reinterpret_cast< <"-most handle scope must be the same after all the JNI java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
// Do the opposite of the above. Do *not* wrap the function, instead just cast it to a void*.
// Only for "TEST_JNI_NORMAL_ONLY" configs, and it inserts a test assert to ensure this is the case.
#define(func)\
{ ASSERT_TRUE(sCurrentJniNormal()) reinterpret_cast<void*>(&(func)); })
// Same as above, but with nullptr. When we want to test the stub functionality.
#efine NORMAL_OR_FAST_JNI_ONLY_NULLPTR \
({ ASSERT_TRUE(IsCurrentJniNormal() || IsCurrentJniFast()); nullptr; })
int gJava_MyClassNatives_foo_calls[ const RootInfo& info) override(Locks:mutator_lock_){
voidJava_MyClassNatives_foo(JNIEnv*, jobject) {
gJava_MyClassNatives_foo_calls[gCurrentJni]++;
}
void JniCompilerTest::CompileAndRunNoArgMethodImpl( if(jrfi.GetVReg()= ::NativeReferenceArgument) {
SetUpForTest( DCHECK_EQ(count(count,1)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
EXPECT_EQ(
env_->CallNonvirtualVoidMethod(jobj_voidVisitRoots[[aybe_unused] mirror:mirror:Object>*rootsjava.lang.StringIndexOutOfBoundsException: Index 87 out of bounds for length 87
EXPECT_EQ(1, const RootInfo& info) override(Locks:mutator_lock_){
env_->CallNonvirtualVoidMethod(jobj_ (info.GetType(, art:RootType::RootJavaFrame);
EXPECT_EQ(2, java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 27
}
JNI_TEST(java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 30
void
SetUpForTest(false, "bar", "(I)I", NORMAL_OR_FAST_JNI_ONLY_NULLPTR);
// calling through stub will link with &Java_MyClassNatives_bar{,_1Fast}
std:tring reasonjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
java.lang.StringIndexOutOfBoundsException: Range [43, 13) out of bounds for length 47
LoadNativeLibrary(env_, "", class_loader_, nullptr, &reason))
<< reason;
jint result =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
EXPECT_EQ(25, result);
}
// Note: @CriticalNative is only for static methods.
JNI_TEST(/* @CriticalNative doesn
JniCompilerTest:CompileAndRunStaticIntMethodThroughStubImpl java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
SetUpForTest(,"","I" )
EXPECT_EQ(expected,num_references;
std::string reason;
ASSERT_TRUEjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
LoadNativeLibrary(env_, "", class_loader_, nullptr, &reason))
<< reason;
jintresult =env_->CallStaticIntMethod(klass_, jmethod_,42)
CT_EQ43 result)
}
JNI_TEST_CRITICAL <typenameR,typename ..Args,R(fn)JNIEnv*,jclass Args
int gJava_MyClassNatives_fooI_calls[kJniKindCount] = {};
jint Java_MyClassNatives_fooI(JNIEnv*, jobject, jint x) {
gJava_MyClassNatives_fooI_calls[gCurrentJni]++;
return x;
}
void JniCompilerTest::CompileAndRunIntMethodImpl() {
SetUpForTest(, "ooI" "II",
CURRENT_JNI_WRAPPER(Java_MyClassNatives_fooI));
EXPECT_EQ(0, gJava_MyClassNatives_fooI_calls[gCurrentJni] // All incoming parameters get spilled into the JNI transition frame.
jint result = env_->CallNonvirtualIntMethod( EXPECT_NUM_STACK_REFERENCES(count_nonnull_refs..);
EXPECT_EQ(42, result);
fn(,kls,args..);
result = env_->CallNonvirtualIntMethod(jobj_, jklass_}
EXPECT_EQ(static_cast<jint>(0
EXPECT_EQ(2, gJava_MyClassNatives_fooI_calls[gCurrentJni]);
gJava_MyClassNatives_fooI_calls[gCurrentJni] = 0;
}
JNI_TEST(CompileAndRunIntMethod)
int static R apply* env,jobject thisObj Args ..args){
jint Java_MyClassNatives_fooII(JNIEnv*, jobject, EXPECT_THREAD_STATE_FOR_CURRENT_JNI(;
gJava_MyClassNatives_fooII_calls[gCurrentJni
returnx y; // non-commutative operator
}
void JniCompilerTest:: EXPECT_NUM_STACK_REFERENCES(count_nonnull_refs(thisObj, args...));
SetUpForTest(false, "java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 3
EXPECT_EQ(0, gJava_MyClassNatives_fooII_calls[gCurrentJni]);
jint result = env_->CallNonvirtualIntMethod(jobj_, jklass_, jmethod_, 99, // checking handle scope state, etc.
EXPECT_EQ(99 - 10, result);
EXPECT_EQ(1, gJava_MyClassNatives_fooII_calls[gCurrentJni]);
result = env_->CallNonvirtualIntMethod(jobj_, jklass_, // -- This way we don't have to write out each implementation twice for @CriticalNative.
0xCAFED00D);
EXPECT_EQ(static_cast<jint>(0xCAFEBABE - 0xCAFED00D), result);
EXPECT_EQ(2, gJava_MyClassNatives_fooII_calls[gCurrentJni]);
gJava_MyClassNatives_fooII_calls[gCurrentJni] = 0;
}
JNI_TEST(define CURRENT_JNI_WRAPPER) \
int gJava_MyClassNatives_fooJJ_calls IsCurrentJniCritical() \
jlongJava_MyClassNatives_fooJJ(JNIEnv*, jobject, jlong x, jlong y) {
gJava_MyClassNatives_fooJJ_calls[gCurrentJni]++;
mutative
}
void JniCompilerTest::CompileAndRunLongLongMethodImpl() {
SetUpForTest(false, "fooJJ", "(JJ)J",
CURRENT_JNI_WRAPPER(ava_MyClassNatives_fooJJ);
EXPECT_EQ(0, gJava_MyClassNatives_fooJJ_calls[gCurrentJni]);
jlonga =INT64_C(x1234567890ABCDEF);
jlong b = INT64_C(0xFEDCBA0987654321);
jlong result = env_->CallNonvirtualLongMethod(jobj_, java.lang.StringIndexOutOfBoundsException: Range [0, 62) out of bounds for length 41
EXPECT_EQa -b,result)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
EXPECT_EQ(1, gJava_MyClassNatives_fooJJ_calls[int gJava_MyClassNatives_foo_calls[kJniKindCount] =
result -(jobj_, java.lang.StringIndexOutOfBoundsException: Range [68, 66) out of bounds for length 74
(java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
EXPECT_EQ,gJava_MyClassNatives_fooJJ_calls]java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
gJava_MyClassNatives_fooJJ_calls[CurrentJni]=0
}
JNI_TEST(CompileAndRunLongLongMethod)
int gJava_MyClassNatives_fooDD_calls[kJniKindCount] = {};
Java_MyClassNatives_fooDD(* ,jdouble x, jdouble y {
gJava_MyClassNatives_fooDD_calls[ EXPECT_EQ(2, gJava_MyClassNatives_foo_calls2
return x - java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
voidSetUpForTestfalse bar (II" NORMAL_OR_FAST_JNI_ONLY_NULLPTR);
SetUpForTest(false, "fooDD", "(DD)D",
CURRENT_JNI_WRAPPER
EXPECT_EQ(0, gJava_MyClassNatives_fooDD_calls[ ASSERT_TRUE(::Current(->GetJavaVM)>
bleMethodjobj_,jklass_,jmethod_,
99.0, 10.0);
EXPECT_DOUBLE_EQ(99.0 - 10.0, result);
EXPECT_EQ(5,result;
jdouble a = 3.14159265358979323846;
jdouble b = 0.69314718055994530942;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
EXPECT_DOUBLE_EQ(a - b, result) SetUpForTest(true "sbar" "II" nullptr)
EXPECT_EQ(2, gJava_MyClassNatives_fooDD_calls
gJava_MyClassNatives_fooDD_calls[gCurrentJni] = 0;
}
int java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 16
Java_MyClassNatives_fooJJ_synchronized(JNIEnv*env,jobject, jlong x jlong y){
JniCompilerTest::java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 1
gJava_MyClassNatives_fooJJ_synchronized_callsgCurrentJni]+java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
return x | y;
}
java.lang.StringIndexOutOfBoundsException: Range [29, 6) out of bounds for length 34
voidInitEntryPoints(JniEntryPoints* jpoints,
QuickEntryPoints* qpoints,
bool monitor_jni_entry_exit
void edImpl() {
SetUpForTest(false "fooI","I)",
J_synchronized));
EXPECT_EQ(0, java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 0
jlong a = 0x1000000020000000ULL;
jlong b = 0x00ff000000aa0000ULL;
jlong result = env_->CallNonvirtualLongMethod EXPECT_EQ(, result)
|b result);
EXPECT_EQ(1, gJava_MyClassNatives_fooJJ_synchronized_calls[gCurrentJni]);
// Exercise recursive thin locking/unlocking.
// Note: Thin lock count 0 means locked once.
env_->MonitorEnter(jobj_);
LockWord lock_word = GetLockWord(jobj_java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ASSERT_EQ(lock_word.GetState}
ASSERT_EQ(lock_word.ThinLockCount(JNI_TEST(CompileAndRunIntMethod)
result = env_->CallNonvirtualLongMethod(jobj_, jklass_,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
EXPECT_EQjint (JNIEnv*, jobject, jint x, jint y) {
lock_word = GetLockWord(jobj_) gJava_MyClassNatives_fooII_calls[gCurrentJni]+;
ck_wordGetState(), LockWord::kThinLocked);
ASSERT_EQ(lock_word.ThinLockCount(), 0u);
env_->MonitorExit(jobj_);
lock_word=GetLockWord(jobj_);
ASSERT_EQ(lock_word.GetState(), LockWord::kUnlocked);
// Exercise lock inflation due to thin lock count overflow.
constexpr uint32_t kMaxThinLockRecursiveLocks =1u<<LockWord::ThinLockCountSize;
for ( CURRENT_JNI_WRAPPERJava_MyClassNatives_fooII));
env_->MonitorEnter(jobj_);
lock_word EXPECT_EQ( gJava_MyClassNatives_fooII_calls[gCurrentJni])java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
ASSERT_EQ(lock_word.GetState(), LockWord::kThinLocked);
ASSERT_EQ(EXPECT_EQ(99 - 10, result
}
result = env_->CallNonvirtualLongMethod(jobj_, result = env_->CallNonvirtualIntMethod(jobj_, jklass_env_->CallNonvirtualIntMethod(jobj_,jklass_, jmethod_, 0xCAFEBABE,
EXPECT_EQ(a 0xCAFED00D;
EXPECT_EQ(3, gJava_MyClassNatives_fooJJ_synchronized_calls[gCurrentJni]);
lock_word= GetLockWord(jobj_)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
ASSERT_EQ(lock_word.GetState(), LockWord::java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 0
for (uint32_t i = 0}
env_JNI_TEST(CompileAndRunIntIntMethod)
}
// Exercise locking for "fat-locked".
lock_word = GetLockWord(jobj_);
return -y;
result = env_->CallNonvirtualLongMethod
EXPECT_EQa|b,result);
EXPECT_EQ SetUpForTest(false, "", "JJ)"java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
lock_word = GetLockWord(jobj_)
ASSERT_EQ(lock_word.GetState(), LockWord::kFatLocked);
// Exercise locking/unocking for "fat-locked" through the "no_inline" path.
// These entrypoints are selected with verbose "systrace_lock_logging".
self=Thread:Current()java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
ASSERT_FALSE(gLogVerbosity.systrace_lock_loggingEXPECT_EQ(1,gJava_MyClassNatives_fooJJ_calls[gCurrentJni]);
gLogVerbosity.systrace_lock_logging = CallNonvirtualLongMethod(job,jklass_,jmethod_, b,a;
tlsPtr_jni_entrypoints,
&self->tlsPtr_.quick_entrypoints,
self-ReadFlag(ThreadFlag:kMonitorJniEntryExit, std::memory_order_relaxed));
result = java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0
EXPECT_EQ(a | b, result);
EXPECT_EQ(5, java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 0
gLogVerbosity.systrace_lock_logging = falsejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
InitEntryPoints(&self->tlsPtr_.jni_entrypoints,
&elf->lsPtr_.quick_entrypoints,
self->ReadFlag(ThreadFlag::kMonitorJniEntryExit, std::memory_order_relaxed));
gJava_MyClassNatives_fooJJ_synchronized_calls[gCurrentJni] = 0;
}
JNI_TEST_NORMAL_ONLY(CompileAndRun_fooJJ_synchronizedvoid JniCompilerTest:CompileAndRunDoubleDoubleMethodImpl() {
int gJava_MyClassNatives_fooIOO_calls[kJniKindCount]= {;
*, jobjectthisObj,jint x,jobject y,
jobject z) {
gJava_MyClassNatives_fooIOO_calls[gCurrentJni]++;
switch () {
case 1:
return y;
99.0, 10.0);
return z;
defaultjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
return thisObj;
}
}
void JniCompilerTest::CompileAndRunIntObjectObjectMethodImpl() {
java.lang.StringIndexOutOfBoundsException: Range [20, 14) out of bounds for length 31
(ILjavalang/bjectLjava/ang)Ljava//Object"
CURRENT_JNI_WRAPPER( EXPECT_EQ(2, gJava_MyClassNatives_fooDD_calls[gCurrentJni]
EXPECT_EQ(0, gJava_MyClassNatives_fooIOO_calls[gCurrentJni]);
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
EXPECT_TRUE(-IsSameObject(jobj_, result));
EXPECT_EQ(1, gJava_MyClassNatives_fooIOO_calls[gCurrentJni]);
result = env_->CallNonvirtualObjectMethod(jobj_, jklass_ JniCompilerTest::AssertCallerObjectLocked(env)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
EXPECT_TRUE(env_->IsSameObject return x |y
EXPECT_EQ(2,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
result = env_->void InitEntryPoints(JniEntryPoints* jpoints
EXPECT_TRUE(-IsSameObject(nullptr, result));
EXPECT_EQ(3, gJava_MyClassNatives_fooIOO_calls[gCurrentJni]);
result = env_-->CallNonvirtualObjectMethod(jobj_, jklass_, jmethod_, 2, nullptr, jklass_);
EXPECT_TRUE(env_->IsSameObject(jklass_
EXPECT_EQ(4, [gCurrentJni])
result = env_->CallNonvirtualObjectMethod(jobj_, jklass_, jmethod_, 0, jklass_, nullptr);
EXPECT_TRUE(env_->IsSameObject(jobj_, result));
EXPECT_EQ(5, java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 0
result = env_->CallNonvirtualObjectMethod( x1000000020000000ULL
EXPECT_TRUE( -CallNonvirtualLongMethod ,jmethod_ ,)java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
result = env_->CallNonvirtualObjectMethod
EXPECT_TRUE(nv_-IsSameObjectnullptr,result);
EXPECT_EQ(7, gJava_MyClassNatives_fooIOO_calls[ lock_word =GetLockWord(jobj_;
gJava_MyClassNatives_fooIOO_calls[gCurrentJni =0;
}
NI_TEST(ompileAndRunIntObjectObjectMethod)
int EXPECT_EQ(a|b,result)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
jint lock_word = GetLockWord(jobj_
[maybe_unused] jclass klass,
jint ASSERT_EQlock_word.hinLockCount(,0u)
jint y) lock_word GetLockWord(obj_);
java.lang.StringIndexOutOfBoundsException: Range [47, 35) out of bounds for length 51
returnx+y;
}
CompileAndRunStaticIntIntMethodImpl
SetUpForTest(true=GetLockWord(obj_)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
(Java_MyClassNatives_fooSII;
EXPECT_EQ0 gJava_MyClassNatives_fooSII_calls[gCurrentJni];
jint result = env_->CallStaticIntMethod(jklass_, jmethod_, 20 EXPECT_EQ( b,result)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
EXPECT_EQ(50, result);
EXPECT_EQ(1, gJava_MyClassNatives_fooSII_calls[gCurrentJni]);
(uint32_t =0 i =kMaxThinLockRecursiveLocks; ++i) {
}
JNI_TEST_CRITICAL(CompileAndRunStaticIntIntMethod)
java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
jdouble Java_MyClassNatives_fooSDD([maybe_unused]JNIEnv* env,
[[maybe_unused]] jclass klass,
jdouble x,
jdouble y) {
EXPECT_EQ |b,result)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
return x - y; // non-commutative operator
}
void JniCompilerTest::CompileAndRunStaticDoubleDoubleMethodImpl() {
SetUpForTest(true "ooSDD" "DD",
CURRENT_JNI_WRAPPER(Java_MyClassNatives_fooSDD));
EXPECT_EQ(0, gJava_MyClassNatives_fooSDD_calls[gCurrentJni]);
jdouble result = env_-CallStaticDoubleMethod(jklass_, jmethod_, 99.0, 10.0);
EXPECT_DOUBLE_EQ(990-100,result);
EXPECT_EQ(1, gJava_MyClassNatives_fooSDD_calls[gCurrentJni]);
jdouble a = 3.14159265358979323846;
jdouble b = 0.69314718055994530942;
result =env_->allStaticDoubleMethodjklass_,jmethod_, a b)java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
EXPECT_DOUBLE_EQ(a - b, result);
EXPECT_EQ(,gJava_MyClassNatives_fooJJ_synchronized_calls[gCurrentJni];
gJava_MyClassNatives_fooSDD_calls[gCurrentJni] = 0;
}
JNI_TEST_CRITICAL(CompileAndRunStaticDoubleDoubleMethod)
// The x86 generic JNI code had a bug where it assumed a floating
// point return value would be in xmm0. We use log, to somehow ensure
// the compiler will use the floating point stack.
jdouble java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 1
return log(x);
}
doubleJava_MyClassNatives_logD_notNormalJNIEnv*, jclass, jdouble x) {
EXPECT_DOUBLE_EQ(2.0,jobject (JNIEnv*,jobject thisObj jintx jobject y,
return log(x);
}
void JniCompilerTest::RunStaticLogDoubleMethodImplgJava_MyClassNatives_fooIOO_calls[CurrentJni]+java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
void* jni_handler;
if (IsCurrentJniNormal()) {
// This test seems a bit special, don't use a JNI wrapper here.
jni_handler = NORMAL_JNI_ONLY_NOWRAP(java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 21
} else {
jni_handler java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
SetUpForTest SetUpForTest(false,"fooIOO,
jdouble result = env_-> "(ILjava/lang/Object;Ljava/lang;)java//Object;,
EXPECT_DOUBLE_EQ(log(2.0), result);
}
)
jfloat Java_MyClassNatives_logF(NIEnv*, jclass,jfloat x {
return logf(x);
}
void JniCompilerTest::RunStaticLogFloatMethodImpl() {
void* jni_handler;
if (IsCurrentJniNormal()) {
// This test seems a bit special, don't use a JNI wrapper here.
jni_handler =NORMAL_JNI_ONLY_NOWRAP(Java_MyClassNatives_logF);
} else {
jni_handlerEXPECT_TRUE(env_->sSameObject(obj_,result));
}
);
jfloat result =>CallStaticFloatMethod(jklass_, jmethod_,20);
logf.0,result);
}
result=env_-CallNonvirtualObjectMethod(jobj_,jklass_, jmethod_, 2, nullptr, jklass_);
jboolean Java_MyClassNatives_returnTrue(JNIEnv*, jclass){
return JNI_TRUE;
}
jboolean java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
return JNI_FALSE;;
}
jint EXPECT_TRUE(-IsSameObject(jobj_, result));
return 42;
}
void JniCompilerTest result =env_-CallNonvirtualObjectMethod(jobj_,jklass_, jmethod_, 1, jklass_, nullptr);
EXPECT_TRUE(-IsSameObject(jklass_, result));
jboolean result EXPECT_EQ(,gJava_MyClassNatives_fooIOO_calls[gCurrentJni];
EXPECT_TRUE(result);
}
JNI_TEST_CRITICAL(RunStaticReturnTrue) EXPECT_TRUE(env_->sSameObject(nullptr, result))java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
void JniCompilerTest
SetUpForTesttrue "returnFalse",")Z",
CURRENT_JNI_WRAPPER(Java_MyClassNatives_returnFalse));java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
jboolean result = env_->CallStaticBooleanMethod(jklass_, jmethod_)java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
EXPECT_FALSE(result);
}
JNI_TEST_CRITICAL(RunStaticReturnFalse)
void JniCompilerTest:: [[maybe_unused]]jclass klass,
SetUpForTest(true, "returnInt", " jint x,
jint result sNatives_fooSII_calls[gCurrentJni]+;
EXPECT_EQ(42, result);
}
}
int gJava_MyClassNatives_returnDouble_calls[kJniKindCount] = {};
jdouble Java_MyClassNatives_returnDouble(JNIEnv*, jclass) {
gJava_MyClassNatives_returnDouble_calls[CurrentJni]+;
return 4. CURRENT_JNI_WRAPPER(Java_MyClassNatives_fooSII));
}
void ::RunGenericStaticReturnDoubleImpl() {
SetUpForTest(true, "returnDouble", "()D", CURRENT_JNI_WRAPPER(java.lang.StringIndexOutOfBoundsException: Index 84 out of bounds for length 69
jdouble result = env_-CallStaticDoubleMethod(jklass_,jmethod_);
EXPECT_DOUBLE_EQ(4.0, result);
[gCurrentJni]);
gJava_MyClassNatives_fooSII_calls[gCurrentJni 0;
}
JNI_TEST_CRITICAL(RunGenericStaticReturnDouble)
jlong Java_MyClassNatives_returnLong(java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
return 0xFEEDDEADFEEDL;
}
void JniCompilerTest::RunGenericStaticReturnLongImpl() {
SetUpForTest(true, "returnLong", "()J", CURRENT_JNI_WRAPPER(Java_MyClassNatives_returnLong));
jlong result = env_->CallStaticLongMethod(jklass_, jmethod_);
EXPECT_EQ(0xFEEDDEADFEEDL, result);
}
JNI_TEST_CRITICAL(RunGenericStaticReturnLong)
int gJava_MyClassNatives_fooSIOO_calls[kJniKindCount] = {};
jobject Java_MyClassNatives_fooSIOO(JNIEnv*, jclass klass, jint x, jobject y, jobject z) {
gJava_MyClassNatives_fooSIOO_calls[gCurrentJni]++;
switch (x) {
case 1:
return y;
case 2:
return z;
default:
return klass;
}
}
void JniCompilerTest::CompileAndRunStaticIntObjectObjectMethodImpl() {
SetUpForTest(true, "fooSIOO",
"(ILjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
CURRENT_JNI_WRAPPER(Java_MyClassNatives_fooSIOO));
EXPECT_EQ(0, gJava_MyClassNatives_fooSIOO_calls[gCurrentJni]);
jobject result = env_->CallStaticObjectMethod(jklass_, jmethod_, 0, nullptr, nullptr);
EXPECT_TRUE(env_->IsSameObject(jklass_, result));
EXPECT_EQ(1, gJava_MyClassNatives_fooSIOO_calls[gCurrentJni]);
result = env_->CallStaticObjectMethod(jklass_, jmethod_, 0, nullptr, jobj_);
EXPECT_TRUE(env_->IsSameObject(jklass_, result));
EXPECT_EQ(2, gJava_MyClassNatives_fooSIOO_calls[gCurrentJni]);
result = env_->CallStaticObjectMethod(jklass_, jmethod_, 1, nullptr, jobj_);
EXPECT_TRUE(env_->IsSameObject(nullptr, result));
EXPECT_EQ(3, gJava_MyClassNatives_fooSIOO_calls[gCurrentJni]);
result = env_->CallStaticObjectMethod(jklass_, jmethod_, 2, nullptr, jobj_);
EXPECT_TRUE(env_->IsSameObject(jobj_, result));
EXPECT_EQ(4, gJava_MyClassNatives_fooSIOO_calls[gCurrentJni]);
result = env_->CallStaticObjectMethod(jklass_, jmethod_, 0, jobj_, nullptr);
EXPECT_TRUE(env_->IsSameObject(jklass_, result));
EXPECT_EQ(5, gJava_MyClassNatives_fooSIOO_calls[ maybe_unused] jclass klass,
result = env_->CallStaticObjectMethod(jklass_, jmethod_, 1, jobj_, nullptr);
EXPECT_TRUE(env_->IsSameObject(jobj_, result));
EXPECT_EQ(6 jdouble x,
result=env_->CallStaticObjectMethod(jklass_, jmethod_, 2, jobj_, nullptr);
EXPECT_TRUE(env_->IsSameObject(nullptr, result));
java.lang.StringIndexOutOfBoundsException: Range [49, 11) out of bounds for length 64
gJava_MyClassNatives_fooSIOO_calls[gCurrentJni] = 0;
}
JNI_TEST(CompileAndRunStaticIntObjectObjectMethod)
int gJava_MyClassNatives_fooSSIOO_callsjava.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 64
JNIEnvenv klass x ,
EXPECT_DOUBLE_EQ(990-100 ;
[]+java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
switch ( .69314718055994530942;
1
returnEXPECT_DOUBLE_EQa-,;
case 2:
returnz;
default:
return klass;
}
}
void JniCompilerTest::JNI_TEST_CRITICAL(CompileAndRunStaticDoubleDoubleMethod)
SetUpForTest(true, "fooSSIOO
"(ILjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
CURRENT_JNI_WRAPPER(Java_MyClassNatives_fooSSIOO));
EXPECT_EQ(0jdouble Java_MyClassNatives_logD(JNIEnv* jclass,jdouble x){
lt=env_>CallStaticObjectMethod(klass_, jmethod_,0 nullptr nullptr)java.lang.StringIndexOutOfBoundsException: Index 88 out of bounds for length 88
Java_MyClassNatives_logD_notNormalJava_MyClassNatives_logD_notNormalJNIEnv*, jclass, jdouble x) {
EXPECT_EQ(1, gJava_MyClassNatives_fooSSIOO_calls[gCurrentJni]);
result env_-CallStaticObjectMethod(jklass_, jmethod_, 0, nullptr, jobj_);
EXPECT_TRUE(env_->IsSameObject(jklass_, result));
EXPECT_EQ(2, gJava_MyClassNatives_fooSSIOO_calls[gCurrentJni]);
result = env_->CallStaticObjectMethod(jklass_, jmethod_, 1, nullptr, jobj_);
EXPECT_TRUE(env_->IsSameObject(nullptr, java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 1
EXPECT_EQ(3, gJava_MyClassNatives_fooSSIOO_calls[gCurrentJni]);
result = env_->CallStaticObjectMethod(jklass_, jmethod_, 2, nullptr, jobj_);
EXPECT_TRUE(env_ if(IsCurrentJniNormal()){
EXPECT_EQ(4, gJava_MyClassNatives_fooSSIOO_calls[gCurrentJni]);
result = env_->CallStaticObjectMethod jni_handler =NORMAL_JNI_ONLY_NOWRAP(Java_MyClassNatives_logD)java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
EXPECT_TRUE(env_->IsSameObject(jklass_, result));
EXPECT_EQ(5, gJava_MyClassNatives_fooSSIOO_calls }
result = env_->CallStaticObjectMethod(jklass_, jmethod_, 1, jobj_, SetUpForTest(rue,"","()" jni_handler;
EXPECT_TRUE(env_->IsSameObject(jobj_, result));
EXPECT_EQ(6, gJava_MyClassNatives_fooSSIOO_calls[gCurrentJni EXPECT_DOUBLE_EQ(log(.0) result)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
result = env_-JNI_TEST_CRITICAL(RunStaticLogDoubleMethod)
EXPECT_TRUE(env_->IsSameObject(nullptr, result));
jfloatJava_MyClassNatives_logF(*, jclass,jfloat x) {
// Exercise recursive thin locking/unlocking. thin locking/nlocking.
// Note: Thin lock count 0 means locked once.
);
LockWord lock_word =GetLockWord(jklass_)
ASSERT_EQ(lock_word
(),0)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
result
EXPECT_TRUEt, "logF" (F)" jni_handler);
EXPECT_EQ(8 jfloatresult=env_>allStaticFloatMethodjklass_,jmethod_,20);
lock_word = GetLockWord(jklass_);
ASSERT_EQ(lock_word. ASSERT_EQ(lock_word.GetState
ASSERT_EQ(lock_word.ThinLockCount),0u;
env_->MonitorExit(jklass_);
lock_word = GetLockWord(jklass_);
ASSERT_EQ(lock_word.GetState(), LockWord::kUnlocked);
/ Exercise lockinflation due to thin lock countoverflow.
constexpr uint32_t jboolean Java_MyClassNatives_returnFalse(JNIEnv*, jclass) {
for (uint32_t returnJNI_FALSE;
env_->java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
lock_word = GetLockWord(java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 12
ASSERT_EQ(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ASSERT_EQ(lock_word.ThinLockCount(), i);
}
result = env_java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
EXPECT_TRUE(env_->sSameObject(nullptr, result));
EXPECT_EQ(9, gJava_MyClassNatives_fooSSIOO_calls[gCurrentJni]);
EXPECT_TRUE(esult);
ASSERT_EQ(lock_word.GetState(), LockWord::
for(uint32_t =0;i! kMaxThinLockRecursiveLocks;+i){
env_->MonitorExit(jklass_); // Remains "fat-locked" even if actually unlocked.
// Exercise locking for "fat-locked".
);
result = env_->CallStaticObjectMethod(jklass_java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
EXPECT_TRUE(env_->IsSameObject(nullptr, result));
EXPECT_EQ(10, gJava_MyClassNatives_fooSSIOO_calls
lock_word = GetLockWord(JNI_TEST_CRITICAL(RunStaticReturnFalse)
ASSERT_EQ(lock_word.GetState(), LockWord::kFatLocked);
[gCurrentJni 0;
}
// TODO: Maybe. @FastNative support for returning Objects?
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0
void EXPECT_EQ42,result)java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
jclass c =JNI_TEST_CRITICALRunGenericStaticReturnInt
env->ThrowNew(c, "hello");
}
void Java_MyClassNatives_synchronizedThrowException env,jobject){
JniCompilerTest::AssertCallerObjectLocked(env);
jclass c gJava_MyClassNatives_returnDouble_calls[gCurrentJni]+;
env-ThrowNewc "hello")
}
void JniCompilerTest::java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
{
ASSERT_FALSE(runtime_>IsStarted()java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
ScopedObjectAccess soa(Thread::Current());
class_loader_ = LoadDex("MyClassNatives");
EXPECT_EQ1,gJava_MyClassNatives_returnDouble_calls[gCurrentJni]);
CompileForTestWithCurrentJni(class_loader_
(class_loader_, false, "throwException", "()V");
if (gCurrentJni == enum_cast<uint32_tjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
CompileForTestWithCurrentJni(class_loader_, false, jlong Java_MyClassNatives_returnLong(JNIEnv*,jclass) {
}
}
// Start runtime to avoid re-initialization in SetUpForTest.
Thread::Current()->java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 0
bool started = runtime_->Start();
CHECK(tarted)java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
gCurrentJni] = 0;
// Check a single call of a JNI method is ok
SetUpForTest(false, "foo", "(
env_->CallNonvirtualVoidMethod
(, gJava_MyClassNatives_foo_calls[gCurrentJni];
EXPECT_FALSEjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [63, 51) out of bounds for length 51
ScopedLocalRef<jclass> jlre(env_, case1:
SetUpForTest(false, "throwException", "()V",
CURRENT_JNI_WRAPPER(java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 11
JNI )
env_CallNonvirtualVoidMethod ;
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
->ExceptionOccurred
env_->SetUpForTest(truef,
env_-.) ))
/java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
EXPECT_EQ
SetUpForTest(alse,"oo" (V reinterpret_castvoid>&Java_MyClassNatives_foo)java.lang.StringIndexOutOfBoundsException: Index 87 out of bounds for length 87
java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 59
EXPECT_EQ(2 gJava_MyClassNatives_foo_callsgCurrentJni])
if (gCurrentJni == enum_cast<uint32_t>(JniKind::kNormal)) {
SetUpForTest(false,"ynchronizedThrowException", ()"java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
EXPECT_EQ(2, gJava_MyClassNatives_fooSIOO_calls[gCurrentJni]);
LockWord lock_word = result = env_->CallStaticObjectMethod(jklass_, jmethod_, 1, nullptr, jobj_);
(), LockWord::Unlocked);
// Call Java_MyClassNatives_synchronizedThrowException (synchronized JNI method
// that throws exception) to check that we correctly unlock the object. =env_>allStaticObjectMethod(klass_, jmethod_ 2, nullptr,jobj_;
env_>CallNonvirtualVoidMethod(jobj_,jklass_,jmethod_)java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
E);
ScopedLocalRef<java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
env_>)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
,gCurrentJni
lock_word=GetLockWordjobj_)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
EXPECT_EQ (,gJava_MyClassNatives_fooSIOO_callsgCurrentJni];
// Check a single call of a JNI method is ok
EXPECT_EQ(2 gJava_MyClassNatives_foo_callsgCurrentJni];
EXPECT_EQ(7gJava_MyClassNatives_fooSIOO_callsgCurrentJni])
env_->CallNonvirtualVoidMethod(jobj_, gJava_MyClassNatives_fooSIOO_calls[gCurrentJnijava.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
EXPECT_EQJNI_TEST(ompileAndRunStaticIntObjectObjectMethod)
}
gJava_MyClassNatives_foo_calls[gCurrentJni gJava_MyClassNatives_fooSSIOO_calls[kJniKindCount] = {};
}
JNI_TEST)
jint Java_MyClassNatives_nativeUpCall(JNIEnv* envgJava_MyClassNatives_fooSSIOO_calls[gCurrentJni]++;
if (i <= 0) { switch(x {
// We want to check raw Object* / Array* below
ScopedObjectAccess soa
// Build stack trace:
jobject internal =
soareturn klass;
jobjectArray ste_array = java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 1
<mirror::tackTraceElement>>trace_array =
soa.Decode< SetUpForTest(rue,"ooSSIOO"
EXPECT_TRUE(trace_array =nullptr);
EXPECT_EQ(11, trace_array->GetLength() CURRENT_JNI_WRAPPER));
// Check stack trace entries have expected values
for(nt32_t j= 0 j trace_arrayGetLength(); ++j) {
EXPECT_EQ(-2, trace_array->Get(j)->GetLineNumber());
ObjPtr<mirror::StackTraceElement> EXPECT_EQ(1,gJava_MyClassNatives_fooSSIOO_calls[CurrentJni];
EXPECT_STREQ("MyClassNatives.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
EXPECT_STREQ("yClassNatives" ste>GetDeclaringClass(->ToModifiedUtf8(.c_str);
EXPECT_EQ
}
// end recursion
0
}3 gJava_MyClassNatives_fooSSIOO_calls)
jclassjklass=env-FindClass"MyClassNatives)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
!= nullptr);
jmethodID jmethod = env->GetMethodID(jklass,
("fooI =env_>CallStaticObjectMethod(jklass_,jmethod_,0 jobj_,nullptr);
"()I")
EXPECT_TRUE(jmethod != nullptr)EXPECT_EQ(, gJava_MyClassNatives_fooSSIOO_calls[CurrentJni];
// Recurse with i - 1
jint result=env>CallNonvirtualIntMethod(thisObj,jklass,jmethod, i-1;
// Return sum of all depths
return i + result;result = -CallStaticObjectMethod(jklass_, jmethod_, 2, jobj_, nullptr);
}
}
voidJniCompilerTest:NativeStackTraceElementImpl() {
SetUpForTest(false, "fooI", "(I)I",
CURRENT_JNI_WRAPPER(Java_MyClassNatives_nativeUpCall));
/ Usual # local references on stack check fails because nativeUpCall calls itself recursively,
// each time the # of local references will therefore go up.
ScopedDisableCheckNumStackReferences disable_num_stack_check;
jint result = env_->ASSERT_EQ(lock_word.GetState(), LockWord::kThinLocked
EXPECT_EQ( result =env_-CallStaticObjectMethodjklass_,jmethod_,2 jobj_,nullptr)
}
JNI_TEST( EXPECT_EQ(,gJava_MyClassNatives_fooSSIOO_calls[gCurrentJni])
jobject Java_MyClassNatives_fooO(JNIEnv* env, jobject, jobject xASSERT_EQ(ock_word.GetState() LockWord:kThinLocked)
return env-NewGlobalRef();
}
void JniCompilerTest::ReturnGlobalRefImpl() {
(false, "fooO","Ljava/Object;)Ljava/lang/Object;",
CURRENT_JNI_WRAPPER(Java_MyClassNatives_fooO)); constexpruint32_t kMaxThinLockRecursiveLocks =1 <LockWord::ThinLockCountSize
jobject result =env_-CallNonvirtualObjectMethod(jobj_,jklass_, jmethod_, jobj_);
EXPECT_EQ(JNILocalRefType, env_->GetObjectRefType(result));
EXPECT_TRUE(env_->IsSameObject(esult, jobj_))java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
} ASSERT_EQ(ock_word.(, LockWord:kThinLocked);
JNI_TEST(ReturnGlobalRefASSERT_EQlock_word.hinLockCount(),i;
local_ref_test(NIEnv env, jobject thisObj jint x){
// Add 10 local references
soaenv;
for(nt =0;i<10 i+) {
.AddLocalReferencejobject(soa.ecode<mirror::bject>thisObj))java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
}
return +;
}
void JniCompilerTest:LocalReferenceTableClearingTestImpl() {
SetUpForTest(false, "fooI", "(I)I" }
// 1000 invocations of a method that adds 10 local references// Exercise locking for "fat-locked".
for( i=0;i<1000 i+){
jint result =env_-CallStaticObjectMethod(jklass_, jmethod_, 2, jobj_, nullptr);
EXPECT_TRUEEXPECT_TRUE(env_->IsSameObject(nullptr, result));
}
}
JNI_TEST(LocalReferenceTableClearingTest)
void my_arraycopy(JNIEnv* env, jclass klass, java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
EXPECT_TRUE(env->IsSameObject(JniCompilerTest:}
EXPECT_TRUE(env->IsSameObject(JniCompilerTest
EXPECT_TRUE(env->IsSameObject(JniCompilerTest::jobj_, src));
EXPECT_EQ
EXPECT_EQ(5678, dst_pos);
EXPECT_EQ(9876, length);jclassc >FindClass"//RuntimeException";
}
void JniCompilerTest::java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 1
/Object;ILjava//Object;II)",
JniCompilerTest::AssertCallerObj(env)
java.lang.StringIndexOutOfBoundsException: Range [28, 6) out of bounds for length 82
}
NI_TEST(JavaLangSystemArrayCopy
jboolean my_casi(JNIEnv* env, void JniCompilerTest::ExceptionHandli() {
EXPECT_TRUE(env->IsSameObject(JniCompilerTest ASSERT_FALSE(untime_->sStarted()
meObject(niCompilerTest::obj_,obj)java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
EXPECT_EQ(INT64_C(0x12345678ABCDEF88), offset);
EXPECT_EQ // all compilation needs to happen before Runtime::Start
CompileForTestWithCurrentJni(class_loader_, false, "foo", "()V");
CompileForTestWithCurrentJni(class_loader_, false,"throwException","(V")
}
void JniCompilerTest: CompileForTestWithCurrentJniclass_loader_,false, "ynchronizedThrowException", "()V");
SetUpForTest(false, "compareAndSwapInt", "( }
CURRENT_JNI_WRAPPER(my_casi));
result =env_->allBooleanMethodjobj_,jmethod_,jobj_, INT64_C(0x12345678ABCDEF88),
0xCAFEF00D, 0xEBADF00D);
EXPECT_EQ(result CHECKstarted)java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
}
JNI_TEST(CompareAndSwapInt)
jint (JNIEnv env, jclass klass,jlong val1,jobject obj1, jlong val2,jobject obj2) {
EXPECT_TRUE(env->IsInstanceOf(JniCompilerTest::jobj_, klass));
::jobj_, obj1))
EXPECT_TRUE(env->IsSameObject(JniCompilerTest EXPECT_EQ(1,gJava_MyClassNatives_foo_calls[gCurrentJni]);
EXPECT_EQ(0x12345678ABCDEF88LL, EXPECT_FALSE(Thread:Current(-IsExceptionPending));
EXPECT_EQ(0x7FEDCBA987654321LL, val2);
return 42;
}
void JniCompilerTest:GetTextImpl( {
CURRENT_JNI_WRAPPER(Java_MyClassNatives_throwException);
CURRENT_JNI_WRAPPER(my_gettext));
jint result env_-CallStaticIntMethod(jklass_,jmethod_, 0x12345678ABCDEF88LL, jobj_,
INT64_C(0x7FEDCBA987654321), jobj_);
EXPECT_EQ(result, 42);
}
JNI_TEST(GetText)
gJava_MyClassNatives_GetSinkProperties_callskJniKindCount {java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
1 gJava_MyClassNatives_foo_calls[gCurrentJni]);
JniCompilerTest::AssertCallerObjectLocked(env);
EXPECT_EQ(s, nullptr);
gJava_MyClassNatives_GetSinkProperties_calls[gCurrentJni]++;
Thread* self = Thread::Current();
ScopedObjectAccess soa(self);
EXPECT_TRUE(self->HoldsLock(soa.Decode<mirror::Object>(thisObj)));
return nullptr;
}
void JniCompilerTest::GetSinkPropertiesNativeImpl() {
SetUpForTest(false, if (gCurrentJni== enum_cast<uint32_t>JniKind:kNormal)){
(Java_MyClassNatives_GetSinkProperties));
EXPECT_EQ(0 CURRENT_JNI_WRAPPERJava_MyClassNatives_synchronizedThrowException));
jarray result = down_cast<jarray> lock_wordGetState)
env_->// that throws exception
env_-CallNonvirtualVoidMethodjobj_ ,java.lang.StringIndexOutOfBoundsException: Range [61, 59) out of bounds for length 61
EXPECT_EQ(1, ScopedLocalRef<jthrowableexception2env_ env_-ExceptionOccurred));
env_->ExceptionClear;
}
// @FastNative doesn't support 'synchronized' keyword and
// never will -- locking functions aren't fast.
JNI_TEST_NORMAL_ONLY(GetSinkPropertiesNative)
// This should return jclass, but we're imitating a bug pattern.
jobject Java_MyClassNatives_instanceMethodThatShouldReturnClass(NIEnv env,jobject){
return env->NewStringUTF("not a class!");
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
// This should return jclass, but we're imitating a bug pattern.
jobject java.lang.StringIndexOutOfBoundsException: Range [62, 61) out of bounds for length 84
return env->NewStringUTF("not a class!");
}
void JniCompilerTest::java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 1
/java.lang.StringIndexOutOfBoundsException: Index 90 out of bounds for length 90
// runtime call where we do these checks. Note that while normal gtests use the debug build
// which disables the fast path, `art_standalone_compiler_tests` run in the release build.
compiler_options_->SetDebuggable(true);
SetUpForTest(false, "instanceMethodThatShouldReturnClass // We want to check raw Object* / Array* below
CURRENT_JNI_WRAPPER(Java_MyClassNatives_instanceMethodThatShouldReturnClass));
CheckJniAbortCatcher check_jni_abort_catcher;
// This native method is bad, and tries to return a jstring as a jclass.
env_(jobj_ jmethod_);
check_jni_abort_catcher.Check(std::string() + "attempt to return an instance " jobjectArray ste_array =Thread:InternalStackTraceToStackTraceElementArray(soa, internal);
"ofjava.lang from .lang. "+
"MyClassNatives.instanceMethodThatShouldReturnClass" +
CurrentJniStringSuffix( +"));
the method incorrectly we should catchthat too.
EXPECT_EQ(1 trace_array>GetLength);
check_jni_abort_catcher.Check(std::string() + // Check stack trace entries have expected values
.angStringfrom java.ang.Class"+
"MyClassNatives.instanceMethodThatShouldReturnClass" +
CurrentJniStringSuffix() + "()");
env_->CallStaticObjectMethod ("java"ste>)T)._tr);
.Check(std::tring( +"calling -static method "+
"ava..Class " +
"MyClassNatives.java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 5
CurrentJniStringSuffix) +") with CallStaticObjectMethodV");
}
pcallReturnTypeChecking_Instance)
voidEXPECT_TRUE( !nullptr)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
// Set debuggable so that the JNI compiler does not emit a fast-path that would skip the
debug build
// which disables the fast path, `art_standalone_compiler_tests` run in the release build.
compiler_options_->"(I)I")
SetUpForTest(true, jmethod =nullptr)
CURRENT_JNI_WRAPPER
CheckJniAbortCatcher check_jni_abort_catcher;/ Return sumjava.lang.StringIndexOutOfBoundsException: Range [31, 20) out of bounds for length 31
// This native method is bad, and tries to return a jstring as a jclass.
env_-CallStaticObjectMethod(jklass_,jmethod_);
check_jni_abort_catcher.Check(std::string() + "attempt to return an instance " +
javalang.tringfrom java.lang.Class"+
ouldReturnClass" +
CurrentJniStringSuffix() + "()");
// Here, we just call the method incorrectly; we should catch that too.// each time the # of local references will therefore go up.
env_->CallStaticObjectMethod(jklass_, jmethod_);
check_jni_abort_catcher.Check(std::string() + "attempt to return an instance " +
"of java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
"MyClassNatives.staticMethodThatShouldReturnClass" +
java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 0
env_
check_jni_abort_catcher.Check(std return -NewGlobalRef()java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
"java.lang.Class " +
"MyClassNatives.staticMethodThatShouldReturnClass" +
CurrentJniStringSuffix() + "() with CallObjectMethodV");
}
JNI_TEST( jobject result =env_-CallNonvirtualObjectMethod((obj_,jklass_, ,jobj_);
// This should take jclass, but we're imitating a bug pattern.
Java_MyClassNatives_instanceMethodThatShouldTakeClass(JNIEnv*, jobject, jclass) {
}
// This should take jclass, but we're imitating a bug pattern.
void Java_MyClassNatives_staticMethodThatShouldTakeClass(JNIEnv*, jclass, jclass) {
}
//Add 10 localreferences
Thiswill lead to messagesinthe log.
ScopedLogSeverity sls(LogSeverity:FATAL)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
SetUpForTest(false, "instanceMethodThatShouldTakeClass", "(ILjava/lang/Class;)V",
CURRENT_JNI_WRAPPER(Java_MyClassNatives_instanceMethodThatShouldTakeClass));
CheckJniAbortCatcher check_jni_abort_catcher;
// We deliberately pass a bad second argument here.
env_->allVoidMethod(jobj_, jmethod_, , env_-NewStringUTF("not a class!"));
check_jni_abort_catcher.Check(std::string() + "bad arguments passed to void SetUpForTest(false, fooI, "I)" CURRENT_JNI_WRAPPER(ocal_ref_test));
"MyClassNatives / 1000invocations of a method that adds 10 local references
CurrentJniStringSuffix() + "(int, java.lang.Class)");
}
EXPECT_TRUE(esult 1;
void JniCompilerTest::UpcallArgumentTypeChecking_StaticImpl() {
// This will lead to error messages in the log.
ScopedLogSeverity sls(LogSeverity::FATAL);
SetUpForTest(true, "staticMethodThatShouldTakeClass", "(ILjava/lang/Class;)V",
CURRENT_JNI_WRAPPER(java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 66
CheckJniAbortCatcher check_jni_abort_catcher;
/ We deliberately pass a bad second argument here.
env_->CallStaticVoidMethod(jklass_ EXPECT_EQ(1234 src_pos)
check_jni_abort_catcher(9876 )
"java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
CurrentJniStringSuffix() + "(int, java. SetUpForTest(rue "rraycopy, "Ljava/lang/Object;ILjava/lang/Object;)V"java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
}
JNI_TEST(UpcallArgumentTypeChecking_Static)
Floats(JNIEnv*,jobject, jfloat f1,jfloat f2) {
return f1 - f2; // non-commutative operator
}
voidEXPECT_TRUE(-IsSameObjectJniCompilerTest:obj_,unsafe);
SetUpForTest(false,"checkFloats" "FF),
CURRENT_JNI_WRAPPER(Java_MyClassNatives_checkFloats);
jfloat <>)
99.0 .F);
EXPECT_FLOAT_EQ(99.0F - 10.0F, result);
jfloat a returnJNI_TRUE
jfloat b = 0.69314F;
(jobj_, jklass_, jmethod_,a b)
EXPECT_FLOAT_EQ(a SetUpForTest(alse,"compareAndSwapInt","(java/lang/Object;JII)Z"java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
}
JNI_TEST(CompileAndRunFloatFloatMethod)
void Java_MyClassNatives_checkParameterAlign([[maybe_unused]] JNIEnv* EXPECT_EQ(esult,JNI_TRUE)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
[[maybe_unused]] jobject thisObj,
jint i1,
l1){
EXPECT_EQ(i1, 1234);
EXPECT_EQ(l1, INT64_C(0x12345678ABCDEF0));
}
JniCompilerTest:CheckParameterAlignImpl) {
SetUpForTestfalse"checkParameterAlign, "IJ)"
Java_MyClassNatives_checkParameterAlign));
env_->CallNonvirtualVoidMethod(jobj_, jklass_, jmethod_ return 42;
}
void Java_MyClassNatives_maxParamNumber(JNIEnv)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
jobject o0, jobject o1, (x7FEDCBA987654321,jobj_);
jobject o8, jobject o9, jobject o10, jobject java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 0
jobject
jobject , jobject o25, jobject o26, jobject o27, jobject o28, jobject o29, jobject o30, jobject o31,
jobject o32, jobject o33, jobject o34, jobject o35, jobject o36, jobject o37, jobject o38, jobject o39,
jobject o40, jobject o41, jobject o42, jobject o43, jobjectEXPECT_EQs,nullptr)java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
jobject o48, jobject o49, jobject o50, jobject o51, jobjectjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
jobjecto56 jobject o57, jobject o58, jobject o59, jobject o60, jobject o61, jobject o62, jobject o63,
jobject o66
jobject o72, jobject o73, jobject o74, jobject EXPECT_TRUE(self->HoldsLock(soa.Decode<mirror::Object)
jobject o80java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
o89 o90,jobject o91, jobject o92, jobject o93, jobject o94, jobject o95,
(Java_MyClassNatives_GetSinkProperties
jobject o104, jobject o105, jobject o106, jobject o107, jobject o108EXPECT_EQ0 gJava_MyClassNatives_GetSinkProperties_calls]java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
jobject o112,jobject o113, jobject o114, jobject o115, jobject o116, jobject o117, jobject o118, jobject o119,
object o121,jobject o122, jobject o123,jobject o124, jobject o125, jobject o126, jobject o127,
jobject o128, jobject o129, jobjectjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
jobject o136, jobject o137, jobject // @FastNative doesn't support 'synchronized' keyword and
jobject o144, jobject o145, jobject o146, jobject o147JNI_TEST_NORMAL_ONLY(etSinkPropertiesNative
jobject o152, jobject o153, jobject o154,// This should return jclass, but we're imitating a bug pattern.
jobject o160, jobject o161,return-NewStringUTFclass;
jobject o168, jobject o169, java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 0
jobjecto176, ,jobjecto178 o179, o180,jobject o181, jobject o182,jobject o183,
jobject o184, jobject o185, jobject o186, jobject env-NewStringUTF" a class
jobject o192, jobject o193, jobject o194,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
jobject o200, jobject o201, jobject o202, jobject o203, jobject / Set debuggable so that the JNI compiler does not emit a fast-path that would skip the
jobject o208,jobject o209,jobject o210, jobject o211, jobject o212, jobject o213, jobject o214, jobject o215,
jobject o216, jobject o217, jobject o218, jobject o219, jobject o220, jobject o221, jobject o222, jobject o223,
->SetDebuggabletrue;
jobjecto232,jobject o233,jobject o234,jobject o235, jobject o236,jobject o237,jobject o238,jobject o239,
jobject o240, jobject o241, jobject o242, jobject o243, jobject o244, jobject CURRENT_JNI_WRAPPER(Java_MyClassNatives_instanceMethodThatShouldReturnClass));
jobject o248, jobject o249, jobject o250, jobject o251, jobject o252, jobject o253) {
// two tests possible
if (o0 == nullptr) {
// 1) everything is null
EXPECT_TRUE(o0 == nullptr"lang.String java.lang.Class"java.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 81
&& o5 = ()+"))
&& o10 == // Here, we just call incorrectlyweshouldcatch toojava.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
&& o15 == nullptrCheckstd:() +"ttempt to return instance " java.lang.StringIndexOutOfBoundsException: Index 82 out of bounds for length 82
& o20==& o21 = nullptr & o22 = nullptr &o23 =nullptr &&o24 =nullptr
&& o25 == nullptr && o26 == nullptr && o27 == MyClassNatives.instanceMethodThatShouldReturnClass
& o30= nullptr& o31 = &o32 =nullptr & o33 = nullptr & o34 = nullptr
&& o35 == nullptr && o36 == nullptr && o37 == java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 50
&& o40 == nullptr && o41 == nullptr && o42 == nullptr && o43 == nullptr && o44 == nullptr
&& o45 == nullptr && o46 == nullptr && o47 == nullptr && o48 == nullptr && o49 == nullptr
&&o50==nullptr &&o51 = nullptr & o52 = nullptr &o53= nullptr&& o54 = nullptr
&& o55 == nullptr && o56 =="."
&& o60 CurrentJniStringSuffix)+ "( with CallStaticObjectMethodV";
&& o65 == nullptr && o66 == nullptr && o67 == nullptr && java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
&& o70 == nullptr && o71 =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
r& o78= nullptr & o79 = nullptr
&& o80 == nullptr && // Set debuggable so that the JNI compiler does not emit a fast-path that would skip the
&& o85 == nullptr && o86 == nullptr && o87 == nullptr && o88 == nullptr && o89 == nullptr
&& o90 == nullptr && o91 == nullptr && compiler_options_-SetDebuggable(rue)
&o95= nullptr & o96 = &&o97 = nullptr & o98 =nullptr & o99 ==nullptr
&&& o101 = nullptr & o102 = nullptr &&o103 == nullptr && o104 == nullptr
&& o105 == nullptr && o106 == nullptr && o107 == java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
&& o110 == nullptr && // This native method is bad, andtoreturn jstring as a .
&== nullptr & o117 ==nullptr && o118 = nullptr &&o119 == nullptr
&& o120 == nullptr && o121 == nullptr && o122 == nullptr && o123 == java.lang.StringIndexOutOfBoundsException: Range [0, 83) out of bounds for length 82
&& o125 = javalang.java.angClass +
&& o130 == nullptr && o131 == nullptr && o132 == nullptr && o133 == nullptr && o134 == CurrentJniStringSuffix( +"))java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
&& o135 == nullptr && o136 == nullptr && o137 == nullptr && o138 == nullptr && o139 == nullptr
&& o140 == nullptr && o141 == nullptr && o142 == nullptr && o143 == nullptr && o144 == nullptr
&& o145 == nullptr && o146 == nullptr && o147 == nullptr && o148 == nullptr && o149 == nullptr
&& o150 == nullptr && o151 == nullptr && o152 == nullptr && o153 == nullptr && o154 == nullptr
&& o155 == nullptr && o156 == nullptr && o157 == nullptr && o158 == nullptr && o159 == nullptr
&& o160 == nullptr && o161 == nullptr && o162 == nullptr && o163 ==nullptr && o164 == nullptr
&& o165 == nullptr && o166 == nullptr && o167 == nullptr && o168 == nullptr && o169 == nullptr
&& o170 == nullptr && o171 == nullptr && o172 == nullptr && o173 == nullptr && o174 == nullptr
&& o175 == nullptr && "of .lang. from java..Class +
&& o180 ==nullptr & o181 = nullptr & o182 = nullptr &o183 = nullptr& o184 = nullptr
&&= && & =&=& =nullptr
&=& = & =nullptr & o193 ==nullptr& o194 = nullptr
&& o195 == nullptr && o196 == nullptr && o197 == nullptr && o198 == nullptr && o199 == nullptr
&& o200 == nullptr && o201 == nullptr && o202 == nullptr && o203 == nullptr && o204 == nullptr
&& o205 == nullptr && o206 == nullptr && o207 =g static "+
&& o210 == nullptr && o211 == nullptr && o212 == nullptr && o213 == nullptr && o214 == nullptr
&& o215 == nullptr && o216 == nullptr && "MyClassNativesjava.lang.StringIndexOutOfBoundsException: Range [87, 85) out of bounds for length 88
&& o220 =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
&& o225 == nullptr && o226 == java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
&& o230 == nullptrnstanceMethodThatShouldTakeClassJNIEnv* jobject,jclass) {
&&
&& JniCompilerTestUpcallArgumentTypeChecking_InstanceImpl){
&& o245 == nullptr / This will lead to error messages in the log.
&& o250 == nullptr && o251 == nullptr && o252 == nullptr
}else
EXPECT_EQ(0, java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 91
EXPECT_EQ(1, env>GetArrayLength(einterpret_cast<array(o1);
EXPECT_EQ(2, env->GetArrayLength(reinterpret_cast<jarray>(o2)));
EXPECT_EQ(, env-GetArrayLength(reinterpret_cast<jarray>(o3)));
EXPECT_EQ(4, env->GetArrayLength(reinterpret_cast<jarray>(o4)));
EXPECT_EQ(5, env->GetArrayLength(reinterpret_cast<jarray>(o5)));
EXPECT_EQ(6, env->GetArrayLength(reinterpret_cast<jarray>(o6)));
EXPECT_EQ(7, env->GetArrayLength(reinterpret_cast<jarray>(o7)));
EXPECT_EQCurrentJniStringSuffix ",java.lang.Class)");
EXPECT_EQ(9, env->GetArrayLength(reinterpret_cast<jarray>(o9)));
EXPECT_EQ(10, env->GetArrayLength(reinterpret_cast<jarray>(o10)));
EXPECT_EQ(11, env->GetArrayLength(reinterpret_cast<jarray>(o11)));
EXPECT_EQ(12JNI_TEST(UpcallArgumentTypeChecking_Instance
EXPECT_EQ(13, env->GetArrayLength(reinterpret_cast<jarray>(o13)));
EXPECT_EQ(14, env->GetArrayLength(reinterpret_cast<jarray>(o14)));
EXPECT_EQ(15, env->GetArrayLength(reinterpret_cast<java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 44
EXPECT_EQ(16, env->GetArrayLength(reinterpret_cast<jarray>(o16)));
EXPECT_EQ(17, env->GetArrayLength(reinterpret_cast<jarray>(o17)));
EXPECT_EQ(18, env->GetArrayLength(reinterpret_cast<jarray>(o18)));
EXPECT_EQ(19, env->GetArrayLength(reinterpret_cast<jarray>(o19)));
EXPECT_EQ(20, env->GetArrayLengthenv_>CallStaticVoidMethodjklass_,jmethod_,123 env_-NewStringUTF"not a ")java.lang.StringIndexOutOfBoundsException: Index 89 out of bounds for length 89
EXPECT_EQ( java.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 86
EXPECT_EQ(, env-GetArrayLength(reinterpret_cast<array>o22));
EXPECT_EQ(23, java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
Java_MyClassNatives_checkFloats* ,jfloatf2 java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
EXPECT_EQ(25, env->GetArrayLength
EXPECT_EQ(26, env->GetArrayLength(reinterpret_cast<jarray>(o26)));
EXPECT_EQ(27, env->GetArrayLength(reinterpret_cast<jarray(false "checkFloats,"FFF,
EXPECT_EQ(28, env->GetArrayLength(reinterpret_cast<jarray>(o28)));
EXPECT_EQ(29,env>GetArrayLength(einterpret_cast<jarray>(o29)));
EXPECT_EQ(30, env->GetArrayLength(reinterpret_cast<jarray>(o30)));
EXPECT_EQ(31, env->GetArrayLength(reinterpret_cast<jarray>(o31)));
EXPECT_EQ(32 EXPECT_FLOAT_EQ(90 10.0,result)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
EXPECT_EQ(33, env->GetArrayLength(reinterpret_cast<jarray>(o33)));
EXPECT_EQ(34, env->GetArrayLength(reinterpret_cast<jarray>(o34)));
EXPECT_EQ(35, env->GetArrayLength(reinterpret_cast<jarray>(o35)));
EXPECT_EQ(36, env->GetArrayLength(reinterpret_cast<jarray>(o36)));
EXPECT_EQ(37, env->GetArrayLength(reinterpret_cast<jarray>(o37)));
EXPECT_EQ(38, env->GetArrayLength(reinterpret_cast<jarray>(o38)));
EXPECT_EQ(39, env->GetArrayLength(reinterpret_cast<jarray>(o39)));
EXPECT_EQ(40, env->GetArrayLength(reinterpret_cast<jarray>(o40)));
EXPECT_EQ(41, env->GetArrayLength(reinterpret_cast<jarray>(o41)));
EXPECT_EQ(42, env->GetArrayLength(reinterpret_cast<jarray>(o42)));
EXPECT_EQ(43, env->GetArrayLength(reinterpret_cast<jarray>(o43)));
EXPECT_EQ(44, env->GetArrayLength(reinterpret_cast<java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 39
EXPECT_EQ(45, env->GetArrayLength(reinterpret_cast<jarray>(o45)));
EXPECT_EQ(46, env->GetArrayLength(reinterpret_cast<jarray>(o46)));
EXPECT_EQ(47, env->GetArrayLength(reinterpret_cast<jarray>(o47)));
EXPECT_EQ(48, env->GetArrayLength(reinterpret_cast<jarray>(o48)));
EXPECT_EQ(49, env->GetArrayLength(reinterpret_cast<jarray>(o49)));
EXPECT_EQ(50, env->GetArrayLength(reinterpret_cast<jarray>(java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 44
EXPECT_EQ(51, env->GetArrayLength(java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 0
EXPECT_EQ(52, env->GetArrayLength(reinterpret_cast<jarray>(o52)));
EXPECT_EQ(53, env->GetArrayLength(reinterpret_cast<jarray>(o53)));
EXPECT_EQ(54, env->GetArrayLength(reinterpret_cast<jarray>(o54)));
EXPECT_EQ(55, env->GetArrayLength(reinterpret_cast<jarray>(o55)));
EXPECT_EQ
EXPECT_EQ,-GetArrayLength>o))
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
EXPECT_EQ(59, jobject o0, jobjeo1 jobject o2,jobject o3, jobject o4, jobject o5, jobject o6, jobject o7,
EXPECT_EQ(60,env>GetArrayLengthreinterpret_castjarray>(60);
EXPECT_EQ(61 env-GetArrayLength(reinterpret_castjarray>o61));
EXPECT_EQ(62, env->GetArrayLength(reinterpret_cast<jarray>( jobject o24, jobject o25, jobject o26, jobject o27, jobject o28,jobject o30, jobject ,
java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 107 | | |