net.bytebuddy.jar.asm.ClassVisitor Java Examples

The following examples show how to use net.bytebuddy.jar.asm.ClassVisitor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BridgeClassVisitorWrapper.java    From kanela with Apache License 2.0 5 votes vote down vote up
@Override
public ClassVisitor wrap(TypeDescription instrumentedType,
                         ClassVisitor classVisitor,
                         Implementation.Context implementationContext,
                         TypePool typePool,
                         FieldList<FieldDescription.InDefinedShape> fields,
                         MethodList<?> methods,
                         int writerFlags,
                         int readerFlags) {

    return  BridgeClassVisitor.from(bridge, instrumentedType.getInternalName(), classVisitor);
}
 
Example #2
Source File: ClassFileVersionValidatorWrapper.java    From kanela with Apache License 2.0 5 votes vote down vote up
@Override
public ClassVisitor wrap(TypeDescription typeDescription,
                         ClassVisitor classVisitor,
                         Implementation.Context context,
                         TypePool typePool,
                         FieldList<FieldDescription.InDefinedShape> fieldList, MethodList<?> methodList,
                         int writerFlags,
                         int readerFlags) {

    return ClassFileVersionValidatorClassVisitor.from(classVisitor);
}
 
Example #3
Source File: MixinClassVisitorWrapper.java    From kanela with Apache License 2.0 5 votes vote down vote up
@Override
public ClassVisitor wrap(TypeDescription instrumentedType,
                         ClassVisitor classVisitor,
                         Implementation.Context implementationContext,
                         TypePool typePool,
                         FieldList<FieldDescription.InDefinedShape> fields,
                         MethodList<?> methods,
                         int writerFlags,
                         int readerFlags) {

    return MixinClassVisitor.from(mixin, instrumentedType.getInternalName(), classVisitor);
}
 
Example #4
Source File: BridgeClassVisitor.java    From kanela with Apache License 2.0 4 votes vote down vote up
public static BridgeClassVisitor from(BridgeDescription bridge, String className, ClassVisitor classVisitor) {
    return new BridgeClassVisitor(bridge, className, classVisitor);
}
 
Example #5
Source File: BridgeClassVisitor.java    From kanela with Apache License 2.0 4 votes vote down vote up
private BridgeClassVisitor(BridgeDescription bridge, String className, ClassVisitor classVisitor) {
    super(OpenedClassReader.ASM_API, classVisitor);
    this.bridge = bridge;
    this.type = Type.getObjectType(className);
}
 
Example #6
Source File: ClassFileVersionValidatorClassVisitor.java    From kanela with Apache License 2.0 4 votes vote down vote up
public static ClassFileVersionValidatorClassVisitor from(ClassVisitor classVisitor) {
    return new ClassFileVersionValidatorClassVisitor(classVisitor);
}
 
Example #7
Source File: ClassFileVersionValidatorClassVisitor.java    From kanela with Apache License 2.0 4 votes vote down vote up
private ClassFileVersionValidatorClassVisitor(ClassVisitor classVisitor) {
    super(OpenedClassReader.ASM_API, classVisitor);
}
 
Example #8
Source File: MixinClassVisitor.java    From kanela with Apache License 2.0 4 votes vote down vote up
public static MixinClassVisitor from(MixinDescription mixin, String className, ClassVisitor classVisitor) {
    return new MixinClassVisitor(mixin, className, classVisitor);
}
 
Example #9
Source File: MixinClassVisitor.java    From kanela with Apache License 2.0 4 votes vote down vote up
private MixinClassVisitor(MixinDescription mixin, String className, ClassVisitor classVisitor) {
    super(OpenedClassReader.ASM_API, classVisitor);
    this.mixin = mixin;
    this.type = Type.getObjectType(className);
}
 
Example #10
Source File: ReactorDebugAgent.java    From reactor-core with Apache License 2.0 4 votes vote down vote up
private static void instrument(Instrumentation instrumentation) {
	ClassFileTransformer transformer = new ClassFileTransformer() {
		@Override
		public byte[] transform(
				ClassLoader loader,
				String className,
				Class<?> clazz,
				ProtectionDomain protectionDomain,
				byte[] bytes
		) {
			if (loader == null) {
				return null;
			}

			if (
					className == null ||
							className.startsWith("java/") ||
							className.startsWith("jdk/") ||
							className.startsWith("sun/") ||
							className.startsWith("com/sun/") ||
							className.startsWith("reactor/core/")
			) {
				return null;
			}

			if (
					clazz != null && (
							clazz.isPrimitive() ||
									clazz.isArray() ||
									clazz.isAnnotation() ||
									clazz.isSynthetic()
					)
			) {
				return null;
			}

			ClassReader cr = new ClassReader(bytes);
			ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS);

			AtomicBoolean changed = new AtomicBoolean();
			ClassVisitor classVisitor = new ReactorDebugClassVisitor(cw, changed);

			try {
				cr.accept(classVisitor, 0);
			}
			catch (Throwable e) {
				e.printStackTrace();
				throw e;
			}

			if (!changed.get()) {
				return null;
			}

			return cw.toByteArray();
		}
	};

	instrumentation.addTransformer(transformer, true);
}
 
Example #11
Source File: ReactorDebugClassVisitor.java    From reactor-core with Apache License 2.0 4 votes vote down vote up
ReactorDebugClassVisitor(ClassVisitor classVisitor, AtomicBoolean changed) {
	super(Opcodes.ASM7, classVisitor);
	this.changed = changed;
}