jdk/src/share/demo/jvmti/java_crw_demo/README.txt
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 2 90ce3da70b43
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
#
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
# Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
# Redistribution and use in source and binary forms, with or without
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
# modification, are permitted provided that the following conditions
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
# are met:
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
#   - Redistributions of source code must retain the above copyright
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
#     notice, this list of conditions and the following disclaimer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
#   - Redistributions in binary form must reproduce the above copyright
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
#     notice, this list of conditions and the following disclaimer in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
#     documentation and/or other materials provided with the distribution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
#
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    15
#   - Neither the name of Oracle nor the names of its
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
#     contributors may be used to endorse or promote products derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
#     from this software without specific prior written permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
java_crw_demo Library
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
The library java_crw_demo is a small C library that is used by HPROF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
and other agent libraries to do some very basic bytecode 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
insertion (BCI) of class files.  This is not an agent 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
library but a general purpose library that can be used to do some 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
very limited bytecode insertion.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
In the demo sources, look for the use of java_crw_demo.h and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
the C function java_crw_demo().  The java_crw_demo library is provided 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
as part of the JRE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
The basic BCI that this library does includes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    * On entry to the java.lang.Object init method (signature "()V"), 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
      a invokestatic call to tclass.obj_init_method(object); is inserted. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    * On any newarray type opcode, immediately following it, the array 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
      object is duplicated on the stack and an invokestatic call to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
      tclass.newarray_method(object); is inserted. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    * On entry to all methods, a invokestatic call to 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
      tclass.call_method(cnum,mnum); is inserted. The agent can map the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
      two integers (cnum,mnum) to a method in a class, the cnum is the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
      number provided to the java_crw_demo library when the classfile was 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
      modified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    * On return from any method (any return opcode), a invokestatic call to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
      tclass.return_method(cnum,mnum); is inserted.  
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
Some methods are not modified at all, init methods and finalize methods 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
whose length is 1 will not be modified.  Classes that are designated 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
"system" will not have their clinit methods modified. In addition, the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
method java.lang.Thread.currentThread() is not modified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
No methods or fields will be added to any class, however new constant 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
pool entries will be added at the end of the original constant pool table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
The exception, line, and local variable tables for each method is adjusted 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
for the modification. The bytecodes are compressed to use smaller offsets 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
and the fewest 'wide' opcodes. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
All attempts are made to minimize the number of bytecodes at each insertion 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
site, however, classes with N return opcodes or N newarray opcodes will get 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
N insertions.  And only the necessary modification dictated by the input 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
arguments to java_crw_demo are actually made.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77