MCPcopy Create free account
hub / github.com/apache/mesos / convert

Function convert

src/java/jni/org_apache_mesos_Log.cpp:63–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61
62template <>
63jobject convert(JNIEnv* env, const Log::Position& position)
64{
65 const std::string& identity = position.identity();
66
67 const char* bytes = identity.c_str();
68
69 uint64_t temp =
70 ((uint64_t) (bytes[0] & 0xff) << 56) |
71 ((uint64_t) (bytes[1] & 0xff) << 48) |
72 ((uint64_t) (bytes[2] & 0xff) << 40) |
73 ((uint64_t) (bytes[3] & 0xff) << 32) |
74 ((uint64_t) (bytes[4] & 0xff) << 24) |
75 ((uint64_t) (bytes[5] & 0xff) << 16) |
76 ((uint64_t) (bytes[6] & 0xff) << 8) |
77 ((uint64_t) (bytes[7] & 0xff));
78
79 jlong jvalue = temp; // Java is expecting a long (i.e., signed).
80
81 // We can create a Java Log.Position directly because JNI does not
82 // enforce access modifiers (thus breaking encapsulation).
83 jclass clazz = env->FindClass("org/apache/mesos/Log$Position");
84
85 jmethodID _init_ = env->GetMethodID(clazz, "<init>", "(J)V");
86
87 jobject jposition = env->NewObject(clazz, _init_, jvalue);
88
89 return jposition;
90}
91
92
93template <>

Callers

nothing calls this directly

Calls 3

dataMethod · 0.80
identityMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected