0
|
1 /*
|
|
2 * Copyright 2002-2005 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 *
|
|
5 * This code is free software; you can redistribute it and/or modify it
|
|
6 * under the terms of the GNU General Public License version 2 only, as
|
|
7 * published by the Free Software Foundation.
|
|
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 *
|
|
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 * CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 * have any questions.
|
|
22 *
|
|
23 */
|
|
24
|
|
25 package sun.jvm.hotspot.types.basic;
|
|
26
|
|
27 import java.util.*;
|
|
28
|
|
29 import sun.jvm.hotspot.debugger.*;
|
|
30 import sun.jvm.hotspot.types.*;
|
|
31
|
|
32 public abstract class BasicVtblAccess implements VtblAccess {
|
|
33 protected SymbolLookup symbolLookup;
|
|
34 protected String[] dllNames;
|
|
35
|
|
36 private Map typeToVtblMap = new HashMap();
|
|
37
|
|
38 public BasicVtblAccess(SymbolLookup symbolLookup,
|
|
39 String[] dllNames) {
|
|
40 this.symbolLookup = symbolLookup;
|
|
41 this.dllNames = dllNames;
|
|
42 }
|
|
43
|
|
44 static Object nullAddress = new Object();
|
|
45
|
|
46 public Address getVtblForType(Type type) {
|
|
47 if (type == null) {
|
|
48 return null;
|
|
49 }
|
|
50 Object result = typeToVtblMap.get(type);
|
|
51 if (result == nullAddress) {
|
|
52 return null;
|
|
53 }
|
|
54 if (result != null) {
|
|
55 return (Address)result;
|
|
56 }
|
|
57 String vtblSymbol = vtblSymbolForType(type);
|
|
58 if (vtblSymbol == null) {
|
|
59 typeToVtblMap.put(type, nullAddress);
|
|
60 return null;
|
|
61 }
|
|
62 for (int i = 0; i < dllNames.length; i++) {
|
|
63 Address addr = symbolLookup.lookup(dllNames[i], vtblSymbol);
|
|
64 if (addr != null) {
|
|
65 typeToVtblMap.put(type, addr);
|
|
66 return addr;
|
|
67 }
|
|
68 }
|
|
69 typeToVtblMap.put(type, nullAddress);
|
|
70 return null;
|
|
71 }
|
|
72
|
|
73 public void clearCaches() {
|
|
74 typeToVtblMap.clear();
|
|
75 }
|
|
76
|
|
77 protected abstract String vtblSymbolForType(Type type);
|
|
78 }
|