Пример #1
0
        public Error GetAllClasses(out ReferenceTypeData[] classes)
        {
            byte[] packet = new byte[HeaderSize];
            int id = GetMessageId();
            SerializeHeader(packet, id, VirtualMachineCommand.AllClassesWithGeneric);

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

            int offset = HeaderSize;
            int classCount = ReadInt32(response, ref offset);
            classes = new ReferenceTypeData[classCount];
            for (int i = 0; i < classCount; i++)
            {
                TypeTag typeTag = (TypeTag)ReadByte(response, ref offset);
                ReferenceTypeId typeId = ReadReferenceTypeId(response, ref offset);
                string signature = ReadString(response, ref offset);
                string genericSignature = ReadString(response, ref offset);
                ClassStatus status = (ClassStatus)ReadInt32(response, ref offset);
                classes[i] = new ReferenceTypeData(new TaggedReferenceTypeId(typeTag, typeId), signature, genericSignature, status);
            }

            return Error.None;
        }
Пример #2
0
        public Error GetClassesBySignature(out ReferenceTypeData[] classes, string signature)
        {
            byte[] encoded = Encoding.UTF8.GetBytes(signature);
            byte[] packet = new byte[HeaderSize + sizeof(int) + encoded.Length];

            int id = GetMessageId();
            SerializeHeader(packet, id, VirtualMachineCommand.ClassesBySignature);
            WriteInt32(packet, HeaderSize, encoded.Length);
            Buffer.BlockCopy(encoded, 0, packet, HeaderSize + sizeof(int), encoded.Length);

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

            int offset = HeaderSize;
            int count = ReadInt32(response, ref offset);
            classes = new ReferenceTypeData[count];
            for (int i = 0; i < count; i++)
            {
                TypeTag typeTag = (TypeTag)ReadByte(response, ref offset);
                ReferenceTypeId typeId = ReadReferenceTypeId(response, ref offset);
                ClassStatus status = (ClassStatus)ReadInt32(response, ref offset);

                string actualSignature;
                string genericSignature;
                errorCode = GetSignature(out actualSignature, out genericSignature, typeId);
                if (errorCode != Error.None)
                {
                    classes = null;
                    return errorCode;
                }

                classes[i] = new ReferenceTypeData(new TaggedReferenceTypeId(typeTag, typeId), actualSignature, genericSignature, status);
            }

            return errorCode;
        }
Пример #3
0
        public Error GetClassesBySignature(string signature, out ReferenceTypeData[] classes)
        {
            classes = null;

            ReferenceTypeData[] tempClasses;
            Error result = GetAllClasses(out tempClasses);
            if (result != Error.None)
                return result;

            classes = tempClasses.Where(i => i.Signature == signature).ToArray();
            return Error.None;
        }
Пример #4
0
        public Error GetAllClasses(out ReferenceTypeData[] classes)
        {
            classes = null;

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

            TaggedReferenceTypeId[] taggedClasses;
            error = environment.GetLoadedClasses(nativeEnvironment, out taggedClasses);
            if (error != jvmtiError.None)
                return GetStandardError(error);

            List<ReferenceTypeData> dataList = new List<ReferenceTypeData>();
            for (int i = 0; i < taggedClasses.Length; i++)
            {
                ClassStatus status;
                Error error2 = GetReferenceTypeStatus(taggedClasses[i].TypeId, out status);
                if (error2 != Error.None)
                    return error2;

                string signature;
                string genericSignature;
                error2 = GetSignature(taggedClasses[i].TypeId, out signature, out genericSignature);
                if (error2 != Error.None)
                    return error2;

                ReferenceTypeData data = new ReferenceTypeData(taggedClasses[i], signature, genericSignature, status);
                dataList.Add(data);
            }

            classes = dataList.ToArray();
            return Error.None;
        }
Пример #5
0
        internal ReferenceType GetMirrorOf(ReferenceTypeData data)
        {
            ReferenceType referenceType = GetMirrorOf(data.ReferenceTypeTag, data.TypeId);
            // todo: fill in some extra info fields for efficiency

            return referenceType;
        }