Showing the changes to java (4 of 4 files). Show all
Unified · Split
Binary file not shown.
| @@ -183,7 +183,10 @@ public final · 182 unmodified lines | |||
| 183 | */ | 183 | */ |
| 184 | public static Class<?> forName(String className) | 184 | public static Class<?> forName(String className) |
| 185 | throws ClassNotFoundException { | 185 | throws ClassNotFoundException { |
| 186 | return forName0(className, true, ClassLoader.getCallerClassLoader()); | 186 | // [Inferno] No need to getCallerClassLoader here, it's not currently implemented < |
| 187 | //return forName0(className, true, ClassLoader.getCallerClassLoader()); | ||
| 188 | return forName0(className, true, null); | ||
| 189 | // [Inferno] > | ||
| 187 | } | 190 | } |
| 188 | 191 | ||
| 189 | 192 | ||
| @@ -1,7 +1,5 @@ | |||
| 1 | implement Class_L; | 1 | implement Class_L; |
| 2 | 2 | ||
| 3 | # javal v1.2 generated file: edit with care | ||
| 4 | |||
| 5 | include "jni.m"; | 3 | include "jni.m"; |
| 6 | jni : JNI; | 4 | jni : JNI; |
| 7 | ClassModule, | 5 | ClassModule, |
| @@ -50,195 +48,212 @@ init( jni_p : JNI ) · 42 unmodified lines | |||
| 50 | #<< | 48 | #<< |
| 51 | } | 49 | } |
| 52 | 50 | ||
| 53 | forName0_rString_Z_rClassLoader_rClass( p0 : JString, p1 : int, p2 : JObject ) : JClass | 51 | forName0_rString_Z_rClassLoader_rClass( p0 : JString,p1 : int,p2 : JObject) : JClass |
| 54 | {#>> | 52 | {#>> |
| 55 | { | 53 | { |
| 56 | jni->sys->print("forName called for class %s\n", p0.str); | 54 | if (p0.str != nil && p0.str[0] == '[') |
| 57 | if ( p0.str != nil && p0.str[0] == '[' ) | 55 | return jni->LookupArrayClass(p0.str); |
| 58 | return( jni->LookupArrayClass(p0.str) ); | 56 | else |
| 59 | else | 57 | return jni->GetClassObject(jni->FindClass(p0.str)); |
| 60 | return( jni->GetClassObject( jni->FindClass(p0.str) ) ); | 58 | } |
| 61 | } | 59 | exception e { |
| 62 | exception e { | 60 | "JLD:e0*" => |
| 63 | "JLD:e0*" => | 61 | jni->ThrowException("java.lang.ClassNotFoundException", p0.str); |
| 64 | jni->ThrowException( "java.lang.ClassNotFoundException", p0.str ); | 62 | } |
| 65 | } | 63 | |
| 66 | 64 | return nil; | |
| 67 | return(nil); | ||
| 68 | }#<< | 65 | }#<< |
| 69 | 66 | ||
| 70 | newInstance_rObject( this : JClass) : JObject | 67 | isAssignableFrom_rClass_Z( this : JClass, p0 : JClass) : int |
| 71 | {#>> | 68 | {#>> |
| 72 | if ( this.class.flags & (JNI->ACC_INTERFACE | JNI->ACC_ABSTRACT) ) { | 69 | return jni->IsAssignable(p0, this); |
| 73 | s : string; | ||
| 74 | if ( isPrimitive_Z(this) == JNI->TRUE ) | ||
| 75 | s = this.class.name[len "inferno/vm/":len this.class.name - 2]; | ||
| 76 | else if ( this.aryname != nil ) | ||
| 77 | s = this.aryname; | ||
| 78 | else | ||
| 79 | s = this.class.name; | ||
| 80 | jni->ThrowException( "java.lang.InstantiationException", s ); | ||
| 81 | } | ||
| 82 | # create new object for the given class | ||
| 83 | return( jni->NewObject(this.class) ); | ||
| 84 | }#<< | 70 | }#<< |
| 85 | 71 | ||
| 86 | isInstance_rObject_Z( this : JClass, p0 : JObject) : int | 72 | isInstance_rObject_Z( this : JClass, p0 : JObject) : int |
| 87 | {#>> | 73 | {#>> |
| 88 | return( jni->IsInstanceOf( p0, this.class ) ); | 74 | return jni->IsInstanceOf(p0, this.class); |
| 89 | }#<< | 75 | }#<< |
| 90 | 76 | ||
| 91 | isAssignableFrom_rClass_Z( this : JClass, p0 : JClass) : int | 77 | getModifiers_I( this : JClass) : int |
| 92 | {#>> | 78 | {#>> |
| 93 | return( jni->IsAssignable( p0, this ) ); | 79 | return (this.class.flags & (~ JNI->ACC_SYNCHRONIZED)); |
| 94 | }#<< | 80 | }#<< |
| 95 | 81 | ||
| 96 | isInterface_Z( this : JClass) : int | 82 | isInterface_Z( this : JClass) : int |
| 97 | {#>> | 83 | {#>> |
| 98 | return( this.class.flags & JNI->ACC_INTERFACE ); | 84 | return (this.class.flags & JNI->ACC_INTERFACE); |
| 99 | }#<< | 85 | }#<< |
| 100 | 86 | ||
| 101 | isArray_Z( this : JClass) : int | 87 | isArray_Z( this : JClass) : int |
| 102 | {#>> | 88 | {#>> |
| 103 | return( this.class.name == "inferno/vm/Array" ); | 89 | return (this.class.name == "inferno/vm/Array"); |
| 104 | }#<< | 90 | }#<< |
| 105 | 91 | ||
| 106 | isPrimitive_Z( this : JClass) : int | 92 | isPrimitive_Z( this : JClass) : int |
| 107 | {#>> | 93 | {#>> |
| 108 | ret : int; | 94 | ret: int; |
| 109 | if ( jni->PrimitiveIndex(this, 0) > 0 ) | 95 | if (jni->PrimitiveIndex(this, 0) > 0) |
| 110 | ret = JNI->TRUE; | 96 | ret = JNI->TRUE; |
| 111 | else | 97 | else |
| 112 | ret = JNI->FALSE; | 98 | ret = JNI->FALSE; |
| 113 | return ret; | 99 | return ret; |
| 114 | }#<< | 100 | }#<< |
| 115 | 101 | ||
| 116 | getName0_rString( this : JClass) : JString | 102 | getSuperclass_rClass( this : JClass) : JClass |
| 117 | {#>> | 103 | {#>> |
| 118 | name : string; | 104 | if (isPrimitive_Z(this) == JNI->TRUE || this.class.flags & JNI->ACC_INTERFACE) |
| 119 | if ( isPrimitive_Z(this) == JNI->TRUE ) | 105 | return nil; |
| 120 | { | 106 | if ((superclass := jni->GetSuperclass(this.class)) == nil) |
| 121 | # mk primitive name from a slice | 107 | return nil; |
| 122 | name = this.class.name[len "inferno/vm/":len this.class.name - 2]; | 108 | return jni->GetClassObject(superclass); |
| 123 | } | ||
| 124 | else | ||
| 125 | { | ||
| 126 | if ( this.aryname != nil ) | ||
| 127 | { | ||
| 128 | name = this.aryname; | ||
| 129 | } | ||
| 130 | else | ||
| 131 | { | ||
| 132 | name = this.class.name; | ||
| 133 | } | ||
| 134 | # change slashes to dots | ||
| 135 | for ( i := 0; i < len name; i++ ) | ||
| 136 | if ( name[i] == '/' ) | ||
| 137 | name[i] = '.'; | ||
| 138 | } | ||
| 139 | return( jni->NewString( name ) ); | ||
| 140 | }#<< | 109 | }#<< |
| 141 | 110 | ||
| 142 | getClassLoader0_rClassLoader( this : JClass) : JObject | 111 | getComponentType_rClass( this : JClass) : JClass |
| 143 | {#>> | 112 | {#>> |
| 144 | junk := (this); | 113 | if(this == nil || this.aryname == nil) |
| 145 | jni->FatalError( "getClassLoader() not implemented" ); | 114 | return nil; |
| 146 | return(nil); | 115 | |
| 116 | name: string; | ||
| 117 | c := this.aryname[1]; | ||
| 118 | if(c == '[') { | ||
| 119 | return jni->LookupArrayClass(this.aryname[1:]); | ||
| 120 | } else { | ||
| 121 | if(c == 'L') { | ||
| 122 | name = this.aryname[2:len this.aryname - 1]; | ||
| 123 | } else { | ||
| 124 | getReflect(); | ||
| 125 | name = "inferno/vm/" + refl->TypeCharToName(c) + "_p"; | ||
| 126 | } | ||
| 127 | return jni->GetClassObject(jni->FindClass(name)); | ||
| 128 | } | ||
| 147 | }#<< | 129 | }#<< |
| 148 | 130 | ||
| 149 | getSuperclass_rClass( this : JClass) : JClass | 131 | registerNatives_V( ) |
| 150 | {#>> | 132 | {#>> |
| 151 | if ( isPrimitive_Z(this) == JNI->TRUE | ||
| 152 | || this.class.flags & JNI->ACC_INTERFACE ) | ||
| 153 | return nil; | ||
| 154 | if ( (superclass := jni->GetSuperclass(this.class)) == nil ) | ||
| 155 | return nil; | ||
| 156 | return( jni->GetClassObject( superclass ) ); | ||
| 157 | }#<< | 133 | }#<< |
| 158 | 134 | ||
| 159 | getInterfaces_aClass( this : JClass) : JArrayJClass | 135 | getName0_rString( this : JClass) : JString |
| 160 | {#>> | 136 | {#>> |
| 161 | n : int; | 137 | name: string; |
| 162 | # kludge for arrays to be consistent with JavaSoft's VM | 138 | if (isPrimitive_Z(this) == JNI->TRUE) { |
| 163 | if ( isArray_Z(this) ) | 139 | name = this.class.name[len "inferno/vm/":len this.class.name - 2]; |
| 164 | n = 0; | 140 | } else { |
| 165 | else | 141 | if ( this.aryname != nil ) |
| 166 | n = len this.class.interdirect; | 142 | name = this.aryname; |
| 167 | interface := array [n] of JObject; | 143 | else |
| 168 | il := this.class.interdirect; | 144 | name = this.class.name; |
| 169 | for (i := n-1; i >= 0; i--) { | 145 | |
| 170 | interface[i] = cast->FromJClass(jni->GetClassObject(hd il)); | 146 | # change slashes to dots |
| 171 | il = tl il; | 147 | for (i := 0; i < len name; i++) |
| 172 | } | 148 | if (name[i] == '/') |
| 173 | classarray := cast->JArrayToClass(cast->ObjectToJArray(jni->MkAObject(interface))); | 149 | name[i] = '.'; |
| 174 | classarray.class = jni->FindClass("java/lang/Class"); | 150 | } |
| 175 | return classarray; | 151 | return jni->NewString(name); |
| 176 | }#<< | 152 | }#<< |
| 177 | 153 | ||
| 178 | getComponentType_rClass(this : JClass) : JClass | 154 | getClassLoader0_rClassLoader( this : JClass) : JObject |
| 179 | {#>> | 155 | {#>> |
| 180 | if(this == nil || this.aryname == nil) | 156 | #jni->FatalError("getClassLoader() not implemented"); |
| 181 | return nil; | 157 | return nil; |
| 182 | |||
| 183 | name : string; | ||
| 184 | c := this.aryname[1]; | ||
| 185 | if(c == '[') { | ||
| 186 | return jni->LookupArrayClass(this.aryname[1:]); | ||
| 187 | } else { | ||
| 188 | if(c == 'L') { | ||
| 189 | name = this.aryname[2:len this.aryname - 1]; | ||
| 190 | } else { | ||
| 191 | getReflect(); | ||
| 192 | name = "inferno/vm/" + refl->TypeCharToName(c) + "_p"; | ||
| 193 | } | ||
| 194 | return jni->GetClassObject(jni->FindClass(name)); | ||
| 195 | } | ||
| 196 | }#<< | 158 | }#<< |
| 197 | 159 | ||
| 198 | getModifiers_I( this : JClass) : int | 160 | getInterfaces_aClass( this : JClass) : JArrayJClass |
| 199 | {#>> | 161 | {#>> |
| 200 | return( this.class.flags & (~ JNI->ACC_SYNCHRONIZED)); | 162 | n: int; |
| 163 | # kludge for arrays to be consistent with JavaSoft's VM | ||
| 164 | if (isArray_Z(this)) | ||
| 165 | n = 0; | ||
| 166 | else | ||
| 167 | n = len this.class.interdirect; | ||
| 168 | interface := array [n] of JObject; | ||
| 169 | il := this.class.interdirect; | ||
| 170 | for (i := n-1; i >= 0; i--) { | ||
| 171 | interface[i] = cast->FromJClass(jni->GetClassObject(hd il)); | ||
| 172 | il = tl il; | ||
| 173 | } | ||
| 174 | classarray := cast->JArrayToClass(cast->ObjectToJArray(jni->MkAObject(interface))); | ||
| 175 | classarray.class = jni->FindClass("java/lang/Class"); | ||
| 176 | return classarray; | ||
| 201 | }#<< | 177 | }#<< |
| 202 | 178 | ||
| 203 | getSigners_aObject( this : JClass) : JArrayJObject | 179 | getSigners_aObject( this : JClass) : JArrayJObject |
| 204 | {#>> | 180 | {#>> |
| 205 | junk := (this); | 181 | #jni->FatalError("getSigners() not implemented"); |
| 206 | jni->FatalError( "getSigners() not implemented" ); | 182 | return nil; |
| 207 | return(nil); | ||
| 208 | }#<< | 183 | }#<< |
| 209 | 184 | ||
| 210 | setSigners_aObject_V( this : JClass, p0 : JArrayJObject) | 185 | setSigners_aObject_V( this : JClass, p0 : JArrayJObject) |
| 211 | {#>> | 186 | {#>> |
| 212 | junk := (this,p0); | 187 | #jni->FatalError("setSigners() not implemented"); |
| 213 | jni->FatalError( "setSigners() not implemented" ); | 188 | }#<< |
| 189 | |||
| 190 | getEnclosingMethod0_aObject( this : JClass) : JArrayJObject | ||
| 191 | {#>> | ||
| 192 | #jni->FatalError("getEnclosingMethod0 is not implemented"); | ||
| 193 | return nil; | ||
| 194 | }#<< | ||
| 195 | |||
| 196 | getDeclaringClass_rClass( this : JClass) : JClass | ||
| 197 | {#>> | ||
| 198 | #jni->FatalError("getDeclaringClass is not implemented"); | ||
| 199 | return nil; | ||
| 200 | }#<< | ||
| 201 | |||
| 202 | getProtectionDomain0_rProtectionDomain( this : JClass) : JObject | ||
| 203 | {#>> | ||
| 204 | #jni->FatalError("getProtectionDomain is not implemented"); | ||
| 205 | return nil; | ||
| 206 | }#<< | ||
| 207 | |||
| 208 | setProtectionDomain0_rProtectionDomain_V( this : JClass, p0 : JObject) | ||
| 209 | {#>> | ||
| 210 | #jni->FatalError("setProtectionDomain is not implemented"); | ||
| 214 | }#<< | 211 | }#<< |
| 215 | 212 | ||
| 216 | getPrimitiveClass_rString_rClass( p0 : JString) : JClass | 213 | getPrimitiveClass_rString_rClass( p0 : JString) : JClass |
| 217 | {#>> | 214 | {#>> |
| 218 | { | 215 | { |
| 219 | return( jni->GetClassObject(jni->FindClass("inferno/vm/"+ p0.str +"_p")) ); | 216 | return jni->GetClassObject(jni->FindClass("inferno/vm/"+ p0.str +"_p")); |
| 220 | } | 217 | } |
| 221 | exception e { | 218 | exception e { |
| 222 | "JLD:e0*" => | 219 | "JLD:e0*" => |
| 223 | ; # do nothing | 220 | ; # do nothing |
| 224 | } | 221 | } |
| 225 | return(nil); | 222 | return nil; |
| 223 | }#<< | ||
| 224 | |||
| 225 | getGenericSignature_rString( this : JClass) : JString | ||
| 226 | {#>> | ||
| 227 | #jni->FatalError("getGenericSignature is not implemented"); | ||
| 228 | return nil; | ||
| 229 | }#<< | ||
| 230 | |||
| 231 | getRawAnnotations_aB( this : JClass) : JArrayB | ||
| 232 | {#>> | ||
| 233 | #jni->FatalError("getRawAnnotations is not implemented"); | ||
| 234 | return nil; | ||
| 235 | }#<< | ||
| 236 | |||
| 237 | getConstantPool_rConstantPool( this : JClass) : JObject | ||
| 238 | {#>> | ||
| 239 | # TODO: our j2d does not save the constant pool | ||
| 240 | jni->FatalError("getConstantPool is not implemented"); | ||
| 241 | return nil; | ||
| 226 | }#<< | 242 | }#<< |
| 227 | 243 | ||
| 228 | getFields0_I_aField( this : JClass, p0 : int) : JArrayJObject | 244 | getDeclaredFields0_Z_aField( this : JClass, p0 : int) : JArrayJObject |
| 229 | {#>> | 245 | {#>> |
| 230 | # 'this' represents the class whose fields are wanted. | ||
| 231 | # p0 == 0 for PUBLIC members (includes inherited members) | 246 | # p0 == 0 for PUBLIC members (includes inherited members) |
| 232 | # p0 == 1 for DECLARED members (All members but not inherited members) | 247 | # p0 == 1 for DECLARED members (All members but not inherited members) |
| 233 | 248 | ||
| 234 | objs : list of JObject; | 249 | objs: list of JObject; |
| 235 | if ( !isArray_Z(this) ) | 250 | if (!isArray_Z(this)) |
| 236 | objs = getFields(this, p0); | 251 | objs = getFields(this, p0); |
| 237 | 252 | ||
| 238 | obj_array := array[len objs] of JObject; | 253 | obj_array := array[len objs] of JObject; |
| 239 | for ( i := 0; objs != nil ; i++ ) { | 254 | for (i := 0; objs != nil ; i++) { |
| 240 | obj_array[i] = hd objs; | 255 | obj_array[i] = hd objs; |
| 241 | objs = tl objs; | 256 | objs = tl objs; |
| 242 | } | 257 | } |
| 243 | 258 | ||
| 244 | fieldarray := jni->MkAObject(obj_array); | 259 | fieldarray := jni->MkAObject(obj_array); |
| @@ -246,24 +261,22 @@ getFields0_I_aField( this : JClass, p0 : int) : JArrayJObject · 1 unmodified line | |||
| 246 | return fieldarray; | 261 | return fieldarray; |
| 247 | }#<< | 262 | }#<< |
| 248 | 263 | ||
| 249 | getMethods0_I_aMethod( this : JClass, p0 : int) : JArrayJObject | 264 | getDeclaredMethods0_Z_aMethod( this : JClass, p0 : int) : JArrayJObject |
| 250 | {#>> | 265 | {#>> |
| 251 | # 'this' represents the class whose methods are wanted. | ||
| 252 | # p0 == 0 for PUBLIC members (includes inherited members) | 266 | # p0 == 0 for PUBLIC members (includes inherited members) |
| 253 | # p0 == 1 for DECLARED members (All members but not inherited members) | 267 | # p0 == 1 for DECLARED members (All members but not inherited members) |
| 254 | 268 | ||
| 255 | objs : list of JObject; | 269 | objs: list of JObject; |
| 256 | 270 | ||
| 257 | # if primitive or interface, filter out java.lang.Object methods | 271 | # if primitive or interface, filter out java.lang.Object methods |
| 258 | if ( isPrimitive_Z(this) == JNI->TRUE | 272 | if (isPrimitive_Z(this) == JNI->TRUE || this.class.flags & JNI->ACC_INTERFACE) |
| 259 | || this.class.flags & JNI->ACC_INTERFACE ) | 273 | p0 = 1; |
| 260 | p0 = 1; | ||
| 261 | objs = getMethods(this, p0); | 274 | objs = getMethods(this, p0); |
| 262 | 275 | ||
| 263 | obj_array := array[len objs] of JObject; | 276 | obj_array := array[len objs] of JObject; |
| 264 | for ( i := 0; objs != nil ; i++ ) { | 277 | for ( i := 0; objs != nil ; i++ ) { |
| 265 | obj_array[i] = hd objs; | 278 | obj_array[i] = hd objs; |
| 266 | objs = tl objs; | 279 | objs = tl objs; |
| 267 | } | 280 | } |
| 268 | 281 | ||
| 269 | methodarray := jni->MkAObject(obj_array); | 282 | methodarray := jni->MkAObject(obj_array); |
| @@ -271,20 +284,19 @@ getMethods0_I_aMethod( this : JClass, p0 : int) : JArrayJObject · 1 unmodified line | |||
| 271 | return methodarray; | 284 | return methodarray; |
| 272 | }#<< | 285 | }#<< |
| 273 | 286 | ||
| 274 | getConstructors0_I_aConstructor( this : JClass, p0 : int) : JArrayJObject | 287 | getDeclaredConstructors0_Z_aConstructor( this : JClass, p0 : int) : JArrayJObject |
| 275 | {#>> | 288 | {#>> |
| 276 | # 'this' represents the class whose constructors are wanted. | ||
| 277 | # p0 == 0 for PUBLIC members (includes inherited members) | 289 | # p0 == 0 for PUBLIC members (includes inherited members) |
| 278 | # p0 == 1 for DECLARED members (All members but not inherited members) | 290 | # p0 == 1 for DECLARED members (All members but not inherited members) |
| 279 | 291 | ||
| 280 | objs : list of JObject; | 292 | objs: list of JObject; |
| 281 | if ( isPrimitive_Z(this) == JNI->FALSE && !isArray_Z(this) ) | 293 | if (isPrimitive_Z(this) == JNI->FALSE && !isArray_Z(this)) |
| 282 | objs = getConstructors(this, p0); | 294 | objs = getConstructors(this, p0); |
| 283 | 295 | ||
| 284 | obj_array := array[len objs] of JObject; | 296 | obj_array := array[len objs] of JObject; |
| 285 | for ( i := 0; objs != nil ; i++ ) { | 297 | for ( i := 0; objs != nil ; i++ ) { |
| 286 | obj_array[i] = hd objs; | 298 | obj_array[i] = hd objs; |
| 287 | objs = tl objs; | 299 | objs = tl objs; |
| 288 | } | 300 | } |
| 289 | 301 | ||
| 290 | constructorarray := jni->MkAObject(obj_array); | 302 | constructorarray := jni->MkAObject(obj_array); |
| @@ -292,118 +304,16 @@ getConstructors0_I_aConstructor( this : JClass, p0 : int) : JArrayJObject · 1 unmodified line | |||
| 292 | return constructorarray; | 304 | return constructorarray; |
| 293 | }#<< | 305 | }#<< |
| 294 | 306 | ||
| 295 | getField0_rString_I_rField( this : JClass, p0 : JString,p1 : int) : JObject | 307 | getDeclaredClasses0_aClass( this : JClass) : JArrayJClass |
| 296 | {#>> | 308 | {#>> |
| 297 | # 'this' represents the class for which a Field is desired. | 309 | # TODO: implement |
| 298 | # p0 is the name of the field. | ||
| 299 | # p1 == 0 for PUBLIC members (includes inherited members) | ||
| 300 | # p1 == 1 for DECLARED members (All members but not inherited members) | ||
| 301 | |||
| 302 | staticfields := this.class.staticdata; | ||
| 303 | flg : int; | ||
| 304 | fld : ref jldr->Field; | ||
| 305 | for ( i := 0; i < len staticfields; i++ ) { | ||
| 306 | fld = staticfields[i]; | ||
| 307 | flg = fld.flags; | ||
| 308 | if ( fld.field == p0.str && | ||
| 309 | (p1 != 0 || (flg & JNI->ACC_PUBLIC) != 0) ) | ||
| 310 | break; | ||
| 311 | } | ||
| 312 | if ( i >= len staticfields ) { # Not a public static field | ||
| 313 | super : list of ref jldr->Field = nil; | ||
| 314 | if ( (superclass := jni->GetSuperclass(this.class)) != nil && | ||
| 315 | superclass != this.class ) | ||
| 316 | super = superclass.objectdata; | ||
| 317 | objfields := this.class.objectdata; | ||
| 318 | for ( i = 0; objfields != nil; i++ ) { | ||
| 319 | if ( p1 == 1 && objfields == super ) # exclude inherited | ||
| 320 | break; | ||
| 321 | fld = hd objfields; | ||
| 322 | flg = fld.flags; | ||
| 323 | if ( fld.field == p0.str && | ||
| 324 | (p1 != 0 || (flg & JNI->ACC_PUBLIC) != 0) ) | ||
| 325 | break; | ||
| 326 | objfields = tl objfields; | ||
| 327 | } | ||
| 328 | if ( objfields == super || objfields == nil ) | ||
| 329 | i = len staticfields + len this.class.objectdata; | ||
| 330 | } | ||
| 331 | if ( i >= len staticfields + len this.class.objectdata ) { | ||
| 332 | jni->ThrowException("java/lang/NoSuchFieldException", ""); | ||
| 333 | return nil; | ||
| 334 | } | ||
| 335 | return makeField(this, fld, i); | ||
| 336 | }#<< | ||
| 337 | |||
| 338 | getMethod0_rString_aClass_I_rMethod( this : JClass, p0 : JString,p1 : JArrayJClass,p2 : int) : JObject | ||
| 339 | {#>> | ||
| 340 | # 'this' represents the class for which a Method is desired. | ||
| 341 | # p0 is the name of the method. | ||
| 342 | # p1 is a Java array of Class objects, corresponding to the formal parameters | ||
| 343 | # of the method for which a Method object is desired. The array | ||
| 344 | # is used to construct a signature string which can be matched against | ||
| 345 | # data compiled by the classloader. | ||
| 346 | # p2 == 0 for PUBLIC members (includes inherited members) | ||
| 347 | # p2 == 1 for DECLARED members (All members but not inherited members) | ||
| 348 | |||
| 349 | signatur := "(" + MakeSignature(p1) + ")"; | ||
| 350 | |||
| 351 | methods := this.class.staticmethods; | ||
| 352 | for ( i := 0; i < len methods; i++ ) { | ||
| 353 | fld := methods[i]; | ||
| 354 | if ( fld.field == p0.str && jni->str->prefix(signatur, fld.signature) && | ||
| 355 | (p2 != 0 || (fld.flags & JNI->ACC_PUBLIC) != 0) ) | ||
| 356 | return makeMethod(this, fld, i, p1, fld.signature[len signatur:]); | ||
| 357 | } | ||
| 358 | methods = this.class.privatemethods; | ||
| 359 | for ( i = 0; i < len methods; i++ ) { | ||
| 360 | fld := methods[i]; | ||
| 361 | if ( fld.field == p0.str && jni->str->prefix(signatur, fld.signature) && | ||
| 362 | (p2 != 0 || (fld.flags & JNI->ACC_PUBLIC) != 0) ) | ||
| 363 | return makeMethod(this, fld, i, p1, fld.signature[len signatur:]); | ||
| 364 | } | ||
| 365 | vmethods := this.class.virtualmethods; | ||
| 366 | for ( i = 0; i < len vmethods; i++ ) { | ||
| 367 | fld := vmethods[i].field; | ||
| 368 | if ( fld.field == p0.str && jni->str->prefix(signatur, fld.signature) && | ||
| 369 | ((p2 != 0 && this.class == vmethods[i].class) | ||
| 370 | || (fld.flags & JNI->ACC_PUBLIC) != 0) ) { | ||
| 371 | if ( vmethods[i].class != this.class ) | ||
| 372 | this = jni->GetClassObject(vmethods[i].class); | ||
| 373 | return makeMethod(this, fld, i, p1, fld.signature[len signatur:]); | ||
| 374 | } | ||
| 375 | } | ||
| 376 | jni->ThrowException("java/lang/NoSuchMethodException", ""); | ||
| 377 | return nil; | 310 | return nil; |
| 378 | }#<< | 311 | }#<< |
| 379 | 312 | ||
| 380 | getConstructor0_aClass_I_rConstructor( this : JClass, p0 : JArrayJClass,p1 : int) : JObject | 313 | desiredAssertionStatus0_rClass_Z( p0 : JClass) : int |
| 381 | {#>> | 314 | {#>> |
| 382 | # 'this' represents the class for which a Constructor is desired. | 315 | #jni->FatalError("desiredAssertionStatus0 is not implemented"); |
| 383 | # p0 is a Java array of Class objects, corresponding to the formal parameters | 316 | return int 0; |
| 384 | # of the constructor for which a Constructor object is desired. The array | ||
| 385 | # is used to construct a signature string which can be matched against | ||
| 386 | # data compiled by the classloader. | ||
| 387 | # p1 == 0 for PUBLIC members (includes inherited members) | ||
| 388 | # p1 == 1 for DECLARED members (All members but not inherited members) | ||
| 389 | |||
| 390 | signatur := "(" + MakeSignature(p0) + ")"; | ||
| 391 | |||
| 392 | initmethods := this.class.initmethods; | ||
| 393 | flg : int; | ||
| 394 | fld : ref jldr->Field; | ||
| 395 | for ( i := 0; i < len initmethods; i++ ) { | ||
| 396 | fld = initmethods[i]; | ||
| 397 | flg = fld.flags; | ||
| 398 | if ( jni->str->prefix(signatur, fld.signature) && | ||
| 399 | (p1 != 0 || (flg & JNI->ACC_PUBLIC) != 0) ) | ||
| 400 | break; | ||
| 401 | } | ||
| 402 | if ( i >= len initmethods ) { | ||
| 403 | jni->ThrowException("java/lang/NoSuchMethodException", ""); | ||
| 404 | return nil; | ||
| 405 | } | ||
| 406 | return makeMethod(this, fld, i, p0, nil); | ||
| 407 | }#<< | 317 | }#<< |
| 408 | 318 | ||
| 409 | # | 319 | # |
| @@ -417,11 +327,11 @@ getConstructor0_aClass_I_rConstructor( this : JClass, p0 : JArrayJClass,p1 : int · 7 unmodified lines | |||
| 417 | 327 | ||
| 418 | getPublicStaticFields(this : JClass, objs : list of JObject) : list of JObject | 328 | getPublicStaticFields(this : JClass, objs : list of JObject) : list of JObject |
| 419 | { | 329 | { |
| 420 | flds := this.class.staticdata; | 330 | flds := this.class.staticdata; |
| 421 | for ( i := len flds - 1; i >= 0; i-- ) | 331 | for ( i := len flds - 1; i >= 0; i-- ) |
| 422 | if ( (flds[i].flags & JNI->ACC_PUBLIC) != 0 ) | 332 | if ( (flds[i].flags & JNI->ACC_PUBLIC) != 0 ) |
| 423 | objs = makeField(this, flds[i], i) :: objs; | 333 | objs = makeField(this, flds[i], i) :: objs; |
| 424 | return objs; | 334 | return objs; |
| 425 | } | 335 | } |
| 426 | 336 | ||
| 427 | # | 337 | # |
| @@ -433,142 +343,142 @@ ifacelist: list of JClass; · 5 unmodified lines | |||
| 433 | 343 | ||
| 434 | doInterfaces(this : JClass, objs : list of JObject) : list of JObject | 344 | doInterfaces(this : JClass, objs : list of JObject) : list of JObject |
| 435 | { | 345 | { |
| 436 | ifaces := this.class.interfaces; | 346 | ifaces := this.class.interfaces; |
| 437 | outer: for ( i := 0; i < len ifaces; i++ ) { | 347 | outer: for ( i := 0; i < len ifaces; i++ ) { |
| 438 | iface := jni->GetClassObject(ifaces[i].class); | 348 | iface := jni->GetClassObject(ifaces[i].class); |
| 439 | for ( l := ifacelist; l != nil; l = tl l ) | 349 | for ( l := ifacelist; l != nil; l = tl l ) |
| 440 | if ( hd l == iface ) | 350 | if ( hd l == iface ) |
| 441 | continue outer; | 351 | continue outer; |
| 442 | ifacelist = iface :: ifacelist; | 352 | ifacelist = iface :: ifacelist; |
| 443 | objs = getPublicStaticFields(iface, objs); | 353 | objs = getPublicStaticFields(iface, objs); |
| 444 | objs = doInterfaces(iface, objs); | 354 | objs = doInterfaces(iface, objs); |
| 445 | } | 355 | } |
| 446 | return objs; | 356 | return objs; |
| 447 | } | 357 | } |
| 448 | 358 | ||
| 449 | # | 359 | # |
| 450 | # A helper function that gets fields for the class represented | 360 | # A helper function that gets fields for the class represented |
| 451 | # by this. p0 == 0 => PUBLIC fields, p0 == 1 => DECLARED fields. | 361 | # by this. p0 == 0 => PUBLIC fields, p0 == 1 => DECLARED fields. |
| 452 | # Candidate fields are found in the loader array staticdata (for | 362 | # Candidate fields are found in the loader array staticdata (for |
| 453 | # static fields) and list objectdata (for instance fields). | 363 | # static fields) and list objectdata (for instance fields). |
| 454 | # | 364 | # |
| 455 | 365 | ||
| 456 | getFields(this : JClass, p0 : int) : list of JObject | 366 | getFields(this : JClass, p0 : int) : list of JObject |
| 457 | { | 367 | { |
| 458 | objs : list of JObject; | 368 | objs: list of JObject; |
| 459 | 369 | ||
| 460 | # get instance fields | 370 | # get instance fields |
| 461 | objdata := this.class.objectdata; | 371 | objdata := this.class.objectdata; |
| 462 | flds := array[len objdata] of ref jldr->Field; | 372 | flds := array[len objdata] of ref jldr->Field; |
| 463 | super : list of ref jldr->Field = nil; | 373 | super : list of ref jldr->Field = nil; |
| 464 | if ( (superclass := jni->GetSuperclass(this.class)) != nil ) | 374 | if ((superclass := jni->GetSuperclass(this.class)) != nil) |
| 465 | super = superclass.objectdata; | 375 | super = superclass.objectdata; |
| 466 | for ( i := 0; objdata != nil; i++ ) { | 376 | for (i := 0; objdata != nil; i++) { |
| 467 | if ( p0 == 1 && objdata == super ) | 377 | if (p0 == 1 && objdata == super) |
| 468 | break; | 378 | break; |
| 469 | flds[i] = hd objdata; | 379 | flds[i] = hd objdata; |
| 470 | objdata = tl objdata; | 380 | objdata = tl objdata; |
| 471 | } | 381 | } |
| 472 | # need to associate declaring class with each instance field ??? | 382 | # need to associate declaring class with each instance field ??? |
| 473 | for ( i--; i >= 0; i-- ) | 383 | for (i--; i >= 0; i--) |
| 474 | if ( p0 != 0 || (flds[i].flags & JNI->ACC_PUBLIC) != 0 ) | 384 | if (p0 != 0 || (flds[i].flags & JNI->ACC_PUBLIC) != 0) |
| 475 | objs = makeField(this, flds[i], i) :: objs; | 385 | objs = makeField(this, flds[i], i) :: objs; |
| 476 | 386 | ||
| 477 | # get class fields of this class | 387 | # get class fields of this class |
| 478 | flds = this.class.staticdata; | 388 | flds = this.class.staticdata; |
| 479 | for ( i = len flds - 1; i >= 0; i-- ) | 389 | for (i = len flds - 1; i >= 0; i--) |
| 480 | if ( p0 != 0 || (flds[i].flags & JNI->ACC_PUBLIC) != 0 ) | 390 | if (p0 != 0 || (flds[i].flags & JNI->ACC_PUBLIC) != 0) |
| 481 | objs = makeField(this, flds[i], i) :: objs; | 391 | objs = makeField(this, flds[i], i) :: objs; |
| 482 | 392 | ||
| 483 | # get class fields of super classes and interfaces | 393 | # get class fields of super classes and interfaces |
| 484 | if ( p0 == 0 ) { | 394 | if (p0 == 0) { |
| 485 | ifacelist = nil; | 395 | ifacelist = nil; |
| 486 | objs = doInterfaces(this, objs); | 396 | objs = doInterfaces(this, objs); |
| 487 | curclass := this; | 397 | curclass := this; |
| 488 | while ( ( curclass = getSuperclass_rClass(curclass) ) != nil ) { | 398 | while ((curclass = getSuperclass_rClass(curclass) ) != nil) { |
| 489 | objs = getPublicStaticFields(curclass, objs); | 399 | objs = getPublicStaticFields(curclass, objs); |
| 490 | objs = doInterfaces(curclass, objs); | 400 | objs = doInterfaces(curclass, objs); |
| 491 | } | 401 | } |
| 492 | } | 402 | } |
| 493 | 403 | ||
| 494 | return objs; | 404 | return objs; |
| 495 | } | 405 | } |
| 496 | # | 406 | # |
| 497 | # A helper function that gets methods for the class represented | 407 | # A helper function that gets methods for the class represented |
| 498 | # by this. p0 == 0 => PUBLIC methods, p0 == 1 => DECLARED methods. | 408 | # by this. p0 == 0 => PUBLIC methods, p0 == 1 => DECLARED methods. |
| 499 | # Candidate methods are found in the loader arrays staticmethods (for | 409 | # Candidate methods are found in the loader arrays staticmethods (for |
| 500 | # class methods), privatemethods (for methods private to this | 410 | # class methods), privatemethods (for methods private to this |
| 501 | # particular class), and virtualmethods (public instance methods of | 411 | # particular class), and virtualmethods (public instance methods of |
| 502 | # this class and all its superclasses). | 412 | # this class and all its superclasses). |
| 503 | # | 413 | # |
| 504 | getMethods(this : JClass, p0 : int) : list of JObject | 414 | getMethods(this : JClass, p0 : int) : list of JObject |
| 505 | { | 415 | { |
| 506 | objs : list of JObject; | 416 | objs: list of JObject; |
| 507 | 417 | ||
| 508 | getReflect(); | 418 | getReflect(); |
| 509 | 419 | ||
| 510 | flds := this.class.staticmethods; | 420 | flds := this.class.staticmethods; |
| 511 | for ( i := 0; i < len flds; i++ ) | 421 | for (i := 0; i < len flds; i++) |
| 512 | if ( p0 != 0 || (flds[i].flags & JNI->ACC_PUBLIC) != 0 ) | 422 | if (p0 != 0 || (flds[i].flags & JNI->ACC_PUBLIC) != 0) |
| 513 | objs = makeAMethod(this, flds[i], i) :: objs; | 423 | objs = makeAMethod(this, flds[i], i) :: objs; |
| 514 | 424 | ||
| 515 | if ( p0 != 0 ) { | 425 | if (p0 != 0) { |
| 516 | flds = this.class.privatemethods; | 426 | flds = this.class.privatemethods; |
| 517 | for ( i = len flds - 1; i >= 0; i-- ) | 427 | for (i = len flds - 1; i >= 0; i--) |
| 518 | objs = makeAMethod(this, flds[i], i) :: objs; | 428 | objs = makeAMethod(this, flds[i], i) :: objs; |
| 519 | } | 429 | } |
| 520 | 430 | ||
| 521 | vflds := this.class.virtualmethods; | 431 | vflds := this.class.virtualmethods; |
| 522 | for ( i = len vflds - 1; i >= 0; i-- ) | 432 | for ( i = len vflds - 1; i >= 0; i-- ) |
| 523 | if ( (p0 == 1 && vflds[i].class == this.class) # declared, this class | 433 | if ((p0 == 1 && vflds[i].class == this.class) # declared, this class |
| 524 | || ( p0 == 0 && (vflds[i].field.flags & JNI->ACC_PUBLIC) != 0 ) ) { | 434 | || (p0 == 0 && (vflds[i].field.flags & JNI->ACC_PUBLIC) != 0)) { |
| 525 | if ( vflds[i].class != this.class ) | 435 | if (vflds[i].class != this.class) |
| 526 | this = jni->GetClassObject(vflds[i].class); | 436 | this = jni->GetClassObject(vflds[i].class); |
| 527 | objs = makeAMethod(this, vflds[i].field, i) :: objs; | 437 | objs = makeAMethod(this, vflds[i].field, i) :: objs; |
| 528 | } | 438 | } |
| 529 | 439 | ||
| 530 | return objs; | 440 | return objs; |
| 531 | } | 441 | } |
| 532 | # | 442 | # |
| 533 | # A helper function that gets constructors for the class represented | 443 | # A helper function that gets constructors for the class represented |
| 534 | # by this. p0 == 0 => PUBLIC constructors, p0 == 1 => DECLARED | 444 | # by this. p0 == 0 => PUBLIC constructors, p0 == 1 => DECLARED |
| 535 | # constructors. Candidate constructors are found in the loader | 445 | # constructors. Candidate constructors are found in the loader |
| 536 | # array initmethods. | 446 | # array initmethods. |
| 537 | # | 447 | # |
| 538 | getConstructors(this : JClass, p0 : int) : list of JObject | 448 | getConstructors(this : JClass, p0 : int) : list of JObject |
| 539 | { | 449 | { |
| 540 | objs : list of JObject; | 450 | objs: list of JObject; |
| 541 | 451 | ||
| 542 | getReflect(); | 452 | getReflect(); |
| 543 | 453 | ||
| 544 | flds := this.class.initmethods; | 454 | flds := this.class.initmethods; |
| 545 | for ( i := len flds - 1; i >= 0; i-- ) | 455 | for (i := len flds - 1; i >= 0; i--) |
| 546 | if ( p0 != 0 || (flds[i].flags & JNI->ACC_PUBLIC) != 0 ) | 456 | if (p0 != 0 || (flds[i].flags & JNI->ACC_PUBLIC) != 0) |
| 547 | objs = makeAMethod(this, flds[i], i) :: objs; | 457 | objs = makeAMethod(this, flds[i], i) :: objs; |
| 548 | 458 | ||
| 549 | return objs; | 459 | return objs; |
| 550 | } | 460 | } |
| 551 | # | 461 | # |
| 552 | # Make sure Reflect module is loaded. | 462 | # Make sure Reflect module is loaded. |
| 553 | # | 463 | # |
| 554 | getReflect() | 464 | getReflect() |
| 555 | { | 465 | { |
| 556 | if ( refl == nil ) { | 466 | if (refl == nil) { |
| 557 | refl = load Reflect Reflect->PATH; | 467 | refl = load Reflect Reflect->PATH; |
| 558 | if ( refl == nil ) | 468 | if (refl == nil) |
| 559 | jni->InitError( jni->sys->sprint( "java.lang.Class: could not load %s: %r", Reflect->PATH ) ); | 469 | jni->InitError(jni->sys->sprint( "java.lang.Class: could not load %s: %r", Reflect->PATH)); |
| 560 | else | 470 | else |
| 561 | refl->init(jni); | 471 | refl->init(jni); |
| 562 | } | 472 | } |
| 563 | } | 473 | } |
| 564 | # | 474 | # |
| 565 | # Construct a Field Object. The field is a member of the class | 475 | # Construct a Field Object. The field is a member of the class |
| 566 | # represented by this, and the loader data for the field is in fld, | 476 | # represented by this, and the loader data for the field is in fld, |
| 567 | # which is at offset ix in the appropriate array or list. The 'slot' | 477 | # which is at offset ix in the appropriate array or list. The 'slot' |
| 568 | # elements of a Field_obj adt is used only by native methods, and has | 478 | # elements of a Field_obj adt is used only by native methods, and has |
| 569 | # the fields modifier flags in the low-order 16 bits, and the index | 479 | # the fields modifier flags in the low-order 16 bits, and the index |
| 570 | # into the array/list in the upper 16 bits. (The index into what | 480 | # into the array/list in the upper 16 bits. (The index into what |
| 571 | # depends on the modifier flags.) | 481 | # depends on the modifier flags.) |
| 572 | # | 482 | # |
| 573 | makeField(this : JClass, fld : ref jldr->Field, ix : int) : JObject | 483 | makeField(this : JClass, fld : ref jldr->Field, ix : int) : JObject |
| 574 | { | 484 | { |
| @@ -581,13 +491,13 @@ makeField(this : JClass, fld : ref jldr->Field, ix : int) : JObject · 6 unmodified lines | |||
| 581 | name := ref Value.TObject(cast->FromJString(jni->NewString(fld.field))); | 491 | name := ref Value.TObject(cast->FromJString(jni->NewString(fld.field))); |
| 582 | jni->SetObjField(fldobj, "name", name); | 492 | jni->SetObjField(fldobj, "name", name); |
| 583 | 493 | ||
| 584 | class : ref Value; | 494 | class: ref Value; |
| 585 | if ( (typ := refl->SigToType(fld.signature)) > 0 ) | 495 | if ((typ := refl->SigToType(fld.signature)) > 0) |
| 586 | class = refl->GetPrimitiveClass(typ); | 496 | class = refl->GetPrimitiveClass(typ); |
| 587 | else { | 497 | else { |
| 588 | classname := fld.signature[1:len fld.signature - 1]; | 498 | classname := fld.signature[1:len fld.signature - 1]; |
| 589 | class = ref Value.TObject(cast->FromJClass( | 499 | class = ref Value.TObject(cast->FromJClass( |
| 590 | jni->GetClassObject(jni->FindClass(classname)))); | 500 | jni->GetClassObject(jni->FindClass(classname)))); |
| 591 | } | 501 | } |
| 592 | jni->SetObjField(fldobj, "type", class); | 502 | jni->SetObjField(fldobj, "type", class); |
| 593 | 503 | ||
| @@ -597,12 +507,12 @@ makeField(this : JClass, fld : ref jldr->Field, ix : int) : JObject · 3 unmodified lines | |||
| 597 | return fldobj; | 507 | return fldobj; |
| 598 | } | 508 | } |
| 599 | # | 509 | # |
| 600 | # Make a new Method/Constructor object for a method or constructor in | 510 | # Make a new Method/Constructor object for a method or constructor in |
| 601 | # the class this. The loader information for the method/constructor is | 511 | # the class this. The loader information for the method/constructor is |
| 602 | # found in the loader Field adt fld, which is at offset ix in its | 512 | # found in the loader Field adt fld, which is at offset ix in its |
| 603 | # array or list. The signature for the arguments is converted into | 513 | # array or list. The signature for the arguments is converted into |
| 604 | # a corresponding array of Class objects by makeParamClassArray, then | 514 | # a corresponding array of Class objects by makeParamClassArray, then |
| 605 | # makeMethod is called to generate the new object. | 515 | # makeMethod is called to generate the new object. |
| 606 | # | 516 | # |
| 607 | makeAMethod(this: JClass, fld : ref jldr->Field, ix : int) : JObject | 517 | makeAMethod(this: JClass, fld : ref jldr->Field, ix : int) : JObject |
| 608 | { | 518 | { |
| @@ -613,68 +523,68 @@ makeAMethod(this: JClass, fld : ref jldr->Field, ix : int) : JObject · 4 unmodified lines | |||
| 613 | return makeMethod(this, fld, ix, classarray, retsig); | 523 | return makeMethod(this, fld, ix, classarray, retsig); |
| 614 | } | 524 | } |
| 615 | # | 525 | # |
| 616 | # Construct a Method Object. Also used to make Constructor Objects, | 526 | # Construct a Method Object. Also used to make Constructor Objects, |
| 617 | # share several elements with Methods. The two can be distinguished | 527 | # share several elements with Methods. The two can be distinguished |
| 618 | # because constructors have the name "<init>" (however, Constructor | 528 | # because constructors have the name "<init>" (however, Constructor |
| 619 | # Objects do not have a 'name' field, nor do they have a 'returnType' | 529 | # Objects do not have a 'name' field, nor do they have a 'returnType' |
| 620 | # field. The 'slot' field, which is only used by native methods, | 530 | # field. The 'slot' field, which is only used by native methods, |
| 621 | # is filled with modifier flags in the lower 16 bits and an index (ix) | 531 | # is filled with modifier flags in the lower 16 bits and an index (ix) |
| 622 | # into an appropriate loader array/list in the upper 16 bits (which | 532 | # into an appropriate loader array/list in the upper 16 bits (which |
| 623 | # array can be determined by the modifier flags. ). The arguments | 533 | # array can be determined by the modifier flags. ). The arguments |
| 624 | # types required by the method are specified by the cl array of | 534 | # types required by the method are specified by the cl array of |
| 625 | # Class ofjects. The return value, if any, is specified by the | 535 | # Class ofjects. The return value, if any, is specified by the |
| 626 | # signature given in retsig. | 536 | # signature given in retsig. |
| 627 | # | 537 | # |
| 628 | makeMethod(this: JClass, fld : ref jldr->Field, ix : int, cl : JArrayJClass, | 538 | makeMethod(this: JClass, fld : ref jldr->Field, ix : int, cl : JArrayJClass, |
| 629 | retsig : string) : JObject | 539 | retsig : string) : JObject |
| 630 | { | 540 | { |
| 631 | mcl : ClassData; | 541 | mcl : ClassData; |
| 632 | isConstructor := 0; | 542 | isConstructor := 0; |
| 633 | if ( fld.field == "<init>" ) | 543 | if (fld.field == "<init>") |
| 634 | isConstructor = 1; | 544 | isConstructor = 1; |
| 635 | if ( isConstructor ) | 545 | if (isConstructor) |
| 636 | mcl = jni->FindClass("java/lang/reflect/Constructor"); | 546 | mcl = jni->FindClass("java/lang/reflect/Constructor"); |
| 637 | else | 547 | else |
| 638 | mcl = jni->FindClass("java/lang/reflect/Method"); | 548 | mcl = jni->FindClass("java/lang/reflect/Method"); |
| 639 | methobj := jni->AllocObject(mcl); | 549 | methobj := jni->AllocObject(mcl); |
| 640 | 550 | ||
| 641 | clazz := ref Value.TObject(cast->FromJClass(this)); | 551 | clazz := ref Value.TObject(cast->FromJClass(this)); |
| 642 | jni->SetObjField(methobj, "clazz", clazz); | 552 | jni->SetObjField(methobj, "clazz", clazz); |
| 643 | 553 | ||
| 644 | if ( ! isConstructor ) { | 554 | if (!isConstructor) { |
| 645 | name := ref Value.TObject(cast->FromJString(jni->NewString(fld.field))); | 555 | name := ref Value.TObject(cast->FromJString(jni->NewString(fld.field))); |
| 646 | jni->SetObjField(methobj, "name", name); | 556 | jni->SetObjField(methobj, "name", name); |
| 647 | } | 557 | } |
| 648 | 558 | ||
| 649 | slot := ref Value.TInt((fld.flags & 16rffff) | (ix << 16)); | 559 | slot := ref Value.TInt((fld.flags & 16rffff) | (ix << 16)); |
| 650 | jni->SetObjField(methobj, "slot", slot); | 560 | jni->SetObjField(methobj, "slot", slot); |
| 651 | 561 | ||
| 652 | if ( ! isConstructor ) { | 562 | if (!isConstructor) { |
| 653 | getReflect(); | 563 | getReflect(); |
| 654 | ret : ref Value; | 564 | ret: ref Value; |
| 655 | if ( (typ := refl->SigToType(retsig)) > 0 ) | 565 | if ((typ := refl->SigToType(retsig)) > 0) |
| 656 | ret = refl->GetPrimitiveClass(typ); | 566 | ret = refl->GetPrimitiveClass(typ); |
| 657 | else { | 567 | else { |
| 658 | rclass: JClass; | 568 | rclass: JClass; |
| 659 | case retsig[0] { | 569 | case retsig[0] { |
| 660 | 'L' => | 570 | 'L' => |
| 661 | rcdata := jni->FindClass(retsig[1:len retsig -1]); | 571 | rcdata := jni->FindClass(retsig[1:len retsig -1]); |
| 662 | rclass = jni->GetClassObject(rcdata); | 572 | rclass = jni->GetClassObject(rcdata); |
| 663 | '[' => | 573 | '[' => |
| 664 | rclass = jni->LookupArrayClass(retsig); | 574 | rclass = jni->LookupArrayClass(retsig); |
| 665 | 'V' => | 575 | 'V' => |
| 666 | rcdata := jni->FindClass("inferno/vm/void_p"); | 576 | rcdata := jni->FindClass("inferno/vm/void_p"); |
| 667 | rclass = jni->GetClassObject(rcdata); | 577 | rclass = jni->GetClassObject(rcdata); |
| 668 | } | 578 | } |
| 669 | ret = ref Value.TObject(cast->FromJClass(rclass)); | 579 | ret = ref Value.TObject(cast->FromJClass(rclass)); |
| 670 | } | 580 | } |
| 671 | jni->SetObjField(methobj, "returnType", ret); | 581 | jni->SetObjField(methobj, "returnType", ret); |
| 672 | } | 582 | } |
| 673 | 583 | ||
| 674 | args := ref Value.TObject(cast->FromJArray(cast->ClassToJArray(cl))); | 584 | args := ref Value.TObject(cast->FromJArray(cast->ClassToJArray(cl))); |
| 675 | jni->SetObjField(methobj, "parameterTypes", args); | 585 | jni->SetObjField(methobj, "parameterTypes", args); |
| 676 | 586 | ||
| 677 | # Don't know how to get the list of exceptions thrown. | 587 | # Don't know how to get the list of exceptions thrown. |
| 678 | # jni->SetObjField(methobj, "exceptionTypes", excs); | 588 | # jni->SetObjField(methobj, "exceptionTypes", excs); |
| 679 | # Set to a sensible default for now. | 589 | # Set to a sensible default for now. |
| 680 | foo := cast->JArrayToClass(cast->ObjectToJArray(makeParamClassArray("()"))); | 590 | foo := cast->JArrayToClass(cast->ObjectToJArray(makeParamClassArray("()"))); |
| @@ -683,104 +593,99 @@ makeMethod(this: JClass, fld : ref jldr->Field, ix : int, cl : JArrayJClass, · 2 unmodified lines | |||
| 683 | return methobj; | 593 | return methobj; |
| 684 | } | 594 | } |
| 685 | # | 595 | # |
| 686 | # Turn a signature into an array of Class Objects. | 596 | # Turn a signature into an array of Class Objects. |
| 687 | # | 597 | # |
| 688 | makeParamClassArray(sig : string) : JArrayJObject | 598 | makeParamClassArray(sig : string) : JArrayJObject |
| 689 | { | 599 | { |
| 690 | if ( sig[0] != '(' || sig[len sig -1] != ')' ) | 600 | if (sig[0] != '(' || sig[len sig -1] != ')') |
| 691 | return nil; | 601 | return nil; |
| 692 | clist := makeParamClass(sig[1:len sig -1]); | 602 | clist := makeParamClass(sig[1:len sig -1]); |
| 693 | jajcl := array[len clist] of JObject; | 603 | jajcl := array[len clist] of JObject; |
| 694 | for ( i := 0; i < len jajcl; i++ ) { | 604 | for (i := 0; i < len jajcl; i++) { |
| 695 | jajcl[i] = hd clist; | 605 | jajcl[i] = hd clist; |
| 696 | clist = tl clist; | 606 | clist = tl clist; |
| 697 | } | 607 | } |
| 698 | paramclassarray := jni->MkAObject(jajcl); | 608 | paramclassarray := jni->MkAObject(jajcl); |
| 699 | paramclassarray.class = jni->FindClass("java/lang/Class"); | 609 | paramclassarray.class = jni->FindClass("java/lang/Class"); |
| 700 | return paramclassarray; | 610 | return paramclassarray; |
| 701 | } | 611 | } |
| 702 | # | 612 | # |
| 703 | # Recursively turn a signature into a list of JClass | 613 | # Recursively turn a signature into a list of JClass |
| 704 | # | 614 | # |
| 705 | makeParamClass(sig : string) : list of JObject | 615 | makeParamClass(sig : string) : list of JObject |
| 706 | { | 616 | { |
| 707 | if ( sig == "" ) | 617 | if (sig == "") |
| 708 | return nil; | 618 | return nil; |
| 709 | 619 | ||
| 710 | (first, rest) := splitSignature(sig); | 620 | (first, rest) := splitSignature(sig); |
| 711 | jobj: JObject; | 621 | jobj: JObject; |
| 712 | case first[0] { | 622 | case first[0] { |
| 713 | 'L' => | 623 | 'L' => |
| 714 | first = first[1:len first - 1]; | 624 | first = first[1:len first - 1]; |
| 715 | newcl := jni->GetClassObject(jni->FindClass(first)); | 625 | newcl := jni->GetClassObject(jni->FindClass(first)); |
| 716 | jobj = cast->FromJClass(newcl); | 626 | jobj = cast->FromJClass(newcl); |
| 717 | '[' => | 627 | '[' => |
| 718 | newcl := jni->LookupArrayClass(first); | 628 | newcl := jni->LookupArrayClass(first); |
| 719 | jobj = cast->FromJClass(newcl); | 629 | jobj = cast->FromJClass(newcl); |
| 720 | 'Z' or 'B' or 'S' or 'C' or 'I' or 'J' or 'F' or 'D' => | 630 | 'Z' or 'B' or 'S' or 'C' or 'I' or 'J' or 'F' or 'D' => |
| 721 | typ := refl->SigToType(first); | 631 | typ := refl->SigToType(first); |
| 722 | jobj = refl->GetPrimitiveClass(typ).Object(); | 632 | jobj = refl->GetPrimitiveClass(typ).Object(); |
| 723 | * => | 633 | * => |
| 724 | return nil; | 634 | return nil; |
| 725 | } | 635 | } |
| 726 | 636 | ||
| 727 | return jobj :: makeParamClass(rest); | 637 | return jobj :: makeParamClass(rest); |
| 728 | } | 638 | } |
| 729 | # | 639 | # |
| 730 | # Convert an array of JClass to the corresponding signature string. | 640 | # Convert an array of JClass to the corresponding signature string. |
| 731 | # | 641 | # |
| 732 | MakeSignature(jcl : JArrayJClass) : string | 642 | MakeSignature(jcl : JArrayJClass) : string |
| 733 | { | 643 | { |
| 734 | clarray: array of JClass; | 644 | clarray: array of JClass; |
| 735 | if ( jcl != nil ) | 645 | if (jcl != nil) |
| 736 | clarray = jcl.ary; | 646 | clarray = jcl.ary; |
| 737 | sig := ""; | 647 | sig := ""; |
| 738 | for ( i := 0; i < len clarray; i++) | 648 | for (i := 0; i < len clarray; i++) |
| 739 | sig += MakeSingleSignature(clarray[i]); | 649 | sig += MakeSingleSignature(clarray[i]); |
| 740 | return sig; | 650 | return sig; |
| 741 | } | 651 | } |
| 742 | # | 652 | # |
| 743 | # Convert a Jclass to the corresponding signature. | 653 | # Convert a Jclass to the corresponding signature. |
| 744 | # | 654 | # |
| 745 | MakeSingleSignature(this : JClass) : string | 655 | MakeSingleSignature(this : JClass) : string |
| 746 | { | 656 | { |
| 747 | if ( (typ := jni->PrimitiveIndex(this, 1)) > 0 ) { | 657 | if ((typ := jni->PrimitiveIndex(this, 1)) > 0) { |
| 748 | getReflect(); | 658 | getReflect(); |
| 749 | return refl->TypeToSig(typ); | 659 | return refl->TypeToSig(typ); |
| 750 | } | 660 | } |
| 751 | 661 | ||
| 752 | if ( this.aryname != nil ) | 662 | if (this.aryname != nil) |
| 753 | return this.aryname; | 663 | return this.aryname; |
| 754 | 664 | ||
| 755 | # | 665 | # |
| 756 | # Must be a class type | 666 | # Must be a class type |
| 757 | # | 667 | # |
| 758 | return "L" + this.class.name + ";"; | 668 | return "L" + this.class.name + ";"; |
| 759 | } | 669 | } |
| 760 | # | 670 | # |
| 761 | # Break a signature into an initial type plus the remainder. | 671 | # Break a signature into an initial type plus the remainder. |
| 762 | # | 672 | # |
| 763 | splitSignature(sig : string) : (string, string) | 673 | splitSignature(sig : string) : (string, string) |
| 764 | { | 674 | { |
| 765 | case sig[0] { | 675 | case sig[0] { |
| 766 | 'L' => | 676 | 'L' => |
| 767 | for ( i := 1; sig[i] != ';'; i++ ) ; | 677 | for (i := 1; sig[i] != ';'; i++) ; |
| 768 | i++; | 678 | i++; |
| 769 | return (sig[0:i], sig[i:]); | 679 | return (sig[0:i], sig[i:]); |
| 770 | 680 | ||
| 771 | '[' => # recurse to get element type | 681 | '[' => # recurse to get element type |
| 772 | (first, rest) := splitSignature(sig[1:]); | 682 | (first, rest) := splitSignature(sig[1:]); |
| 773 | return ("[" + first, rest); | 683 | return ("[" + first, rest); |
| 774 | 684 | ||
| 775 | 'Z' or 'B' or 'S' or 'C' or 'I' or 'J' or 'F' or 'D' => | 685 | 'Z' or 'B' or 'S' or 'C' or 'I' or 'J' or 'F' or 'D' => |
| 776 | return (sig[0:1], sig[1:]); | 686 | return (sig[0:1], sig[1:]); |
| 777 | } | 687 | } |
| 778 | return (nil, nil); | 688 | return (nil, nil); |
| 779 | } | 689 | } |
| 780 | 690 | ||
| 781 | 691 | ||
| 782 | registerNatives_V( ) | ||
| 783 | {#>> | ||
| 784 | # currently empty... | ||
| 785 | }#<< | ||
| 786 | |||
| @@ -1,31 +1,36 @@ | |||
| 1 | # javal v1.2 generated file: edit with care | 1 | # generated file edit with care |
| 2 | 2 | ||
| 3 | Class_L : module | 3 | Class_L : module |
| 4 | { | 4 | { |
| 5 | 5 | ||
| 6 | init : fn( jni_p : JNI ); | 6 | init : fn( jni_p : JNI ); |
| 7 | forName0_rString_Z_rClassLoader_rClass : fn( p0 : JString, p1 : int, p2 : JObject ) : JClass; | 7 | forName0_rString_Z_rClassLoader_rClass : fn( p0 : JString,p1 : int,p2 : JObject) : JClass; |
| 8 | newInstance_rObject : fn( this : JClass) : JObject; | ||
| 9 | isInstance_rObject_Z : fn( this : JClass, p0 : JObject) : int; | ||
| 10 | isAssignableFrom_rClass_Z : fn( this : JClass, p0 : JClass) : int; | 8 | isAssignableFrom_rClass_Z : fn( this : JClass, p0 : JClass) : int; |
| 9 | isInstance_rObject_Z : fn( this : JClass, p0 : JObject) : int; | ||
| 10 | getModifiers_I : fn( this : JClass) : int; | ||
| 11 | isInterface_Z : fn( this : JClass) : int; | 11 | isInterface_Z : fn( this : JClass) : int; |
| 12 | isArray_Z : fn( this : JClass) : int; | 12 | isArray_Z : fn( this : JClass) : int; |
| 13 | isPrimitive_Z : fn( this : JClass) : int; | 13 | isPrimitive_Z : fn( this : JClass) : int; |
| 14 | getSuperclass_rClass : fn( this : JClass) : JClass; | ||
| 15 | getComponentType_rClass : fn( this : JClass) : JClass; | ||
| 16 | registerNatives_V : fn( ); | ||
| 14 | getName0_rString : fn( this : JClass) : JString; | 17 | getName0_rString : fn( this : JClass) : JString; |
| 15 | getClassLoader0_rClassLoader : fn( this : JClass) : JObject; | 18 | getClassLoader0_rClassLoader : fn( this : JClass) : JObject; |
| 16 | getSuperclass_rClass : fn( this : JClass) : JClass; | ||
| 17 | getInterfaces_aClass : fn( this : JClass) : JArrayJClass; | 19 | getInterfaces_aClass : fn( this : JClass) : JArrayJClass; |
| 18 | getComponentType_rClass : fn( this : JClass) : JClass; | ||
| 19 | getModifiers_I : fn( this : JClass) : int; | ||
| 20 | getSigners_aObject : fn( this : JClass) : JArrayJObject; | 20 | getSigners_aObject : fn( this : JClass) : JArrayJObject; |
| 21 | setSigners_aObject_V : fn( this : JClass, p0 : JArrayJObject); | 21 | setSigners_aObject_V : fn( this : JClass, p0 : JArrayJObject); |
| 22 | getEnclosingMethod0_aObject : fn( this : JClass) : JArrayJObject; | ||
| 23 | getDeclaringClass_rClass : fn( this : JClass) : JClass; | ||
| 24 | getProtectionDomain0_rProtectionDomain : fn( this : JClass) : JObject; | ||
| 25 | setProtectionDomain0_rProtectionDomain_V : fn( this : JClass, p0 : JObject); | ||
| 22 | getPrimitiveClass_rString_rClass : fn( p0 : JString) : JClass; | 26 | getPrimitiveClass_rString_rClass : fn( p0 : JString) : JClass; |
| 23 | getFields0_I_aField : fn( this : JClass, p0 : int) : JArrayJObject; | 27 | getGenericSignature_rString : fn( this : JClass) : JString; |
| 24 | getMethods0_I_aMethod : fn( this : JClass, p0 : int) : JArrayJObject; | 28 | getRawAnnotations_aB : fn( this : JClass) : JArrayB; |
| 25 | getConstructors0_I_aConstructor : fn( this : JClass, p0 : int) : JArrayJObject; | 29 | getConstantPool_rConstantPool : fn( this : JClass) : JObject; |
| 26 | getField0_rString_I_rField : fn( this : JClass, p0 : JString,p1 : int) : JObject; | 30 | getDeclaredFields0_Z_aField : fn( this : JClass, p0 : int) : JArrayJObject; |
| 27 | getMethod0_rString_aClass_I_rMethod : fn( this : JClass, p0 : JString,p1 : JArrayJClass,p2 : int) : JObject; | 31 | getDeclaredMethods0_Z_aMethod : fn( this : JClass, p0 : int) : JArrayJObject; |
| 28 | getConstructor0_aClass_I_rConstructor : fn( this : JClass, p0 : JArrayJClass,p1 : int) : JObject; | 32 | getDeclaredConstructors0_Z_aConstructor : fn( this : JClass, p0 : int) : JArrayJObject; |
| 29 | registerNatives_V : fn( ); | 33 | getDeclaredClasses0_aClass : fn( this : JClass) : JArrayJClass; |
| 34 | desiredAssertionStatus0_rClass_Z : fn( p0 : JClass) : int; | ||
| 30 | 35 | ||
| 31 | }; | 36 | }; |