Fix bug 437988. Rhino must discover the abstract methods in the interface
of a base class in JavaAdapter git-svn-id: svn://10.0.0.236/trunk@252248 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
eed9bcbb68
commit
c0bcb6d911
@ -452,31 +452,39 @@ public final class JavaAdapter implements IdFunctionCall
|
||||
ArrayList<Method> list = new ArrayList<Method>();
|
||||
HashSet<String> skip = new HashSet<String>();
|
||||
while (c != null) {
|
||||
Method[] methods = c.getDeclaredMethods();
|
||||
for (int i = 0; i < methods.length; i++) {
|
||||
String methodKey = methods[i].getName() +
|
||||
getMethodSignature(methods[i],
|
||||
methods[i].getParameterTypes());
|
||||
if (skip.contains(methodKey))
|
||||
continue; // skip this method
|
||||
int mods = methods[i].getModifiers();
|
||||
if (Modifier.isStatic(mods))
|
||||
continue;
|
||||
if (Modifier.isFinal(mods)) {
|
||||
// Make sure we don't add a final method to the list
|
||||
// of overridable methods.
|
||||
skip.add(methodKey);
|
||||
continue;
|
||||
}
|
||||
if (Modifier.isPublic(mods) || Modifier.isProtected(mods)) {
|
||||
list.add(methods[i]);
|
||||
skip.add(methodKey);
|
||||
}
|
||||
}
|
||||
appendOverridableMethods(c, list, skip);
|
||||
for (Class<?> intf: c.getInterfaces())
|
||||
appendOverridableMethods(intf, list, skip);
|
||||
c = c.getSuperclass();
|
||||
}
|
||||
return list.toArray(new Method[list.size()]);
|
||||
}
|
||||
|
||||
private static void appendOverridableMethods(Class<?> c,
|
||||
ArrayList<Method> list, HashSet<String> skip)
|
||||
{
|
||||
Method[] methods = c.getDeclaredMethods();
|
||||
for (int i = 0; i < methods.length; i++) {
|
||||
String methodKey = methods[i].getName() +
|
||||
getMethodSignature(methods[i],
|
||||
methods[i].getParameterTypes());
|
||||
if (skip.contains(methodKey))
|
||||
continue; // skip this method
|
||||
int mods = methods[i].getModifiers();
|
||||
if (Modifier.isStatic(mods))
|
||||
continue;
|
||||
if (Modifier.isFinal(mods)) {
|
||||
// Make sure we don't add a final method to the list
|
||||
// of overridable methods.
|
||||
skip.add(methodKey);
|
||||
continue;
|
||||
}
|
||||
if (Modifier.isPublic(mods) || Modifier.isProtected(mods)) {
|
||||
list.add(methods[i]);
|
||||
skip.add(methodKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Class<?> loadAdapterClass(String className, byte[] classBytes)
|
||||
{
|
||||
|
||||
11
mozilla/js/rhino/testsrc/jstests/437988.jstest
Normal file
11
mozilla/js/rhino/testsrc/jstests/437988.jstest
Normal file
@ -0,0 +1,11 @@
|
||||
// Rhino must discover the abstract methods in the interface
|
||||
// of AbstractTableModel
|
||||
var tableModel = new javax.swing.table.AbstractTableModel() {
|
||||
getRowCount: function() { return 2; },
|
||||
getColumnCount: function() { return 2; },
|
||||
getValueAt: function(row, column) {
|
||||
return "ABC";
|
||||
}
|
||||
};
|
||||
var jTable = new javax.swing.JTable(tableModel);
|
||||
"success";
|
||||
Loading…
x
Reference in New Issue
Block a user