Bug 1210585 - Avoid fields with same name in class and superclass; r=snorp

Java allows a class field to have the same name as a superclass field,
but when we generate bindings for them, they'll end up with the same C++
name and cause an error. This patch makes the SDK processor filter out
any superclass fields that are hidden by a subclass field with the same
name.
This commit is contained in:
Jim Chen 2015-10-22 17:45:45 -04:00
Родитель 23a0cee1a8
Коммит 654a730e13
1 изменённых файлов: 14 добавлений и 0 удалений

Просмотреть файл

@ -162,6 +162,20 @@ public class SDKProcessor {
continue;
}
// Sometimes (e.g. KeyEvent) a field can appear in both a class and a superclass. In
// that case we want to filter out the version that appears in the superclass, or
// we'll have bindings with duplicate names.
try {
if (m instanceof Field && !m.equals(cls.getField(m.getName()))) {
// m is a field in a superclass that has been hidden by
// a field with the same name in a subclass.
System.out.println("Skipping " + m.getName() +
" from " + m.getDeclaringClass());
continue;
}
} catch (final NoSuchFieldException e) {
}
list.add(m);
}