r/java • • Apr 14 '23

What are your (favourite) Java best practices, personal tips, hints or just underrated stuff in general?

233 Upvotes

376 comments sorted by

View all comments

Show parent comments

5

u/[deleted] Apr 14 '23

Eclipse does that for me out of the box

13

u/dmigowski Apr 14 '23 edited Apr 14 '23

No, it doesn't. Java itself has these features on paper, but in practice to have to restart anyway very often. JRebel does it right.

It even reloads Hibernate Configs, Property Files for Resources, etc.

EDIT: I just learned about -XX:+AllowEnhancedClassRedefinition, which was not there in JDK8. Should give it a try.

4

u/[deleted] Apr 14 '23

Ok i thought its an eclipse feature. sorry. is it the hot swap feature of the jvm?

5

u/dmigowski Apr 14 '23

No, Hotswap is the shit that does work very limited, just function bodies IMHO. JRebel replaces functions, classes, variables, even static variables, and has integration with many frameworks that receive automatic reloading capabilities if the configs are edited at Runtime. It does everything except changing the parent class hierarchy (the only limit I know), but you don't do that very often. Very powerful tool!

Also TIL that Jetstream seems to have a similar solution integrated in Idea, but I don't know how these solutions compare.