@@ -262,7 +262,7 @@ public class Java2ScriptVisitor extends ASTVisitor {
262262 * parameterized
263263 *
264264 */
265- private boolean temp_addUnqualifiedMethod ;
265+ private boolean temp_add$UnqualifiedMethod ;
266266
267267 // the three key elements of any class
268268
@@ -1001,15 +1001,10 @@ private void processMethodDeclaration(IMethodBinding mBinding, List<ASTNode> par
10011001 boolean isPrivate = !isPublic && !isConstructor && isPrivate (mBinding );
10021002 boolean isStatic = isStatic (mBinding );
10031003 int qualification = (lambdaType != NOT_LAMBDA ? METHOD_FULLY_QUALIFIED
1004- : temp_addUnqualifiedMethod ? METHOD_$_QUALIFIED
1005- : isUserApplet && !isConstructor && !isStatic && isPublic ? METHOD_UNQUALIFIED
1004+ : temp_add$UnqualifiedMethod ? METHOD_$_QUALIFIED
10061005 : METHOD_FULLY_QUALIFIED );
1007-
1008- // boolean addUnqualified = lambdaType == NOT_LAMBDA && (temp_addUnqualifiedMethod // method call to lambda
1009- // || isUserApplet && !isConstructor && !isStatic && isPublic
1010- // // public applet methods could never be overloaded in
1011- // // JavaScript anyway.
1012- // );
1006+ if (isUserApplet && lambdaType == NOT_LAMBDA && !isConstructor && !isStatic && isPublic )
1007+ qualification |= METHOD_UNQUALIFIED ;
10131008 String finalName = getFinalMethodNameOrArrayForDeclaration (mBinding , isConstructor , qualification );
10141009 boolean isMain = isStatic && isPublic && mBinding .getName ().equals ("main" )
10151010 && mBinding .getKey ().endsWith (";.main([Ljava/lang/String;)V" );
@@ -2020,15 +2015,14 @@ private void addClassOrInterface(ASTNode node, ITypeBinding binding, List<?> bod
20202015 log ("default method " + method .getKey ());
20212016 defpt = buffer .length ();
20222017 }
2023- boolean addUnqualifiedCurrent = temp_addUnqualifiedMethod ;
2018+ boolean addUnqualifiedCurrent = temp_add$UnqualifiedMethod ;
20242019 if (unqualifiedMethods != null ) {
20252020 // check for all methods that override a functional interface abstract method,
2026- // as those
2027- // methods are not to be qualified
2021+ // as those methods are to be qualified only with $
20282022
20292023 for (int i = unqualifiedMethods .size (); --i >= 0 ;) {
20302024 if (method .overrides (unqualifiedMethods .get (i ))) {
2031- temp_addUnqualifiedMethod = true ;
2025+ temp_add$UnqualifiedMethod = true ;
20322026 break ;
20332027 }
20342028 }
@@ -2038,7 +2032,7 @@ private void addClassOrInterface(ASTNode node, ITypeBinding binding, List<?> bod
20382032 defaults .append (buffer .substring (defpt ));
20392033 buffer .setLength (defpt );
20402034 }
2041- temp_addUnqualifiedMethod = addUnqualifiedCurrent ;
2035+ temp_add$UnqualifiedMethod = addUnqualifiedCurrent ;
20422036 }
20432037 }
20442038 }
@@ -4847,19 +4841,28 @@ private String getFinalMethodNameOrArrayForDeclaration(IMethodBinding mBinding,
48474841 ITypeBinding methodClass = mBinding .getDeclaringClass ();
48484842 List <String > names = null ;
48494843 List <String []> methodList = getGenericMethodList (methodClass , nodeName );
4844+
48504845 if (methodList != null ) {
48514846 names = new ArrayList <String >();
48524847 for (int i = methodList .size (); --i >= 0 ;) {
48534848 String pname = getFinalMethodNameWith$Params (methodName , null , mBinding , methodList .get (i ), false ,
48544849 METHOD_NOTSPECIAL );
48554850 if (pname != null )
48564851 names .add (pname );
4857- if (qualification = = METHOD_FULLY_QUALIFIED )
4852+ if (qualification ! = METHOD_FULLY_QUALIFIED )
48584853 names .add (ensureMethod$Name (methodName , mBinding , getJavaClassNameQualified (methodClass )));
48594854 }
4860- } else if (qualification != METHOD_FULLY_QUALIFIED && !methodName .equals (qname ) && !classHasMethod (methodClass , methodName )) {
4861- names = new ArrayList <String >();
4862- names .add (methodName + (qualification == METHOD_UNQUALIFIED || methodName .indexOf ("$" ) >= 0 ? "" : "$" ));
4855+ }
4856+ if ((qualification & METHOD_$_QUALIFIED ) != 0 && !methodName .equals (qname )
4857+ && !classHasNoParameterMethod (methodClass , methodName )) {
4858+ if (names == null )
4859+ names = new ArrayList <String >();
4860+ names .add (methodName + (methodName .indexOf ("$" ) >= 0 ? "" : "$" ));
4861+ }
4862+ if ((qualification & METHOD_UNQUALIFIED ) != 0 ) {
4863+ if (names == null )
4864+ names = new ArrayList <String >();
4865+ names .add (methodName );
48634866 }
48644867 if (names == null || names .size () == 0 )
48654868 return "'" + qname + "'" ;
@@ -4872,7 +4875,7 @@ private String getFinalMethodNameOrArrayForDeclaration(IMethodBinding mBinding,
48724875 return "[" + qname .substring (1 ) + "]" ;
48734876 }
48744877
4875- private static boolean classHasMethod (ITypeBinding methodClass , String methodName ) {
4878+ private static boolean classHasNoParameterMethod (ITypeBinding methodClass , String methodName ) {
48764879 while (methodClass != null ) {
48774880 IMethodBinding [] methods = methodClass .getDeclaredMethods ();
48784881 for (int i = methods .length ; --i >= 0 ;) {
0 commit comments