(mis)using modern Java
Modern Java is really awesome when it comes to “Hello, World!” demos. It’s also cool for a sophisticated systems and algorithms, provided their authors write code which obeys a few fairly simple contracts and avoids obvious traps.
There are a few mantras regarding recent features of modern Java, such as:
- records can replace JavaBeans everywhere
- you never need to write
hashCode()for records - pattern matching with
instanceofis the best tool forequals() - just ignore
--illegal-accessand set it topermit synchronize (new Long(42))is the best for monitoring and so on.
This talk has been given at jLove, Doing Java Better and Java Day Lviv.