Пример #1
0
        public Error GetMethods(ReferenceTypeId referenceType, out DeclaredMethodData[] methods)
        {
            methods = null;

            JniEnvironment nativeEnvironment;
            JvmtiEnvironment environment;
            jvmtiError error = GetEnvironment(out environment, out nativeEnvironment);
            if (error != jvmtiError.None)
                return GetStandardError(error);

            MethodId[] methodIds;
            error = environment.GetClassMethods(nativeEnvironment, referenceType, out methodIds);
            if (error != jvmtiError.None)
                return GetStandardError(error);

            List<DeclaredMethodData> methodsList = new List<DeclaredMethodData>();
            foreach (var methodId in methodIds)
            {
                string name;
                string signature;
                string genericSignature;
                error = environment.GetMethodName(methodId, out name, out signature, out genericSignature);
                if (error != jvmtiError.None)
                    return GetStandardError(error);

                JvmAccessModifiers modifiers;
                error = environment.GetMethodModifiers(methodId, out modifiers);

                methodsList.Add(new DeclaredMethodData(methodId, name, signature, genericSignature, (AccessModifiers)modifiers));
            }

            methods = methodsList.ToArray();
            return Error.None;
        }
Пример #2
0
        public Error GetMethods(out DeclaredMethodData[] methods, ReferenceTypeId referenceType)
        {
            byte[] packet = new byte[HeaderSize + ReferenceTypeIdSize];
            int id = GetMessageId();
            SerializeHeader(packet, id, ReferenceTypeCommand.MethodsWithGeneric);
            WriteReferenceTypeId(packet, HeaderSize, referenceType);

            byte[] response = SendPacket(id, packet);
            Error errorCode = ReadErrorCode(response);
            if (errorCode != Error.None)
            {
                methods = null;
                return errorCode;
            }

            int offset = HeaderSize;
            int methodCount = ReadInt32(response, ref offset);
            methods = new DeclaredMethodData[methodCount];
            for (int i = 0; i < methodCount; i++)
            {
                MethodId methodId = ReadMethodId(response, ref offset);
                string name = ReadString(response, ref offset);
                string signature = ReadString(response, ref offset);
                string genericSignature = ReadString(response, ref offset);
                AccessModifiers modifiers = (AccessModifiers)ReadInt32(response, ref offset);
                methods[i] = new DeclaredMethodData(methodId, name, signature, genericSignature, modifiers);
            }

            return Error.None;
        }
Пример #3
0
        internal Method GetMirrorOf(ReferenceType declaringType, DeclaredMethodData methodData)
        {
            lock (_methods)
            {
                List<Method> methods;
                if (!_methods.TryGetValue(declaringType.ReferenceTypeId, out methods))
                {
                    methods = new List<Method>();
                    _methods[declaringType.ReferenceTypeId] = methods;
                }

                Method method = methods.SingleOrDefault(i => i.MethodId == methodData.MethodId);
                if (method == null)
                {
                    method = new Method(this, declaringType, methodData.Name, methodData.Signature, methodData.GenericSignature, (AccessModifiers)methodData.Modifiers, methodData.MethodId);
                    methods.Add(method);
                }

                return method;
            }
        }