@@ -1261,13 +1261,6 @@ Clazz.instanceOf = function (obj, clazz) {
12611261/* public */
12621262Clazz . _initializingException = false ;
12631263
1264- /**
1265- * BH: used in Throwable
1266- *
1267- */
1268- /* public */
1269- Clazz . _callingStackTraces = [ ] ;
1270-
12711264/**
12721265 * MethodException will be used as a signal to notify that the method is
12731266 * not found in the current clazz hierarchy.
@@ -2842,7 +2835,7 @@ updateNode = function(node, ulev, chain, _updateNode) {
28422835 for ( var mustLength = node . musts . length , i = mustLength ; -- i >= 0 ; ) {
28432836 var n = node . musts [ i ] ;
28442837 n . requiredBy = node ;
2845- System . out . println ( n . name + " required by " + node . name )
2838+ // System.out.println(n.name + " required by " + node.name)
28462839 if ( n . status < Node . STATUS_DECLARED && isClassDefined ( n . name ) ) {
28472840 var nns = [ ] ; // a stack for onLoaded events
28482841 n . status = Node . STATUS_LOAD_COMPLETE ;
@@ -4065,23 +4058,24 @@ Number.getName=Clazz._inF.getName;
40654058Number . prototype . compareTo = function ( x ) { var a = this . valueOf ( ) , b = x . valueOf ( ) ; return ( a < b ? - 1 : a == b ? 0 : 1 ) } ;
40664059Number . compare = function ( a , b ) { return ( a < b ? - 1 : a == b ? 0 : 1 ) } ;
40674060
4061+ var $b$ = new Int8Array ( 1 ) ;
4062+ var $s$ = new Int16Array ( 1 ) ;
4063+ var $i$ = new Int32Array ( 1 ) ;
4064+
40684065m$ ( Number , "shortValue" ,
40694066function ( ) {
4070- var x = ( this | 0 ) & 0xffff ;
4071- return ( x >= 0x8000 ? x - 0x10000 : x ) ;
4067+ return ( $s$ [ 0 ] = this , $s$ [ 0 ] ) ;
40724068} ) ;
40734069
40744070m$ ( Number , "byteValue" ,
40754071function ( ) {
4076- var x = ( this | 0 ) & 0xff ;
4077- return ( x >= 0x80 ? x - 0x100 : x ) ;
4072+ return ( $b$ [ 0 ] = this , $b$ [ 0 ] ) ;
40784073} ) ;
40794074
40804075
40814076m$ ( Number , "intValue" ,
40824077function ( ) {
4083- var x = ( this | 0 ) & 0xffffffff ;
4084- return ( x >= 0x80000000 ? x - 0x100000000 : x ) ;
4078+ return ( $i$ [ 0 ] = this , $i$ [ 0 ] ) ;
40854079} ) ;
40864080
40874081m$ ( Number , "longValue" ,
@@ -4095,7 +4089,7 @@ return this.valueOf();
40954089} ) ;
40964090m$ ( Number , "doubleValue" ,
40974091function ( ) {
4098- return parseFloat ( this . valueOf ( ) ) ;
4092+ return this . valueOf ( ) ;
40994093} ) ;
41004094
41014095m$ ( Number , "hashCode" ,
@@ -5331,6 +5325,7 @@ String.copyValueOf=sp.copyValueOf=function(){
53315325} ;
53325326
53335327sp . codePointAt || ( sp . codePointAt = sp . charCodeAt ) ; // Firefox only
5328+ sp . $c = function ( ) { return this . charCodeAt ( 0 ) } ;
53345329sp . codePointAt$I = sp . codePointAt ;
53355330// in order to implement CharSequence, we need .length(), but String only has .length
53365331// so in ALL classes the transpiler changes x.length() to x.length$()
@@ -5490,6 +5485,9 @@ m$(c$,"charCodeAt",
54905485function ( i ) {
54915486return ( this . value ) . charCodeAt ( i ) ;
54925487} ) ;
5488+
5489+ c$ . prototype . $c = function ( ) { return this . value . charCodeAt ( 0 ) } ;
5490+
54935491m$ ( c$ , "compareTo" ,
54945492function ( c ) {
54955493return ( this . value ) . charCodeAt ( 0 ) - ( c . value ) . charCodeAt ( 0 ) ;
@@ -5679,39 +5677,29 @@ Clazz.newInstance$ (this, arguments);
56795677
56805678m$ ( C$ , 'construct' , function ( ) {
56815679this . fillInStackTrace ( ) ;
5682- this . detailMessage = null ;
5680+ this . detailMessage = this . stack ;
56835681this . cause = this ;
5684- this . stackTrace = null ;
56855682} , 1 ) ;
56865683
56875684m$ ( C$ , 'construct$S' , function ( message ) {
56885685this . fillInStackTrace ( ) ;
56895686this . cause = this ;
5690- this . stackTrace = null ;
56915687this . detailMessage = message ;
56925688} , 1 ) ;
56935689
56945690m$ ( C$ , 'construct$S$Throwable' , function ( message , cause ) {
56955691this . fillInStackTrace ( ) ;
5696- this . stackTrace = null ;
56975692this . detailMessage = message ;
56985693this . cause = cause ;
56995694} , 1 ) ;
57005695
57015696m$ ( C$ , 'construct$Throwable' , function ( cause ) {
57025697this . fillInStackTrace ( ) ;
5703- this . stackTrace = null ;
5704- this . detailMessage = ( cause == null ? null : cause . toString ( ) ) ;
5698+ this . detailMessage = ( cause == null ? this . stack : cause . toString ( ) ) ;
57055699this . cause = cause ;
57065700} , 1 ) ;
57075701
5708- m$ ( C$ , 'getMessage' , function ( ) {
5709- {
5710- if ( typeof this . message != "undefined" ) {
5711- return this . message ;
5712- }
5713- } return this . detailMessage ;
5714- } ) ;
5702+ m$ ( C$ , 'getMessage' , function ( ) { return this . message || this . detailMessage } ) ;
57155703
57165704m$ ( C$ , 'getLocalizedMessage' , function ( ) {
57175705return this . getMessage ( ) ;
@@ -5734,17 +5722,22 @@ var message = this.getLocalizedMessage ();
57345722return ( message != null ) ? ( s + ": " + message ) : s ;
57355723} ) ;
57365724
5725+ m$ ( C$ , 'getStackTrace' , function ( ) {
5726+ return this . stackTrace ;
5727+ } ) ;
5728+
57375729m$ ( C$ , 'printStackTrace' , function ( ) {
57385730System . err . println$O ( this ) ;
57395731for ( var i = 0 ; i < this . stackTrace . length ; i ++ ) {
57405732var t = this . stackTrace [ i ] ;
57415733var x = t . methodName . indexOf ( "(" ) ;
5742- var n = t . methodName . substring ( 0 , x ) . replace ( / \s + / g, "" ) ;
5743- if ( n != "construct" || t . nativeClazz == null
5744- || Clazz . getInheritedLevel ( t . nativeClazz , Throwable ) < 0 ) {
5734+ //var n = (x < 0 ? t.methodName : t.methodName.substring (0, x)).replace (/\s+/g, "");
5735+ if ( t . nativeClazz == null || Clazz . getInheritedLevel ( t . nativeClazz , Throwable ) < 0 ) {
57455736System . err . println ( t ) ;
57465737}
57475738}
5739+ // from a JavaScript error
5740+ this . stack && System . err . println ( this . stack ) ;
57485741} ) ;
57495742
57505743Clazz . newMethod$ ( C$ , 'printStackTrace$java_io_PrintStream' , function ( s ) {
@@ -5756,54 +5749,40 @@ this.printStackTrace ();
57565749} ) ;
57575750
57585751Clazz . newMethod$ ( C$ , 'fillInStackTrace' , function ( ) {
5759- this . stackTrace = new Array ( ) ;
5752+ this . stackTrace = Clazz . newArray$ ( StackTraceElement ) ;
57605753var caller = arguments . callee . caller ;
57615754var superCaller = null ;
5762- var callerList = new Array ( ) ;
5763- var index = Clazz . _callingStackTraces . length - 1 ;
5764- var noLooping = true ;
5765- while ( index > - 1 || caller != null ) {
5766- var clazzName = null ;
5767- var nativeClazz = null ;
5768- if ( ! noLooping || caller == Clazz . tryToSearchAndExecute || caller == Clazz . superCall || caller == null ) {
5769- if ( index < 0 ) {
5770- break ;
5771- }
5772- noLooping = true ;
5773- superCaller = Clazz . callingStackTraces [ index ] . caller ;
5774- nativeClazz = Clazz . callingStackTraces [ index ] . owner ;
5775- index -- ;
5776- } else {
5777- superCaller = caller ;
5778- if ( superCaller . claxxOwner != null ) {
5779- nativeClazz = superCaller . claxxOwner ;
5780- } else if ( superCaller . exClazz != null ) {
5781- nativeClazz = superCaller . exClazz ;
5782- }
5783- }
5784- var st = Clazz . $new ( StackTraceElement . construct , [
5785- ( ( nativeClazz != null && nativeClazz . __CLASS_NAME__ . length != 0 ) ?
5786- nativeClazz . __CLASS_NAME__ : "anonymous" ) ,
5787- ( ( superCaller . exName == null ) ? "anonymous" : superCaller . exName ) ,
5788- null , - 1 ] ) ;
5789- st . nativeClazz = nativeClazz ;
5790- this . stackTrace [ this . stackTrace . length ] = st ;
5791- for ( var i = 0 ; i < callerList . length ; i ++ ) {
5792- if ( callerList [ i ] == superCaller ) {
5793- // ... stack information lost as recursive invocation existed ...
5794- var st = Clazz . $new ( StackTraceElement . construct , [ "lost" , "missing" , null , - 3 ] ) ;
5795- st . nativeClazz = null ;
5796- this . stackTrace [ this . stackTrace . length ] = st ;
5797- noLooping = false ;
5798- //break;
5799- }
5800- }
5801- if ( superCaller != null ) {
5802- callerList [ callerList . length ] = superCaller ;
5803- }
5804- //caller = superCaller.arguments.callee.caller;
5805- // Udo
5806- caller = ( superCaller && superCaller . arguments && superCaller . arguments . callee ) ? superCaller . arguments . callee . caller : null ;
5755+ var callerList = [ ] ;
5756+ var index = 0 ;
5757+ while ( index < 20 && caller != null ) {
5758+ index ++ ;
5759+ var clazzName = null ;
5760+ var nativeClazz = null ;
5761+ superCaller = caller ;
5762+ if ( superCaller . exClazz != null ) {
5763+ nativeClazz = superCaller . exClazz ;
5764+ }
5765+ var st = Clazz . $new ( StackTraceElement . construct , [
5766+ ( ( nativeClazz != null && nativeClazz . __CLASS_NAME__ . length != 0 ) ?
5767+ nativeClazz . __CLASS_NAME__ : "anonymous" ) ,
5768+ ( ( superCaller . exName == null ) ? "anonymous" : superCaller . exName ) ,
5769+ null , - 1 ] ) ;
5770+ st . nativeClazz = nativeClazz ;
5771+ this . stackTrace . push ( st ) ;
5772+ for ( var i = 0 ; i < callerList . length ; i ++ ) {
5773+ if ( callerList [ i ] == superCaller ) {
5774+ // ... stack information lost as recursive invocation existed ...
5775+ var st = Clazz . $new ( StackTraceElement . construct , [ "lost" , "missing" , null , - 3 ] ) ;
5776+ st . nativeClazz = null ;
5777+ this . stackTrace . push ( st ) ;
5778+ index = 100 ;
5779+ break ;
5780+ }
5781+ }
5782+ if ( superCaller != null ) {
5783+ callerList . push ( superCaller ) ;
5784+ }
5785+ caller = ( superCaller && superCaller . arguments && superCaller . arguments . callee ) ? superCaller . arguments . callee . caller : null ;
58075786}
58085787Clazz . initializingException = false ;
58095788return this ;
@@ -5882,24 +5861,24 @@ return this.lineNumber==-2;
58825861} ) ;
58835862m$ ( c$ , "toString" ,
58845863function ( ) {
5885- var buf = new StringBuilder ( 80 ) ;
5886- buf . append ( this . getClassName ( ) ) ;
5887- buf . append ( '.' ) ;
5888- buf . append ( this . getMethodName ( ) ) ;
5864+ var buf = Clazz . $ new( StringBuilder . construct$I , [ 80 ] ) ;
5865+ buf . append$S ( this . getClassName ( ) ) ;
5866+ buf . append$S ( '.' ) ;
5867+ buf . append$S ( this . getMethodName ( ) ) ;
58895868if ( this . isNativeMethod ( ) ) {
5890- buf . append ( "(Native Method)" ) ;
5869+ buf . append$S ( "(Native Method)" ) ;
58915870} else {
58925871var fName = this . getFileName ( ) ;
58935872if ( fName == null ) {
5894- buf . append ( "(Unknown Source)" ) ;
5873+ buf . append$S ( "(Unknown Source)" ) ;
58955874} else {
58965875var lineNum = this . getLineNumber ( ) ;
5897- buf . append ( '(' ) ;
5898- buf . append ( fName ) ;
5876+ buf . append$S ( '(' ) ;
5877+ buf . append$S ( fName ) ;
58995878if ( lineNum >= 0 ) {
5900- buf . append ( ':' ) ;
5901- buf . append ( lineNum ) ;
5902- } buf . append ( ')' ) ;
5879+ buf . append$S ( ':' ) ;
5880+ buf . append$I ( lineNum ) ;
5881+ } buf . append$ ( ')' ) ;
59035882} } return buf . toString ( ) ;
59045883} ) ;
59055884
@@ -5910,12 +5889,17 @@ TypeError.prototype.getMessage || (TypeError.prototype.getMessage = function(){
59105889Clazz . Error = Error ;
59115890
59125891var declareType = function ( prefix , name , clazzSuper , interfacez ) {
5913- return Clazz . decorateAsClass ( prefix , name , function ( ) { } , clazzSuper , interfacez ) ;
5892+ return Clazz . decorateAsClass ( prefix , name , null , clazzSuper , interfacez ) ;
59145893} ;
59155894
59165895// at least allow Error() by itself to work as before
59175896Clazz . _Error || ( Clazz . _Error = Error ) ;
5897+ ( function ( ) {
5898+ for ( var i in Throwable . prototype )
5899+ Clazz . _Error . prototype [ i ] = Throwable . prototype [ i ] ;
5900+ } ) ( ) ;
59185901
5902+ inheritClass ( Clazz . _Error , Throwable ) ;
59195903Clazz . decorateAsClass ( java . lang , "Error" , function ( ) { return Clazz . _Error ( ) ; } , Throwable ) ;
59205904
59215905declareType ( java . lang , "Exception" , Throwable ) ;
0 commit comments