@@ -218,6 +218,8 @@ Clazz.clone = function(me) {
218218 * @author : sgurin
219219 */
220220Clazz . exceptionOf = function ( e , clazz ) {
221+ if ( typeof clazz == "string" )
222+ clazz = Clazz . load ( clazz ) ;
221223 if ( e . __CLASS_NAME__ )
222224 return Clazz . instanceOf ( e , clazz ) ;
223225 if ( ! e . getMessage ) {
@@ -1598,24 +1600,16 @@ Clazz._Loader = Clazz.ClazzLoader = function () {};
15981600
15991601ClassLoader = java . lang . ClassLoader = _Loader ;
16001602_Loader . __CLASS_NAME__ = "ClassLoader" ;
1603+
16011604Clazz . allClasses [ "java.lang.ClassLoader" ] = _Loader ;
16021605_Loader . sysLoader = null ;
16031606
16041607_Loader . getSystemClassLoader = function ( ) {
16051608 return ( _Loader . sysLoader ? _Loader . sysLoader : ( _Loader . sysLoader = new Class ( ) . getClassLoader ( ) ) ) ;
16061609} ;
16071610
1608- _Loader . prototype . setDefaultAssertionStatus$Z = function ( tf ) {
1609- Clazz . defaultAssertionStatus = tf ;
1610- } ;
1611-
16121611var assertionStatus = { } ;
16131612
1614- _Loader . prototype . clearAssertionStatus = function ( ) {
1615- assertionStatus = { } ;
1616- Clazz . defaultAssertionStatus = false ;
1617- }
1618-
16191613_Loader . $getClassAssertionStatus = function ( clazz ) {
16201614 var ret ;
16211615 var clazzName = clazz . __CLASS_NAME__ + "." ;
@@ -1628,6 +1622,18 @@ _Loader.$getClassAssertionStatus = function(clazz) {
16281622 return ( ret === false ? false : ret || Clazz . defaultAssertionStatus ) ;
16291623}
16301624
1625+ _Loader . prototype . hashCode = function ( ) { return 1 } ;
1626+
1627+
1628+ _Loader . prototype . setDefaultAssertionStatus$Z = function ( tf ) {
1629+ Clazz . defaultAssertionStatus = tf ;
1630+ } ;
1631+
1632+ _Loader . prototype . clearAssertionStatus = function ( ) {
1633+ assertionStatus = { } ;
1634+ Clazz . defaultAssertionStatus = false ;
1635+ }
1636+
16311637_Loader . prototype . setClassAssertionStatus$S$Z = _Loader . prototype . setPackageAssertionStatus$S$Z = function ( clazzName , tf ) {
16321638 if ( Clazz . allClasses [ clazzName ] ) Clazz . allClasses [ clazzName ] . $_ASSERT_ENABLED_ = tf ;
16331639 assertionStatus [ clazzName + "." ] = tf ;
@@ -2862,14 +2868,15 @@ var radix=(n.startsWith("0x", i) ? 16 : n.startsWith("0", i) ? 8 : 10);
28622868// The general problem with parseInt is that is not strict -- ParseInt("10whatever") == 10.
28632869// Number is strict, but Number("055") does not work, though ParseInt("055", 8) does.
28642870// need to make sure negative numbers are negative
2871+ if ( n == "" )
2872+ return NaN
28652873n = Number ( n ) & 0xFFFFFFFF ;
28662874return ( radix == 8 ? parseInt ( n , 8 ) : n ) ;
28672875} , 1 ) ;
28682876
28692877m$ ( Integer , "decode" , function ( n ) {
2870- n = Integer . decodeRaw ( n ) ;
2871- if ( isNaN ( n ) || n < Integer . MIN_VALUE || n > Integer . MAX_VALUE )
2872- throw Clazz . new_ ( NumberFormatException . c$$S , [ "Invalid Integer" ] ) ;
2878+ if ( isNaN ( n = Integer . decodeRaw ( n ) ) || n < Integer . MIN_VALUE || n > Integer . MAX_VALUE )
2879+ throw Clazz . new_ ( NumberFormatException . c$$S , [ "Invalid Integer" ] ) ;
28732880 return Clazz . new_ ( Integer . c$ , [ n ] ) ;
28742881} , 1 ) ;
28752882
@@ -2932,8 +2939,7 @@ return i.toString(2);
29322939
29332940m$ ( Long , "decode" ,
29342941function ( n ) {
2935- n = Integer . decodeRaw ( n ) ;
2936- if ( isNaN ( n ) )
2942+ if ( isNaN ( n = Integer . decodeRaw ( n ) ) )
29372943 throw Clazz . new_ ( NumberFormatException . c$$S , [ "Invalid Long" ] ) ;
29382944 return Clazz . new_ ( Long . c$ , [ n ] ) ;
29392945} , 1 ) ;
@@ -2998,8 +3004,7 @@ Short.toBinaryString = Short.prototype.toBinaryString = function (i) {
29983004
29993005m$ ( Short , "decode" ,
30003006function ( n ) {
3001- n = Integer . decodeRaw ( n ) ;
3002- if ( isNaN ( n ) || n < - 32768 || n > 32767 )
3007+ if ( isNaN ( n = Integer . decodeRaw ( n ) ) || n < - 32768 || n > 32767 )
30033008 throw Clazz . new_ ( NumberFormatException . c$$S , [ "Invalid Short" ] ) ;
30043009 return Clazz . new_ ( Short . c$ , [ n ] ) ;
30053010} , 1 ) ;
@@ -3064,8 +3069,7 @@ return i.toString(2);
30643069
30653070m$ ( Byte , "decode" ,
30663071function ( n ) {
3067- n = Integer . decodeRaw ( n ) ;
3068- if ( isNaN ( n ) || n < - 128 || n > 127 )
3072+ if ( isNaN ( n = Integer . decodeRaw ( n ) ) || n < - 128 || n > 127 )
30693073 throw Clazz . new_ ( NumberFormatException . c$$S , [ "Invalid Byte" ] ) ;
30703074 return Clazz . new_ ( Byte . c$ , [ n ] ) ;
30713075} , 1 ) ;
@@ -4328,6 +4332,17 @@ var declareType = function(prefix, name, clazzSuper, interfacez) {
43284332Clazz . _Error || ( Clazz . _Error = Error ) ;
43294333//setSuperclass(Clazz._Error, Throwable);
43304334
4335+ var setEx = function ( C$ ) {
4336+ C$ . $clinit$ = function ( ) { Clazz . load ( C$ , 1 ) ; }
4337+ m$ ( C$ , "c$" , function ( ) { C$ . superclazz . c$ . apply ( this , [ ] ) ; } , 1 ) ;
4338+ m$ ( C$ , "c$$S" , function ( detailMessage ) { C$ . superclazz . c$$S . apply ( this , [ detailMessage ] ) ; } , 1 ) ;
4339+ return C$ ;
4340+ }
4341+
4342+ var newEx = function ( prefix , name , clazzSuper ) {
4343+ return setEx ( declareType ( prefix , name , clazzSuper ) ) ;
4344+ }
4345+
43314346( function ( ) {
43324347var C$ = Clazz . newClass ( java . lang , "Error" , function ( ) {
43334348var err = Clazz . _Error ( ) ;
@@ -4337,63 +4352,54 @@ return err;
43374352//setSuperclass(java.lang.Error, Throwable);
43384353//setSuperclass(Clazz._Error, Throwable);
43394354
4340- C$ . $clinit$ = function ( ) { Clazz . load ( C$ , 1 ) ;
4341- }
4342-
4343- m$ ( C$ , "c$" , function ( ) {
4344- C$ . superclazz . c$ . apply ( this , [ ] ) ;
4345- } , 1 ) ;
4346-
4347- m$ ( C$ , "c$$S" , function ( detailMessage ) {
4348- C$ . superclazz . c$$S . apply ( this , [ detailMessage ] ) ;
4349- } , 1 ) ;
4355+ setEx ( C$ ) ;
43504356
43514357} ) ( ) ;
43524358
4353- C$ = declareType ( java . lang , "Exception" , Throwable ) ;
4359+ C$ = newEx ( java . lang , "Exception" , Throwable ) ;
43544360m$ ( C$ , "c$" , function ( ) { } , 1 ) ;
43554361
4356- declareType ( java . lang , "RuntimeException" , Exception ) ;
4357- declareType ( java . lang , "IllegalArgumentException" , RuntimeException ) ;
4358- declareType ( java . lang , "LinkageError" , Error ) ;
4359- declareType ( java . lang , "VirtualMachineError" , Error ) ;
4360- declareType ( java . lang , "IncompatibleClassChangeError" , LinkageError ) ;
4361-
4362- declareType ( java . lang , "AbstractMethodError" , IncompatibleClassChangeError ) ;
4363- declareType ( java . lang , "ArithmeticException" , RuntimeException ) ;
4364- declareType ( java . lang , "ArrayStoreException" , RuntimeException ) ;
4365- declareType ( java . lang , "ClassCircularityError" , LinkageError ) ;
4366- declareType ( java . lang , "ClassFormatError" , LinkageError ) ;
4367- declareType ( java . lang , "CloneNotSupportedException" , Exception ) ;
4368- declareType ( java . lang , "IllegalAccessError" , IncompatibleClassChangeError ) ;
4369- declareType ( java . lang , "IllegalAccessException" , Exception ) ;
4370- declareType ( java . lang , "IllegalMonitorStateException" , RuntimeException ) ;
4371- declareType ( java . lang , "IllegalStateException" , RuntimeException ) ;
4372- declareType ( java . lang , "IllegalThreadStateException" , IllegalArgumentException ) ;
4373- declareType ( java . lang , "IndexOutOfBoundsException" , RuntimeException ) ;
4374- declareType ( java . lang , "InstantiationError" , IncompatibleClassChangeError ) ;
4375- declareType ( java . lang , "InstantiationException" , Exception ) ;
4376- declareType ( java . lang , "InternalError" , VirtualMachineError ) ;
4377- declareType ( java . lang , "InterruptedException" , Exception ) ;
4378- declareType ( java . lang , "NegativeArraySizeException" , RuntimeException ) ;
4379- declareType ( java . lang , "NoClassDefFoundError" , LinkageError ) ;
4380- declareType ( java . lang , "NoSuchFieldError" , IncompatibleClassChangeError ) ;
4381- declareType ( java . lang , "NoSuchFieldException" , Exception ) ;
4382- declareType ( java . lang , "NoSuchMethodException" , Exception ) ;
4383- declareType ( java . lang , "NoSuchMethodError" , IncompatibleClassChangeError ) ;
4384- declareType ( java . lang , "NullPointerException" , RuntimeException ) ;
4385- declareType ( java . lang , "NumberFormatException" , IllegalArgumentException ) ;
4386- declareType ( java . lang , "OutOfMemoryError" , VirtualMachineError ) ;
4387- declareType ( java . lang , "SecurityException" , RuntimeException ) ;
4388- declareType ( java . lang , "StackOverflowError" , VirtualMachineError ) ;
4389- declareType ( java . lang , "ThreadDeath" , Error ) ;
4390- declareType ( java . lang , "UnknownError" , VirtualMachineError ) ;
4391- declareType ( java . lang , "UnsatisfiedLinkError" , LinkageError ) ;
4392- declareType ( java . lang , "UnsupportedClassVersionError" , ClassFormatError ) ;
4393- declareType ( java . lang , "UnsupportedOperationException" , RuntimeException ) ;
4394- declareType ( java . lang , "VerifyError" , LinkageError ) ;
4395-
4396- declareType ( java . lang , "ClassCastException" , RuntimeException ) ;
4362+ newEx ( java . lang , "RuntimeException" , Exception ) ;
4363+ newEx ( java . lang , "IllegalArgumentException" , RuntimeException ) ;
4364+ newEx ( java . lang , "LinkageError" , Error ) ;
4365+ newEx ( java . lang , "VirtualMachineError" , Error ) ;
4366+ newEx ( java . lang , "IncompatibleClassChangeError" , LinkageError ) ;
4367+
4368+ newEx ( java . lang , "AbstractMethodError" , IncompatibleClassChangeError ) ;
4369+ newEx ( java . lang , "ArithmeticException" , RuntimeException ) ;
4370+ newEx ( java . lang , "ArrayStoreException" , RuntimeException ) ;
4371+ newEx ( java . lang , "ClassCircularityError" , LinkageError ) ;
4372+ newEx ( java . lang , "ClassFormatError" , LinkageError ) ;
4373+ newEx ( java . lang , "CloneNotSupportedException" , Exception ) ;
4374+ newEx ( java . lang , "IllegalAccessError" , IncompatibleClassChangeError ) ;
4375+ newEx ( java . lang , "IllegalAccessException" , Exception ) ;
4376+ newEx ( java . lang , "IllegalMonitorStateException" , RuntimeException ) ;
4377+ newEx ( java . lang , "IllegalStateException" , RuntimeException ) ;
4378+ newEx ( java . lang , "IllegalThreadStateException" , IllegalArgumentException ) ;
4379+ newEx ( java . lang , "IndexOutOfBoundsException" , RuntimeException ) ;
4380+ newEx ( java . lang , "InstantiationError" , IncompatibleClassChangeError ) ;
4381+ newEx ( java . lang , "InstantiationException" , Exception ) ;
4382+ newEx ( java . lang , "InternalError" , VirtualMachineError ) ;
4383+ newEx ( java . lang , "InterruptedException" , Exception ) ;
4384+ newEx ( java . lang , "NegativeArraySizeException" , RuntimeException ) ;
4385+ newEx ( java . lang , "NoClassDefFoundError" , LinkageError ) ;
4386+ newEx ( java . lang , "NoSuchFieldError" , IncompatibleClassChangeError ) ;
4387+ newEx ( java . lang , "NoSuchFieldException" , Exception ) ;
4388+ newEx ( java . lang , "NoSuchMethodException" , Exception ) ;
4389+ newEx ( java . lang , "NoSuchMethodError" , IncompatibleClassChangeError ) ;
4390+ newEx ( java . lang , "NullPointerException" , RuntimeException ) ;
4391+ newEx ( java . lang , "NumberFormatException" , IllegalArgumentException ) ;
4392+ newEx ( java . lang , "OutOfMemoryError" , VirtualMachineError ) ;
4393+ newEx ( java . lang , "SecurityException" , RuntimeException ) ;
4394+ newEx ( java . lang , "StackOverflowError" , VirtualMachineError ) ;
4395+ newEx ( java . lang , "ThreadDeath" , Error ) ;
4396+ newEx ( java . lang , "UnknownError" , VirtualMachineError ) ;
4397+ newEx ( java . lang , "UnsatisfiedLinkError" , LinkageError ) ;
4398+ newEx ( java . lang , "UnsupportedClassVersionError" , ClassFormatError ) ;
4399+ newEx ( java . lang , "UnsupportedOperationException" , RuntimeException ) ;
4400+ newEx ( java . lang , "VerifyError" , LinkageError ) ;
4401+
4402+ newEx ( java . lang , "ClassCastException" , RuntimeException ) ;
43974403
43984404C$ = Clazz . newClass ( java . lang , "ClassNotFoundException" , function ( ) { this . ex = null ; } , Exception ) ;
43994405m$ ( C$ , "c$$S$Throwable" , function ( detailMessage , exception ) {
@@ -4409,7 +4415,7 @@ function(){
44094415return this . ex ;
44104416} ) ;
44114417
4412- C$ = declareType ( java . lang , "StringIndexOutOfBoundsException" , IndexOutOfBoundsException ) ;
4418+ C$ = newEx ( java . lang , "StringIndexOutOfBoundsException" , IndexOutOfBoundsException ) ;
44134419m$ ( C$ , "c$$I" , function ( index ) {
44144420C$ . superclazz . c$$S . apply ( this , [ "String index out of range: " + index ] ) ;
44154421} , 1 ) ;
@@ -4454,19 +4460,19 @@ function(){
44544460return this . undeclaredThrowable ;
44554461} ) ;
44564462
4457- declareType ( java . io , "IOException" , Exception ) ;
4458- declareType ( java . io , "CharConversionException" , java . io . IOException ) ;
4459- declareType ( java . io , "EOFException" , java . io . IOException ) ;
4460- declareType ( java . io , "FileNotFoundException" , java . io . IOException ) ;
4461- declareType ( java . io , "ObjectStreamException" , java . io . IOException ) ;
4462- declareType ( java . io , "SyncFailedException" , java . io . IOException ) ;
4463- declareType ( java . io , "UnsupportedEncodingException" , java . io . IOException ) ;
4464- declareType ( java . io , "UTFDataFormatException" , java . io . IOException ) ;
4463+ newEx ( java . io , "IOException" , Exception ) ;
4464+ newEx ( java . io , "CharConversionException" , java . io . IOException ) ;
4465+ newEx ( java . io , "EOFException" , java . io . IOException ) ;
4466+ newEx ( java . io , "FileNotFoundException" , java . io . IOException ) ;
4467+ newEx ( java . io , "ObjectStreamException" , java . io . IOException ) ;
4468+ newEx ( java . io , "SyncFailedException" , java . io . IOException ) ;
4469+ newEx ( java . io , "UnsupportedEncodingException" , java . io . IOException ) ;
4470+ newEx ( java . io , "UTFDataFormatException" , java . io . IOException ) ;
44654471
4466- declareType ( java . io , "InvalidObjectException" , java . io . ObjectStreamException ) ;
4467- declareType ( java . io , "NotActiveException" , java . io . ObjectStreamException ) ;
4468- declareType ( java . io , "NotSerializableException" , java . io . ObjectStreamException ) ;
4469- declareType ( java . io , "StreamCorruptedException" , java . io . ObjectStreamException ) ;
4472+ newEx ( java . io , "InvalidObjectException" , java . io . ObjectStreamException ) ;
4473+ newEx ( java . io , "NotActiveException" , java . io . ObjectStreamException ) ;
4474+ newEx ( java . io , "NotSerializableException" , java . io . ObjectStreamException ) ;
4475+ newEx ( java . io , "StreamCorruptedException" , java . io . ObjectStreamException ) ;
44704476
44714477C$ = Clazz . newClass ( java . io , "InterruptedIOException" , function ( ) {
44724478this . bytesTransferred = 0 ;
@@ -4514,11 +4520,11 @@ function(){
45144520return this . detail ;
45154521} ) ;
45164522
4517- declareType ( java . util , "EmptyStackException" , RuntimeException ) ;
4518- declareType ( java . util , "NoSuchElementException" , RuntimeException ) ;
4519- declareType ( java . util , "TooManyListenersException" , Exception ) ;
4523+ newEx ( java . util , "EmptyStackException" , RuntimeException ) ;
4524+ newEx ( java . util , "NoSuchElementException" , RuntimeException ) ;
4525+ newEx ( java . util , "TooManyListenersException" , Exception ) ;
45204526
4521- C$ = declareType ( java . util , "ConcurrentModificationException" , RuntimeException ) ;
4527+ C$ = newEx ( java . util , "ConcurrentModificationException" , RuntimeException ) ;
45224528m$ ( C$ , "c$" , function ( detailMessage , rootCause ) {
45234529Clazz . super ( C$ , this ) ;
45244530} , 1 ) ;
0 commit comments