public override FieldVisitor VisitField(AccessFlags access, string name, string desc, string signature, object value) { // Get the class field information for step 4 of the algorithm. Also determine if the class // already has a SVUID. if (computeSvuid) { if ("serialVersionUID".Equals(name)) { // Since the class already has SVUID, we won't be computing it. computeSvuid = false; hasSvuid = true; } // Collect the non private fields. Only the ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, // ACC_STATIC, ACC_FINAL, ACC_VOLATILE, and ACC_TRANSIENT flags are used when computing // serialVersionUID values. if (access.HasNotFlagFast(AccessFlags.Private) || (access & (AccessFlags.Static | AccessFlags.Transient)) == 0) { var mods = access & (AccessFlags.Public | AccessFlags.Private | AccessFlags.Protected | AccessFlags.Static | AccessFlags .Final | AccessFlags.Volatile | AccessFlags.Transient); svuidFields.Add(new Item(name, mods, desc)); } } return(base.VisitField(access, name, desc, signature, value)); }
public override MethodVisitor VisitMethod(AccessFlags access, string name, string descriptor , string signature, string[] exceptions) { // Get constructor and method information (step 5 and 7). Also determine if there is a class // initializer (step 6). if (computeSvuid) { if (Clinit.Equals(name)) { hasStaticInitializer = true; } // Collect the non private constructors and methods. Only the ACC_PUBLIC, ACC_PRIVATE, // ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT and // ACC_STRICT flags are used. var mods = access & (AccessFlags.Public | AccessFlags.Private | AccessFlags.Protected | AccessFlags.Static | AccessFlags .Final | AccessFlags.Synchronized | AccessFlags.Native | AccessFlags .Abstract | AccessFlags.Strict); if (access.HasNotFlagFast(AccessFlags.Private)) { if ("<init>".Equals(name)) { svuidConstructors.Add(new Item(name, mods, descriptor)); } else if (!Clinit.Equals(name)) { svuidMethods.Add(new Item(name, mods, descriptor)); } } } return(base.VisitMethod(access, name, descriptor, signature, exceptions)); }
/// <summary> /// Constructs a new /// <see cref="MethodNode" /> /// . /// </summary> /// <param name="api"> /// the ASM API version implemented by this visitor. Must be one of /// <see cref="Org.Objectweb.Asm.Opcodes.Asm4" /> /// , /// <see cref="Org.Objectweb.Asm.Opcodes.Asm5" /> /// , /// <see cref="Org.Objectweb.Asm.Opcodes.Asm6" /> /// or /// <see cref="Org.Objectweb.Asm.Opcodes.Asm7" /> /// . /// </param> /// <param name="access"> /// the method's access flags (see /// <see cref="Org.Objectweb.Asm.Opcodes" /> /// ). This parameter also indicates if /// the method is synthetic and/or deprecated. /// </param> /// <param name="name">the method's name.</param> /// <param name="descriptor"> /// the method's descriptor (see /// <see cref="Org.Objectweb.Asm.Type" /> /// ). /// </param> /// <param name="signature"> /// the method's signature. May be /// <literal>null</literal> /// . /// </param> /// <param name="exceptions"> /// the internal names of the method's exception classes (see /// <see cref="Org.Objectweb.Asm.Type.GetInternalName()" /> /// ). May be /// <literal>null</literal> /// . /// </param> public MethodNode(VisitorAsmApiVersion api, AccessFlags access, string name, string descriptor, string signature , string[] exceptions) : base(api) { this.access = access; this.name = name; desc = descriptor; this.signature = signature; this.exceptions = Util.AsArrayList(exceptions); if (access.HasNotFlagFast(AccessFlags.Abstract)) { localVariables = new List <LocalVariableNode>(5); } tryCatchBlocks = new List <TryCatchBlockNode>(); instructions = new InsnList(); }
// ----------------------------------------------------------------------------------------------- // Overridden methods // ----------------------------------------------------------------------------------------------- public override void Visit(int version, AccessFlags access, string name, string signature , string superName, string[] interfaces) { // Get the class name, access flags, and interfaces information (step 1, 2 and 3) for SVUID // computation. computeSvuid = access.HasNotFlagFast(AccessFlags.Enum); if (computeSvuid) { this.name = name; this.access = access; this.interfaces = (string[])interfaces.Clone(); svuidFields = new List <Item>(); svuidConstructors = new List <Item>(); svuidMethods = new List <Item>(); } base.Visit(version, access, name, signature, superName, interfaces); }
/// <summary> /// Constructs a new /// <see cref="AnalyzerAdapter" /> /// . /// </summary> /// <param name="api"> /// the ASM API version implemented by this visitor. Must be one of /// <see cref="Opcodes.Asm4" /> /// , /// <see cref="Opcodes.Asm5" /> /// , /// <see cref="Opcodes.Asm6" /> /// or /// <see cref="Opcodes.Asm7" /> /// . /// </param> /// <param name="owner">the owner's class name.</param> /// <param name="access"> /// the method's access flags (see /// <see cref="Opcodes" /> /// ). /// </param> /// <param name="name">the method's name.</param> /// <param name="descriptor"> /// the method's descriptor (see /// <see cref="Org.Objectweb.Asm.Type" /> /// ). /// </param> /// <param name="methodVisitor"> /// the method visitor to which this adapter delegates calls. May be /// <literal>null</literal> /// . /// </param> protected internal AnalyzerAdapter(VisitorAsmApiVersion api, string owner, AccessFlags access, string name , string descriptor, MethodVisitor methodVisitor) : base(api, methodVisitor) { this.owner = owner; locals = new List <object>(); stack = new List <object>(); uninitializedTypes = new Dictionary <object, object>(); if (access.HasNotFlagFast(AccessFlags.Static)) { if ("<init>".Equals(name)) { locals.Add(OpcodesConstants.Uninitialized_This); } else { locals.Add(owner); } } foreach (var argumentType in Type.GetArgumentTypes(descriptor)) { switch (argumentType.GetSort()) { case Type.Boolean: case Type.Char: case Type.Byte: case Type.Short: case Type.Int: { locals.Add(OpcodesConstants.Integer); break; } case Type.Float: { locals.Add(OpcodesConstants.Float); break; } case Type.Long: { locals.Add(OpcodesConstants.Long); locals.Add(OpcodesConstants.Top); break; } case Type.Double: { locals.Add(OpcodesConstants.Double); locals.Add(OpcodesConstants.Top); break; } case Type.Array: { locals.Add(argumentType.GetDescriptor()); break; } case Type.Object: { locals.Add(argumentType.GetInternalName()); break; } default: { throw new AssertionError(); } } } maxLocals = locals.Count; }