Hi,

End of November we added initial support for Java and Kotlin code indexing to 
mozilla-central on Searchfox, see 
https://groups.google.com/a/mozilla.org/g/dev-platform/c/kerF6YSMFIY/m/BGcQB57fAAAJ.

We have now added support for analyzing and displaying bindings between C++ and 
Java code.
This appears in two places:
* In the search page, when searching for a symbol:
  - If the symbol is a binding, an element in the foreign language appears 
under “Definitions”.
  - If the symbol is bound from another language, the bindings appears under 
“Bindings”.
* When triggering the context menu on a symbol that is marked as a binding to 
an element in another language, or is itself bound from another language: “go 
to” and “search” actions for the foreign symbol are proposed.

Where this works:
* C/C++ functions whose name match the pattern `Java_<qualified Java method 
name>[__.*]` are automatically annotated as bound from the matching Java method.
  This is mostly used by mozglue, for instance:
  - The Java native method 
`org::mozilla::gecko::mozglue::GeckoLoader::nativeRun`[1] links to its 
definition in C.
  - The C function `Java_org_mozilla_gecko_mozglue_GeckoLoader_nativeRun`[2] 
links back to the Java binding.

* C/C++ items generated via the @WrapForJNI Java annotation are automatically 
annotated as well.
  For instance:
  - The generated C++ class `mozilla::java::GeckoSession`[3] links to its Java 
class definition.
  - The Java class `org::mozilla::geckoview::GeckoSession`[4] links back to the 
generated C++ binding.

  - The generated C++ member function 
`mozilla::java::GeckoSession::GetCompositorEv`[5] links to its Java method 
definition.
  - The Java method 
`org::mozilla::geckoview::GeckoSession::getCompositorFromNative`[6] links back 
to the generated C++ binding.

  - The generated C++ methods `mozilla::java::GeckoHLSSample::DurationEv` 
(getter[7]/setter[8] pair) link to their Java field definition.
  - The Java field `mozilla::gecko::media::GeckoHLSSample::duration`[9] links 
back to both the generated C++ getter and setter.

  - The generated C++ constant 
`_ZN7mozilla4java10CodecProxy15INVALID_SESSIONE`[10] links to the matching Java 
constant definition.

  - The Java class `org::mozilla::geckoview::GeckoSession::Window`[11] links to 
its C++ class definition.
  - The C++ class `mozilla::widget::GeckoViewSupport`[12] links back to the 
Java class.

  - The native Java method 
`org::mozilla::geckoview::GeckoSession::Window::open`[13] links to its C++ 
member function definition.
  - The C++ member function `mozilla::widget::GeckoViewSupport::Open`[14] links 
back to the Java binding declaration.

* C/C++ items can be manually annotated with `__attributes__((annotate("<binding_to|bound_as>", "jvm", 
"<class|method|setter|getter|const>", "<foreign symbol>")))`
  No code uses this directly for now, but this is the common basis used by all 
the cases above.

For more details, see bug 1865048.[0]

[0] https://bugzilla.mozilla.org/show_bug.cgi?id=1865048
[1] 
https://searchfox.org/mozilla-central/search?q=symbol%3AS_jvm_org%2Fmozilla%2Fgecko%2Fmozglue%2FGeckoLoader%23nativeRun().
[2] 
https://searchfox.org/mozilla-central/search?q=symbol:Java_org_mozilla_gecko_mozglue_GeckoLoader_nativeRun
[3] 
https://searchfox.org/mozilla-central/search?q=symbol%3AT_mozilla%3A%3Ajava%3A%3AGeckoSession
[4] 
https://searchfox.org/mozilla-central/search?q=symbol:S_jvm_org%2Fmozilla%2Fgeckoview%2FGeckoSession%23
[5] 
https://searchfox.org/mozilla-central/search?q=symbol%3A_ZNK7mozilla4java12GeckoSession13GetCompositorEv
[6] 
https://searchfox.org/mozilla-central/search?q=symbol:S_jvm_org%2Fmozilla%2Fgeckoview%2FGeckoSession%23getCompositorFromNative().
[7] 
https://searchfox.org/mozilla-central/search?q=symbol:_ZNK7mozilla4java14GeckoHLSSample8DurationEv
[8] 
https://searchfox.org/mozilla-central/search?q=symbol:_ZNK7mozilla4java14GeckoHLSSample8DurationEx
[9] 
https://searchfox.org/mozilla-central/search?q=symbol%3AS_jvm_org%2Fmozilla%2Fgecko%2Fmedia%2FGeckoHLSSample%23duration.
[10] 
https://searchfox.org/mozilla-central/search?q=symbol:_ZN7mozilla4java10CodecProxy15INVALID_SESSIONE
[11] 
https://searchfox.org/mozilla-central/search?q=symbol%3AS_jvm_org%2Fmozilla%2Fgeckoview%2FGeckoSession%23Window%23
[12] 
https://searchfox.org/mozilla-central/search?q=symbol:T_mozilla%3A%3Awidget%3A%3AGeckoViewSupport
[13] 
https://searchfox.org/mozilla-central/search?q=symbol%3AS_jvm_org%2Fmozilla%2Fgeckoview%2FGeckoSession%23Window%23open().
[14] 
https://searchfox.org/mozilla-central/search?q=symbol:_ZN7mozilla6widget16GeckoViewSupport4OpenERKNS_3jni8LocalRefINS2_11TypedObjectIP7_jclassEEEERKNS2_3RefINS_4java12GeckoSession6WindowEP8_jobjectEERKNSB_INS2_6ObjectESG_EESN_SN_SN_SN_RKNS2_11StringParamESQ_b

Cheers,
--
Nicolas Guichard | [email protected] | Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel: France +33 (0)4 90 84 08 53, http://www.kdab.fr
KDAB - The Qt, C++ and OpenGL Experts

--
You received this message because you are subscribed to the Google Groups 
"[email protected]" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/a/mozilla.org/d/msgid/dev-platform/cb1749a0-7872-4902-88a9-3f366f989afc%40kdab.com.

Attachment: smime.p7s
Description: Signature cryptographique S/MIME

Reply via email to