diff --git a/sources/net.sf.j2s.core/dist/swingjs/net.sf.j2s.core.jar b/sources/net.sf.j2s.core/dist/swingjs/net.sf.j2s.core.jar index f3dcf8139..e69de29bb 100644 Binary files a/sources/net.sf.j2s.core/dist/swingjs/net.sf.j2s.core.jar and b/sources/net.sf.j2s.core/dist/swingjs/net.sf.j2s.core.jar differ diff --git a/sources/net.sf.j2s.core/dist/swingjs/timestamp b/sources/net.sf.j2s.core/dist/swingjs/timestamp index 2898c400e..1c0239479 100644 --- a/sources/net.sf.j2s.core/dist/swingjs/timestamp +++ b/sources/net.sf.j2s.core/dist/swingjs/timestamp @@ -1 +1,5 @@ -20230311212845 +<<<<<<< HEAD +20230329174944 +======= +20230329170441 +>>>>>>> branch 'hanson1' of https://github.com/BobHanson/java2script diff --git a/sources/net.sf.j2s.core/dist/swingjs/ver/3.3.1/net.sf.j2s.core.jar b/sources/net.sf.j2s.core/dist/swingjs/ver/3.3.1/net.sf.j2s.core.jar index f3dcf8139..e69de29bb 100644 Binary files a/sources/net.sf.j2s.core/dist/swingjs/ver/3.3.1/net.sf.j2s.core.jar and b/sources/net.sf.j2s.core/dist/swingjs/ver/3.3.1/net.sf.j2s.core.jar differ diff --git a/sources/net.sf.j2s.core/dist/swingjs/ver/3.3.1/timestamp b/sources/net.sf.j2s.core/dist/swingjs/ver/3.3.1/timestamp index 2898c400e..1c0239479 100644 --- a/sources/net.sf.j2s.core/dist/swingjs/ver/3.3.1/timestamp +++ b/sources/net.sf.j2s.core/dist/swingjs/ver/3.3.1/timestamp @@ -1 +1,5 @@ -20230311212845 +<<<<<<< HEAD +20230329174944 +======= +20230329170441 +>>>>>>> branch 'hanson1' of https://github.com/BobHanson/java2script diff --git a/sources/net.sf.j2s.core/src/net/sf/j2s/core/CorePlugin.java b/sources/net.sf.j2s.core/src/net/sf/j2s/core/CorePlugin.java index 5f5c4d829..934525c93 100644 --- a/sources/net.sf.j2s.core/src/net/sf/j2s/core/CorePlugin.java +++ b/sources/net.sf.j2s.core/src/net/sf/j2s/core/CorePlugin.java @@ -25,11 +25,12 @@ public class CorePlugin extends Plugin { * "net.sf.j2s.core.jar" not "net.sf.j2s.core.3.2.5" * */ - public static String VERSION = "3.3.1-v6"; + public static String VERSION = "3.3.1-v7"; // if you change the x.x.x number, be sure to also indicate that in // j2sApplet.js and also (Bob only) update.bat, update-clean.bat + // 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 // BH 2022.06.27 -- 3.3.1-v5 fixes missing method annotations // BH 2022.01.17 -- 3.3.1-v4 fixes default interface methods referencing their own static fields diff --git a/sources/net.sf.j2s.core/src/net/sf/j2s/core/Java2ScriptVisitor.java b/sources/net.sf.j2s.core/src/net/sf/j2s/core/Java2ScriptVisitor.java index b3318f41e..ac4929b00 100644 --- a/sources/net.sf.j2s.core/src/net/sf/j2s/core/Java2ScriptVisitor.java +++ b/sources/net.sf.j2s.core/src/net/sf/j2s/core/Java2ScriptVisitor.java @@ -136,6 +136,9 @@ // TODO: superclass inheritance for JAXB XmlAccessorType // TODO: Transpiler bug allows static String name, but JavaScript function().name is read-only and will be "clazz" +//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 +//BH 2022.06.27 -- 3.3.1-v5 fixes missing method annotations //BH 2022.01.17 -- 3.3.1-v4 fixes default interface methods referencing their own static fields //BH 2021.01.14 -- 3.3.1-v3 fixes missing finals for nested () -> {...} //BH 2021.01.03 -- 3.3.1-v2 adds @j2sAsync adds async for function - experimental @@ -1578,11 +1581,16 @@ private boolean addMethodInvocation(SimpleName javaQualifier, List arguments, String privateVar = (isPrivateAndNotStatic ? getPrivateVar(declaringClass, false) : null); boolean doLogMethodCalled = (!isPrivate && global_htMethodsCalled != null); boolean needBname = ( - - !isStatic && lambdaArity < 0 && (expression == null + !isStatic + && (lambdaArity < 0 + && (expression == null ? !areEqual(declaringClass, class_typeBinding) && !class_typeBinding.isAssignmentCompatible(declaringClass) - : expression instanceof ThisExpression && ((ThisExpression) expression).getQualifier() != null) || class_localType == LAMBDA_EXPRESSION); + : expression instanceof ThisExpression + && ((ThisExpression) expression).getQualifier() != null) + || class_localType == LAMBDA_EXPRESSION) + ); + String bname = (needBname ? getThisRefOrSyntheticReference(javaQualifier, declaringClass, null) : null); // add the qualifier int pt = buffer.length(); @@ -4879,7 +4887,7 @@ private void addQualifiedNameForBinding(IVariableBinding varBinding, boolean isS * * For general fields, this will be "this.". * - * For fields in outer classes, we need a synthetic references, + * For nonstatic fields in outer classes, we need a synthetic references, * this.b$[className] that points to the outer object, which may be one or more * levels higher than this one. * diff --git a/sources/net.sf.j2s.java.core/doc/Differences.txt b/sources/net.sf.j2s.java.core/doc/Differences.txt index 4e3c9213e..773c19360 100644 --- a/sources/net.sf.j2s.java.core/doc/Differences.txt +++ b/sources/net.sf.j2s.java.core/doc/Differences.txt @@ -1,6 +1,7 @@ java2script/SwingJS Notes ========================= +updated 3/11/2023 -- adds support for Java Regex Matcher.start/end(groupID) and .start/end(groupName) updated 12/31/2020 -- full support for 64-bit long updated 12/6/2020 -- note about restrictions on long, including BitSet and Scanner updated 3/21/2020 -- adds note about HashMap, Hashtable, and HashSet iterator ordering diff --git a/sources/net.sf.j2s.java.core/src/javajs/util/CifDataParser.java b/sources/net.sf.j2s.java.core/src/javajs/util/CifDataParser.java index 278c4bd38..dc3ce766f 100644 --- a/sources/net.sf.j2s.java.core/src/javajs/util/CifDataParser.java +++ b/sources/net.sf.j2s.java.core/src/javajs/util/CifDataParser.java @@ -339,10 +339,11 @@ public String readLine() { if (line == null) return null; if (isHeader) { - if (line.startsWith("#")) + if (line.startsWith("#")) { fileHeader.append(line).appendC('\n'); - else + } else if (line.length() > 0) { isHeader = false; + } } return line; } catch (Exception e) { diff --git a/sources/net.sf.j2s.java.core/src/test/Test_.java b/sources/net.sf.j2s.java.core/src/test/Test_.java index d64b98406..143c186aa 100644 --- a/sources/net.sf.j2s.java.core/src/test/Test_.java +++ b/sources/net.sf.j2s.java.core/src/test/Test_.java @@ -95,6 +95,15 @@ private static void _test1(String[] args) { static boolean isBatch = false; + /** + * static public j2sHeadless TRUE + * triggers headless operation in swingjs2.js + * + * Additional way to initiate headless operation: + * + * From URL: ?j2sheadless or &j2sheadless + * + */ static public boolean j2sHeadless = true; static public int bhtest = 100; diff --git a/sources/net.sf.j2s.java.core/src/test/Test_Class.java b/sources/net.sf.j2s.java.core/src/test/Test_Class.java index e0a9b5351..73596f928 100644 --- a/sources/net.sf.j2s.java.core/src/test/Test_Class.java +++ b/sources/net.sf.j2s.java.core/src/test/Test_Class.java @@ -444,10 +444,12 @@ public static void main(String[] args) { e1.printStackTrace(); } + String whatever = "whatever"; + class LocalClass { String hello() { - return "LocalClass says hello"; + return "LocalClass says hello " + whatever; } } diff --git a/sources/net.sf.j2s.java.core/src/test/Test_J8_lambdafinal.java b/sources/net.sf.j2s.java.core/src/test/Test_J8_lambdafinal.java index f0a585efe..7c44ced02 100644 --- a/sources/net.sf.j2s.java.core/src/test/Test_J8_lambdafinal.java +++ b/sources/net.sf.j2s.java.core/src/test/Test_J8_lambdafinal.java @@ -30,10 +30,11 @@ public class Test_J8_lambdafinal extends Test_ { public static void main(String args[]) { + new Test_J8_lambdafinal(). testFinal(); } - private static void testFinal() { + private void testFinal() { Runnable r = () -> { for (String s : new String[] { "a", "b" }) { @@ -41,12 +42,20 @@ private static void testFinal() { for (int i : new int[] { 0, 1, 2 }) { System.out.println(i + " " + s); } + testDone(s); }; r1.run(); } + testDone(""); }; r.run(); } + + private static void testDone(String s) { + System.out.println("DONE " + s); + } + + } diff --git a/sources/net.sf.j2s.java.core/src/test/Test_J8_lambdafinal2.java b/sources/net.sf.j2s.java.core/src/test/Test_J8_lambdafinal2.java new file mode 100644 index 000000000..b657f2630 --- /dev/null +++ b/sources/net.sf.j2s.java.core/src/test/Test_J8_lambdafinal2.java @@ -0,0 +1,60 @@ +package test; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.function.BiPredicate; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.function.ToIntFunction; +import java.util.stream.DoubleStream; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +import javax.swing.JButton; +import javax.swing.SwingUtilities; +import javax.swing.Timer; + +import test.baeldung.doublecolon.Computer; +import test.baeldung.doublecolon.MacbookPro; + +public class Test_J8_lambdafinal2 extends Test_ { + + + public static void main(String args[]) { + + testFinal(); + } + + private static void testFinal() { + + Runnable r = () -> { + for (String s : new String[] { "a", "b" }) { + Runnable r1 = () -> { + for (int i : new int[] { 0, 1, 2 }) { + System.out.println(i + " " + s); + } + testDone(s); + + }; + r1.run(); + } + testDone(""); + }; + r.run(); + } + + private static void testDone(String s) { + System.out.println("DONE " + s); + } + + + +}