本文整理汇总了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);
}
}
示例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);
}