Validate upfront that an interface is compatible with our Java backend,

emit diagnostics if it is not. Also cleans up all other error messages to
clearly indicate an error condition.

Bug: 30876839
Change-Id: I18bcd723107ab93abcad38c976f3c38dda60a743
diff --git a/Scope.cpp b/Scope.cpp
index 0e21c8e..6449f49 100644
--- a/Scope.cpp
+++ b/Scope.cpp
@@ -13,7 +13,8 @@
 bool Scope::addType(const char *localName, NamedType *type) {
     if (mTypeIndexByName.indexOfKey(localName) >= 0) {
         fprintf(stderr,
-                "A type named '%s' is already declared in the current scope.\n",
+                "ERROR: A type named '%s' is already declared in the current "
+                "scope.\n",
                 localName);
 
         return false;
@@ -126,7 +127,7 @@
 }
 
 
-Vector<Type *> Scope::getSubTypes() const {
+const std::vector<Type *> &Scope::getSubTypes() const {
     return mTypes;
 }
 
@@ -140,5 +141,15 @@
     return OK;
 }
 
+bool Scope::isJavaCompatible() const {
+    for (const auto &type : mTypes) {
+        if (!type->isJavaCompatible()) {
+            return false;
+        }
+    }
+
+    return true;
+}
+
 }  // namespace android