Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/utilities/soql/JSMap.java @ 10343:6bd680e9ea35
8003421: NPG: Move oops out of InstanceKlass into mirror
Summary: Inject protection_domain, signers, init_lock into java_lang_Class
Reviewed-by: stefank, dholmes, sla
author | coleenp |
---|---|
date | Wed, 22 May 2013 14:37:49 -0400 |
parents | c18cbe5936b8 |
children |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
2 * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. |
0 | 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. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 package sun.jvm.hotspot.utilities.soql; | |
26 | |
27 import java.util.*; | |
28 import sun.jvm.hotspot.oops.*; | |
29 | |
30 /** | |
31 This is JavaScript wrapper for a Map. | |
32 */ | |
33 | |
34 public class JSMap extends DefaultScriptObject { | |
35 public JSMap(Map map, JSJavaFactory fac) { | |
36 this.map = map; | |
37 this.factory = fac; | |
38 } | |
39 | |
40 public Object get(String name) { | |
41 if (map.containsKey(name)) { | |
42 return wrapObject(map.get(name)); | |
43 } else { | |
44 return super.get(name); | |
45 } | |
46 } | |
47 | |
48 public Object[] getIds() { | |
49 Object[] superIds = super.getIds(); | |
50 Object[] tmp = map.keySet().toArray(); | |
51 Object[] res = new Object[superIds.length + tmp.length]; | |
52 System.arraycopy(tmp, 0, res, 0, tmp.length); | |
53 System.arraycopy(superIds, 0, res, tmp.length, superIds.length); | |
54 return res; | |
55 } | |
56 | |
57 public boolean has(String name) { | |
58 if (map.containsKey(name)) { | |
59 return true; | |
60 } else { | |
61 return super.has(name); | |
62 } | |
63 } | |
64 | |
65 public void put(String name, Object value) { | |
66 if (! map.containsKey(name)) { | |
67 super.put(name, value); | |
68 } | |
69 } | |
70 | |
71 public String toString() { | |
72 StringBuffer buf = new StringBuffer(); | |
73 Set keys = map.keySet(); | |
74 buf.append('{'); | |
75 for (Iterator itr = keys.iterator(); itr.hasNext();) { | |
76 Object key = itr.next(); | |
77 buf.append(key); | |
78 buf.append('='); | |
79 buf.append(wrapObject(map.get(key))); | |
80 if (itr.hasNext()) { | |
81 buf.append(", "); | |
82 } | |
83 } | |
84 buf.append('}'); | |
85 return buf.toString(); | |
86 } | |
87 | |
88 private Object wrapObject(Object obj) { | |
89 return factory.newJSJavaWrapper(obj); | |
90 } | |
91 | |
92 private final Map map; | |
93 private final JSJavaFactory factory; | |
94 } |