Add @JavaPassthrough annotation
The AIDL annotation is used to pass Java annotation to the generated
java code. It is ignored in other backends like C++ and NDK.
Specifically, an AIDL method
@JavaPassthrough(annotation="@com.android.MyAnnotation")
void foo();
becomes a Java method
@com.android.MyAnnotation
void foo() extends RemoteException;
Note that the Java annotation syntax inside the "annotation" parameter
is not parsed. It's left to the Java compiler which will compile the
generated code.
Bug: 135686385
Test: run aidl_unittests
Change-Id: I3dbdb455f1e2ac62b327101e86a8984722c0cbb7
diff --git a/ast_java.cpp b/ast_java.cpp
index f997494..8604bc2 100644
--- a/ast_java.cpp
+++ b/ast_java.cpp
@@ -108,6 +108,9 @@
Variable::Variable(const string& t, const string& n) : type(t), name(n) {}
void Variable::WriteDeclaration(CodeWriter* to) const {
+ for (const auto& a : this->annotations) {
+ to->Write("%s ", a.c_str());
+ }
to->Write("%s %s", this->type.c_str(), this->name.c_str());
}