Skip to content

Commit fd8c6e4

Browse files
committed
runtime additions
1 parent 349b460 commit fd8c6e4

2 files changed

Lines changed: 22 additions & 15 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,6 +1745,7 @@ J2S.Cache.put = function(filename, data) {
17451745
if(!availableParams || availableParams.indexOf(";" + i.toLowerCase() + ";") >= 0){
17461746
if (Info[i] == null || i == "language" && !J2S.featureDetection.supportsLocalization())
17471747
continue;
1748+
// params.put$TK$TV(i, (Info[i] === true ? Boolean.TRUE: Info[i] === false ? Boolean.FALSE : Info[i]))
17481749
if (isHashtable)
17491750
params.put$TK$TV(i, (Info[i] === true ? Boolean.TRUE: Info[i] === false ? Boolean.FALSE : Info[i]))
17501751
else

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

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
// NOTES by Bob Hanson
77

8+
// BH 11/16/2017 10:52:53 PM adds method name aliasing for generics; adds String.contains$CharSequence(cs)
89
// BH 10/14/2017 8:17:57 AM removing all node-based dependency class loading; fix String.initialize with four arguments (arr->byte)
910
// BH 10/13/2017 7:03:28 AM fix for String.initialize(bytes) applying bytes as arguments
1011
// BH 10/12/2017 6:34:01 AM totally re-written class loading using load(); no dependency nodes
@@ -127,7 +128,7 @@ Clazz.new = function(c, args, cl) {
127128

128129
var t0 = (_profileNew ? window.performance.now() : 0);
129130

130-
if (c.__CLASS_NAME__)
131+
if (c.__CLASS_NAME__ && c.c$)
131132
c = c.c$;
132133

133134
// an inner class will attach arguments to the arguments returned
@@ -291,26 +292,22 @@ var unwrapArray = function (arr) {
291292
return arr;
292293
};
293294

294-
/**
295-
* Prepare synthetic callback references b$[] for an anonymous inner class.
296-
*
297-
* This implementation takes advantage of the fact that the inheritance of the
298-
* outer object is a property of itself.
299-
*
300-
* @param innerObj this object
301-
* @param args args[0] will be the outer object; args [1...]
302-
* must be shifted back to be actual calling arguments
303-
* @author Bob Hanson
304-
*/
305295
Clazz.newMethod$ = function (clazzThis, funName, funBody, isStatic) {
296+
if (funName.constructor == Array) {
297+
// If funName is an array, we are setting aliases for generic calls.
298+
// For example: ['compareTo$S', 'compareTo$TK', 'compareTo$TA']
299+
// where K and A are generic types that are from a class<K> or class<A> assignment.
300+
for (var i = funName.length; --i >= 0;)
301+
Clazz.newMethod$(clazzThis, funName[i], funBody, isStatic);
302+
return;
303+
}
306304
Clazz.saemCount0++;
307305
funBody.exName = funName;
308306
funBody.exClazz = clazzThis; // make it traceable
309307
var f;
310308
if (isStatic || funName == "c$")
311-
clazzThis[funName] = clazzThis.prototype[funName] = funBody;
312-
else
313-
clazzThis.prototype[funName] = funBody;
309+
clazzThis[funName] = funBody;
310+
clazzThis.prototype[funName] = funBody; // allow static calls as though they were not static
314311
};
315312

316313
var aas = "AAA";
@@ -3937,11 +3934,20 @@ return-1;
39373934
}
39383935
};
39393936

3937+
39403938
sp.contentEquals$StringBuffer=function(sb){
39413939
return (this == sb.s);
39423940
};
39433941

3942+
sp.contains$CharSequence=function(cs){
3943+
if(cs==null)
3944+
throw new NullPointerException();
3945+
return (this == cs || this.length > cs.length$() && this.indexOf(cs.toString()) > -1);
3946+
};
3947+
39443948
sp.contentEquals$CharSequence=function(cs){
3949+
if(cs==null)
3950+
throw new NullPointerException();
39453951
if(this == cs)
39463952
return true;
39473953
if(this.length!=cs.length$())

0 commit comments

Comments
 (0)