Can I cast native primitive type into a JNI primitive type without worrying about endianness?

Let’s say I have

const uint16_t n = 0x0001;

Then can I cast like this?

const jint j = (jint) n;

Without worrying about endianness of the native platform?


I have a function changes a value into an char array.

char * value_to_array(void * value, const size_t size) {
  char * array = malloc(size);
  if (array != NULL) {
    memcpy(array, value, size);
  return array;

Now I should care about the endianness, right? What about the above simple cast?

Source: c#

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.