Skip to content

Commit 8218af4

Browse files
committed
// BH 2023.03.29 -- 3.3.1-v7 fixes outer static method call from within
lambda expression. // BH 2023.02.09 -- 3.3.1.v6 fixes j2s.excluded.paths needing /src/xxxx Pattern/Matcher fixed
1 parent 781c6e4 commit 8218af4

File tree

9 files changed

+91
-9
lines changed

9 files changed

+91
-9
lines changed
54 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20230311212845
1+
20230329170441
54 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20230311212845
1+
20230329170441

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ public class CorePlugin extends Plugin {
2525
* "net.sf.j2s.core.jar" not "net.sf.j2s.core.3.2.5"
2626
*
2727
*/
28-
public static String VERSION = "3.3.1-v6";
28+
public static String VERSION = "3.3.1-v7";
2929

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 2023.03.29 -- 3.3.1-v7 fixes outer static method call from within lambda expression.
3334
// BH 2023.02.09 -- 3.3.1.v6 fixes j2s.excluded.paths needing /src/xxxx
3435
// BH 2022.06.27 -- 3.3.1-v5 fixes missing method annotations
3536
// BH 2022.01.17 -- 3.3.1-v4 fixes default interface methods referencing their own static fields

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@
136136
// TODO: superclass inheritance for JAXB XmlAccessorType
137137
// TODO: Transpiler bug allows static String name, but JavaScript function().name is read-only and will be "clazz"
138138

139+
//BH 2023.03.29 -- 3.3.1-v7 fixes outer static method call from within lambda expression.
140+
//BH 2023.02.09 -- 3.3.1.v6 fixes j2s.excluded.paths needing /src/xxxx
141+
//BH 2022.06.27 -- 3.3.1-v5 fixes missing method annotations
139142
//BH 2022.01.17 -- 3.3.1-v4 fixes default interface methods referencing their own static fields
140143
//BH 2021.01.14 -- 3.3.1-v3 fixes missing finals for nested () -> {...}
141144
//BH 2021.01.03 -- 3.3.1-v2 adds @j2sAsync adds async for function - experimental
@@ -1578,11 +1581,18 @@ private boolean addMethodInvocation(SimpleName javaQualifier, List<?> arguments,
15781581
String privateVar = (isPrivateAndNotStatic ? getPrivateVar(declaringClass, false) : null);
15791582
boolean doLogMethodCalled = (!isPrivate && global_htMethodsCalled != null);
15801583
boolean needBname = (
1581-
1582-
!isStatic && lambdaArity < 0 && (expression == null
1584+
!isStatic
1585+
&& (lambdaArity < 0
1586+
&& (expression == null
15831587
? !areEqual(declaringClass, class_typeBinding)
15841588
&& !class_typeBinding.isAssignmentCompatible(declaringClass)
1585-
: expression instanceof ThisExpression && ((ThisExpression) expression).getQualifier() != null) || class_localType == LAMBDA_EXPRESSION);
1589+
: expression instanceof ThisExpression
1590+
&& ((ThisExpression) expression).getQualifier() != null)
1591+
|| class_localType == LAMBDA_EXPRESSION)
1592+
);
1593+
1594+
bufferDebug("needbname " + needBname + " " + methodName + " " + isStatic);
1595+
15861596
String bname = (needBname ? getThisRefOrSyntheticReference(javaQualifier, declaringClass, null) : null);
15871597
// add the qualifier
15881598
int pt = buffer.length();
@@ -4879,7 +4889,7 @@ private void addQualifiedNameForBinding(IVariableBinding varBinding, boolean isS
48794889
*
48804890
* For general fields, this will be "this.".
48814891
*
4882-
* For fields in outer classes, we need a synthetic references,
4892+
* For nonstatic fields in outer classes, we need a synthetic references,
48834893
* this.b$[className] that points to the outer object, which may be one or more
48844894
* levels higher than this one.
48854895
*

sources/net.sf.j2s.java.core/src/test/Test_Class.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,12 @@ public static void main(String[] args) {
444444
e1.printStackTrace();
445445
}
446446

447+
String whatever = "whatever";
448+
447449
class LocalClass {
448450

449451
String hello() {
450-
return "LocalClass says hello";
452+
return "LocalClass says hello " + whatever;
451453
}
452454
}
453455

sources/net.sf.j2s.java.core/src/test/Test_J8_lambdafinal.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,32 @@ public class Test_J8_lambdafinal extends Test_ {
3030

3131
public static void main(String args[]) {
3232

33+
new Test_J8_lambdafinal().
3334
testFinal();
3435
}
3536

36-
private static void testFinal() {
37+
private void testFinal() {
3738

3839
Runnable r = () -> {
3940
for (String s : new String[] { "a", "b" }) {
4041
Runnable r1 = () -> {
4142
for (int i : new int[] { 0, 1, 2 }) {
4243
System.out.println(i + " " + s);
4344
}
45+
testDone(s);
4446

4547
};
4648
r1.run();
4749
}
50+
testDone("");
4851
};
4952
r.run();
5053
}
54+
55+
private static void testDone(String s) {
56+
System.out.println("DONE " + s);
57+
}
58+
59+
5160

5261
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package test;
2+
3+
import java.awt.event.ActionEvent;
4+
import java.awt.event.ActionListener;
5+
import java.beans.PropertyChangeEvent;
6+
import java.beans.PropertyChangeListener;
7+
import java.util.ArrayList;
8+
import java.util.Arrays;
9+
import java.util.Comparator;
10+
import java.util.Date;
11+
import java.util.List;
12+
import java.util.function.BiPredicate;
13+
import java.util.function.Consumer;
14+
import java.util.function.Function;
15+
import java.util.function.Predicate;
16+
import java.util.function.ToIntFunction;
17+
import java.util.stream.DoubleStream;
18+
import java.util.stream.IntStream;
19+
import java.util.stream.Stream;
20+
21+
import javax.swing.JButton;
22+
import javax.swing.SwingUtilities;
23+
import javax.swing.Timer;
24+
25+
import test.baeldung.doublecolon.Computer;
26+
import test.baeldung.doublecolon.MacbookPro;
27+
28+
public class Test_J8_lambdafinal2 extends Test_ {
29+
30+
31+
public static void main(String args[]) {
32+
33+
testFinal();
34+
}
35+
36+
private static void testFinal() {
37+
38+
Runnable r = () -> {
39+
for (String s : new String[] { "a", "b" }) {
40+
Runnable r1 = () -> {
41+
for (int i : new int[] { 0, 1, 2 }) {
42+
System.out.println(i + " " + s);
43+
}
44+
testDone(s);
45+
46+
};
47+
r1.run();
48+
}
49+
testDone("");
50+
};
51+
r.run();
52+
}
53+
54+
private static void testDone(String s) {
55+
System.out.println("DONE " + s);
56+
}
57+
58+
59+
60+
}

0 commit comments

Comments
 (0)