1212
1313import java .text .SimpleDateFormat ;
1414import java .util .ArrayList ;
15+ //import java.util.Arrays;
1516import java .util .Date ;
1617import java .util .HashMap ;
1718import java .util .HashSet ;
@@ -1293,7 +1294,7 @@ private void processMethodDeclaration(MethodDeclaration mnode, IMethodBinding mB
12931294 : temp_add$UnqualifiedMethod ? METHOD_$_QUALIFIED : METHOD_FULLY_QUALIFIED );
12941295 if (isUserApplet && lambdaType == NOT_LAMBDA && !isConstructor && !isStatic && isPublic )
12951296 qualification |= METHOD_UNQUALIFIED ;
1296- String finalName = getFinalMethodNameOrArrayForDeclaration (mBinding , isConstructor , aliases , qualification );
1297+ String finalName = getMethodNameWithSyntheticBridgeForDeclaration (mBinding , isConstructor , aliases , qualification );
12971298 boolean isMain = (isStatic && isPublic && mBinding .getName ().equals ("main" )
12981299 && mBinding .getKey ().indexOf (";.main([Ljava/lang/String;)V" ) >= 0 );
12991300
@@ -5107,14 +5108,15 @@ private void visitList(List<ASTNode> list, String separator) {
51075108 /**
51085109 * Check a class, interface, or Enum binding for generics.
51095110 *
5110- * This is used in the method declaration to add alias names to methods.
5111+ * This is used in the method declaration to add synthetic names to methods.
51115112 *
51125113 * @param topBinding -- the class being declared
51135114 * @param binding
51145115 * @return true if this class could have generic replacements
51155116 */
51165117 private boolean checkGenericClass (ITypeBinding topBinding , ITypeBinding binding ) {
51175118 // debugListAllOverrides(binding);
5119+ // from addClassOrInterface
51185120 if (topBinding == binding )
51195121 syntheticClassMethodNameMap .put (binding .getKey (), null );
51205122 // check all superclasses from most super to least super
@@ -5145,6 +5147,7 @@ private boolean checkGenericClass(ITypeBinding topBinding, ITypeBinding binding)
51455147 */
51465148 private void addSyntheticMethods (String topClassKey , ITypeBinding binding ) {
51475149 Map <String , String > classTypes = getGenericClassTypes (binding );
5150+ //buffer Debug(">addSynthMethods " + topClassKey + " " + classTypes);
51485151 if (classTypes == null )
51495152 return ;
51505153 String classKey = binding .getKey ();
@@ -5154,11 +5157,12 @@ private void addSyntheticMethods(String topClassKey, ITypeBinding binding) {
51545157 String methodName = m .getName ();
51555158 ITypeBinding [] params = m .getParameterTypes ();
51565159 boolean haveGeneric = false ;
5157- for (int j = params .length ; --j >= 0 && !haveGeneric ;)
5160+ for (int j = params .length ; --j >= 0 && !haveGeneric ;) {
51585161 if (isTypeOrArrayType (params [j ]))
51595162 haveGeneric = true ;
5163+ }
51605164 if (!haveGeneric )
5161- return ;
5165+ continue ;
51625166 String [] list = new String [params .length ];
51635167 for (int j = list .length ; --j >= 0 ;) {
51645168 String name = params [j ].getName ();
@@ -5167,7 +5171,24 @@ private void addSyntheticMethods(String topClassKey, ITypeBinding binding) {
51675171 addSyntheticMethod (classKey , methodName , list );
51685172 addSyntheticMethod (topClassKey , methodName , list );
51695173 }
5174+ }
5175+
5176+ /**
5177+ * add a generic class method to syntheticClassMethodNameMap under the class and method
5178+ *
5179+ * @param classKey
5180+ * @param methodName
5181+ * @param list
5182+ */
5183+ private void addSyntheticMethod (String classKey , String methodName , String [] list ) {
51705184
5185+ Map <String , List <String []>> classMap = syntheticClassMethodNameMap .get (classKey );
5186+ if (classMap == null )
5187+ syntheticClassMethodNameMap .put (classKey , classMap = new Hashtable <String , List <String []>>());
5188+ List <String []> methodList = classMap .get (methodName );
5189+ if (methodList == null )
5190+ classMap .put (methodName , methodList = new ArrayList <String []>());
5191+ methodList .add (list );
51715192 }
51725193
51735194 private static ASTNode getAbstractOrAnonymousParentForNode (ASTNode node ) {
@@ -5228,7 +5249,7 @@ private Map<String, String> getGenericClassTypes(ITypeBinding type) {
52285249 }
52295250
52305251 String [] tokens = sb .toString ().split ("," );
5231- for (int i = tokens . length ; -- i >= 0 ; ) {
5252+ for (int i = 0 ; i < tokens . length ; i ++ ) {
52325253 String key = tokens [i ].trim ();
52335254 key = key .substring (0 , (key + " " ).indexOf (" " ));
52345255 String value = (i < types .length ? getJavaClassNameQualified (types [i ]) : "java.lang.Object" );
@@ -5251,24 +5272,6 @@ private List<String[]> getGenericMethodList(ITypeBinding methodClass, String met
52515272 return (methodList == null ? null : methodList .get (methodName ));
52525273 }
52535274
5254- /**
5255- * add a generic class method to the genericClassMap under the class and method
5256- *
5257- * @param classKey
5258- * @param methodName
5259- * @param list
5260- */
5261- private void addSyntheticMethod (String classKey , String methodName , String [] list ) {
5262-
5263- Map <String , List <String []>> classMap = syntheticClassMethodNameMap .get (classKey );
5264- if (classMap == null )
5265- syntheticClassMethodNameMap .put (classKey , classMap = new Hashtable <String , List <String []>>());
5266- List <String []> methodList = classMap .get (methodName );
5267- if (methodList == null )
5268- classMap .put (methodName , methodList = new ArrayList <String []>());
5269- methodList .add (list );
5270- }
5271-
52725275 /**
52735276 *
52745277 * This is the method used to get the name or names to write into the method
@@ -5282,8 +5285,8 @@ private void addSyntheticMethod(String classKey, String methodName, String[] lis
52825285 * @param mode
52835286 * @return j2s-qualified name or an array of j2s-qualified names
52845287 */
5285- String getFinalMethodNameOrArrayForDeclaration (IMethodBinding mBinding , boolean isConstructor ,
5286- String aliases , int mode ) {
5288+ String getMethodNameWithSyntheticBridgeForDeclaration (IMethodBinding mBinding , boolean isConstructor ,
5289+ String aliases , int mode ) {
52875290 String nodeName = mBinding .getName ();
52885291 String methodName = (isConstructor ? "c$" : nodeName );
52895292 String qname = getFinalMethodNameWith$Params (methodName , null , mBinding , null , false , null , METHOD_NOTSPECIAL );
@@ -6693,7 +6696,7 @@ public static void addClassAnnotations(Java2ScriptVisitor visitor, int accessTyp
66936696 if (mBinding == null )
66946697 continue ;
66956698 varName = "M:" + mBinding .getName ();
6696- signature = visitor .getFinalMethodNameOrArrayForDeclaration (mBinding , mBinding .isConstructor (), null , METHOD_FULLY_QUALIFIED );
6699+ signature = visitor .getMethodNameWithSyntheticBridgeForDeclaration (mBinding , mBinding .isConstructor (), null , METHOD_FULLY_QUALIFIED );
66976700 type = mBinding .getReturnType ();
66986701 } else if (a .node instanceof AnnotationTypeMemberDeclaration ) {
66996702 MethodDeclaration method = (MethodDeclaration ) a .node ;
0 commit comments