|
1 | 1 | // j2sClazz.js |
2 | | -// NOTE: updates to this file should be copies to j2sjmol.js |
| 2 | +// NOTE: updates to this file should be copied to j2sjmol.js |
3 | 3 |
|
4 | 4 | // latest author: Bob Hanson, St. Olaf College, hansonr@stolaf.edu |
5 | 5 |
|
6 | 6 | // NOTES by Bob Hanson |
7 | 7 |
|
8 | 8 | // Google closure compiler cannot handle Clazz.new or Clazz.super |
9 | 9 |
|
| 10 | +// BH 2022.09.20 fix for Class.forName not loading static inner classes directly |
| 11 | +// BH 2022.09.20 fix for default toString for classes using "." name not "$" name for inner classes |
10 | 12 | // BH 2022.09.15 fix for new Error() failing; just letting java.lang.Error subclass Throwable |
11 | 13 | // BH 2022.09.08 Fix new Test_Inner().getClass().getMethod("testDollar", new Class<?>[] {Test_Abstract_a.class}).getName() |
12 | 14 | // BH 2022.04.19 TypeError and ResourceError gain printStackTrace$() methods |
@@ -1493,7 +1495,7 @@ var _jsid = 0; |
1493 | 1495 | addProto(proto, "notifyAll$", function () {}); |
1494 | 1496 | addProto(proto, "wait$", function () {alert("Object.wait was called!" + arguments.callee.caller.toString())}); |
1495 | 1497 | addProto(proto, "toString$", Object.prototype.toString); |
1496 | | - addProto(proto, "toString", function () { return (this.__CLASS_NAME__ ? "[" + this.__CLASS_NAME__ + " object]" : this.toString$.apply(this, arguments)); }); |
| 1498 | + addProto(proto, "toString", function () { return (this.__CLASS_NAME__ ? "[" + (this.__CLASS_NAME$__ || this.__CLASS_NAME__) + " object]" : this.toString$.apply(this, arguments)); }); |
1497 | 1499 |
|
1498 | 1500 | })(Clazz._O.prototype); |
1499 | 1501 |
|
@@ -2632,14 +2634,17 @@ Clazz._4Name = function(clazzName, applet, state, asClazz, initialize, isQuiet) |
2632 | 2634 | } |
2633 | 2635 | if (!isok) { |
2634 | 2636 | var name2 = null; |
2635 | | - if (clazzName.indexOf("$") >= 0) { |
| 2637 | + var pt = clazzName.lastIndexOf("$"); |
| 2638 | + if (pt >= 0) { |
2636 | 2639 | // BH we allow Java's java.swing.JTable.$BooleanRenderer as a stand-in |
2637 | 2640 | // for java.swing.JTable.BooleanRenderer |
2638 | 2641 | // when the static nested class is created using declareType |
2639 | 2642 | name2 = clazzName.replace(/\$/g,"."); |
2640 | 2643 | if (Clazz._isClassDefined(name2)) { |
2641 | 2644 | clazzName = name2; |
2642 | 2645 | } else { |
| 2646 | + cl = Clazz._4Name(clazzName.substring(0, pt), applet, state, true, initialize, isQuiet); |
| 2647 | + cl && (clazzName = name2); |
2643 | 2648 | name2 = null; |
2644 | 2649 | } |
2645 | 2650 | } |
@@ -6705,8 +6710,6 @@ var printStackTrace = function(e, ps) { |
6705 | 6710 | } |
6706 | 6711 | } |
6707 | 6712 |
|
6708 | | -TypeError.prototype.printStackTrace$ = ReferenceError.prototype.printStackTrace$ = function() { console.log(this);printStackTrace(this,System.err) } |
6709 | | - |
6710 | 6713 | var C$ = Clazz.newClass(java.lang, "Throwable", function () { |
6711 | 6714 | Clazz.newInstance(this, arguments); |
6712 | 6715 | }, null, java.io.Serializable); |
@@ -6735,7 +6738,7 @@ this.detailMessage = (cause == null ? this.stack : cause.toString ()); |
6735 | 6738 | this.cause = cause; |
6736 | 6739 | }, 1); |
6737 | 6740 |
|
6738 | | -m$(C$, 'getMessage$', function () {return this.message || this.detailMessage}); |
| 6741 | +m$(C$, 'getMessage$', function () {return this.message || this.detailMessage || null}); |
6739 | 6742 |
|
6740 | 6743 | m$(C$, 'getLocalizedMessage$', function () { |
6741 | 6744 | return this.getMessage$(); |
@@ -6917,11 +6920,17 @@ if(lineNum>=0){ |
6917 | 6920 | }); |
6918 | 6921 |
|
6919 | 6922 |
|
6920 | | -TypeError.prototype.getMessage$ || (TypeError.prototype.getMessage$ = TypeError.prototype.getLocalizedMessage$ |
| 6923 | +TypeError.prototype.getMessage$ || ( |
| 6924 | + |
| 6925 | + ReferenceError.prototype.getMessage$ = TypeError.prototype.getMessage$ |
| 6926 | + = ReferenceError.prototype.getMessage$ = TypeError.prototype.getLocalizedMessage$ |
6921 | 6927 | = function(){ return (this.stack ? this.stack : this.message || this.toString()) + (this.getStackTrace ? this.getStackTrace$() : Clazz._getStackTrace())}); |
6922 | | -TypeError.prototype.printStackTrace$ = function(){System.out.println(this + "\n" + this.stack)}; |
6923 | | -TypeError.prototype.printStackTrace$java_io_PrintStream = function(stream){stream.println$S(this + "\n" + this.stack);}; |
6924 | | -TypeError.prototype.printStackTrace$java_io_PrintWriter = function(printer){printer.println$S(this + "\n" + this.stack);}; |
| 6928 | + |
| 6929 | +TypeError.prototype.getStackTrace$ = ReferenceError.prototype.getStackTrace$ = function() { return Clazz._getStackTrace() } |
| 6930 | +TypeError.prototype.printStackTrace$ = ReferenceError.prototype.printStackTrace$ = function() { printStackTrace(this,System.err) } |
| 6931 | +ReferenceError.prototype.printStackTrace$java_io_PrintStream = TypeError.prototype.printStackTrace$java_io_PrintStream = function(stream){stream.println$S(this + "\n" + this.stack);}; |
| 6932 | +ReferenceError.prototype.printStackTrace$java_io_PrintWriter = TypeError.prototype.printStackTrace$java_io_PrintWriter = function(printer){printer.println$S(this + "\n" + this.stack);}; |
| 6933 | + |
6925 | 6934 | Clazz.Error = Error; |
6926 | 6935 |
|
6927 | 6936 | var declareType = function(prefix, name, clazzSuper, interfacez) { |
|
0 commit comments