List of usage examples for org.objectweb.asm Opcodes ACC_SYNTHETIC
int ACC_SYNTHETIC
To view the source code for org.objectweb.asm Opcodes ACC_SYNTHETIC.
Click Source Link
From source file:com.masetta.spann.metadata.reader.asm3_2.ModifierImpl.java
License:Apache License
public boolean isSynthetic() { return (modifier & Opcodes.ACC_SYNTHETIC) != 0; }
From source file:com.mebigfatguy.deadmethods.ClassInfo.java
License:Apache License
public boolean isSynthetic() { return (classAccess & Opcodes.ACC_SYNTHETIC) != 0; }
From source file:com.mebigfatguy.deadmethods.MethodInfo.java
License:Apache License
public boolean isSynthetic() { return (methodAccess & Opcodes.ACC_SYNTHETIC) != 0; }
From source file:com.mebigfatguy.loc4j.LocClassVisitor.java
License:Apache License
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { if ((access & Opcodes.ACC_SYNTHETIC) != 0) { return null; }//from ww w. java 2 s .co m counts.addMethodCounts(1); return mv; }
From source file:com.sun.tdk.jcov.instrument.ClassMorph.java
License:Open Source License
/** * <p> Instrument loaded class data. </p> * * @param classfileBuffer Class data/*ww w .jav a 2s . c o m*/ * @param loader ClassLoader containing this class (used in agent) * @param flushPath * @return * @throws IOException */ public byte[] morph(byte[] classfileBuffer, ClassLoader loader, String flushPath) throws IOException { if (loader == null) { loader = ClassLoader.getSystemClassLoader(); } if (classfileBuffer[0] != -54 || classfileBuffer[1] != -2 || classfileBuffer[2] != -70 || classfileBuffer[3] != -66) { throw new IOException("Not a java classfile (0xCAFEBABE header not found)"); } OffsetLabelingClassReader cr = new OffsetLabelingClassReader(classfileBuffer); String fullname = cr.getClassName(); if (!isTransformable(fullname)) { return null; } boolean shouldFlush = (flushPath != null); if (isAlreadyTransformed(fullname)) { long cs = computeCheckSum(classfileBuffer); Long oldCs = instrumented.get(fullname); if (oldCs > 0) { if (cs == oldCs && flushPath != null) { // the same class - restore from flushed logger.log(Level.FINE, "{0} - instrumented copy used", fullname); return DebugUtils.readClass(fullname, flushPath); } else { logger.log(Level.WARNING, "application has different classes with the same name: {0}", fullname); } } } if (params.isClassesReload() && !shouldTransform(fullname) && isAlreadyTransformed(fullname) && params.isDynamicCollect()) { return instrumentedValues.get(fullname); } if (!shouldTransform(fullname)) { if (!params.isDynamicCollect() || // isStatic !params.isCallerFilterOn() && !params.isInstrumentFields()) { if (isAlreadyTransformed(fullname)) { logger.log(Level.INFO, "{0} - skipped (already instrumented)", fullname); } if (!params.isIncluded(fullname)) { logger.log(Level.INFO, "{0} - skipped (is not included or is excluded explicitly)", fullname); } //null tells to AbstractUniversalInstrumenter not to overwrite existing data return null; } // support of caller_include feature // even those classes which are out of scope require some minor // transformation ClassWriter cw = new OverriddenClassWriter(cr, ClassWriter.COMPUTE_MAXS, loader); ClassVisitor cv = shouldFlush ? new TraceClassVisitor(cw, DebugUtils.getPrintWriter(fullname, flushPath)) : cw; cv = new InvokeClassAdapter(cv, params); cr.accept(cv, 0); byte[] res = cw.toByteArray(); if (shouldFlush) { DebugUtils.flushInstrumentedClass(flushPath, fullname, res); } if (!params.isDynamicCollect() && !rtClassesInstrumented && isPreVMLoadClass(fullname)) { rtClassesInstrumented = true; logger.log(Level.WARNING, "It's possible that you are instrumenting classes which are loaded before VM is loaded. It's recomended to add saveatend at java/lang/Shutdown.runHooks method. Data could be lost otherwise."); } return res; } // Checksum should be counted before changing content long checksum = params.isDynamicCollect() ? -1 : computeCheckSum(classfileBuffer); // The stackmap should be calculated only when static instrumentation // is used and class version 50. In this case the classfiles should // be downgraded to v 49. int opt = ClassWriter.COMPUTE_MAXS; if (params.isStackMapShouldBeUpdated()) { if (params.isDynamicCollect() && classfileBuffer[7] == 50) { classfileBuffer[7] = 49; } } if (classfileBuffer[7] > 49) { opt = ClassWriter.COMPUTE_FRAMES; } ClassWriter cw = new OverriddenClassWriter(cr, opt, loader); DataClass k = new DataClass(root.rootId(), fullname, checksum, false); // ClassVisitor cv = shouldFlush ? new TraceClassVisitor // (cw, DebugUtils.getPrintWriter(fullname, Options.getFlushPath())) : // cw; ClassVisitor cv = cw; cv = new DeferringMethodClassAdapter(cv, k, params); cr.accept(cv, new Attribute[] { new CharacterRangeTableAttribute(root.rootId()) }, 0); if (k.hasModifier(Opcodes.ACC_SYNTHETIC) && !params.isInstrumentSynthetic()) { return null; } else { root.addClass(k); instrumented.put(fullname, checksum); instrumentedValues.put(fullname, cw.toByteArray()); byte[] res = cw.toByteArray(); if (shouldFlush) { DebugUtils.flushInstrumentedClass(flushPath, fullname, res); } if (!params.isDynamicCollect() && !rtClassesInstrumented && isPreVMLoadClass(fullname)) { rtClassesInstrumented = true; logger.log(Level.WARNING, "It's possible that you are instrumenting classes which are loaded before VM is loaded. It's recomended to add saveatend at java/lang/Shutdown.runHooks method. Data could be lost otherwise."); } return res; } }
From source file:com.thomas15v.packetlib.codegenerator.asm.ASMHelper.java
License:MIT License
/** * Generate a new method "boolean name()", which returns a constant value. * * @param clazz Class to add method to//w w w. j a va 2 s . c om * @param name Name of method * @param retval Return value of method */ public static void generateBooleanMethodConst(ClassNode clazz, String name, boolean retval) { MethodNode method = new MethodNode(Opcodes.ASM5, Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC, name, "()Z", null, null); InsnList code = method.instructions; code.add(ASMHelper.pushIntConstant(retval ? 1 : 0)); code.add(new InsnNode(Opcodes.IRETURN)); clazz.methods.add(method); }
From source file:com.thomas15v.packetlib.codegenerator.asm.ASMHelper.java
License:MIT License
/** * Generate a new method "int name()", which returns a constant value. * * @param clazz Class to add method to/*from w w w. j a v a 2 s . c om*/ * @param name Name of method * @param retval Return value of method */ public static void generateIntegerMethodConst(ClassNode clazz, String name, short retval) { MethodNode method = new MethodNode(Opcodes.ASM5, Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC, name, "()I", null, null); InsnList code = method.instructions; code.add(ASMHelper.pushIntConstant(retval)); code.add(new InsnNode(Opcodes.IRETURN)); clazz.methods.add(method); }
From source file:com.thomas15v.packetlib.codegenerator.asm.ASMHelper.java
License:MIT License
/** * Generate a forwarding method of the form * "T name() { return this.forward(); }". * * @param clazz Class to generate new method on * @param name Name of method to generate * @param forwardname Name of method to call * @param rettype Return type of method/*from w w w .ja v a 2 s . c o m*/ */ public static void generateSelfForwardingMethod(ClassNode clazz, String name, String forwardname, Type rettype) { MethodNode method = new MethodNode(Opcodes.ASM5, Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC, name, "()" + rettype.getDescriptor(), null, null); ASMHelper.populateSelfForwardingMethod(method, forwardname, rettype, Type.getObjectType(clazz.name)); clazz.methods.add(method); }
From source file:com.thomas15v.packetlib.codegenerator.asm.ASMHelper.java
License:MIT License
/** * Generate a forwarding method of the form * "static T name(S object) { return object.forward(); }". * * @param clazz Class to generate new method on * @param name Name of method to generate * @param forwardname Name of method to call * @param rettype Return type of method/*w ww . ja v a 2 s. com*/ * @param argtype Argument type */ public static void generateStaticForwardingMethod(ClassNode clazz, String name, String forwardname, Type rettype, Type argtype) { MethodNode method = new MethodNode(Opcodes.ASM5, Opcodes.ACC_STATIC | Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC, name, "()" + rettype.getDescriptor(), null, null); ASMHelper.populateSelfForwardingMethod(method, forwardname, rettype, argtype); clazz.methods.add(method); }
From source file:com.thomas15v.packetlib.codegenerator.asm.ASMHelper.java
License:MIT License
/** * Generate a forwarding method of the form * "T name() { return Class.forward(this); }". * * @param clazz Class to generate new method on * @param name Name of method to generate * @param forwardname Name of method to call * @param rettype Return type of method//from w w w .j av a2 s . co m * @param fowardtype Forward type */ public static void generateForwardingToStaticMethod(ClassNode clazz, String name, String forwardname, Type rettype, Type fowardtype) { MethodNode method = new MethodNode(Opcodes.ASM5, Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC, name, "()" + rettype.getDescriptor(), null, null); ASMHelper.populateForwardingToStaticMethod(method, forwardname, rettype, Type.getObjectType(clazz.name), fowardtype); clazz.methods.add(method); }