Skip to content

Commit 3d5adb9

Browse files
authored
Merge pull request #135 from BobHanson/master
new transpiler for Java 11 and minor fixes in j2s and SwingJS
2 parents 9031b03 + 360927e commit 3d5adb9

File tree

21 files changed

+775
-40
lines changed

21 files changed

+775
-40
lines changed
-2.26 KB
Binary file not shown.
12 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20191025154731
1+
20191027191514
-2.26 KB
Binary file not shown.
12 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20191025154731
1+
20191027191514

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
@@ -19,7 +19,8 @@ public class CorePlugin extends Plugin {
1919
* register the bundle version properly. So we use VERSION here instead.
2020
*
2121
*/
22-
public static String VERSION = "3.2.4.08";
22+
public static String VERSION = "3.2.4.09";
23+
// BH 2019.10.27 -- 3.2.4.09 fixes problem with method of name c() becoming c$() -- constructor
2324
// BH 2019.10.25 -- 3.2.4.09 adds j2s.compiler.java.version (default 8)
2425
// BH 2019.10.25 -- 3.2.4.09 adds j2s.break.on.error (default false)
2526
// BH 2019.10.25 -- 3.2.4.09 fixes missing resource copy for git projects

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5014,7 +5014,8 @@ private static boolean classHasNoParameterMethod(ITypeBinding methodClass, Strin
50145014
|| j2sName.indexOf("$", 2) >= 0 || j2sName.equals("c$")
50155015
|| className != null && NameMapper.isMethodNonqualified(className, mBinding.getName()))
50165016
return j2sName;
5017-
return j2sName + "$";
5017+
// c() must be changed to c$$, not c$, which is the constructor
5018+
return (j2sName.equals("c") ? "c$$" : j2sName + "$");
50185019
}
50195020

50205021
/**
-2.26 KB
Binary file not shown.

sources/net.sf.j2s.java.core/doc/Differences.txt

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Notes
22
=====
3+
updated 10/26/19 -- adds information about File.createTempFile()
34
updated 8/16/19 -- minor typos and added summary paragraph
45
updated 7/19/19 -- clarification that AWT and Swing classes are supported directly
56
updated 5/13/19 -- Mandarin U+79D8 reserved character; Missing Math methods; int and long
@@ -233,6 +234,12 @@ a2s components, which in turn subclass JComponents. So no changes in code are ne
233234
successfully transpiled over 500 applets using this strategy. (Kind of surprising, actually, that
234235
the original Java developers did not see that option. But we have a hindsight advantage here.)
235236

237+
Temporary Files
238+
===============
239+
240+
SwingJS will maintain a pseudo-filesystem for files created with File.createTempFile(). This
241+
is useful in that closure of writing to the file does not generate a download to the user's
242+
machine (which typically requires user intervention).
236243

237244
UNIMPLEMENTED CLASSES BY DESIGN
238245
===============================
@@ -459,6 +466,76 @@ It's a simple modification:
459466
System.out.println("int value is " + value);
460467
}
461468

469+
javax.swing.JOptionPane dialogs
470+
-------------------------------
471+
472+
For this action to work, the parentComponent must implement
473+
propertyChangeListener, and any call to JOptionPanel should allow for
474+
asynchronous response.
475+
476+
In addition, for compatibility with the Java version, implementation should
477+
wrap the call to getConfirmDialog or getOptionDialog in a method call to
478+
handle the Java:
479+
480+
onDialogReturn(JOptionPane.showConfirmDialog(parentFrame,
481+
messageOrMessagePanel, "title", JOptionPane.OK_CANCEL_OPTION));
482+
483+
Then parentFrame.propertyChange(event) should also call onDialogReturn.
484+
485+
This will then work in both Java and JavaScript.
486+
487+
Note that there is an int and an Object version of onDialogReturn().
488+
489+
490+
In JavaScript:
491+
492+
The initial return from JOptionPane.showConfirmDialog and showMessageDialog
493+
will be NaN, testable as an impossible Java int value using ret !=
494+
Math.floor(ret) if the parent implements PropertyChangeListeneer, or -1
495+
(CLOSE_OPTION) if not.
496+
497+
For showOptionDialog (which returns Object) or showInputDialog (which returns
498+
String), the initial return will be JDialog.ASYNCHRONOUS_OBJECT, testable as
499+
((Object) ret) instanceof javax.swing.plaf.UIResource if the parent implements
500+
PropertyChangeListeneer, or null if not.
501+
502+
The second return will be the desired return.
503+
504+
In Java:
505+
506+
The initial return will be the one and only modal final return.
507+
508+
509+
510+
For full compatibility, The calling method must not continue beyond this
511+
call.
512+
513+
All of the standard Java events associated with Components are also
514+
available.
515+
516+
Certain fall back mechanisms are possible, where onReturn does not exist, but
517+
only for the falling cases:
518+
519+
520+
For showMessageDialog, for WARNING_MESSAGE and ERROR_MESSAGE, a simple
521+
JavaScript alert() is used, returning 0 (OK_OPTION) or -1 (CLOSED_OPTION).
522+
523+
For showInputDialog, if the message is a string, a simple JavaScript prompt()
524+
with input box is used, returning the entered string or null.
525+
526+
For showConfirmDialog, a simple JavaScript confirm() is used, in which case:
527+
528+
for YES_NO_OPTION: YES_OPTION or NO_OPTION
529+
530+
for YES_NO_CANCEL_OPTION: YES_OPTION or CANCEL_OPTION
531+
532+
for OK_CANCEL_OPTION or any other: OK_OPTION or CANCEL_OPTION
533+
534+
Note that you should implement a response for CLOSED_OPTION for
535+
showConfirmDialog. For other dialogs, a null return indicates the dialog was
536+
closed, just as for Java.
537+
538+
462539

463540

464541
native methods

0 commit comments

Comments
 (0)