JavaDecompiler/JavaClass.cs
/// <summary>
/// Reads the class file by the given binary reader.
/// Remember: This must be an big endian reader!
/// </summary>
/// <param name="reader"></param>
Reads the class file by the given binary reader.
Remember: This must be an big endian reader!
Reads the class file by the given binary reader . Remember : This must be an big endian reader!
public void Read(BinaryReader reader)
        {
            var magic = reader.ReadUInt32();
            if (magic != MagicNumber)
            {
                throw new JavaClassMagicNumberException();
            }
            MinorVersion = reader.ReadUInt16();
            MajorVersion = reader.ReadUInt16();
            var constants = reader.ReadUInt16();
            ConstantPool = new JavaConstantInfo[constants];
            for (int i = 1; i < constants; i++)
            {
                var constant = JavaConstantInfo.CreateAndRead(reader);
                ConstantPool[i] = constant;
                if (constant.Type == ConstantInfoType.Double ||
                    constant.Type == ConstantInfoType.Long)
                {
                    i++;
                }
            }
            AccessFlag = (JavaAccessFlag)reader.ReadUInt16();
            ThisClass = reader.ReadUInt16();
            SuperClass = reader.ReadUInt16();
            var interfaces = reader.ReadUInt16();
            Interfaces = new ushort[interfaces];
            for (int i = 0; i < interfaces; i++)
            {
                Interfaces[i] = reader.ReadUInt16();
            }
            var fields = reader.ReadUInt16();
            Fields = new JavaFieldInfo[fields];
            for (int i = 0; i < fields; i++)
            {
                Fields[i] = JavaFieldInfo.CreateAndRead(reader, this);
            }
            var methods = reader.ReadUInt16();
            Methods = new JavaMethodInfo[methods];
            for (int i = 0; i < methods; i++)
            {
                Methods[i] = JavaMethodInfo.CreateAndRead(reader, this);
            }
            var attributes = reader.ReadUInt16();
            Attributes = new JavaAttributeInfo[attributes];
            for (int i = 0; i < attributes; i++)
            {
                Attributes[i] = JavaAttributeInfo.CreateAndRead(reader, this);
            }
        }
public void Read ( BinaryReader reader ) { var magic = reader . ReadUInt32 ( ) ; if ( magic != MagicNumber ) { throw new JavaClassMagicNumberException ( ) ; } MinorVersion = reader . ReadUInt16 ( ) ; MajorVersion = reader . ReadUInt16 ( ) ; var constants = reader . ReadUInt16 ( ) ; ConstantPool = new JavaConstantInfo [ constants ] ; for ( int i = 1 ; i < constants ; i ++ ) { var constant = JavaConstantInfo . CreateAndRead ( reader ) ; ConstantPool [ i ] = constant ; if ( constant . Type == ConstantInfoType . Double || constant . Type == ConstantInfoType . Long ) { i ++ ; } } AccessFlag = ( JavaAccessFlag ) reader . ReadUInt16 ( ) ; ThisClass = reader . ReadUInt16 ( ) ; SuperClass = reader . ReadUInt16 ( ) ; var interfaces = reader . ReadUInt16 ( ) ; Interfaces = new ushort [ interfaces ] ; for ( int i = 0 ; i < interfaces ; i ++ ) { Interfaces [ i ] = reader . ReadUInt16 ( ) ; } var fields = reader . ReadUInt16 ( ) ; Fields = new JavaFieldInfo [ fields ] ; for ( int i = 0 ; i < fields ; i ++ ) { Fields [ i ] = JavaFieldInfo . CreateAndRead ( reader , this ) ; } var methods = reader . ReadUInt16 ( ) ; Methods = new JavaMethodInfo [ methods ] ; for ( int i = 0 ; i < methods ; i ++ ) { Methods [ i ] = JavaMethodInfo . CreateAndRead ( reader , this ) ; } var attributes = reader . ReadUInt16 ( ) ; Attributes = new JavaAttributeInfo [ attributes ] ; for ( int i = 0 ; i < attributes ; i ++ ) { Attributes [ i ] = JavaAttributeInfo . CreateAndRead ( reader , this ) ; } }
Reads the class file by the given binary reader.
Reads the class file by the given binary reader .
// Reads the magic number // Reads the constant pool. // The first constnat (0) is always zero. // The first valid index is 1. // There is an odd special case for double and long. // For some reasons you have to add an empty index // if you read an double or long constant. // Reads the interfaces // Reads the fields // Reads the methods // Reads the attributes
reader
BinaryReader
None