Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified sources/net.sf.j2s.core/dist/swingjs/net.sf.j2s.core.jar
Binary file not shown.
6 changes: 5 additions & 1 deletion sources/net.sf.j2s.core/dist/swingjs/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
20230311212845
<<<<<<< HEAD
20230329174944
=======
20230329170441
>>>>>>> branch 'hanson1' of https://github.com/BobHanson/java2script
Binary file not shown.
6 changes: 5 additions & 1 deletion sources/net.sf.j2s.core/dist/swingjs/ver/3.3.1/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
20230311212845
<<<<<<< HEAD
20230329174944
=======
20230329170441
>>>>>>> branch 'hanson1' of https://github.com/BobHanson/java2script
3 changes: 2 additions & 1 deletion sources/net.sf.j2s.core/src/net/sf/j2s/core/CorePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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.
*
Expand Down
1 change: 1 addition & 0 deletions sources/net.sf.j2s.java.core/doc/Differences.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions sources/net.sf.j2s.java.core/src/test/Test_.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion sources/net.sf.j2s.java.core/src/test/Test_Class.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
11 changes: 10 additions & 1 deletion sources/net.sf.j2s.java.core/src/test/Test_J8_lambdafinal.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,32 @@ 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" }) {
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);
}



}
60 changes: 60 additions & 0 deletions sources/net.sf.j2s.java.core/src/test/Test_J8_lambdafinal2.java
Original file line number Diff line number Diff line change
@@ -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);
}



}