org.objectweb.asm.commons.LocalVariablesSorter Java Examples
The following examples show how to use
org.objectweb.asm.commons.LocalVariablesSorter.
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: MonitorClassVisitor.java From bistoury with GNU General Public License v3.0 | 6 votes |
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { final MethodVisitor methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); if (name.equals(methodName) && desc.equals(methodDesc)) { logger.debug("visit method, name: {}, desc: {}", name, desc); MonitorMethodVisitor monitorMV = new MonitorMethodVisitor(methodVisitor, access, name, desc, className); AnalyzerAdapter analyzerAdapter = new AnalyzerAdapter(className, access, name, desc, monitorMV); monitorMV.setAnalyzerAdapter(analyzerAdapter); LocalVariablesSorter localVariablesSorter = new LocalVariablesSorter(access, desc, analyzerAdapter); monitorMV.setLocalVariablesSorter(localVariablesSorter); return localVariablesSorter; } else { return methodVisitor; } }
Example #2
Source File: ASMTest.java From bistoury with GNU General Public License v3.0 | 6 votes |
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { System.out.println(name); final MethodVisitor methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); /*if (!"setCount".equals(name)) { return methodVisitor; }*/ MonitorAdviceAdapter monitorMV = new MonitorAdviceAdapter(ASM7, methodVisitor, access, name, desc, className, exceptions); AnalyzerAdapter analyzerAdapter = new AnalyzerAdapter(className, access, name, desc, monitorMV); monitorMV.setAnalyzerAdapter(analyzerAdapter); LocalVariablesSorter localVariablesSorter = new LocalVariablesSorter(access, desc, analyzerAdapter); monitorMV.setLocalVariablesSorter(localVariablesSorter); //MonitorAdviceAdapter monitorMV = new MonitorAdviceAdapter(ASM7, new LocalVariablesSorter(access, desc, methodVisitor), access, name, desc, className, exceptions); return localVariablesSorter; }
Example #3
Source File: AllocationClassAdapter.java From allocation-instrumenter with Apache License 2.0 | 6 votes |
/** * For each method in the class being instrumented, <code>visitMethod</code> is called and the * returned MethodVisitor is used to visit the method. Note that a new MethodVisitor is * constructed for each method. */ @Override public MethodVisitor visitMethod( int access, String base, String desc, String signature, String[] exceptions) { MethodVisitor mv = cv.visitMethod(access, base, desc, signature, exceptions); if (mv != null) { // We need to compute stackmaps (see // AllocationInstrumenter#instrument). This can't really be // done for old bytecode that contains JSR and RET instructions. // So, we remove JSRs and RETs. JSRInlinerAdapter jsria = new JSRInlinerAdapter(mv, access, base, desc, signature, exceptions); AllocationMethodAdapter aimv = new AllocationMethodAdapter(jsria, recorderClass, recorderMethod); LocalVariablesSorter lvs = new LocalVariablesSorter(access, desc, aimv); aimv.lvs = lvs; mv = lvs; } return mv; }
Example #4
Source File: ConstructorInstrumenter.java From allocation-instrumenter with Apache License 2.0 | 5 votes |
/** * For each method in the class being instrumented, <code>visitMethod</code> is called and the * returned MethodVisitor is used to visit the method. Note that a new MethodVisitor is * constructed for each method. */ @Override public MethodVisitor visitMethod( int access, String name, String desc, String signature, String[] exceptions) { MethodVisitor mv = cv.visitMethod(access, name, desc, signature, exceptions); if ((mv != null) && "<init>".equals(name)) { ConstructorMethodAdapter aimv = new ConstructorMethodAdapter(mv, cl); LocalVariablesSorter lvs = new LocalVariablesSorter(access, desc, aimv); aimv.lvs = lvs; mv = lvs; } return mv; }
Example #5
Source File: MonitorMethodVisitor.java From bistoury with GNU General Public License v3.0 | 4 votes |
public void setLocalVariablesSorter(LocalVariablesSorter localVariablesSorter) { this.localVariablesSorter = localVariablesSorter; }
Example #6
Source File: MonitorAdviceAdapter.java From bistoury with GNU General Public License v3.0 | 4 votes |
public void setLocalVariablesSorter(LocalVariablesSorter localVariablesSorter) { this.localVariablesSorter = localVariablesSorter; }
Example #7
Source File: AbstractDynamicTypeBuilderForInliningTest.java From byte-buddy with Apache License 2.0 | 4 votes |
@Test @SuppressWarnings("unchecked") public void testReaderHint() throws Exception { AsmVisitorWrapper asmVisitorWrapper = mock(AsmVisitorWrapper.class); when(asmVisitorWrapper.wrap(any(TypeDescription.class), any(ClassVisitor.class), any(Implementation.Context.class), any(TypePool.class), any(FieldList.class), any(MethodList.class), anyInt(), anyInt())).then(new Answer<ClassVisitor>() { public ClassVisitor answer(InvocationOnMock invocationOnMock) throws Throwable { return new ClassVisitor(OpenedClassReader.ASM_API, (ClassVisitor) invocationOnMock.getArguments()[1]) { @Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { return new LocalVariablesSorter(access, desc, super.visitMethod(access, name, desc, signature, exceptions)); } }; } }); when(asmVisitorWrapper.mergeWriter(0)).thenReturn(ClassWriter.COMPUTE_MAXS); when(asmVisitorWrapper.mergeReader(0)).thenReturn(ClassReader.EXPAND_FRAMES); Class<?> type = create(StackMapFrames.class) .visit(asmVisitorWrapper) .make() .load(ClassLoadingStrategy.BOOTSTRAP_LOADER, ClassLoadingStrategy.Default.WRAPPER) .getLoaded(); assertThat(type.getDeclaredMethod(FOO).invoke(type.getDeclaredConstructor().newInstance()), is((Object) BAR)); verify(asmVisitorWrapper).mergeWriter(0); verify(asmVisitorWrapper).mergeReader(0); verify(asmVisitorWrapper).wrap(any(TypeDescription.class), any(ClassVisitor.class), any(Implementation.Context.class), any(TypePool.class), any(FieldList.class), any(MethodList.class), anyInt(), anyInt()); verifyNoMoreInteractions(asmVisitorWrapper); }
Example #8
Source File: LocalVariablesSorterVisitor.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 4 votes |
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { MethodVisitor mv = cv.visitMethod(access, name, desc, signature, exceptions); return methods == null || methods.contains(new ObfMapping(owner, name, desc)) ? new LocalVariablesSorter(access, desc, mv) : mv; }