author | egahlin |
Mon, 08 Jul 2019 23:08:05 +0200 | |
branch | JEP-349-branch |
changeset 57460 | bcbc53560c77 |
parent 50113 | caf115bb98ad |
child 58112 | e7754025004b |
permissions | -rw-r--r-- |
50113 | 1 |
/* |
2 |
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package jdk.jfr.consumer; |
|
27 |
||
28 |
import java.lang.reflect.Modifier; |
|
29 |
||
30 |
import jdk.jfr.internal.Type; |
|
31 |
||
32 |
/** |
|
33 |
* A recorded method. |
|
34 |
* |
|
35 |
* @since 9 |
|
36 |
*/ |
|
37 |
public final class RecordedMethod extends RecordedObject { |
|
38 |
||
39 |
static ObjectFactory<RecordedMethod> createFactory(Type type, TimeConverter timeConverter) { |
|
57460
bcbc53560c77
Reduce allocation rate by minimizing number of fields in RecordedEvent
egahlin
parents:
50113
diff
changeset
|
40 |
return new ObjectFactory<RecordedMethod>(type, timeConverter) { |
50113 | 41 |
@Override |
57460
bcbc53560c77
Reduce allocation rate by minimizing number of fields in RecordedEvent
egahlin
parents:
50113
diff
changeset
|
42 |
RecordedMethod createTyped(ObjectContext objectContext, long id, Object[] values) { |
bcbc53560c77
Reduce allocation rate by minimizing number of fields in RecordedEvent
egahlin
parents:
50113
diff
changeset
|
43 |
return new RecordedMethod(objectContext, values); |
50113 | 44 |
} |
45 |
}; |
|
46 |
} |
|
47 |
||
57460
bcbc53560c77
Reduce allocation rate by minimizing number of fields in RecordedEvent
egahlin
parents:
50113
diff
changeset
|
48 |
private RecordedMethod(ObjectContext objectContext, Object[] values) { |
bcbc53560c77
Reduce allocation rate by minimizing number of fields in RecordedEvent
egahlin
parents:
50113
diff
changeset
|
49 |
super(objectContext, values); |
50113 | 50 |
} |
51 |
||
52 |
/** |
|
53 |
* Returns the class this method belongs to, if it belong to a Java frame. |
|
54 |
* <p> |
|
55 |
* To ensure this is a Java frame, use the {@link RecordedFrame#isJavaFrame()} |
|
56 |
* method. |
|
57 |
* |
|
58 |
* @return the class, may be {@code null} if not a Java frame |
|
59 |
* |
|
60 |
* @see RecordedFrame#isJavaFrame() |
|
61 |
*/ |
|
62 |
public RecordedClass getType() { |
|
63 |
return getTyped("type", RecordedClass.class, null); |
|
64 |
} |
|
65 |
||
66 |
/** |
|
67 |
* Returns the name of this method, for example {@code "toString"}. |
|
68 |
* <p> |
|
69 |
* If this method doesn't belong to a Java frame the result is undefined. |
|
70 |
* |
|
71 |
* @return method name, or {@code null} if doesn't exist |
|
72 |
* |
|
73 |
* @see RecordedFrame#isJavaFrame() |
|
74 |
*/ |
|
75 |
public String getName() { |
|
76 |
return getTyped("name", String.class, null); |
|
77 |
} |
|
78 |
||
79 |
/** |
|
80 |
* Returns the method descriptor for this method (for example, |
|
81 |
* {@code "(Ljava/lang/String;)V"}). |
|
82 |
* <p> |
|
83 |
* See Java Virtual Machine Specification, 4.3 |
|
84 |
* <p> |
|
85 |
* If this method doesn't belong to a Java frame then the the result is undefined. |
|
86 |
* |
|
87 |
* @return method descriptor. |
|
88 |
* |
|
89 |
* @see RecordedFrame#isJavaFrame() |
|
90 |
*/ |
|
91 |
public String getDescriptor() { |
|
92 |
return getTyped("descriptor", String.class, null); |
|
93 |
} |
|
94 |
||
95 |
/** |
|
96 |
* Returns the modifiers for this method. |
|
97 |
* <p> |
|
98 |
* If this method doesn't belong to a Java frame, then the result is undefined. |
|
99 |
* |
|
100 |
* @return the modifiers |
|
101 |
* |
|
102 |
* @see Modifier |
|
103 |
* @see RecordedFrame#isJavaFrame |
|
104 |
*/ |
|
105 |
public int getModifiers() { |
|
106 |
return getTyped("modifiers", Integer.class, Integer.valueOf(0)); |
|
107 |
} |
|
108 |
||
109 |
/** |
|
110 |
* Returns whether this method is hidden (for example, wrapper code in a lambda |
|
111 |
* expressions). |
|
112 |
* |
|
113 |
* @return {@code true} if method is hidden, {@code false} otherwise |
|
114 |
*/ |
|
115 |
public boolean isHidden() { |
|
116 |
return getTyped("hidden", Boolean.class, Boolean.FALSE); |
|
117 |
} |
|
118 |
} |