You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sources/net.sf.j2s.core/doc/howItWorks.md
+9-11Lines changed: 9 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,12 +7,12 @@ As such, it use the "legacy" version of the transpiler created and formerly main
7
7
solely by Zhou Renjien. This code was the basis for SwingJS, and by careful adapting Jmol
8
8
to fit it, we could make it work with this somewhat quirky code. (For example, there is no
9
9
support for boxing and unboxing numbers -- int i = Integer.valueOf(3) is not properly turned
10
-
into just the number 3. I got around this in those early days by just going through all
10
+
into just the number 3.) I got around this in those early days by just going through all
11
11
(and I mean ALL) of the Jmol code, making sure there were no implicit boxing or unboxing.
12
12
13
13
The primary issue with this transpiler is that it does not "qualify" method names.
14
14
Thus, BufferedWriter.write(char) and BufferedWriter.write(int) both run through the
15
-
same method in JavaScript, and (a very complex and time-expensive) algorithm then
15
+
same method in JavaScript, and a (very complex and time-expensive) algorithm then
16
16
sorts out based on the JavaScript parameter type what is the MOST LIKELY intended
17
17
method target. I did a huge amount of refactoring in Jmol to ensure that it almost
18
18
never calls overloaded methods like this.
@@ -64,6 +64,7 @@ The full java2script/SwingJS operation involves two parts: Creating the JavaScri
64
64
The code for these two parts are well-separated:
65
65
66
66
net.sf.j2s.core java2script transpiler
67
+
67
68
net.sf.j2s.java.core SwingJS runtime
68
69
69
70
@@ -91,14 +92,14 @@ thank you https://bugs.eclipse.org/bugs/show_bug.cgi?id=525280
91
92
]
92
93
93
94
94
-
When it is desired to create the transpiler (net.sf.j2s.core.jar):
95
+
When it is desired to create the transpiler (j2s.core.jar):
95
96
96
97
1) Use File...Export...Deployable plug-ins and fragments
97
98
(if you do not see this option, check that you are using Eclipse
98
99
Enterprise)
99
-
2) Choose net.sf.j2s.core (Version x.x.x), check the directory,
100
+
2) Choose j2s.core.jar (Version x.x.x), indicate the output directory,
100
101
and press finish.
101
-
3) Copy this file to the drop-ins directory, restart Eclipse,
102
+
3) Copy this file to the dropins directory, restart Eclipse,
102
103
and test.
103
104
4) Copy this file to the project dist/swingjs folder and also
104
105
to the swingjs/ver/x.x.x folder (or appropriate).
@@ -107,12 +108,9 @@ When it is desired to create the transpiler (net.sf.j2s.core.jar):
107
108
108
109
I do this with a DOS batch file, which also adds a timestamp.
109
110
110
-
That's it. I advise to NOT change the version number. I know, this
111
-
sounds stupid, but if you change that number, installation in Eclipse requires starting Eclipse with a -clean as the first option. https://www.eclipsezone.com//eclipse/forums/t61566.html
112
-
This is pain. If you do not do this clean build, Eclipse just
113
-
ignores your drop-in.
111
+
That's it.
114
112
115
-
The dist directory also includes SwingJS-site.zip, created from the net.sf.j2s.core.java project.
113
+
The dist directory includes SwingJS-site.zip, created from the net.sf.j2s.core.java project.
116
114
117
115
118
116
**SwingJS runtime maintenance**
@@ -130,7 +128,7 @@ The important thing here is to maintain backward compatibility at all times. It
130
128
So, basically, you can add to or modify any of the several thousand classes in j2s.net.sf.java.core/src. Just be careful to allow for what is already there to still run. Adding a new class can be a challenge. Note that we have not implemented serialization or accessibility. This was a design decision based on need. We needed applet code to run, and these two features added far too much complexity to the task. So we ignored them. (Serialization, in particular, is probably not ever going to work in JavaScript, because the java2script transpiler does not preserve enough information about variable types to make that work properly.)
0 commit comments