Register DDM handlers at the beginning of main method.
Compiler initializes RuntimeInit during compilation and stores an initialized version of the class in oat file. Same thing happens to DdmServer which handles DDM packets in JDWP thread started during JVM creation. This means that after the creation of JVM all DDM packets are handled by DdmServer.dispatch and since it's already initialized during compilation it has all framework related handlers already registered. If a packet arrives before AndroidRuntime.startReg is called then framework native methods are not yet registered and the processing of the packet fails with UnsatisfiedLinkError. To fix this problem the registration of framework related DDM handlers is moved to the beginning of ZygoteInit.main and RuntimeInit.main. This means that the handlers won't be registered until main method is called and that's guaranteed to be after AndroidRuntime.startReg is called. It also guarantees that DDM packets will be properly handled as soon as Java code is executed. Bug: 18081539. Change-Id: I9c674f53f3f62d58c46886e0b60698182e08f0c3
Loading
Please register or sign in to comment