Ever wondered how the JVM debugger 'Evaluate' feature works in IDEs? Long ago I thought that the Java debug interface (JDI) actually allows you to specify the expression and get back its value.

However, this is not quite possible: there's no Java language compiler inside the JVM. When the process is paused JDI allows you to read or write any variables and fields or even execute an existing method with given arguments. But nothing like addition or multiplication.
On the other hand, #IntelliJIDEA debugger allows you to evaluate even statements! You can write there `for`, `if`, `while`, `switch` - whatever. You can even declare local variables. So how this works?
The answer is simple: IDEA debugger has a built-in interpreter for Java! If you access an existing variable or a field, call a method or instantiate an object, it queries JDI. Otherwise, IDE itself does all the calculations.
The amusing thing is that debugger authors didn't bother to make it as strict as Java itself, so the language inside the interpreter is a much more permissive version of Java. For example, you don't need to initialize variables there! Default values like 0 are used automatically.
Of course, final variables could be changed. Why artificial limitations?
Another thing: most of the casts are not necessary. This interpreted Java more resembles dynamically typed languages like JavaScript. Duck-typing works: if there's a method, we can call it. Even if the highlighter complains.
Switch statements and expressions are more permissive there: you can switch over any type. Also, no default is necessary for switch expressions. If it's not visited, the evaluation will be successful.
In addition to use any type, you can use any expressions as case labels, not just constants! The first matching branch will be executed.
Finally, even if your project still uses Java 6 JDK, it doesn't stop you from using new language features. For example, 'var' declarations and patterns in instanceof work perfectly, because they are interpreted by IDE, not by your JDK. Just ignore error messages!

More from Tech

A common misunderstanding about Agile and “Big Design Up Front”:

There’s nothing in the Agile Manifesto or Principles that states you should never have any idea what you’re trying to build.

You’re allowed to think about a desired outcome from the beginning.

It’s not Big Design Up Front if you do in-depth research to understand the user’s problem.

It’s not BDUF if you spend detailed time learning who needs this thing and why they need it.

It’s not BDUF if you help every team member know what success looks like.

Agile is about reducing risk.

It’s not Agile if you increase risk by starting your sprints with complete ignorance.

It’s not Agile if you don’t research.

Don’t make the mistake of shutting down critical understanding by labeling it Bg Design Up Front.

It would be a mistake to assume this research should only be done by designers and researchers.

Product management and developers also need to be out with the team, conducting the research.

Shared Understanding is the key objective


Big Design Up Front is a thing to avoid.

Defining all the functionality before coding is BDUF.

Drawing every screen and every pixel is BDUF.

Promising functionality (or delivery dates) to customers before development starts is BDUF.

These things shouldn’t happen in Agile.

You May Also Like

ARE WE FAMILIAR WITH THE MEANING & POWER OF MANTRAS WE CHANT?

Whenever we chant a Mantra in Sanskrit, it starts with 'Om' and mostly ends with 'Swaha' or 'Namaha'. This specific alignment of words has a specific meaning to it which is explained in Dharma Shastra.


Mantra is a Sanskrit word meaning sacred syllable or sacred word. But Mantras r not just words put together,they r also vibrations.The whole Universe is a cosmic energy in different states of vibration &this energy in different states of vibration forms the objects of Universe.

According to Scriptures,Om is considered to be ekaakshar Brahman,which means Om is the ruler of 3 properties of creator,preserver&destroyer which make the
https://t.co/lyhkWeCdtv is also seen as a symbol of Lord Ganesha, as when starting the prayer,it's him who is worshipped 1st.


'Om' is the sound of the Universe. It's the first original vibration of the nothingness through which manifested the whole Cosmos. It represents the birth, death and rebirth process. Chanting 'Om' brings us into harmonic resonance with the Universe. It is a scientific fact.

Therefore, Mantras are described as vibrational words that are recited, spoken or sung and are invoked towards attaining some very specific results. They make very specific sounds at a frequency that conveys a directive into our subconcious.