/** * Peer method for the <code>java.lang.reflect.Field.set</code> method. * * @author Mirko Stojmenovic ([email protected]) * @author Igor Andjelkovic ([email protected]) * @author Milos Gligoric ([email protected]) */ public static void set__Ljava_lang_Object_2Ljava_lang_Object_2__V( MJIEnv env, int objRef, int fobjRef, int val) { FieldInfo fi = getFieldInfo(env, objRef); int modifiers = fi.getModifiers(); if (!isAvailable(env, fi, fobjRef)) { return; } if (Modifier.isFinal(modifiers)) { env.throwException("java.lang.IllegalAccessException", "field " + fi.getName() + " is final"); return; } ClassInfo ci = fi.getClassInfo(); ClassInfo cio = env.getClassInfo(fobjRef); if (!fi.isStatic() && !cio.isInstanceOf(ci)) { env.throwException( "java.lang.IllegalArgumentException", fi.getType() + "field " + fi.getName() + " does not belong to this object"); return; } Object[] attrs = env.getArgAttributes(); Object attr = (attrs == null) ? null : attrs[2]; if (!setValue(env, fi, fobjRef, val, attr)) { env.throwException( "java.lang.IllegalArgumentException", "Can not set " + fi.getType() + " field " + fi.getFullName() + " to " + ((MJIEnv.NULL != val) ? env.getClassInfo(val).getName() + " object " : "null")); } }
/** * Peer method for the <code>java.lang.reflect.Field.set</code> method. * * @author Mirko Stojmenovic ([email protected]) * @author Igor Andjelkovic ([email protected]) * @author Milos Gligoric ([email protected]) */ @MJI public void set__Ljava_lang_Object_2Ljava_lang_Object_2__V( MJIEnv env, int objRef, int fobjRef, int val, FeatureExpr ctx) { FieldInfo fi = getFieldInfo(ctx, env, objRef); if (!isAvailable(env, fi, fobjRef, ctx)) { return; } if (fi.isFinal() && fi.isStatic()) { env.throwException( ctx, IllegalAccessException.class.getName(), "Can not set static final " + fi.getType() + " field " + fi.getFullName()); return; } if (!env.getBooleanField(objRef, "isAccessible").getValue() && fi.isFinal()) { env.throwException( ctx, IllegalAccessException.class.getName(), "Can not set final " + fi.getType() + " field " + fi.getFullName()); return; } ClassInfo ci = fi.getClassInfo(); ClassInfo cio = env.getClassInfo(fobjRef); if (!fi.isStatic() && !cio.isInstanceOf(ci)) { env.throwException( ctx, IllegalAccessException.class.getName(), fi.getType() + "field " + fi.getName() + " does not belong to this object"); return; } if (!env.getBooleanField(objRef, "isAccessible").getValue()) { if (!fi.isStatic() && cio.isInstanceOf(ci)) { if (!fi.isPublic()) { env.throwException( ctx, IllegalAccessException.class.getName(), fi.getType() + " field " + fi.getName()); return; } } else { if (!fi.isPublic()) { env.throwException( ctx, IllegalAccessException.class.getName(), fi.getType() + " field " + fi.getName()); return; } } } Object[] attrs = env.getArgAttributes(); Object attr = (attrs == null) ? null : attrs[2]; if (!setValue(ctx, env, fi, fobjRef, val, attr)) { env.throwException( ctx, IllegalAccessException.class.getName(), "Can not set " + fi.getType() + " field " + fi.getFullName() + " to " + ((MJIEnv.NULL != val) ? env.getClassInfo(val).getName() + " object " : "null")); } }