Skip to content

Commit cac58c0

Browse files
committed
Fix for added applet unqualified names
should not do this if class or any superclass has the unqualified method name already. TODO -- or a field!
1 parent 1dc1306 commit cac58c0

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed
147 Bytes
Binary file not shown.
147 Bytes
Binary file not shown.

sources/net.sf.j2s.core/src/net/sf/j2s/core/astvisitors/Java2ScriptVisitor.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3941,7 +3941,6 @@ private String getMethodNameOrArrayForDeclaration(MethodDeclaration node, IMetho
39413941
// System.err.println("checking methodList for " + nodeName.toString() +
39423942
// " in " + methodClass.getKey());
39433943
List<String[]> methodList = getGenericMethodList(methodClass, nodeName.toString());
3944-
39453944
if (methodList != null) {
39463945
// System.err.println("have methodList for " + nodeName + " " +
39473946
// methodList.size());
@@ -3955,7 +3954,7 @@ private String getMethodNameOrArrayForDeclaration(MethodDeclaration node, IMetho
39553954
if (pname != null)
39563955
names.add(pname);
39573956
}
3958-
} else if (addUnqualified && !methodName.equals(qname)) {
3957+
} else if (addUnqualified && !methodName.equals(qname) && !classHasMethod(methodClass, methodName)) {
39593958
names = new ArrayList<String>();
39603959
names.add(methodName);
39613960
}
@@ -3970,6 +3969,20 @@ private String getMethodNameOrArrayForDeclaration(MethodDeclaration node, IMetho
39703969
return "[" + qname.substring(1) + "]";
39713970
}
39723971

3972+
private static boolean classHasMethod(ITypeBinding methodClass, String methodName) {
3973+
while (methodClass != null) {
3974+
IMethodBinding[] methods = methodClass.getDeclaredMethods();
3975+
for (int i = methods.length; --i >= 0;) {
3976+
IMethodBinding m = methods[i];
3977+
if (m.getName().equals(methodName) && m.getParameterTypes().length == 0
3978+
&& !Modifier.isPrivate(m.getModifiers()))
3979+
return true;
3980+
}
3981+
methodClass = methodClass.getSuperclass();
3982+
}
3983+
return false;
3984+
}
3985+
39733986
/**
39743987
* Determine the qualified parameter suffix for method names, including
39753988
* constructors.

0 commit comments

Comments
 (0)