• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Opcodes类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.asm.Opcodes的典型用法代码示例。如果您正苦于以下问题:Java Opcodes类的具体用法?Java Opcodes怎么用?Java Opcodes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Opcodes类属于org.springframework.asm包,在下文中一共展示了Opcodes类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: LazyEntityGenerator

import org.springframework.asm.Opcodes; //导入依赖的package包/类
public LazyEntityGenerator(Class<?> entityType) {
	this.writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
	this.emitter = new ClassEmitter(writer);
	this.entityType = entityType;
	this.proxyClassName = entityType.getName() + "$$Hibatis$Lazy";
	this.metadata = EntityMetadata.get(entityType);
	// 开始声明类
	this.beginClass();
	// 加入属性
	addField(Opcodes.ACC_PRIVATE, "$target", Type.getType(Object.class).getDescriptor() , null);
	addField(Opcodes.ACC_PRIVATE, "$source", Type.getType(HibatisEntity.class).getDescriptor() , null);
	addField(Opcodes.ACC_PRIVATE, "$association", Type.getType(AssociationProperty.class).getDescriptor() , null);
	// 重写属性
	this.overrideProperties();
	// 结束声明类
	this.emitter.visitEnd();
}
 
开发者ID:yaoakeji,项目名称:hibatis,代码行数:18,代码来源:LazyEntityGenerator.java


示例2: ProxyClassGenerator

import org.springframework.asm.Opcodes; //导入依赖的package包/类
public ProxyClassGenerator(Class<?> entityType , boolean overrideProperties) {
	this.writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
	this.emitter = new ClassEmitter(writer);

	this.entityType = entityType;
	this.proxyClassName = entityType.getName() + "$$Hibatis";
	this.proxyClassPath = proxyClassName.replace(".", "/");
	this.entityClassPath = entityType.getName().replace(".", "/");
	this.metadata = EntityMetadata.get(entityType);
	// 开始声明类
	this.beginClass();
	// 声明字段
	Long serialVersionUID = new Long(proxyClassName.hashCode());
	int access = Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL;
	this.addField(access, "serialVersionUID", "J", serialVersionUID);
	// 加入字段
	this.addField(Opcodes.ACC_PRIVATE, "$propertyChanges", Type.getDescriptor(List.class), null);
	// 加入属性
	this.addProperty("$version", Type.getType(String.class), false, false); // 版本
	this.addProperty("$state", Type.getType(EntityState.class), false, false); // 状态
	this.addProperty("$type", Type.getType(Class.class), false, false); // 类型
	// 重写所有的属性
	if(overrideProperties){
		this.overrideProperties();
	}
	// 结束声明类
	this.emitter.visitEnd();
}
 
开发者ID:yaoakeji,项目名称:hibatis,代码行数:29,代码来源:ProxyClassGenerator.java


示例3: beginClass

import org.springframework.asm.Opcodes; //导入依赖的package包/类
private void beginClass() {
	Type supperType = Type.getType(entityType);
	Type[] interfaceTypes = new Type[] { Type.getType(Serializable.class), Type.getType(HibatisEntity.class) };
	this.emitter.begin_class(Opcodes.V1_5, Opcodes.ACC_PUBLIC, proxyClassName, supperType, interfaceTypes,
			null);
	addConstructor();
}
 
开发者ID:yaoakeji,项目名称:hibatis,代码行数:8,代码来源:ProxyClassGenerator.java


示例4: addConstructor

import org.springframework.asm.Opcodes; //导入依赖的package包/类
private void addConstructor() {
	// 创建构造方法
	CodeEmitter e = emitter.begin_method(Opcodes.ACC_PUBLIC, TypeUtils.parseConstructor(""), null);
	e.load_this();
	e.super_invoke_constructor();
	putField(e, "$version", metadata.getVersion()); // 设置版本
	putEnumField(e, "$state", EntityState.Transient); // 设置状态
	putClassField(e, "$type", entityType); // 实体类型
	putNewField(e, "$propertyChanges", ArrayList.class, List.class);
	// 返回值
	e.return_value();
	// 结束方法
	e.end_method();
}
 
开发者ID:yaoakeji,项目名称:hibatis,代码行数:15,代码来源:ProxyClassGenerator.java


示例5: putNewField

import org.springframework.asm.Opcodes; //导入依赖的package包/类
private void putNewField(CodeEmitter e, String name, Class<?> realType, Class<?> interfaceType) {
	String realTypePath = realType.getName().replace(".", "/");
	e.visitVarInsn(Opcodes.ALOAD, 0);
	e.visitTypeInsn(Opcodes.NEW, realTypePath);
	e.visitInsn(Opcodes.DUP);
	e.visitMethodInsn(Opcodes.INVOKESPECIAL, realTypePath, "<init>", "()V", false);
	e.visitFieldInsn(Opcodes.PUTFIELD, proxyClassPath, name, Type.getDescriptor(interfaceType));
}
 
开发者ID:yaoakeji,项目名称:hibatis,代码行数:9,代码来源:ProxyClassGenerator.java


示例6: addConstructor

import org.springframework.asm.Opcodes; //导入依赖的package包/类
private void addConstructor() {
	// 创建构造方法
	CodeEmitter e = emitter.begin_method(Opcodes.ACC_PUBLIC, TypeUtils.parseConstructor(""), null);
	e.load_this();
	e.super_invoke_constructor();
	// 返回值
	e.return_value();
	// 结束方法
	e.end_method();
}
 
开发者ID:yaoakeji,项目名称:hibatis,代码行数:11,代码来源:LazyEntityGenerator.java


示例7: visitMethod

import org.springframework.asm.Opcodes; //导入依赖的package包/类
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
	// Skip bridge methods - we're only interested in original annotation-defining user methods.
	// On JDK 8, we'd otherwise run into double detection of the same annotated method...
	if ((access & Opcodes.ACC_BRIDGE) != 0) {
		return super.visitMethod(access, name, desc, signature, exceptions);
	}
	return new MethodMetadataReadingVisitor(name, access, getClassName(),
			Type.getReturnType(desc).getClassName(), this.classLoader, this.methodMetadataSet);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:AnnotationMetadataReadingVisitor.java


示例8: visit

import org.springframework.asm.Opcodes; //导入依赖的package包/类
@Override
public void visit(int version, int access, String name, String signature, String supername, String[] interfaces) {
	this.className = ClassUtils.convertResourcePathToClassName(name);
	this.isInterface = ((access & Opcodes.ACC_INTERFACE) != 0);
	this.isAnnotation = ((access & Opcodes.ACC_ANNOTATION) != 0);
	this.isAbstract = ((access & Opcodes.ACC_ABSTRACT) != 0);
	this.isFinal = ((access & Opcodes.ACC_FINAL) != 0);
	if (supername != null && !this.isInterface) {
		this.superClassName = ClassUtils.convertResourcePathToClassName(supername);
	}
	this.interfaces = new String[interfaces.length];
	for (int i = 0; i < interfaces.length; i++) {
		this.interfaces[i] = ClassUtils.convertResourcePathToClassName(interfaces[i]);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:ClassMetadataReadingVisitor.java


示例9: visitInnerClass

import org.springframework.asm.Opcodes; //导入依赖的package包/类
@Override
public void visitInnerClass(String name, String outerName, String innerName, int access) {
	if (outerName != null) {
		String fqName = ClassUtils.convertResourcePathToClassName(name);
		String fqOuterName = ClassUtils.convertResourcePathToClassName(outerName);
		if (this.className.equals(fqName)) {
			this.enclosingClassName = fqOuterName;
			this.independentInnerClass = ((access & Opcodes.ACC_STATIC) != 0);
		}
		else if (this.className.equals(fqOuterName)) {
			this.memberClassNames.add(fqName);
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:15,代码来源:ClassMetadataReadingVisitor.java


示例10: visitMethod

import org.springframework.asm.Opcodes; //导入依赖的package包/类
@Override
public MethodVisitor visitMethod(int access, String name, String desc,
		String signature, String[] exceptions) {
	if (isAccess(access, Opcodes.ACC_PUBLIC, Opcodes.ACC_STATIC)
			&& MAIN_METHOD_NAME.equals(name)
			&& MAIN_METHOD_TYPE.getDescriptor().equals(desc)) {
		this.found = true;
	}
	return null;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:MainClassFinder.java


示例11: visitMethod

import org.springframework.asm.Opcodes; //导入依赖的package包/类
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
	// Skip bridge methods - we're only interested in original annotation-defining user methods.
	// On JDK 8, we'd otherwise run into double detection of the same annotated method...
	if ((access & Opcodes.ACC_BRIDGE) != 0) {
		return super.visitMethod(access, name, desc, signature, exceptions);
	}
	return new MethodMetadataReadingVisitor(name, access, getClassName(), this.classLoader, this.methodMetadataSet);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:10,代码来源:AnnotationMetadataReadingVisitor.java


示例12: visit

import org.springframework.asm.Opcodes; //导入依赖的package包/类
public void visit(int version, int access, String name, String signature, String supername, String[] interfaces) {
	this.className = ClassUtils.convertResourcePathToClassName(name);
	this.isInterface = ((access & Opcodes.ACC_INTERFACE) != 0);
	this.isAbstract = ((access & Opcodes.ACC_ABSTRACT) != 0);
	this.isFinal = ((access & Opcodes.ACC_FINAL) != 0);
	if (supername != null) {
		this.superClassName = ClassUtils.convertResourcePathToClassName(supername);
	}
	this.interfaces = new String[interfaces.length];
	for (int i = 0; i < interfaces.length; i++) {
		this.interfaces[i] = ClassUtils.convertResourcePathToClassName(interfaces[i]);
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:14,代码来源:ClassMetadataReadingVisitor.java


示例13: visitInnerClass

import org.springframework.asm.Opcodes; //导入依赖的package包/类
public void visitInnerClass(String name, String outerName, String innerName, int access) {
	if (outerName != null) {
		String fqName = ClassUtils.convertResourcePathToClassName(name);
		String fqOuterName = ClassUtils.convertResourcePathToClassName(outerName);
		if (this.className.equals(fqName)) {
			this.enclosingClassName = fqOuterName;
			this.independentInnerClass = ((access & Opcodes.ACC_STATIC) != 0);
		}
		else if (this.className.equals(fqOuterName)) {
			this.memberClassNames.add(fqName);
		}
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:14,代码来源:ClassMetadataReadingVisitor.java


示例14: putField

import org.springframework.asm.Opcodes; //导入依赖的package包/类
private void putField(CodeEmitter e, String name, Object value) {
	String desc = Type.getDescriptor(value.getClass());
	e.visitVarInsn(Opcodes.ALOAD, 0);
	e.visitLdcInsn(value);
	e.visitFieldInsn(Opcodes.PUTFIELD, proxyClassPath, name, desc);
}
 
开发者ID:yaoakeji,项目名称:hibatis,代码行数:7,代码来源:ProxyClassGenerator.java


示例15: putEnumField

import org.springframework.asm.Opcodes; //导入依赖的package包/类
private void putEnumField(CodeEmitter e, String name, Enum<?> value) {
	Type type = Type.getType(value.getClass());
	e.visitVarInsn(Opcodes.ALOAD, 0);
	e.getstatic(type, value.name(), type);
	e.visitFieldInsn(Opcodes.PUTFIELD, proxyClassPath, name, type.getDescriptor());
}
 
开发者ID:yaoakeji,项目名称:hibatis,代码行数:7,代码来源:ProxyClassGenerator.java


示例16: putClassField

import org.springframework.asm.Opcodes; //导入依赖的package包/类
private void putClassField(CodeEmitter e, String name, Class<?> type) {
	String desc = Type.getDescriptor(type.getClass());
	e.visitVarInsn(Opcodes.ALOAD, 0);
	e.visitLdcInsn(Type.getType(type));
	e.visitFieldInsn(Opcodes.PUTFIELD, proxyClassPath, name, desc);
}
 
开发者ID:yaoakeji,项目名称:hibatis,代码行数:7,代码来源:ProxyClassGenerator.java


示例17: isSyntheticOrBridged

import org.springframework.asm.Opcodes; //导入依赖的package包/类
private static boolean isSyntheticOrBridged(int access) {
	return (((access & Opcodes.ACC_SYNTHETIC) | (access & Opcodes.ACC_BRIDGE)) > 0);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:4,代码来源:LocalVariableTableParameterNameDiscoverer.java


示例18: isStatic

import org.springframework.asm.Opcodes; //导入依赖的package包/类
private static boolean isStatic(int access) {
	return ((access & Opcodes.ACC_STATIC) > 0);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:4,代码来源:LocalVariableTableParameterNameDiscoverer.java


示例19: isAbstract

import org.springframework.asm.Opcodes; //导入依赖的package包/类
@Override
public boolean isAbstract() {
	return ((this.access & Opcodes.ACC_ABSTRACT) != 0);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:5,代码来源:MethodMetadataReadingVisitor.java


示例20: isStatic

import org.springframework.asm.Opcodes; //导入依赖的package包/类
@Override
public boolean isStatic() {
	return ((this.access & Opcodes.ACC_STATIC) != 0);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:5,代码来源:MethodMetadataReadingVisitor.java



注:本文中的org.springframework.asm.Opcodes类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LocalHistory类代码示例发布时间:2022-05-23
下一篇:
Java PendingRangeCalculatorService类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap