Skip to content

Commit 0932924

Browse files
committed
BH 2020.05.01 -- 3.2.9-v1i fix for nested lambda methods
1 parent bf37383 commit 0932924

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

sources/net.sf.j2s.core/src/net/sf/j2s/core/CorePlugin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class CorePlugin extends Plugin {
3030
// if you change the x.x.x number, be sure to also indicate that in
3131
// j2sApplet.js and also (Bob only) update.bat, update-clean.bat
3232

33+
// BH 2020.05.01 -- 3.2.9-v1i fix for nested lambda methods
3334
// BH 2020.04.26 -- 3.2.9-v1h fix for inner classes of interfaces duplicated; fix for api.js inner class method names unqualified
3435
// BH 2020.04.15 -- 3.2.9-v1g fix for qualified super() in inner classes using Class.super_ call (Tracker)
3536
// BH 2020.04.05 -- 3.2.9-v1f (Boolean ? ...) not unboxed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135

136136
// TODO: superclass inheritance for JAXB XmlAccessorType
137137

138+
//BH 2020.05.01 -- 3.2.9-v1i fix for nested lambda methods
138139
//BH 2020.04.26 -- 3.2.9-v1h fix for inner classes of interfaces duplicated; fix for api.js inner class method names unqualified
139140
//BH 2020.04.15 -- 3.2.9-v1g fix for qualified super() in inner classes using Class.super_ call (Tracker)
140141
//BH 2020.04.05 -- 3.2.9-v1f (Boolean ? ...) not unboxed
@@ -2021,6 +2022,7 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List<?>
20212022
if (binding == null)
20222023
return false;
20232024

2025+
20242026
// checkGenericBinding(binding, binding);
20252027

20262028
ASTNode parent = node.getParent();
@@ -2035,6 +2037,7 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List<?>
20352037
boolean isTopLevel = (!isLambda && binding.isTopLevel());
20362038
boolean isAbstract = ((binding.getModifiers() & Modifier.ABSTRACT) != 0);
20372039

2040+
20382041
if (!isTopLevel && !isAnonymous && node != innerNode) {
20392042
// inner named class first pass only
20402043

@@ -2074,7 +2077,6 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List<?>
20742077
} else {
20752078
tempVisitor.addClassOrInterface(node, binding, bodyDeclarations, type);
20762079
}
2077-
20782080
// append it to our TrailingBuffer
20792081
trailingBuffer.append(tempVisitor.buffer.toString());
20802082

@@ -2134,6 +2136,8 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List<?>
21342136
finalPackageName = checkPackageP$Name(class_fullName.substring(0, pt1));
21352137
}
21362138

2139+
int lc = lambdaCount;
2140+
21372141
// add the anonymous wrapper if needed
21382142

21392143
if (!isTopLevel) {
@@ -2579,7 +2583,6 @@ && checkAnnotations(element, CHECK_J2S_IGNORE_AND_ANNOTATIONS)) {
25792583
xml_annotationType = ANNOTATION_TYPE_UNKNOWN;
25802584
// class_hasTypeAnnotations = false;
25812585
}
2582-
25832586
buffer.append(trailingBuffer.getString()); // also writes the assert string
25842587
if (isAnonymous) {
25852588
// if anonymous, restore old static def buffer
@@ -2610,6 +2613,11 @@ && checkAnnotations(element, CHECK_J2S_IGNORE_AND_ANNOTATIONS)) {
26102613
class_annotations = oldAnnotations;
26112614
}
26122615
}
2616+
2617+
2618+
lambdaCount = lc;
2619+
2620+
26132621
return isStatic;
26142622
}
26152623

@@ -4948,7 +4956,8 @@ private String getUnreplacedJavaClassNameSuperNoBrackets(ITypeBinding typeBindin
49484956
private int lambdaCount = 0;
49494957

49504958
private String getMyJavaClassNameLambda(boolean andIncrement) {
4951-
return package_name + "." + class_shortName.replace('.', '$') + "$lambda"
4959+
return package_name + "." + class_shortName.replace('.', '$')
4960+
+ (class_shortName.indexOf("$lambda") >= 0 ? "$" : "$lambda")
49524961
+ (andIncrement ? ++lambdaCount : lambdaCount);
49534962
}
49544963

0 commit comments

Comments
 (0)