Closed Bug 1271874 Opened 8 years ago Closed 3 years ago

Header Include dependency between Refs.h and Types.h

Categories

(Firefox for Android Graveyard :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: JamesCheng, Unassigned)

Details

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
          (Base::Env()->*detail::TypeAdapter<ElementType>::GetArray)(
=======================================================================

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
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)
We have completed our launch of our new Firefox on Android. The development of the new versions use GitHub for issue tracking. If the bug report still reproduces in a current version of [Firefox on Android nightly](https://play.google.com/store/apps/details?id=org.mozilla.fenix) an issue can be reported at the [Fenix GitHub project](https://github.com/mozilla-mobile/fenix/). If you want to discuss your report please use [Mozilla's chat](https://wiki.mozilla.org/Matrix#Connect_to_Matrix) server https://chat.mozilla.org and join the [#fenix](https://chat.mozilla.org/#/room/#fenix:mozilla.org) channel.
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → INCOMPLETE
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.