cafebabe icon indicating copy to clipboard operation
cafebabe copied to clipboard

How can I figure out the index of an entry of the constant pool?

Open LizBing opened this issue 11 months ago • 4 comments

Currently, I am trying to implementing my own JVM using Rust and your crate. Thanks for your significant effort.

I am working on the runtime constant pool right now, and I need to know the index for each entry. It seems that you only provided a simple iterator which may be the only way to access to the entries of constant pool and is not able to acquire the index of a certain entry.

I do suppose that we can have the iterator return a tuple like (index, entry). What do you think?

LizBing avatar Mar 09 '25 01:03 LizBing

Hi, thanks for reaching out. I'm curious, why do you need the index of the entries in the constant pool? What kinds of operations do you need to do that require it?

staktrace avatar Mar 09 '25 01:03 staktrace

Hi, thanks for reaching out. I'm curious, why do you need the index of the entries in the constant pool? What kinds of operations do you need to do that require it?

I notice that you have already resolved the entries and bound them to the opcode like ldc, but I would like to deal with the opcode in a more primitive way, that is, to process them in the executor byte-wise. Besides, having these indexes might make the use of the constant pool more flexible.

By the way, is it your goal to support some reserved opcodes further?

LizBing avatar Mar 09 '25 05:03 LizBing

The indexes are kind of an implementation detail given the abstraction layer this library is targeting, which is why I intentionally didn't expose them in the API. That's why I'd like to know why you need them exposed. It's possible that what you're trying to do should instead be part of this library to maintain a consistent abstraction. Do you have sample or WIP code that illustrates the use case?

staktrace avatar Mar 10 '25 00:03 staktrace

Also which reserved opcodes are you referring to?

staktrace avatar Mar 10 '25 00:03 staktrace

Closing issue due to lack of response

staktrace avatar Jun 02 '25 10:06 staktrace