Nashorn translates javascript source code directly into memory. Is there any way to access the bytecode just for reading purpose? (manipulation isn't required). If there is, kindly explain in detail as I have limited experience... I am aware of javap but it is showing only Java specific bytecode. I want to look at Nashorn translated javascript bytecode.
You can use Nashorn command line option "-pc" or "--print-code". Nashorn will print generated bytecode in javap-like format. For example:
jjs -pc hello.js
If you want to have .class files (which you'd want to look/analyze by other tools), you can use "-d" or "--dump-debug-dir" to specify a directory where generated classes are saved. For example,
jjs -d=tmp hello.js
will generate .class files under "tmp" directory. Please look for "jdk/nashorn/internal/script" directory under the directory you specified.
Note that you'll not be able to offline manipulate and re-load these classes in a later nashorn session. This is just a debugging facility.