List of usage examples for org.objectweb.asm Opcodes ASM4
int ASM4
To view the source code for org.objectweb.asm Opcodes ASM4.
Click Source Link
From source file:org.springframework.cglib.transform.FieldVisitorTee.java
License:Apache License
public FieldVisitorTee(FieldVisitor fv1, FieldVisitor fv2) { super(Opcodes.ASM4); this.fv1 = fv1; this.fv2 = fv2; }
From source file:org.springframework.cglib.transform.MethodVisitorTee.java
License:Apache License
public MethodVisitorTee(MethodVisitor mv1, MethodVisitor mv2) { super(Opcodes.ASM4); this.mv1 = mv1; this.mv2 = mv2; }
From source file:org.summer.ana.CyclomaticComplexityPrinter.java
License:Open Source License
public CyclomaticComplexityPrinter() { super(Opcodes.ASM4); }
From source file:sonia.legman.maven.GuavaMigrationMojo.java
License:Apache License
/** * Method description//w w w . j a v a 2 s .c o m * * * @param file * * @throws IOException */ void processClassFile(File file) throws IOException { InputStream stream = null; try { stream = new FileInputStream(file); ClassReader reader = new ClassReader(stream); Builder builder = MethodAnnotationClassVisitor.builder(); builder.api(Opcodes.ASM4); builder.annotateClasses(Subscribe.class, AllowConcurrentEvents.class); builder.methodAnnotationHandler(new MethodAnnotationHandler() { @Override public void handleMethodAnnotation(String className, String methodName, String annotationName) { //J- String message = template.replace("{class}", className).replace("{method}", methodName) .replace("{annotation}", annotationName) .replace("{subscribe}", com.github.legman.Subscribe.class.getName()); //J+ getLog().warn(message); } }); reader.accept(builder.build(), 0); } finally { Closeables.close(stream, true); } }
From source file:st.redline.compiler.TracingClassVisitor.java
License:Open Source License
public TracingClassVisitor(ClassVisitor delegate, PrintWriter printWriter) { super(Opcodes.ASM4); this.delegate = delegate; this.out = printWriter; }
From source file:tk.wurst_client.hooks.injector.JarHookInjector.java
License:Open Source License
public void injectHooks(File inputFile, File outputFile, JarData settings) throws IOException { JarFile inputJar = new JarFile(inputFile); outputFile.getParentFile().mkdirs(); JarInputStream input = new JarInputStream(new FileInputStream(inputFile)); JarOutputStream output = new JarOutputStream(new FileOutputStream(outputFile), inputJar.getManifest()); inputJar.close();/*w w w . j a v a 2s .co m*/ for (JarEntry entry; (entry = input.getNextJarEntry()) != null;) if (entry.isDirectory()) { output.putNextEntry(entry); output.closeEntry(); } else if (!entry.getName().endsWith(".class")) { if (entry.getName().equals("META-INF/MANIFEST.MF")) continue; output.putNextEntry(entry); byte[] buffer = new byte[8192]; for (int length; (length = input.read(buffer)) != -1;) output.write(buffer, 0, length); output.closeEntry(); } else { output.putNextEntry(new JarEntry(entry.getName())); ClassReader reader = new ClassReader(input); ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); ClassData classData = settings.getClass(entry.getName().substring(0, entry.getName().length() - 6)); ClassHookInjector hookInjector = new ClassHookInjector(Opcodes.ASM4, writer, classData); reader.accept(hookInjector, 0); output.write(writer.toByteArray()); output.closeEntry(); } input.close(); output.putNextEntry(new JarEntry("tk/")); output.closeEntry(); output.putNextEntry(new JarEntry("tk/wurst_client/")); output.closeEntry(); output.putNextEntry(new JarEntry("tk/wurst_client/hooks/")); output.closeEntry(); output.putNextEntry(new JarEntry("tk/wurst_client/hooks/HookManager.class")); InputStream input2 = getClass().getClassLoader() .getResourceAsStream("tk/wurst_client/hooks/HookManager.class"); byte[] buffer = new byte[8192]; for (int length; (length = input2.read(buffer)) != -1;) output.write(buffer, 0, length); output.closeEntry(); input2.close(); output.putNextEntry(new JarEntry("tk/wurst_client/hooks/HookManager$Hook.class")); input2 = getClass().getClassLoader().getResourceAsStream("tk/wurst_client/hooks/HookManager$Hook.class"); buffer = new byte[8192]; for (int length; (length = input2.read(buffer)) != -1;) output.write(buffer, 0, length); output.closeEntry(); input2.close(); output.close(); }
From source file:tk.wurst_client.hooks.reader.JarDataReader.java
License:Open Source License
public JarData read(File file) throws IOException { DefaultMutableTreeNode root = new DefaultMutableTreeNode(file.getName()); JarData jarData = new JarData(); JarInputStream input = new JarInputStream(new FileInputStream(file)); for (JarEntry entry; (entry = input.getNextJarEntry()) != null;) if (entry.isDirectory()) root.add(new DefaultMutableTreeNode( entry.getName().substring(0, entry.getName().length() - 1).replace("/", "."), true)); else if (entry.getName().endsWith(".class")) { ClassReader reader = new ClassReader(input); ClassDataReader wReader = new ClassDataReader(Opcodes.ASM4, jarData); reader.accept(wReader, 0);/* ww w.jav a 2s.c om*/ if (entry.getName().contains("/")) getNode(root, entry.getName().substring(0, entry.getName().lastIndexOf("/")).replace("/", ".")) .add(new DefaultMutableTreeNode( entry.getName().substring(entry.getName().lastIndexOf("/") + 1), false)); else root.add(new DefaultMutableTreeNode(entry.getName(), false)); } else if (entry.getName().contains("/")) getNode(root, entry.getName().substring(0, entry.getName().lastIndexOf("/")).replace("/", ".")).add( new DefaultMutableTreeNode(entry.getName().substring(entry.getName().lastIndexOf("/") + 1), false)); else root.add(new DefaultMutableTreeNode(entry, false)); input.close(); getNode(root, "META-INF").add(new DefaultMutableTreeNode("MANIFEST.MF", false)); sortNode(root); tree.setModel(new DefaultTreeModel(root)); return jarData; }