Giter Site home page Giter Site logo

jvmgo-book's Issues

IINC is wrong

它的两个操作数,第一个是8个字节的索引,第二个是8个字节的数字,这个数字是有符号数
所以应该是这样的:self.Index = uint(reader.ReadUint8())
self.Const = int32(int8(reader.ReadInt8()))

java版CompositeEntry 代码问题

java版CompositeEntry 中的readClass 方法循环内部直接是return,会导致只会执行一次,同时,异常发生后也会中断循环。我已解决,希望提交pr修复。

书中第七章发现错误

第七章中 , 下段文本发现错误

原文如下:

parseMethodDescriptor()函数分解方法描述符,返回一个
MethodDescriptor结构体实例。这个结构体定义在
ch06\rtda\heap\method_descriptor.go文件中,代码如下:

其中 method_descriptor.go 此文件应在 ch07\rtda\heap\method_descriptor.go 路径中

English version?

I ran into your repo and your book.
I was wondering if you had any plans of writing the book in english and selling it in amazon because i might be interested in purchasing a copy or 2?
:)

排版错误

P70页 push()方法内的两对大括号未对齐

37页 常量池大小 图文不符

  • 第1版第1次印刷
  • 第37页 3.3.1 ConstantPool结构体
  • 图3-8内容与文字不符

ClassFileTest的常量池大小是61如图3-8所示

然而图中却是64 -> 00 40
按照第25页上的ClassFileTest代码编译出来class文件的ConstantPool大小确实是64,不过如果去掉主函数上的RuntimeException申明就是61了

为什么使用[]Slot 而不使用[]*Slot

在定义操作数栈还有局部变量表的时候为什么使用了结构体切片,而不是使用结构体指针切片。使用结构体切片不是会引起结构体拷贝浪费空间?

拼写错误

199页最后一行的newMultiArray()应该为newMultiDimensionalArray()

第三章测试时报错

纸质的第一版第三章测试时报错,省略的attr_local_variable_table.go文件和cp_invoke_dynamic.go文件,应在相关小节提醒一下读者。cp_utf8.go文件中如果用简化版的decodeMUTF8函数,会报导入的包未用到,这个是小问题。

代码错误

第二版194页第二段代码中
classRef := cp.GetConstant(self.Index).(*rtc.ClassRef)应该为
classRef := cp.GetConstant(self.Index).(*heap.ClassRef)

206页getField()函数的声明中的isStatic参数缺少类型

不知道新版有没有改正

排版错误

P71页 4.3.3 Frame结构体未对齐(operandStack)

书中代码与源码中不符

在《自己动手写java虚拟机》中,您的书中194页 anewarray.go 文件中 Execute函数中 classRef := cp.GetConstant(self.Index).(*rtc.ClassRef),而实际应该是classRef := cp.GetConstant(self.Index).(*heap.ClassRef) 。不知道我有没有理解错误

编辑错误

第一版
P52 最后一段最后一句

表3-5给出了这23中属性...

是否应该改为 表3-4给出了...

ch06 运行结果有异常

作者您好,在拜读您的著作 自己动手写Java虚拟机。在运行ch06的代码的时候,发现有两处和书本结果不同的地方

  1. facoty.go 不支持0xb1 在运行的时候会抛出异常
  2. 在参照ch07的时候,发现会多出一个栈信息 pc:53 inst:*control.RETURN{}.然后提示jvm stack is empty 个人理解为这个时候return是结束标示,操作栈中应该是空,因此删除了frame.Thread().PopFrame()。此时提示index out of range。

如果想和书本上的运行结果一致,应该如何修改ch06的代码,谢谢

参数类型不符

书中115页中frame := thread.NewFrame(maxLocals, maxStack)的两个参数均为uint16类型,而NewFrame函数接收两个uint类型的参数

代码错误

第189页 ArrayLength()代码 第二行

switch self.fields.(type) {

应该是self.data

instructions/factory.go的重构建议

最近拜读大作获益匪浅,非常感谢,作者高才,本书立意非常好。
交流一下,instructions/factory.go中,可否如下重构,如果重构,有什么好处和坏处:
type CMDExexute interface {
Execute(frame *rtda.Frame)
}

var (
cmds map[byte]CMDExexute
)

func initCommands() {
if len(cmds) > 0 {
return
}
initCMDMap(0x00, func() CMDExexute { return &constants.NOP{}})
//...
}

func initCMDMap(code byte, fun func() CMDExexute) {
cmd := fun()
cmds[code] = CMDExexute(cmd)
}

func NewInstruction(opcode byte) base.Instruction {
initCommands()
v, ok := cmds[opcode]
if !ok {
panic(fmt.Errorf("Unsupported opcode: 0x%x!", opcode))
}
return v.(base.Instruction)
}

factory.txt

编辑错误

2.3.2上面strings.HasSuffix(path, ".JAR")后面少一个||符号
2.3.4上面readClass中defer r.Close()是不是应该判断err != nil之前,也就是放在return之前,几个defer都需要调整下位置

invalid char '\\'

张老师您好,
第一章最后go install jvmgo\ch01,报错go: jvmgo\ch01: malformed module path "jvmgo\ch01": invalid char '\'
我在网上找了很久,也试了很多方法,都解决不了,
您能帮忙看下吗?
感谢!

排版错误

170页invokestatic结构体Execute方法里

if !resolved.IsStatic()

应替换为

if !resolvedMethod.IsStatic()

CH03 not working

亲爱的作者,我是您书的忠实粉丝,哈哈
最近刚刚完成第三章,发现总是解析 Constant Pool的tag时候出错,fmt出来发现有3位数的tag出现
然后就到您这边下载了原书code,编译以后发现load class时候出现同样的问题

$ ./ch03.exe -cp "C:\Develop\Java\JVM" test
Constant Pool Length: 43panic: 215

goroutine 1 [running]:
panic(0x53f9e0, 0xc08241a390)
        C:/Go/src/runtime/panic.go:481 +0x3f4
main.loadClass(0xc08200a256, 0x4, 0xc0820522a0, 0x1)
        C:/Develop/GO/src/jvmgo-source/ch03/main.go:36 +0x105
main.startJVM(0xc0820122d0)
        C:/Develop/GO/src/jvmgo-source/ch03/main.go:23 +0xfc
main.main()
        C:/Develop/GO/src/jvmgo-source/ch03/main.go:16 +0x124

不知可否答疑解惑

多谢哈

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.