本文整理汇总了Java中net.bytebuddy.ClassFileVersion.isAtLeast方法的典型用法代码示例。如果您正苦于以下问题:Java ClassFileVersion.isAtLeast方法的具体用法?Java ClassFileVersion.isAtLeast怎么用?Java ClassFileVersion.isAtLeast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.bytebuddy.ClassFileVersion
的用法示例。
在下文中一共展示了ClassFileVersion.isAtLeast方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compile
import net.bytebuddy.ClassFileVersion; //导入方法依赖的package包/类
@Override
public MethodRegistry.Compiled compile(Implementation.Target.Factory implementationTargetFactory, ClassFileVersion classFileVersion) {
Map<Handler, Handler.Compiled> compilationCache = new HashMap<Handler, Handler.Compiled>();
Map<MethodAttributeAppender.Factory, MethodAttributeAppender> attributeAppenderCache = new HashMap<MethodAttributeAppender.Factory, MethodAttributeAppender>();
LinkedHashMap<MethodDescription, Compiled.Entry> entries = new LinkedHashMap<MethodDescription, Compiled.Entry>();
Implementation.Target implementationTarget = implementationTargetFactory.make(instrumentedType, methodGraph, classFileVersion);
for (Map.Entry<MethodDescription, Entry> entry : implementations.entrySet()) {
Handler.Compiled cachedHandler = compilationCache.get(entry.getValue().getHandler());
if (cachedHandler == null) {
cachedHandler = entry.getValue().getHandler().compile(implementationTarget);
compilationCache.put(entry.getValue().getHandler(), cachedHandler);
}
MethodAttributeAppender cachedAttributeAppender = attributeAppenderCache.get(entry.getValue().getAppenderFactory());
if (cachedAttributeAppender == null) {
cachedAttributeAppender = entry.getValue().getAppenderFactory().make(instrumentedType);
attributeAppenderCache.put(entry.getValue().getAppenderFactory(), cachedAttributeAppender);
}
entries.put(entry.getKey(), new Compiled.Entry(cachedHandler,
cachedAttributeAppender,
entry.getValue().getMethodDescription(),
entry.getValue().resolveBridgeTypes(),
entry.getValue().getVisibility(),
entry.getValue().isBridgeMethod()));
}
return new Compiled(instrumentedType,
loadedTypeInitializer,
typeInitializer,
methods,
entries,
classFileVersion.isAtLeast(ClassFileVersion.JAVA_V5));
}
示例2: visit
import net.bytebuddy.ClassFileVersion; //导入方法依赖的package包/类
@Override
public void visit(int version, int modifiers, String name, String signature, String superName, String[] interfaces) {
ClassFileVersion classFileVersion = ClassFileVersion.ofMinorMajor(version);
List<Constraint> constraints = new ArrayList<Constraint>();
constraints.add(new Constraint.ForClassFileVersion(classFileVersion));
if (name.endsWith('/' + PackageDescription.PACKAGE_CLASS_NAME)) {
constraints.add(Constraint.ForPackageType.INSTANCE);
} else if ((modifiers & Opcodes.ACC_ANNOTATION) != 0) {
if (!classFileVersion.isAtLeast(ClassFileVersion.JAVA_V5)) {
throw new IllegalStateException("Cannot define an annotation type for class file version " + classFileVersion);
}
constraints.add(classFileVersion.isAtLeast(ClassFileVersion.JAVA_V8)
? Constraint.ForAnnotation.JAVA_8
: Constraint.ForAnnotation.CLASSIC);
} else if ((modifiers & Opcodes.ACC_INTERFACE) != 0) {
constraints.add(classFileVersion.isAtLeast(ClassFileVersion.JAVA_V8)
? Constraint.ForInterface.JAVA_8
: Constraint.ForInterface.CLASSIC);
} else if ((modifiers & Opcodes.ACC_ABSTRACT) != 0) {
constraints.add(Constraint.ForClass.ABSTRACT);
} else {
constraints.add(Constraint.ForClass.MANIFEST);
}
constraint = new Constraint.Compound(constraints);
constraint.assertType(modifiers, interfaces != null, signature != null);
super.visit(version, modifiers, name, signature, superName, interfaces);
}
示例3: of
import net.bytebuddy.ClassFileVersion; //导入方法依赖的package包/类
/**
* Resolves a default method invocation depending on the class file version permitting such calls.
*
* @param classFileVersion The class file version to resolve for.
* @return A suitable default method invocation mode.
*/
public static DefaultMethodInvocation of(ClassFileVersion classFileVersion) {
return classFileVersion.isAtLeast(ClassFileVersion.JAVA_V8)
? ENABLED
: DISABLED;
}