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