bugzilla.mozilla.org has resumed normal operation. Attachments prior to 2014 will be unavailable for a few days. This is tracked in Bug 1475801.
Please report any other irregularities here.

Header Include dependency between Refs.h and Types.h




Firefox for Android
2 years ago
2 years ago


(Reporter: JamesCheng, Unassigned)


Firefox Tracking Flags

(Not tracked)




2 years ago
I encounter a compile error when I want to 

mozilla::jni::ByteArray::LocalRef data;
auto rv = javaObj->API(&data);
data->GetElements(); <---- This will cause a compile error.

/obj-arm-linux-androideabi/dist/include/mozilla/jni/Refs.h:734:23: error: invalid use of incomplete type 'struct mozilla::jni::detail::TypeAdapter<signed char>'
                  sizeof(typename detail::TypeAdapter<ElementType>::JNIType),
/obj-arm-linux-androideabi/dist/include/mozilla/jni/Refs.h:701:33: error: declaration of 'struct mozilla::jni::detail::TypeAdapter<signed char>'
      template<typename T> struct TypeAdapter;
 /obj-arm-linux-androideabi/dist/include/mozilla/jni/Refs.h:741:21: error: incomplete type 'mozilla::jni::detail::TypeAdapter<signed char>' used in nested name specifier

The compile error is caused by when [1] wants to use TypeAdapter but it can only see the declaration but specialization definition [2] at this stage.

So I need to |#include "mozilla/jni/Types.h"| before Refs.h...

But currently, Types.h includes Refs.h [3]...

[1] https://dxr.mozilla.org/mozilla-central/rev/043082cb7bd8490c60815f67fbd1f33323ad7663/widget/android/jni/Refs.h#734

[2] https://dxr.mozilla.org/mozilla-central/rev/043082cb7bd8490c60815f67fbd1f33323ad7663/widget/android/jni/Types.h#121

[3] https://dxr.mozilla.org/mozilla-central/rev/043082cb7bd8490c60815f67fbd1f33323ad7663/widget/android/jni/Types.h#6

Comment 1

2 years ago
Hi Jim,

Based on comment 1,

Is it caused by misusing or it is really an issue?

Could you please give me some suggestion since I am not familiar with Fennec.

Thank you :)
Flags: needinfo?(nchen)
You should include Types.h *after* Refs.h, i.e.
> #include "mozilla/jni/Refs.h"
> #include "mozilla/jni/Types.h"

In the future, we can probably make Refs.h include Types.h instead of the other way.
Flags: needinfo?(nchen)
You need to log in before you can comment on or make changes to this bug.