Skip to content

Commit 58602a1

Browse files
committed
BH 2019.12.07 3.2.5-v2 fix for lambda expression
- with $$ wrapper must not be cached - still could be a problem with finals there -- must check
1 parent 9b003fd commit 58602a1

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed
-156 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20191207025452
1+
20191207231619
-156 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20191207025452
1+
20191207231619

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

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
// HashSet as the basis for the {a:a,b:this.$finals$.b} mapping listFinalVariables.
168168
// This fixed all of the stream issues. See Test_Local, Test_java8, Test_Class.
169169

170+
// BH 2019.12.07 3.2.5-v2 fix for lambda expression with $$ must not be cached
170171
// BH 2019.11.18 3.2.5-v0 fix for anonymous subclass of a local class not handling finals
171172
// BH 2019.11.18 3.2.5-v0 fix for main method that throws exception not generating html test
172173
// BH 2019.11.18 3.2.5-v0 fix for lambda expressions in classes with annotations
@@ -1267,11 +1268,11 @@ private boolean addMethodInvocation(SimpleName javaQualifier, List<?> arguments,
12671268
) // BH Added 2019.05.13
12681269
&& lambdaArity == mBinding.getParameterTypes().length));
12691270

1270-
bufferDebug("addmeth isclasstarget " + isStatic + " classIsTarget="+ classIsTarget
1271-
+ " ivarbinding=" +isVariableBinding(expression) + " exp=" + (expression == null ?
1272-
null : expression.getClass().getName())
1273-
+ " " + declaringClassJavaClassName
1274-
);
1271+
//bufferDebug("addmeth isclasstarget " + isStatic + " classIsTarget="+ classIsTarget
1272+
// + " ivarbinding=" +isVariableBinding(expression) + " exp=" + (expression == null ?
1273+
// null : expression.getClass().getName())
1274+
// + " " + declaringClassJavaClassName
1275+
// );
12751276
String opening = (classIsTarget ? "$$." : "t.") + finalMethodNameWith$Params + ".apply("
12761277
+ (isStatic ? "null" : classIsTarget ? "$$" : "t") + ",[";
12771278
buffer.append(opening);
@@ -1760,9 +1761,18 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List<?>
17601761
finalShortClassName = finalShortClassName.substring(3);
17611762
}
17621763
setClassAndBinding(finalShortClassName, binding);
1763-
if (isLambda)
1764+
if (isLambda) {
17641765
buffer.append("(");
1765-
buffer.append("(P$." + finalShortClassName + "||");
1766+
1767+
1768+
// problem here 2019.12.07 cifbinary was that $$-wrapped lambda methods must NOT be reused.
1769+
//bufferDebug("addcoi " + isLambda + " " + class_localType);
1770+
1771+
1772+
}
1773+
buffer.append("(");
1774+
if (!isLambda || class_localType != LAMBDA_WRAPPED)
1775+
buffer.append("P$." + finalShortClassName + "||");
17661776
finalPackageName = "P$";
17671777
} else {
17681778
// Top or inner named classes are already set.
@@ -6882,7 +6892,7 @@ private void addLambdaReuse(int pt, String anonName) {
68826892
String tmp = buffer.substring(pt);
68836893
buffer.setLength(pt);
68846894

6885-
bufferDebug("addLambdaReuse " + anonName);
6895+
// bufferDebug("addLambdaReuse " + anonName);
68866896

68876897
anonName = getFinalJ2SClassName(anonName, FINAL_P);
68886898
buffer.append("(" + anonName + "$||(" + anonName + "$=(")

0 commit comments

Comments
 (0)