-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial implementation of Java bindings #455
Conversation
8cc47eb
to
0c0b008
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Got cosmetic feedback.
bindings/java/java/src/test/java/org/ethereum/evmc/TestMessage.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my standpoint there should be a pair of abstractions:
Evmc
as a general interface toevmc
EvmcVM
which is instantiated viaEvmc.create(String filename)
and effectively a VM instance
It looks organic to me and allows user to instantiate several VM instances at a time.
EvmcVM
could implement AutoCloseable
interface to utilize try-with-resources pattern.
I enabled building of external PR. If you push more commits the CI jobs should run correctly. |
You can also check #171. |
513cc45
to
ee6d68c
Compare
That does sound nice, but realistically why I would want to call Evmc.create(filename) multiple times. It's a little awkward considering that I will only load the shared object once. @chfast pointed out in another comment that there is typically one long lived vm that can handle multiple concurrent calls. That being said, I have some work to do to make sure everything is thread safe. |
8422c1d
to
1d61ebb
Compare
We are using this abstraction in all language bindings. This is mostly to make sure the VM instance is automatically released and also it wraps execution result object to also make sure it is properly released. But still the I still have to review this PR. I also don't think introducing this abstraction in the first iteration is crucial. I'm also guessing your goal is to consume other VM, not to export Java one. |
Fair point. My abstraction model came out of my understanding of evmc design but it looks overcomplicated from user's perspective. I'd then keep From my experience having a deal with statically stored state is not that convenient in some cases. What if you want to run two VM instances within the same JVM process? For example, to test whether two different implementations are conformant with each other; however, this is hardly the case for this bindings and not that good example. To conclude, IMO it's better to get rid of statics, it would give more flexibility to the user. But I agree that this is not necessary at the moment and could be done on demand.
Good point. Also, I think it worth to mention in the head of |
@mkalinin, @chfast, @atoulme great discussion. Thanks to for the guidance. Tbh, I am still getting a feel for how this will be used so your input here is invaluable. I want to point out that the test coverage is abysmal at this point. That being said, it could potentially be merged assuming we document it as in progress (once @chfast reviews of course). An iterative approach might make it easier to review going fwd. 2k line PRs are incredibly difficult to review - sorry about that. |
Thanks for this and good point about ensuring the result object is properly released. I have some work to do on this front. I will keep it static (for now) and change it to the abstraction that you, @mkalinin and @atoulme all suggested.
I can stop now and wait for your review, or I can continue work. I think the size of the PR is starting to reach the point where it becomes difficult to review.
Yessir the goal is to consume another VM |
This was very well said and totally doable.
100% agree here
Good question.
agreed. i am open to suggestions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need gradle-wrapper.jar
and gradlew
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a quick review.
I've found some issues with the C code, most of them should be fixed before merging.
I'm also concern a bit about the build process. Can we actually live without adding gradle wrapper and assume gradle is installed? Is there also a concern about the gradle version?
bindings/java/Makefile
Outdated
|
||
build: | ||
mkdir -p $(OUT_DIR) | ||
gcc $(DEBUG_FLAG) -c $(INCLUDES) -o $(OUT_DIR)/loader.o ../../lib/loader/loader.c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this common to provide build scripts for C compilation? If yes, then I think JNI should be pulled to main cmake script and build with it. I can handle that later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that'd be great if you could tie it into the main script. thanks!
Also as a measure before merging, can you enable C formatting checks? In https://github.com/ethereum/evmc/blob/master/circle.yml#L67 change: - find examples include lib test -name '*.hpp' -o -name '*.cpp' -o -name '*.h' -o -name '*.c' | xargs clang-format -i
+ find bindings/java examples include lib test -name '*.hpp' -o -name '*.cpp' -o -name '*.h' -o -name '*.c' | xargs clang-format -i Also useful to install |
@jrhea and let me know when the PR is ready for a final review. |
I believe it is ready for a final review |
This is not normal procedure, but because it only adds new stuff and has a reformat commit in the middle, I prefer to squash it. Also, please add a changelog entry. I actually have some number of suggestions for improvements, but it will be better to merge it as it is and follow up with future PRs. |
ok that's fine, then squash it. I only added the reformat commit bc i was asked to.
done.
ditto...it was a good first pass at least. |
Includes JNI bindings, tests and build system
This PR implements bindings for Java. All tests pass on OSX and debian:lastest.
Punchlist
Code:
Tests:
Build
Other
Resolves #137
helps with ethereum/ethereumj#1025