nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeDebug.java
author lagergren
Fri, 26 Sep 2014 18:47:20 +0200
changeset 26886 18c744ab4df2
parent 26765 97501edd2979
child 27525 e7d3c00b9fb8
permissions -rw-r--r--
8059211: Changed ArrayData.length accessor to use the protected field and fixed javadoc warnings related to this Reviewed-by: attila, hannesw
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     1
/*
16151
97c1e756ae1e 8005663: Update copyright year to 2013
jlaskey
parents: 16147
diff changeset
     2
 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     4
 *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    10
 *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    15
 * accompanied this code).
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    16
 *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    20
 *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    23
 * questions.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    24
 */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    25
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    26
package jdk.nashorn.internal.objects;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    27
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    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
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    31
import java.util.Objects;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    32
import jdk.nashorn.internal.objects.annotations.Attribute;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    33
import jdk.nashorn.internal.objects.annotations.Function;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    34
import jdk.nashorn.internal.objects.annotations.ScriptClass;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    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
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    39
import jdk.nashorn.internal.runtime.PropertyMap;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    40
import jdk.nashorn.internal.runtime.ScriptFunction;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    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
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    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
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    45
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    46
/**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    47
 * Nashorn specific debug utils. This is meant for Nashorn developers.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    48
 * The interface is subject to change without notice!!
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    49
 *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    50
 */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    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
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    61
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    62
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    63
    @Override
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    64
    public String getClassName() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    65
        return "Debug";
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    66
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    67
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    68
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    69
     * Nashorn extension: get context, context utility
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    70
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    71
     * @param self self reference
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    72
     * @return context
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    73
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    74
    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    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
79e75274df99 8022707: Revisit all doPrivileged blocks
sundar
parents: 18865
diff changeset
    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
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    80
        return Global.getThisContext();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    81
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    82
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    83
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    84
     * Nashorn extension: get map from {@link ScriptObject}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    85
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    86
     * @param self self reference
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    87
     * @param obj script object
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    88
     * @return the map for the current ScriptObject
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    89
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    90
    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    91
    public static Object map(final Object self, final Object obj) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    92
        if (obj instanceof ScriptObject) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    93
            return ((ScriptObject)obj).getMap();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    94
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    95
        return UNDEFINED;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    96
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    97
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    98
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    99
     * Check object identity comparison regardless of type
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   100
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   101
     * @param self self reference
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   102
     * @param obj1 first object in comparison
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   103
     * @param obj2 second object in comparison
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   104
     * @return true if reference identity
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   105
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   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
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   108
        return obj1 == obj2;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   109
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   110
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   111
    /**
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 19459
diff changeset
   112
     * Returns true if if the two objects are both property maps, and they have identical properties in the same order,
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 19459
diff changeset
   113
     * but allows the properties to differ in their types.
24720
75f8388b79df 8035836: Array performance improvements
lagergren
parents: 24719
diff changeset
   114
     * @param self self
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 19459
diff changeset
   115
     * @param m1 first property map
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 19459
diff changeset
   116
     * @param m2 second property map
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 19459
diff changeset
   117
     * @return true if they have identical properties in same order, with possibly different types.
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 19459
diff changeset
   118
     */
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 19459
diff changeset
   119
    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 19459
diff changeset
   120
    public static Object equalWithoutType(final Object self, final Object m1, final Object m2) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 19459
diff changeset
   121
        return ((PropertyMap)m1).equalsWithoutType((PropertyMap)m2);
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 19459
diff changeset
   122
    }
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 19459
diff changeset
   123
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 19459
diff changeset
   124
    /**
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 19459
diff changeset
   125
     * Returns a diagnostic string representing the difference of two property maps.
24720
75f8388b79df 8035836: Array performance improvements
lagergren
parents: 24719
diff changeset
   126
     * @param self self
24719
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 19459
diff changeset
   127
     * @param m1 first property map
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 19459
diff changeset
   128
     * @param m2 second property map
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 19459
diff changeset
   129
     * @return a diagnostic string representing the difference of two property maps.
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 19459
diff changeset
   130
     */
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 19459
diff changeset
   131
    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 19459
diff changeset
   132
    public static Object diffPropertyMaps(final Object self, final Object m1, final Object m2) {
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 19459
diff changeset
   133
        return PropertyMap.diff((PropertyMap)m1, (PropertyMap)m2);
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 19459
diff changeset
   134
    }
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 19459
diff changeset
   135
f726e9d67629 8035820: Optimistic recompilation
attila
parents: 19459
diff changeset
   136
    /**
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   137
     * Object util - getClass
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   138
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   139
     * @param self self reference
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   140
     * @param obj  object
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   141
     * @return class of {@code obj}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   142
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   143
    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   144
    public static Object getClass(final Object self, final Object obj) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   145
        if (obj != null) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   146
            return obj.getClass();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   147
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   148
        return UNDEFINED;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   149
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   150
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   151
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   152
     * Object util - equals
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   153
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   154
     * @param self self reference
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   155
     * @param obj1 first object in comparison
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   156
     * @param obj2 second object in comparison
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   157
     * @return return {@link Object#equals(Object)} for objects.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   158
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   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
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   162
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   163
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   164
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   165
     * Object util - toJavaString
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   166
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   167
     * @param self self reference
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   168
     * @param obj  object to represent as a string
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   169
     * @return Java string representation of {@code obj}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   170
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   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
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   173
        return Objects.toString(obj);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   174
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   175
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   176
    /**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   177
     * Do not call overridden toString -- use default toString impl
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   178
     *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   179
     * @param self self reference
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   180
     * @param obj  object to represent as a string
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   181
     * @return string representation
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   182
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   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
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   185
        if (obj == null) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   186
            return "null";
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   187
        }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   188
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   189
        final int hash = System.identityHashCode(obj);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   190
        return obj.getClass() + "@" + Integer.toHexString(hash);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   191
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   192
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   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
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   206
     * Dump all Nashorn debug mode counters. Calling this may be better if
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   207
     * you want to print all counters. This way you can avoid too many callsites
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   208
     * due to counter access itself!!
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   209
     * @param self self reference
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   210
     * @return undefined
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   211
     */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   212
    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   213
    public static Object dumpCounters(final Object self) {
16185
893aabe8c800 8006635: Reduce access levels as much as possible
sundar
parents: 16155
diff changeset
   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
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   216
        out.println("ScriptObject count " + ScriptObject.getCount());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   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
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   221
        out.println("ScriptFunction invokes " + ScriptFunction.getInvokes());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   222
        out.println("ScriptFunction allocations " + ScriptFunction.getAllocations());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   223
        out.println("PropertyMap count " + PropertyMap.getCount());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   224
        out.println("PropertyMap cloned " + PropertyMap.getClonedCount());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   225
        out.println("PropertyMap history hit " + PropertyMap.getHistoryHit());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   226
        out.println("PropertyMap proto invalidations " + PropertyMap.getProtoInvalidations());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   227
        out.println("PropertyMap proto history hit " + PropertyMap.getProtoHistoryHit());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   228
        out.println("PropertyMap setProtoNewMapCount " + PropertyMap.getSetProtoNewMapCount());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   229
        out.println("Callsite count " + LinkerCallSite.getCount());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   230
        out.println("Callsite misses " + LinkerCallSite.getMissCount());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   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
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   233
        LinkerCallSite.getMissCounts(out);
16155
a8ab83cbaa49 8005788: Loggers and their corresponding system properties not working correctly
lagergren
parents: 16151
diff changeset
   234
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   235
        return UNDEFINED;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   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
attila
parents: 24742 23763
diff changeset
   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
attila
parents: 24742 23763
diff changeset
   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
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   366
}