X Tutup
Skip to content

Commit 0aaa901

Browse files
committed
update to new Clazz method names
1 parent 1d31e45 commit 0aaa901

File tree

27 files changed

+36769
-65
lines changed

27 files changed

+36769
-65
lines changed

sources/net.sf.j2s.core/src/net/sf/j2s/core/astvisitors/ASTScriptVisitor.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ public boolean visit(ClassInstanceCreation node) {
330330
String className = TypeAdapter.getTypeStringName(node.getType());
331331
String fqName = getShortenedQualifiedName(className);
332332
if ("Object".equals(fqName)) {
333-
buffer.append(" Clazz.new()");
333+
buffer.append(" Clazz.new_()");
334334
return false;
335335
}
336336
String prefix = null, postfix = null;
@@ -1090,7 +1090,7 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List<?>
10901090
// arg1 is the package name
10911091
// arg2 is the full class name in quotes
10921092
// arg3 is the class definition function, C$, which is called in
1093-
// Clazz.new().
1093+
// Clazz.new_().
10941094
// arg4 is the superclass
10951095
// arg5 is the superinterface(s)
10961096
// arg6 is the type: anonymous(1), local(2), or absent
@@ -1441,8 +1441,8 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List<?>
14411441
}
14421442

14431443
/**
1444-
* For Clazz.newClass$ we want an array if there is an inner class
1445-
* so that the outer class is guarranteed to be loaded first.
1444+
* For Clazz.newClass we want an array if there is an inner class
1445+
* so that the outer class is guaranteed to be loaded first.
14461446
*
14471447
* @param className
14481448
* @return
@@ -1598,7 +1598,7 @@ private boolean addFieldDeclaration(FieldDeclaration field, int mode) {
15981598

15991599
/**
16001600
*
1601-
* generate the Clazz.new(...) call for an inner class.
1601+
* generate the Clazz.new_(...) call for an inner class.
16021602
*
16031603
* @param node
16041604
* @param innerName
@@ -1664,7 +1664,7 @@ private void addMethodParameterList(List<?> arguments, IMethodBinding methodDecl
16641664
// We allow use of a default constructor using new foo().
16651665
// Here we always add a [] argument to a default constuctor, as null
16661666
// will indicate
1667-
// that we did not use Clazz.new and instead called new foo()
1667+
// that we did not use Clazz.new_ and instead called new foo()
16681668
// directly.
16691669
if (prefix != null) {
16701670
buffer.append(prefix);
@@ -1688,7 +1688,7 @@ private void addMethodParameterList(List<?> arguments, IMethodBinding methodDecl
16881688
private void addSuperConstructor(SuperConstructorInvocation node, IMethodBinding methodDeclaration) {
16891689
if (node == null) {
16901690
// default constructor
1691-
buffer.append("Clazz.super(C$, this,1);\r\n");
1691+
buffer.append("Clazz.super_(C$, this,1);\r\n");
16921692
return;
16931693
}
16941694
buffer.append(getJ2SQualifiedName("C$.superclazz.c$", null, node.resolveConstructorBinding(), null, false));
@@ -1772,14 +1772,14 @@ protected void log(String msg) {
17721772
}
17731773

17741774
/**
1775-
* Start a new Clazz.new() call for class creation or inner classes. Uses Clazz.load for dynamic loading
1775+
* Start a new Clazz.new_() call for class creation or inner classes. Uses Clazz.load for dynamic loading
17761776
*
17771777
* @param className
17781778
* @param dotMethodName
17791779
* @return true if this is the default constructor
17801780
*/
17811781
private void openNew(String className, IMethodBinding mbinding) {
1782-
buffer.append("Clazz.new(");
1782+
buffer.append("Clazz.new_(");
17831783
String name = assureQualifiedName(className);
17841784
if (!name.equals("C$"))
17851785
name = getQualifiedStaticName(null, className, true, true, false);

sources/net.sf.j2s.core/src/net/sf/j2s/core/compiler/Java2ScriptCompiler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ private String getDefaultHTMLTemplate() {
326326
+" main: _MAIN_,\n"
327327
+" width: 850,\n"
328328
+" height: 550,\n"
329-
+" serverURL: 'http://chemapps.stolaf.edu/jmol/jsmol/php/jsmol.php',\n"
329+
+" serverURL: 'https://chemapps.stolaf.edu/jmol/jsmol/php/jsmol.php',\n"
330330
+" j2sPath: 'swingjs/j2s',\n"
331331
+" console:'sysoutdiv',\n"
332332
+" allowjavascript: true\n"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
})();
3+
4+
Clazz._coreLoaded = true;
5+
6+
7+

sources/net.sf.j2s.core/test/dev/core/corebottom2.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
;(function() {
2+
3+
if (Jmol._debugCode)return;
4+

sources/net.sf.j2s.core/test/dev/core/coretop2.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sources/net.sf.j2s.java.core/build_core_applet.xml

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,75 @@
207207
swingjs/plaf/JSSliderUI.js
208208
swingjs/plaf/LazyActionMap.js
209209
swingjs/plaf/Resizer.js
210+
211+
java/awt/color/ColorSpace.js
212+
java/awt/Cursor.js
213+
java/awt/Dialog.js
214+
java/awt/event/AdjustmentEvent.js
215+
java/awt/event/FocusEvent.js
216+
java/awt/event/ItemEvent.js
217+
java/awt/event/WindowAdapter.js
218+
java/awt/event/WindowEvent.js
219+
java/awt/Frame.js
220+
java/awt/geom/Point2D.js
221+
java/awt/GraphicsCallback.js
222+
java/awt/peer/FramePeer.js
223+
java/awt/peer/WindowPeer.js
224+
java/awt/Point.js
225+
java/awt/Window.js
226+
java/lang/Enum.js
227+
java/util/Random.js
228+
java/util/Vector.js
229+
javax/swing/AbstractListModel.js
230+
javax/swing/AncestorNotifier.js
231+
javax/swing/BoxLayout.js
232+
javax/swing/ButtonGroup.js
233+
javax/swing/ClientPropertyKey.js
234+
javax/swing/ComboBoxModel.js
235+
javax/swing/DefaultComboBoxModel.js
236+
javax/swing/DefaultSingleSelectionModel.js
237+
javax/swing/event/AncestorEvent.js
238+
javax/swing/event/ChangeEvent.js
239+
javax/swing/event/ListDataEvent.js
240+
javax/swing/event/ListDataListener.js
241+
javax/swing/JCheckBox.js
242+
javax/swing/JCheckBoxMenuItem.js
243+
javax/swing/JComboBox.js
244+
javax/swing/JFrame.js
245+
javax/swing/JMenu.js
246+
javax/swing/JMenuBar.js
247+
javax/swing/JMenuItem.js
248+
javax/swing/JPopupMenu.js
249+
javax/swing/JRadioButtonMenuItem.js
250+
javax/swing/JSeparator.js
251+
javax/swing/JToggleButton.js
252+
javax/swing/KeyboardManager.js
253+
javax/swing/ListModel.js
254+
javax/swing/MenuElement.js
255+
javax/swing/MutableComboBoxModel.js
256+
javax/swing/SingleSelectionModel.js
257+
javax/swing/SizeRequirements.js
258+
javax/swing/WindowConstants.js
259+
swingjs/plaf/DefaultMenuLayout.js
260+
swingjs/plaf/JSCheckBoxMenuItemUI.js
261+
swingjs/plaf/JSCheckBoxUI.js
262+
swingjs/plaf/JSComboBoxUI.js
263+
swingjs/plaf/JSFrameUI.js
264+
swingjs/plaf/JSMenuBarUI.js
265+
swingjs/plaf/JSMenuItemUI.js
266+
swingjs/plaf/JSMenuUI.js
267+
swingjs/plaf/JSPopupMenuSeparatorUI.js
268+
swingjs/plaf/JSPopupMenuUI.js
269+
swingjs/plaf/JSRadioButtonMenuItemUI.js
270+
swingjs/plaf/JSRadioButtonUI.js
271+
swingjs/plaf/JSSeparatorUI.js
272+
swingjs/plaf/JSWindowUI.js
273+
210274
" />
211275

212276

213277
<antcall target="call-core">
214-
<param name="call-core.name" value="applet" />
278+
<param name="call-core.name" value="swingjs" />
215279
<param name="call-core.list" value="
216280
${javaCoreAppletFiles}
217281
" />

sources/net.sf.j2s.java.core/src/java/io/File.java

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ private File(String child, File parent) {
221221
}
222222

223223
private String resolve(String path, String child) {
224-
if (!path.endsWith("/"))
224+
if (child.length() > 0 && !path.endsWith("/"))
225225
path += "/";
226226
return path + child;
227227
}
@@ -236,7 +236,7 @@ private String resolve(String path, String child) {
236236
* If the <code>pathname</code> argument is <code>null</code>
237237
*/
238238
public File(String pathname) {
239-
this(null, pathname, 0);
239+
this(pathname, "");
240240
// if (pathname == null) {
241241
// throw new NullPointerException();
242242
// }
@@ -277,7 +277,21 @@ public File(String pathname) {
277277
* If <code>child</code> is <code>null</code>
278278
*/
279279
public File(String parent, String child) {
280-
this(parent, child, 0);
280+
if (child == null) {
281+
throw new NullPointerException();
282+
}
283+
if (parent != null) {
284+
if (parent.equals("")) {
285+
this.path = resolve(".", child); // fs.resolve(fs.getDefaultParent(),
286+
// fs.normalize(child));
287+
} else {
288+
this.path = resolve(parent, child);// fs.resolve(fs.normalize(parent),
289+
// fs.normalize(child));
290+
}
291+
} else {
292+
this.path = resolve(".", child);// normalize(child);
293+
}
294+
this.prefixLength = this.path.lastIndexOf("/") + 1; // 1efixLength(this.path);
281295
}
282296

283297
/**
@@ -306,7 +320,7 @@ public File(String parent, String child) {
306320
* If <code>child</code> is <code>null</code>
307321
*/
308322
public File(File parent, String child) {
309-
this(parent == null ? null : parent.getPath(), child, 0);
323+
this(parent == null ? null : parent.getPath(), child);
310324
// if (child == null) {
311325
// throw new NullPointerException();
312326
// }
@@ -394,25 +408,6 @@ public File(File parent, String child) {
394408

395409
/* -- Path-component accessors -- */
396410

397-
public File(String parent, String child, int junk) {
398-
if (child == null) {
399-
throw new NullPointerException();
400-
}
401-
if (parent != null) {
402-
if (parent.equals("")) {
403-
this.path = resolve(".", child); // fs.resolve(fs.getDefaultParent(),
404-
// fs.normalize(child));
405-
} else {
406-
this.path = resolve(parent, child);// fs.resolve(fs.normalize(parent),
407-
// fs.normalize(child));
408-
}
409-
} else {
410-
this.path = resolve(".", child);// normalize(child);
411-
}
412-
this.prefixLength = this.path.lastIndexOf("/") + 1; // 1efixLength(this.path);
413-
414-
}
415-
416411
/**
417412
* Returns the name of the file or directory denoted by this abstract
418413
* pathname. This is just the last name in the pathname's name

sources/net.sf.j2s.java.core/src/java/lang/Class.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,7 +1748,7 @@ public Method getMethod(String name, Class<?>... paramTypes) throws NoSuchMethod
17481748
/**
17491749
* @j2sNative
17501750
*
1751-
* return Clazz.new(java.lang.reflect.Method.c$$Class$S$ClassA$Class$ClassA$I, [this, name,
1751+
* return Clazz.new_(java.lang.reflect.Method.c$$Class$S$ClassA$Class$ClassA$I, [this, name,
17521752
* paramTypes, java.lang.Void, [], 0]);
17531753
*/
17541754
{
@@ -1816,7 +1816,7 @@ public Constructor<T> getConstructor(Class<?>... parameterTypes) throws NoSuchMe
18161816
/**
18171817
* @j2sNative
18181818
*
1819-
* return Clazz.new(java.lang.reflect.Constructor.c$$Class$ClassA$ClassA$I, [this, parameterTypes || [], [], java.lang.reflect.Modifier.PUBLIC]);
1819+
* return Clazz.new_(java.lang.reflect.Constructor.c$$Class$ClassA$ClassA$I, [this, parameterTypes || [], [], java.lang.reflect.Modifier.PUBLIC]);
18201820
*/
18211821
{
18221822
return null;
@@ -2192,6 +2192,7 @@ public Constructor<T> getDeclaredConstructor(Class<?>... parameterTypes)
21922192
* If {@code name} is {@code null}
21932193
* @since JDK1.1
21942194
*/
2195+
21952196
public InputStream getResourceAsStream(String name) {
21962197
// allows an optional second argument to be a base directory in JavaScript
21972198
@SuppressWarnings("unused")
@@ -2237,11 +2238,11 @@ public InputStream getResourceAsStream(String name) {
22372238
try {
22382239
if (fname.indexOf(":/") < 0) {
22392240
var d = document.location.href.split("?")[0].split("/");
2240-
d[d.length - 1] = fname;
2241-
fname = d.join("/");
2241+
d[d.length - 1] = fname;
2242+
fname = d.join("/");
22422243
}
2243-
Clazz.loadClass("java.net.URL");
2244-
url = Clazz.new(java.net.URL.c$$S,[fname]);
2244+
Clazz.load("java.net.URL");
2245+
url = Clazz.new_(java.net.URL.c$$S,[fname]);
22452246
} catch (e) {
22462247
return null;
22472248
}
@@ -2254,9 +2255,9 @@ public InputStream getResourceAsStream(String name) {
22542255
return null;
22552256
22562257
var bytes = (data.__BYTESIZE == 1 ? data : J2S._strToBytes(data));
2257-
Clazz.loadClass("java.io.BufferedInputStream");
2258-
Clazz.loadClass("java.io.ByteArrayInputStream");
2259-
var is = Clazz.new(java.io.BufferedInputStream.c$$java_io_InputStream, [Clazz.new(java.io.ByteArrayInputStream.c$$BA, [bytes])]);
2258+
Clazz.load("java.io.BufferedInputStream");
2259+
Clazz.load("java.io.ByteArrayInputStream");
2260+
var is = Clazz.new_(java.io.BufferedInputStream.c$$java_io_InputStream, [Clazz.new_(java.io.ByteArrayInputStream.c$$BA, [bytes])]);
22602261
is.url = url;
22612262
url._streamData = is;
22622263
return is;
@@ -2808,13 +2809,13 @@ private Method[] privateGetPublicMethods() {
28082809
for (var attr in p) {
28092810
if (typeof p[attr] == "function" && !p[attr].__CLASS_NAME__ && p[attr] != this.$clazz$[attr] && p[attr].exClazz == this.$clazz$) {
28102811
// there are polynormical methods.
2811-
ms.push(Clazz.new(Clazz.load('java.lang.reflect.Method').c$$Class$S$ClassA$Class$ClassA$I, [this, attr, [], java.lang.Void, [], 1]));
2812+
ms.push(Clazz.new_(Clazz.load('java.lang.reflect.Method').c$$Class$S$ClassA$Class$ClassA$I, [this, attr, [], java.lang.Void, [], 1]));
28122813
}
28132814
}
28142815
p = this.$clazz$;
28152816
for (var attr in p) {
28162817
if (typeof p[attr] == "function" && !p[attr].__CLASS_NAME__ && p[attr].exClazz == this.$clazz$) {
2817-
ms.push(Clazz.new(Clazz.load('java.lang.reflect.Method').c$$Class$S$ClassA$Class$ClassA$I, [this, attr, [], java.lang.Void, [], 1 | 8]));
2818+
ms.push(Clazz.new_(Clazz.load('java.lang.reflect.Method').c$$Class$S$ClassA$Class$ClassA$I, [this, attr, [], java.lang.Void, [], 1 | 8]));
28182819
}
28192820
}
28202821
*/

sources/net.sf.j2s.java.core/src/java/lang/Thread.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,11 @@ public static Thread currentThread() {
295295
*
296296
* java.lang.Thread.thisThread = "working";
297297
* java.lang.Thread.thisThread =
298-
* Clazz.new(java.lang.Thread.c$$S, ["master"]);
298+
* Clazz.new_(java.lang.Thread.c$$S, ["master"]);
299299
* var name = J2S._applets["master"]._id; var g =
300-
* Clazz.new(Clazz.load('swingjs.JSThreadGroup').c$$ThreadGroup$S,
300+
* Clazz.new_(Clazz.load('swingjs.JSThreadGroup').c$$ThreadGroup$S,
301301
* [null, name]); java.lang.Thread.thisThread =
302-
* Clazz.new(Clazz.load("javajs.util.JSThread").c$$ThreadGroup$S,
302+
* Clazz.new_(Clazz.load("javajs.util.JSThread").c$$ThreadGroup$S,
303303
* [g, name]);
304304
*
305305
*/

0 commit comments

Comments
 (0)
X Tutup