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