当前位置: 首页>>代码示例>>Java>>正文


Java FieldDescription.isStatic方法代码示例

本文整理汇总了Java中net.bytebuddy.description.field.FieldDescription.isStatic方法的典型用法代码示例。如果您正苦于以下问题:Java FieldDescription.isStatic方法的具体用法?Java FieldDescription.isStatic怎么用?Java FieldDescription.isStatic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.bytebuddy.description.field.FieldDescription的用法示例。


在下文中一共展示了FieldDescription.isStatic方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolve

import net.bytebuddy.description.field.FieldDescription; //导入方法依赖的package包/类
@Override
public Target resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, Context context) {
    FieldDescription fieldDescription = resolve(instrumentedType);
    if (!fieldDescription.isStatic() && instrumentedMethod.isStatic()) {
        throw new IllegalStateException("Cannot read non-static field " + fieldDescription + " from static method " + instrumentedMethod);
    } else if (!context.isInitialized() && !fieldDescription.isStatic()) {
        throw new IllegalStateException("Cannot access non-static field before calling constructor: " + instrumentedMethod);
    }
    StackManipulation readAssignment = assigner.assign(fieldDescription.getType(), target, typing);
    if (!readAssignment.isValid()) {
        throw new IllegalStateException("Cannot assign " + fieldDescription + " to " + target);
    } else if (readOnly) {
        return new Target.ForField.ReadOnly(fieldDescription, readAssignment);
    } else {
        StackManipulation writeAssignment = assigner.assign(target, fieldDescription.getType(), typing);
        if (!writeAssignment.isValid()) {
            throw new IllegalStateException("Cannot assign " + target + " to " + fieldDescription);
        }
        return new Target.ForField.ReadWrite(fieldDescription.asDefined(), readAssignment, writeAssignment);
    }
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:22,代码来源:Advice.java

示例2: access

import net.bytebuddy.description.field.FieldDescription; //导入方法依赖的package包/类
/**
 * Checks a field access and loads the {@code this} instance if necessary.
 *
 * @param fieldDescription   The field to get a value
 * @param instrumentedMethod The instrumented method.
 * @param fieldAccess        A stack manipulation describing the field access.
 * @return An appropriate stack manipulation.
 */
private StackManipulation access(FieldDescription fieldDescription, MethodDescription instrumentedMethod, StackManipulation fieldAccess) {
    if (!fieldAccess.isValid()) {
        throw new IllegalStateException("Incompatible type of " + fieldDescription + " and " + instrumentedMethod);
    } else if (instrumentedMethod.isStatic() && !fieldDescription.isStatic()) {
        throw new IllegalArgumentException("Cannot call instance field " + fieldDescription + " from static method " + instrumentedMethod);
    }
    return new StackManipulation.Compound(fieldDescription.isStatic()
            ? StackManipulation.Trivial.INSTANCE
            : MethodVariableAccess.loadThis(), fieldAccess);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:19,代码来源:FieldAccessor.java


注:本文中的net.bytebuddy.description.field.FieldDescription.isStatic方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。