Skip to content

Commit 25ecbd2

Browse files
hansonrhansonr
authored andcommitted
Transpiler 3.2.9.v1o Java8 lambda expression fix
- test for static lambda expression was not looking for use of "this" or "super"
1 parent e41fe46 commit 25ecbd2

File tree

14 files changed

+441
-97
lines changed

14 files changed

+441
-97
lines changed
-2 Bytes
Binary file not shown.
134 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20200731074830
1+
20200801171531
-2 Bytes
Binary file not shown.
134 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20200731074830
1+
20200801171531

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public class CorePlugin extends Plugin {
3131
// j2sApplet.js and also (Bob only) update.bat, update-clean.bat
3232

3333

34+
// BH 2020.08.01 -- 3.2.9-v1o fix for lambda expressions too static
35+
// BH 2020.07.08 -- 3.2.9-v1n fix for try with resources and adds option varOrLet
3436
// BH 2020.07.04 -- 3.2.9.v1m fix for X.super.y() in anonymous class
3537
// BH 2020.06.22 -- 3.2.9.v1k fix for varargs not proper qualified arrays
3638
// BH 2020.06.17 -- 3.2.9-v1j fix for functional interface this::privateMethod

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135

136136
// TODO: superclass inheritance for JAXB XmlAccessorType
137137

138+
//BH 2020.08.01 -- 3.2.9-v1o fix for lambda expressions too static
138139
//BH 2020.07.08 -- 3.2.9-v1n fix for try with resources and adds option varOrLet
139140
//BH 2020.07.04 -- 3.2.9-v1m fix for X.super.y() in anonymous class
140141
//BH 2020.06.22 -- 3.2.9-v1k fix for varargs not proper qualified arrays
@@ -654,6 +655,8 @@ int getPrimitiveDefaultType(Code code) {
654655
*/
655656
private boolean[] package_haveStaticArgsReversal = new boolean[] {false};
656657

658+
private int b$count;
659+
657660
private void addApplication() {
658661
if (apps == null)
659662
apps = new ArrayList<String>();
@@ -1054,6 +1057,8 @@ private String processLocalInstance(ASTNode node, ASTNode anonymousClassDeclarat
10541057
// instantiation, so we need to cache the final string "{m:m,b:b,...}" at
10551058
// creation time and recover it here.
10561059

1060+
int b$count0 = b$count;
1061+
10571062
// String finals;
10581063
boolean isStatic = true;
10591064
if (localType != REALLY_LOCAL_CLASS) {
@@ -1092,7 +1097,9 @@ private String processLocalInstance(ASTNode node, ASTNode anonymousClassDeclarat
10921097

10931098
String key = binding.getKey();
10941099
Set<IVariableBinding> set = package_htClassKeyToVisitedFinalVars.get(key);
1095-
return (set == null || set.isEmpty() ? anonName : null);
1100+
boolean canBeReused = (set == null || set.isEmpty()
1101+
&& b$count == b$count0);
1102+
return (canBeReused ? anonName : null);
10961103
}
10971104

10981105
/**
@@ -4804,6 +4811,7 @@ private String getClassNameAndDot(ASTNode node, ITypeBinding declaringClass, boo
48044811
* @return "this" + .qualifier
48054812
*/
48064813
private String getSyntheticReference(String className) {
4814+
b$count++;
48074815
return "this" + (className.equals("java.lang.Object") || className.equals("Object") ? ""
48084816
//: className.equals(this$0Name) ? ".this$0"
48094817
: ".b$['" + getFinalJ2SClassName(className, FINAL_RAW) + "']");
-2 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)