author | lagergren |
Fri, 26 Sep 2014 18:47:20 +0200 | |
changeset 26886 | 18c744ab4df2 |
parent 26765 | 97501edd2979 |
child 27525 | e7d3c00b9fb8 |
permissions | -rw-r--r-- |
16147 | 1 |
/* |
16151 | 2 |
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
16147 | 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.nashorn.internal.objects; |
|
27 |
||
28 |
import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED; |
|
16155
a8ab83cbaa49
8005788: Loggers and their corresponding system properties not working correctly
lagergren
parents:
16151
diff
changeset
|
29 |
import java.io.PrintWriter; |
24731
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
30 |
import java.util.LinkedList; |
16147 | 31 |
import java.util.Objects; |
32 |
import jdk.nashorn.internal.objects.annotations.Attribute; |
|
33 |
import jdk.nashorn.internal.objects.annotations.Function; |
|
34 |
import jdk.nashorn.internal.objects.annotations.ScriptClass; |
|
35 |
import jdk.nashorn.internal.objects.annotations.Where; |
|
16155
a8ab83cbaa49
8005788: Loggers and their corresponding system properties not working correctly
lagergren
parents:
16151
diff
changeset
|
36 |
import jdk.nashorn.internal.runtime.Context; |
24731
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
37 |
import jdk.nashorn.internal.runtime.JSType; |
23084
6c5c02d1023a
8035948: Redesign property listeners for shared classes
hannesw
parents:
19459
diff
changeset
|
38 |
import jdk.nashorn.internal.runtime.PropertyListeners; |
16147 | 39 |
import jdk.nashorn.internal.runtime.PropertyMap; |
40 |
import jdk.nashorn.internal.runtime.ScriptFunction; |
|
41 |
import jdk.nashorn.internal.runtime.ScriptObject; |
|
24742
a9afb384e654
8040655: When processing a RewriteException debug object, the return value has already been reset to null. We need to catch this value before that.
lagergren
parents:
24731
diff
changeset
|
42 |
import jdk.nashorn.internal.runtime.events.RuntimeEvent; |
16147 | 43 |
import jdk.nashorn.internal.runtime.linker.LinkerCallSite; |
26765
97501edd2979
8047764: Indexed or polymorphic set on global affects Object.prototype
hannesw
parents:
25865
diff
changeset
|
44 |
import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor; |
16147 | 45 |
|
46 |
/** |
|
47 |
* Nashorn specific debug utils. This is meant for Nashorn developers. |
|
48 |
* The interface is subject to change without notice!! |
|
49 |
* |
|
50 |
*/ |
|
51 |
@ScriptClass("Debug") |
|
16226
0e4f37e6cc40
8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
16185
diff
changeset
|
52 |
public final class NativeDebug extends ScriptObject { |
18618
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
17524
diff
changeset
|
53 |
|
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
17524
diff
changeset
|
54 |
// initialized by nasgen |
18855
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
55 |
@SuppressWarnings("unused") |
18618
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
17524
diff
changeset
|
56 |
private static PropertyMap $nasgenmap$; |
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
17524
diff
changeset
|
57 |
|
18851
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18618
diff
changeset
|
58 |
private NativeDebug() { |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18618
diff
changeset
|
59 |
// don't create me! |
bdb92c95f886
8019947: inherited property invalidation does not work with two globals in same context
sundar
parents:
18618
diff
changeset
|
60 |
throw new UnsupportedOperationException(); |
16147 | 61 |
} |
62 |
||
63 |
@Override |
|
64 |
public String getClassName() { |
|
65 |
return "Debug"; |
|
66 |
} |
|
67 |
||
68 |
/** |
|
69 |
* Nashorn extension: get context, context utility |
|
70 |
* |
|
71 |
* @param self self reference |
|
72 |
* @return context |
|
73 |
*/ |
|
74 |
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) |
|
75 |
public static Object getContext(final Object self) { |
|
16226
0e4f37e6cc40
8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
16185
diff
changeset
|
76 |
final SecurityManager sm = System.getSecurityManager(); |
0e4f37e6cc40
8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
16185
diff
changeset
|
77 |
if (sm != null) { |
19459 | 78 |
sm.checkPermission(new RuntimePermission(Context.NASHORN_GET_CONTEXT)); |
16226
0e4f37e6cc40
8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
16185
diff
changeset
|
79 |
} |
16147 | 80 |
return Global.getThisContext(); |
81 |
} |
|
82 |
||
83 |
/** |
|
84 |
* Nashorn extension: get map from {@link ScriptObject} |
|
85 |
* |
|
86 |
* @param self self reference |
|
87 |
* @param obj script object |
|
88 |
* @return the map for the current ScriptObject |
|
89 |
*/ |
|
90 |
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) |
|
91 |
public static Object map(final Object self, final Object obj) { |
|
92 |
if (obj instanceof ScriptObject) { |
|
93 |
return ((ScriptObject)obj).getMap(); |
|
94 |
} |
|
95 |
return UNDEFINED; |
|
96 |
} |
|
97 |
||
98 |
/** |
|
99 |
* Check object identity comparison regardless of type |
|
100 |
* |
|
101 |
* @param self self reference |
|
102 |
* @param obj1 first object in comparison |
|
103 |
* @param obj2 second object in comparison |
|
104 |
* @return true if reference identity |
|
105 |
*/ |
|
106 |
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) |
|
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
23084
diff
changeset
|
107 |
public static boolean identical(final Object self, final Object obj1, final Object obj2) { |
16147 | 108 |
return obj1 == obj2; |
109 |
} |
|
110 |
||
111 |
/** |
|
24719 | 112 |
* Returns true if if the two objects are both property maps, and they have identical properties in the same order, |
113 |
* but allows the properties to differ in their types. |
|
24720 | 114 |
* @param self self |
24719 | 115 |
* @param m1 first property map |
116 |
* @param m2 second property map |
|
117 |
* @return true if they have identical properties in same order, with possibly different types. |
|
118 |
*/ |
|
119 |
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) |
|
120 |
public static Object equalWithoutType(final Object self, final Object m1, final Object m2) { |
|
121 |
return ((PropertyMap)m1).equalsWithoutType((PropertyMap)m2); |
|
122 |
} |
|
123 |
||
124 |
/** |
|
125 |
* Returns a diagnostic string representing the difference of two property maps. |
|
24720 | 126 |
* @param self self |
24719 | 127 |
* @param m1 first property map |
128 |
* @param m2 second property map |
|
129 |
* @return a diagnostic string representing the difference of two property maps. |
|
130 |
*/ |
|
131 |
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) |
|
132 |
public static Object diffPropertyMaps(final Object self, final Object m1, final Object m2) { |
|
133 |
return PropertyMap.diff((PropertyMap)m1, (PropertyMap)m2); |
|
134 |
} |
|
135 |
||
136 |
/** |
|
16147 | 137 |
* Object util - getClass |
138 |
* |
|
139 |
* @param self self reference |
|
140 |
* @param obj object |
|
141 |
* @return class of {@code obj} |
|
142 |
*/ |
|
143 |
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) |
|
144 |
public static Object getClass(final Object self, final Object obj) { |
|
145 |
if (obj != null) { |
|
146 |
return obj.getClass(); |
|
147 |
} |
|
148 |
return UNDEFINED; |
|
149 |
} |
|
150 |
||
151 |
/** |
|
152 |
* Object util - equals |
|
153 |
* |
|
154 |
* @param self self reference |
|
155 |
* @param obj1 first object in comparison |
|
156 |
* @param obj2 second object in comparison |
|
157 |
* @return return {@link Object#equals(Object)} for objects. |
|
158 |
*/ |
|
159 |
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) |
|
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
23084
diff
changeset
|
160 |
public static boolean equals(final Object self, final Object obj1, final Object obj2) { |
18855
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
161 |
return Objects.equals(obj1, obj2); |
16147 | 162 |
} |
163 |
||
164 |
/** |
|
165 |
* Object util - toJavaString |
|
166 |
* |
|
167 |
* @param self self reference |
|
168 |
* @param obj object to represent as a string |
|
169 |
* @return Java string representation of {@code obj} |
|
170 |
*/ |
|
171 |
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) |
|
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
23084
diff
changeset
|
172 |
public static String toJavaString(final Object self, final Object obj) { |
16147 | 173 |
return Objects.toString(obj); |
174 |
} |
|
175 |
||
176 |
/** |
|
177 |
* Do not call overridden toString -- use default toString impl |
|
178 |
* |
|
179 |
* @param self self reference |
|
180 |
* @param obj object to represent as a string |
|
181 |
* @return string representation |
|
182 |
*/ |
|
183 |
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) |
|
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
23084
diff
changeset
|
184 |
public static String toIdentString(final Object self, final Object obj) { |
16147 | 185 |
if (obj == null) { |
186 |
return "null"; |
|
187 |
} |
|
188 |
||
189 |
final int hash = System.identityHashCode(obj); |
|
190 |
return obj.getClass() + "@" + Integer.toHexString(hash); |
|
191 |
} |
|
192 |
||
193 |
/** |
|
18855
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
194 |
* Returns the property listener count for a script object |
18865
8844964e5fc5
8020325: static property does not work on accessible, public classes
sundar
parents:
18855
diff
changeset
|
195 |
* |
8844964e5fc5
8020325: static property does not work on accessible, public classes
sundar
parents:
18855
diff
changeset
|
196 |
* @param self self reference |
8844964e5fc5
8020325: static property does not work on accessible, public classes
sundar
parents:
18855
diff
changeset
|
197 |
* @param obj script object whose listener count is returned |
18855
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
198 |
* @return listener count |
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
199 |
*/ |
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
200 |
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) |
23763
950d8bc0554f
8038456: improve nasgen type checks and use specific return type for @Function, @SpecializedFunctio methods
sundar
parents:
23084
diff
changeset
|
201 |
public static int getListenerCount(final Object self, final Object obj) { |
23084
6c5c02d1023a
8035948: Redesign property listeners for shared classes
hannesw
parents:
19459
diff
changeset
|
202 |
return (obj instanceof ScriptObject) ? PropertyListeners.getListenerCount((ScriptObject) obj) : 0; |
18855
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
203 |
} |
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
204 |
|
408663ef8f66
8020015: shared PropertyMaps should not be used without duplication
sundar
parents:
18851
diff
changeset
|
205 |
/** |
16147 | 206 |
* Dump all Nashorn debug mode counters. Calling this may be better if |
207 |
* you want to print all counters. This way you can avoid too many callsites |
|
208 |
* due to counter access itself!! |
|
209 |
* @param self self reference |
|
210 |
* @return undefined |
|
211 |
*/ |
|
212 |
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) |
|
213 |
public static Object dumpCounters(final Object self) { |
|
16185 | 214 |
final PrintWriter out = Context.getCurrentErr(); |
16155
a8ab83cbaa49
8005788: Loggers and their corresponding system properties not working correctly
lagergren
parents:
16151
diff
changeset
|
215 |
|
16147 | 216 |
out.println("ScriptObject count " + ScriptObject.getCount()); |
217 |
out.println("Scope count " + ScriptObject.getScopeCount()); |
|
23084
6c5c02d1023a
8035948: Redesign property listeners for shared classes
hannesw
parents:
19459
diff
changeset
|
218 |
out.println("ScriptObject listeners added " + PropertyListeners.getListenersAdded()); |
6c5c02d1023a
8035948: Redesign property listeners for shared classes
hannesw
parents:
19459
diff
changeset
|
219 |
out.println("ScriptObject listeners removed " + PropertyListeners.getListenersRemoved()); |
18618
136279c4cbe6
8019157: Avoid calling ScriptObject.setProto() if possible
hannesw
parents:
17524
diff
changeset
|
220 |
out.println("ScriptFunction constructor calls " + ScriptFunction.getConstructorCount()); |
16147 | 221 |
out.println("ScriptFunction invokes " + ScriptFunction.getInvokes()); |
222 |
out.println("ScriptFunction allocations " + ScriptFunction.getAllocations()); |
|
223 |
out.println("PropertyMap count " + PropertyMap.getCount()); |
|
224 |
out.println("PropertyMap cloned " + PropertyMap.getClonedCount()); |
|
225 |
out.println("PropertyMap history hit " + PropertyMap.getHistoryHit()); |
|
226 |
out.println("PropertyMap proto invalidations " + PropertyMap.getProtoInvalidations()); |
|
227 |
out.println("PropertyMap proto history hit " + PropertyMap.getProtoHistoryHit()); |
|
228 |
out.println("PropertyMap setProtoNewMapCount " + PropertyMap.getSetProtoNewMapCount()); |
|
229 |
out.println("Callsite count " + LinkerCallSite.getCount()); |
|
230 |
out.println("Callsite misses " + LinkerCallSite.getMissCount()); |
|
231 |
out.println("Callsite misses by site at " + LinkerCallSite.getMissSamplingPercentage() + "%"); |
|
16155
a8ab83cbaa49
8005788: Loggers and their corresponding system properties not working correctly
lagergren
parents:
16151
diff
changeset
|
232 |
|
16147 | 233 |
LinkerCallSite.getMissCounts(out); |
16155
a8ab83cbaa49
8005788: Loggers and their corresponding system properties not working correctly
lagergren
parents:
16151
diff
changeset
|
234 |
|
16147 | 235 |
return UNDEFINED; |
236 |
} |
|
24731
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
237 |
|
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
238 |
/* |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
239 |
* Framework for logging runtime events |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
240 |
*/ |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
241 |
|
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
242 |
private static final String EVENT_QUEUE = "__eventQueue__"; |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
243 |
private static final String EVENT_QUEUE_CAPACITY = "__eventQueueCapacity__"; |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
244 |
|
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
245 |
/** |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
246 |
* Get the capacity of the event queue |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
247 |
* @param self self reference |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
248 |
* @return capacity of event queue as an integer |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
249 |
*/ |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
250 |
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
251 |
public static Object getEventQueueCapacity(final Object self) { |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
252 |
final ScriptObject sobj = (ScriptObject)self; |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
253 |
Integer cap; |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
254 |
if (sobj.has(EVENT_QUEUE_CAPACITY)) { |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
255 |
cap = JSType.toInt32(sobj.get(EVENT_QUEUE_CAPACITY)); |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
256 |
} else { |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
257 |
setEventQueueCapacity(self, cap = RuntimeEvent.RUNTIME_EVENT_QUEUE_SIZE); |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
258 |
} |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
259 |
return cap; |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
260 |
} |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
261 |
|
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
262 |
/** |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
263 |
* Set the event queue capacity |
26886
18c744ab4df2
8059211: Changed ArrayData.length accessor to use the protected field and fixed javadoc warnings related to this
lagergren
parents:
26765
diff
changeset
|
264 |
* @param self an event queue |
18c744ab4df2
8059211: Changed ArrayData.length accessor to use the protected field and fixed javadoc warnings related to this
lagergren
parents:
26765
diff
changeset
|
265 |
* @param newCapacity new capacity |
24731
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
266 |
*/ |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
267 |
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
268 |
public static void setEventQueueCapacity(final Object self, final Object newCapacity) { |
26765
97501edd2979
8047764: Indexed or polymorphic set on global affects Object.prototype
hannesw
parents:
25865
diff
changeset
|
269 |
((ScriptObject)self).set(EVENT_QUEUE_CAPACITY, newCapacity, NashornCallSiteDescriptor.CALLSITE_STRICT); |
24731
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
270 |
} |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
271 |
|
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
272 |
/** |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
273 |
* Add a runtime event to the runtime event queue. The queue has a fixed |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
274 |
* size {@link RuntimeEvent#RUNTIME_EVENT_QUEUE_SIZE} and the oldest |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
275 |
* entry will be thrown out of the queue is about to overflow |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
276 |
* @param self self reference |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
277 |
* @param event event to add |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
278 |
*/ |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
279 |
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
280 |
public static void addRuntimeEvent(final Object self, final Object event) { |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
281 |
final LinkedList<RuntimeEvent<?>> q = getEventQueue(self); |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
282 |
final int cap = (Integer)getEventQueueCapacity(self); |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
283 |
while (q.size() >= cap) { |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
284 |
q.removeFirst(); |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
285 |
} |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
286 |
q.addLast(getEvent(event)); |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
287 |
} |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
288 |
|
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
289 |
/** |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
290 |
* Expands the event queue capacity, or truncates if capacity is lower than |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
291 |
* current capacity. Then only the newest entries are kept |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
292 |
* @param self self reference |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
293 |
* @param newCapacity new capacity |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
294 |
*/ |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
295 |
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
296 |
public static void expandEventQueueCapacity(final Object self, final Object newCapacity) { |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
297 |
final LinkedList<RuntimeEvent<?>> q = getEventQueue(self); |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
298 |
final int nc = JSType.toInt32(newCapacity); |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
299 |
while (q.size() > nc) { |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
300 |
q.removeFirst(); |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
301 |
} |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
302 |
setEventQueueCapacity(self, nc); |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
303 |
} |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
304 |
|
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
305 |
/** |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
306 |
* Clear the runtime event queue |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
307 |
* @param self self reference |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
308 |
*/ |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
309 |
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
310 |
public static void clearRuntimeEvents(final Object self) { |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
311 |
final LinkedList<RuntimeEvent<?>> q = getEventQueue(self); |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
312 |
q.clear(); |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
313 |
} |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
314 |
|
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
315 |
/** |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
316 |
* Remove a specific runtime event from the event queue |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
317 |
* @param self self reference |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
318 |
* @param event event to remove |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
319 |
*/ |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
320 |
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
321 |
public static void removeRuntimeEvent(final Object self, final Object event) { |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
322 |
final LinkedList<RuntimeEvent<?>> q = getEventQueue(self); |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
323 |
final RuntimeEvent<?> re = getEvent(event); |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
324 |
if (!q.remove(re)) { |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
325 |
throw new IllegalStateException("runtime event " + re + " was not in event queue"); |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
326 |
} |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
327 |
} |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
328 |
|
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
329 |
/** |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
330 |
* Return all runtime events in the queue as an array |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
331 |
* @param self self reference |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
332 |
* @return array of events |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
333 |
*/ |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
334 |
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) |
24769 | 335 |
public static Object getRuntimeEvents(final Object self) { |
24731
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
336 |
final LinkedList<RuntimeEvent<?>> q = getEventQueue(self); |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
337 |
return q.toArray(new RuntimeEvent<?>[q.size()]); |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
338 |
} |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
339 |
|
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
340 |
/** |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
341 |
* Return the last runtime event in the queue |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
342 |
* @param self self reference |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
343 |
* @return the freshest event, null if queue is empty |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
344 |
*/ |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
345 |
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) |
24769 | 346 |
public static Object getLastRuntimeEvent(final Object self) { |
24731
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
347 |
final LinkedList<RuntimeEvent<?>> q = getEventQueue(self); |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
348 |
return q.isEmpty() ? null : q.getLast(); |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
349 |
} |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
350 |
|
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
351 |
@SuppressWarnings("unchecked") |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
352 |
private static LinkedList<RuntimeEvent<?>> getEventQueue(final Object self) { |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
353 |
final ScriptObject sobj = (ScriptObject)self; |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
354 |
LinkedList<RuntimeEvent<?>> q; |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
355 |
if (sobj.has(EVENT_QUEUE)) { |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
356 |
q = (LinkedList<RuntimeEvent<?>>)((ScriptObject)self).get(EVENT_QUEUE); |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
357 |
} else { |
26765
97501edd2979
8047764: Indexed or polymorphic set on global affects Object.prototype
hannesw
parents:
25865
diff
changeset
|
358 |
((ScriptObject)self).set(EVENT_QUEUE, q = new LinkedList<>(), NashornCallSiteDescriptor.CALLSITE_STRICT); |
24731
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
359 |
} |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
360 |
return q; |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
361 |
} |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
362 |
|
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
363 |
private static RuntimeEvent<?> getEvent(final Object event) { |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
364 |
return (RuntimeEvent<?>)event; |
ab0c8fc915ae
8038406: Testability: as a first step of moving loggers away from the process global space, the Debug object now supports logging POJOs from log entries as an event queue, which can be introspected from test scripts. This is way better than screen scraping brittle and subject-to-change log output.
lagergren
parents:
24727
diff
changeset
|
365 |
} |
16147 | 366 |
} |