Skip to content

Commit 775c292

Browse files
committed
upgrade for asynchronous packaging
1 parent 58d90a5 commit 775c292

File tree

10 files changed

+51
-45
lines changed

10 files changed

+51
-45
lines changed
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20230210093656
1+
20230212221227
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20230210093656
1+
20230212221227

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
import org.eclipse.jdt.core.dom.WildcardType;
135135

136136
// TODO: superclass inheritance for JAXB XmlAccessorType
137+
// TODO: Transpiler bug allows static String name, but JavaScript function().name is read-only and will be "clazz"
137138

138139
//BH 2022.01.17 -- 3.3.1-v4 fixes default interface methods referencing their own static fields
139140
//BH 2021.01.14 -- 3.3.1-v3 fixes missing finals for nested () -> {...}
Binary file not shown.

sources/net.sf.j2s.java.core/src/java/awt/Container.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2447,7 +2447,8 @@ static class DropTargetEventTargetFilter implements EventTargetFilter {
24472447

24482448
private DropTargetEventTargetFilter() {}
24492449

2450-
public boolean accept(final Component comp) {
2450+
@Override
2451+
public boolean accept(final Component comp) {
24512452
DropTarget dt = comp.getDropTarget();
24522453
return dt != null && dt.isActive();
24532454
}

sources/net.sf.j2s.java.core/srcjs/js/j2sApplet.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,13 @@ window.J2S = J2S = (function() {
312312
return $.ajax(info);
313313
}
314314

315+
J2S.$getScriptAsync = function(file, whenDone) {
316+
if (J2S._nozcore) {
317+
file = file.replace(/\.z\.js/,".js");
318+
}
319+
return $.getScript(file, whenDone);
320+
}
321+
315322
var fixProtocol = function(url) {
316323
if (!J2S._isFile && url.indexOf("file://") >= 0)
317324
url = "http" + url.substring(4);
@@ -1996,7 +2003,7 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
19962003
var xym = getXY(who, ev, 0);
19972004
if (!xym)
19982005
return false;
1999-
who.applet._processEvent(505, xym, ev);// MouseEvent.MOUSE_EXITED
2006+
who.applet._processEvent(505, xym, ev, who._frameViewer);// MouseEvent.MOUSE_EXITED
20002007
return false;
20012008
}
20022009

sources/net.sf.j2s.java.core/srcjs/js/j2sClazz.js

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,11 +2401,12 @@ _Loader.loadPackageClasspath = function (pkg, base, isIndex, fSuccess, mode, pt)
24012401
// pkgRefCount++;
24022402
if (pkg == "java")
24032403
pkg = "core" // JSmol -- moves java/package.js to core/package.js
2404-
_Loader.loadClass(pkg + ".package", function () {
2405-
// if (--pkgRefCount == 0)
2406-
// runtimeLoaded();
2407-
// fSuccess && fSuccess();
2408-
}, true, true, 1);
2404+
2405+
if (fSuccess) {
2406+
J2S.$getScriptAsync(_Loader.getClasspathFor(pkg + ".package"), fSuccess);
2407+
return;
2408+
}
2409+
_Loader.loadClass(pkg + ".package", null, true, true, 1);
24092410
return;
24102411
}
24112412
fSuccess && fSuccess();
@@ -2628,6 +2629,7 @@ Clazz._getClassCount = function() {
26282629
}
26292630

26302631
Clazz._4Name = function(clazzName, applet, state, asClazz, initialize, isQuiet) {
2632+
// applet and state always null in SwingJS
26312633
var cl;
26322634
if (clazzName.indexOf("[") == 0) {
26332635
cl = getArrayClass(clazzName);
@@ -2755,16 +2757,9 @@ _Loader.MODE_SCRIPT = 4;
27552757
_Loader.MODE_XHR = 2;
27562758
_Loader.MODE_SYNC = 1;
27572759

2758-
/**
2759-
* String mode: asynchronous modes: async(...).script, async(...).xhr,
2760-
* async(...).xmlhttprequest, script.async(...), xhr.async(...),
2761-
* xmlhttprequest.async(...), script
2762-
*
2763-
* synchronous modes: sync(...).xhr, sync(...).xmlhttprequest, xhr.sync(...),
2764-
* xmlhttprequest.sync(...), xmlhttprequest, xhr
2765-
*
2766-
* Integer mode: Script 4; XHR 2; SYNC bit 1;
2767-
*/
2760+
// Integer mode: Script 4; XHR 2; SYNC bit 1;
2761+
// async is currently ignored
2762+
27682763
/* public */
27692764
_Loader.setLoadingMode = function (mode, timeLag) {
27702765
var async = true;
@@ -2782,10 +2777,10 @@ _Loader.setLoadingMode = function (mode, timeLag) {
27822777
else
27832778
async = !(mode & _Loader.MODE_SYNC);
27842779
}
2785-
isUsingXMLHttpRequest = ajax;
2786-
isAsynchronousLoading = async;
2787-
loadingTimeLag = (async && timeLag >= 0 ? timeLag: -1);
2788-
return async;
2780+
isUsingXMLHttpRequest = ajax; // ignored
2781+
isAsynchronousLoading = async; // ignored
2782+
loadingTimeLag = (async && timeLag >= 0 ? timeLag: -1); // ignored
2783+
return async; // will be false
27892784
};
27902785

27912786
/*
@@ -3405,7 +3400,7 @@ setps(Sys.err, function(s) {Con.consoleOutput(s, "red")});
34053400
Clazz._Loader.registerPackages("java", [ "io", "lang", "lang.reflect", "util" ]);
34063401

34073402

3408-
J2S.setGlobal("java.registered", true);
3403+
// old J2S.setGlobal("java.registered", true);
34093404

34103405
// /////////////// special definitions of standard Java class methods
34113406
// ///////////

sources/net.sf.j2s.java.core/srcjs/swingjs2.js

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10998,6 +10998,13 @@ window.J2S = J2S = (function() {
1099810998
return $.ajax(info);
1099910999
}
1100011000

11001+
J2S.$getScriptAsync = function(file, whenDone) {
11002+
if (J2S._nozcore) {
11003+
file = file.replace(/\.z\.js/,".js");
11004+
}
11005+
return $.getScript(file, whenDone);
11006+
}
11007+
1100111008
var fixProtocol = function(url) {
1100211009
if (!J2S._isFile && url.indexOf("file://") >= 0)
1100311010
url = "http" + url.substring(4);
@@ -12682,7 +12689,7 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
1268212689
var xym = getXY(who, ev, 0);
1268312690
if (!xym)
1268412691
return false;
12685-
who.applet._processEvent(505, xym, ev);// MouseEvent.MOUSE_EXITED
12692+
who.applet._processEvent(505, xym, ev, who._frameViewer);// MouseEvent.MOUSE_EXITED
1268612693
return false;
1268712694
}
1268812695

@@ -16455,11 +16462,12 @@ _Loader.loadPackageClasspath = function (pkg, base, isIndex, fSuccess, mode, pt)
1645516462
// pkgRefCount++;
1645616463
if (pkg == "java")
1645716464
pkg = "core" // JSmol -- moves java/package.js to core/package.js
16458-
_Loader.loadClass(pkg + ".package", function () {
16459-
// if (--pkgRefCount == 0)
16460-
// runtimeLoaded();
16461-
// fSuccess && fSuccess();
16462-
}, true, true, 1);
16465+
16466+
if (fSuccess) {
16467+
J2S.$getScriptAsync(_Loader.getClasspathFor(pkg + ".package"), fSuccess);
16468+
return;
16469+
}
16470+
_Loader.loadClass(pkg + ".package", null, true, true, 1);
1646316471
return;
1646416472
}
1646516473
fSuccess && fSuccess();
@@ -16682,6 +16690,7 @@ Clazz._getClassCount = function() {
1668216690
}
1668316691

1668416692
Clazz._4Name = function(clazzName, applet, state, asClazz, initialize, isQuiet) {
16693+
// applet and state always null in SwingJS
1668516694
var cl;
1668616695
if (clazzName.indexOf("[") == 0) {
1668716696
cl = getArrayClass(clazzName);
@@ -16809,16 +16818,9 @@ _Loader.MODE_SCRIPT = 4;
1680916818
_Loader.MODE_XHR = 2;
1681016819
_Loader.MODE_SYNC = 1;
1681116820

16812-
/**
16813-
* String mode: asynchronous modes: async(...).script, async(...).xhr,
16814-
* async(...).xmlhttprequest, script.async(...), xhr.async(...),
16815-
* xmlhttprequest.async(...), script
16816-
*
16817-
* synchronous modes: sync(...).xhr, sync(...).xmlhttprequest, xhr.sync(...),
16818-
* xmlhttprequest.sync(...), xmlhttprequest, xhr
16819-
*
16820-
* Integer mode: Script 4; XHR 2; SYNC bit 1;
16821-
*/
16821+
// Integer mode: Script 4; XHR 2; SYNC bit 1;
16822+
// async is currently ignored
16823+
1682216824
/* public */
1682316825
_Loader.setLoadingMode = function (mode, timeLag) {
1682416826
var async = true;
@@ -16836,10 +16838,10 @@ _Loader.setLoadingMode = function (mode, timeLag) {
1683616838
else
1683716839
async = !(mode & _Loader.MODE_SYNC);
1683816840
}
16839-
isUsingXMLHttpRequest = ajax;
16840-
isAsynchronousLoading = async;
16841-
loadingTimeLag = (async && timeLag >= 0 ? timeLag: -1);
16842-
return async;
16841+
isUsingXMLHttpRequest = ajax; // ignored
16842+
isAsynchronousLoading = async; // ignored
16843+
loadingTimeLag = (async && timeLag >= 0 ? timeLag: -1); // ignored
16844+
return async; // will be false
1684316845
};
1684416846

1684516847
/*
@@ -17459,7 +17461,7 @@ setps(Sys.err, function(s) {Con.consoleOutput(s, "red")});
1745917461
Clazz._Loader.registerPackages("java", [ "io", "lang", "lang.reflect", "util" ]);
1746017462

1746117463

17462-
J2S.setGlobal("java.registered", true);
17464+
// old J2S.setGlobal("java.registered", true);
1746317465

1746417466
// /////////////// special definitions of standard Java class methods
1746517467
// ///////////

0 commit comments

Comments
 (0)