Ambiguous base class

Java API classes generated by Java API generator often (indirectly) derive from the same base class multiple times. This can be java::lang::Object (all Java classes AND interfaces extend it), or some interface implemented by more than one base class.

In such cases, convert ref to appropriate base type:

#include <scapix/java_api/java/lang/String.h>
#include <scapix/java_api/java/util/HashSet.h>

namespace jni = scapix::jni;
using namespace scapix::java_api;

void ambiguous_base_example()
    // java::lang::String derives from java::lang::Object more than once:

    auto s = jni::new_object<java::lang::String>();
    s->getClass(); // Error: ambiguous
    jni::ref<java::lang::Object>(s)->getClass(); // OK

    // java::util::HashSet derives from java::util::Collection more than once:

    auto h = jni::new_object<java::util::HashSet>();
    h->toArray(); // Error: ambiguous
    jni::ref<java::util::Collection>(h)->toArray(); // OK