Fields.java 文件源码

java
阅读 22 收藏 0 点赞 0 评论 0

项目:Skript 作者:
public void setField(final Object o, final Field f, final Yggdrasil y) throws StreamCorruptedException {
    if (Modifier.isStatic(f.getModifiers()))
        throw new StreamCorruptedException("The field " + id + " of " + f.getDeclaringClass() + " is static");
    if (Modifier.isTransient(f.getModifiers()))
        throw new StreamCorruptedException("The field " + id + " of " + f.getDeclaringClass() + " is transient");
    if (f.getType().isPrimitive() != isPrimitiveValue)
        throw new StreamCorruptedException("The field " + id + " of " + f.getDeclaringClass() + " is " + (f.getType().isPrimitive() ? "" : "not ") + "primitive");
    try {
        f.setAccessible(true);
        f.set(o, value);
    } catch (final IllegalArgumentException e) {
        if (!(o instanceof YggdrasilRobustSerializable) || !((YggdrasilRobustSerializable) o).incompatibleField(f, this))
            y.incompatibleField(o, f, this);
    } catch (final IllegalAccessException e) {
        assert false;
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号