JavaWriter(Stream _stream, JavaClass _class) { Where = new JavaException.Where(); var memoryStream = new MemoryStream(); stream = memoryStream; forkedStreams = new Stack <Stream>(); constants = new JavaConstantPool(); _class.Write(this); stream = _stream; Write32(0xCAFEBABE); Write16(0); Write16(52); constants.Write(this); memoryStream.WriteTo(_stream); memoryStream.Dispose(); }
JavaReader(Stream _stream, string whereText, bool withCode) { Where = new JavaException.Where(); Where.Push(whereText); stream = _stream; if (Read32() != 0xCAFEBABE) { throw Where.Exception("bad class magic number"); } var(minorVersion, majorVersion) = (Read16(), Read16()); if (majorVersion < 45) { throw Where.Exception("bad class major version number"); } constants = new JavaConstantPool(this); new JavaClass(this, majorVersion, minorVersion, withCode); Where.Pop(); }