java - Is bytecode manipulation safe -
performing bytecode manipulation using apis javaassist modify class files after compilation. but, if java code optimized can't modifications performed in wrong place? there ways avoid problem? story different between regular java , android?
a typical java program compiled multiple times. in first step, java source code translated java byte code. in second step, java byte code translated machine code.
the details of process of course dependent on virtual machine runs code. versions of java did example not include so-called just-in-time compiler. in case, byte code interpreted instruction instruction byte code manipulations of course have performance impact. not longer true. both openjdk's hotspot virtual machine android's art , dex runtimes perform optimizations of byte code.
the javac compiler translates source code byte code performs few optimizations. should not worry performance impact of to-byte-code translation step. however, in cases, byte code produced runtime code generation can have performance impact. happens when just-in-time compiler observes byte code difficult optimize. typically, caused unnecessary object allocations difficult optimize away.
if want in details of matter, have given presentation talk bit problem: https://www.youtube.com/watch?v=xmy6ha7_h5y
as safety: long byte code manipulation not corrupt byte code, there no problem. if corrupt byte code, java virtual machine refuse loading class corrupt code. both true hotspot , android verify byte code previous loading class.
Comments
Post a Comment