Exemple #1
0
        /// <summary>
        /// Reads attributes from a stream.
        /// </summary>
        /// <param name="stream">The stream to read from.</param>
        /// <param name="count">The amount of attributes to read.</param>
        /// <param name="constantPool">The constant pool.</param>
        /// <returns>An array of attributes read from the stream.</returns>
        public static IJavaAttribute[] ReadFromStream(Stream stream, int count, JavaConstantPool constantPool)
        {
            Guard.NotNull(ref stream, nameof(stream));
            Guard.NotNull(ref constantPool, nameof(constantPool));

            IJavaAttribute[] result = new IJavaAttribute[count];

            for (int i = 0; i < count; i++)
            {
                result[i] = ReadAttribute(stream, constantPool);
            }

            return(result);
        }
Exemple #2
0
        public static void ConstructorTest()
        {
            JavaMethodAccessFlags flags = JavaMethodAccessFlags.Native | JavaMethodAccessFlags.Private;
            ushort us1 = 1;
            ushort us2 = 2;
            ushort us3 = 3;

            IJavaAttribute[] attributes = new IJavaAttribute[2];
            JavaMethod       jm         = new JavaMethod(flags, us1, us2, us3, attributes);

            AssertThat(jm.AccessFlags).IsEqualTo(flags);
            AssertThat(jm.NameIndex).IsEqualTo(us1);
            AssertThat(jm.DescriptorIndex).IsEqualTo(us2);
            AssertThat(jm.AttributesCount).IsEqualTo(us3);
            AssertThat(jm.Attributes).ContainsExactly(attributes);
        }