Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/demo/jvmti/java_crw_demo/README.txt
38829 views
#1# Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.2#3# Redistribution and use in source and binary forms, with or without4# modification, are permitted provided that the following conditions5# are met:6#7# - Redistributions of source code must retain the above copyright8# notice, this list of conditions and the following disclaimer.9#10# - Redistributions in binary form must reproduce the above copyright11# notice, this list of conditions and the following disclaimer in the12# documentation and/or other materials provided with the distribution.13#14# - Neither the name of Oracle nor the names of its15# contributors may be used to endorse or promote products derived16# from this software without specific prior written permission.17#18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS19# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,20# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR21# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR22# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,23# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,24# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR25# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF26# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING27# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS28# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.29#3031java_crw_demo Library3233The library java_crw_demo is a small C library that is used by HPROF34and other agent libraries to do some very basic bytecode35insertion (BCI) of class files. This is not an agent36library but a general purpose library that can be used to do some37very limited bytecode insertion.3839In the demo sources, look for the use of java_crw_demo.h and40the C function java_crw_demo(). The java_crw_demo library is provided41as part of the JRE.4243The basic BCI that this library does includes:4445* On entry to the java.lang.Object init method (signature "()V"),46a invokestatic call to tclass.obj_init_method(object); is inserted.4748* On any newarray type opcode, immediately following it, the array49object is duplicated on the stack and an invokestatic call to50tclass.newarray_method(object); is inserted.5152* On entry to all methods, a invokestatic call to53tclass.call_method(cnum,mnum); is inserted. The agent can map the54two integers (cnum,mnum) to a method in a class, the cnum is the55number provided to the java_crw_demo library when the classfile was56modified.5758* On return from any method (any return opcode), a invokestatic call to59tclass.return_method(cnum,mnum); is inserted.6061Some methods are not modified at all, init methods and finalize methods62whose length is 1 will not be modified. Classes that are designated63"system" will not have their clinit methods modified. In addition, the64method java.lang.Thread.currentThread() is not modified.6566No methods or fields will be added to any class, however new constant67pool entries will be added at the end of the original constant pool table.68The exception, line, and local variable tables for each method is adjusted69for the modification. The bytecodes are compressed to use smaller offsets70and the fewest 'wide' opcodes.7172All attempts are made to minimize the number of bytecodes at each insertion73site, however, classes with N return opcodes or N newarray opcodes will get74N insertions. And only the necessary modification dictated by the input75arguments to java_crw_demo are actually made.76777879