01: /*
02: * @(#)JDKClassFactory.java 1.10 06/10/10
03: *
04: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: *
26: */
27:
28: package vm;
29:
30: import consts.Const;
31: import components.ConstantPool;
32: import components.ClassInfo;
33: import java.util.Hashtable;
34:
35: public class JDKClassFactory implements VMClassFactory {
36:
37: public ClassClass newVMClass(ClassInfo c) {
38: return new JDKClass(c);
39: }
40:
41: private static boolean setType(String name, int value) {
42: ClassInfo ci = ClassInfo.lookupClass(name);
43: ClassClass cc;
44: if ((ci == null) || ((cc = ci.vmClass) == null))
45: return false;
46: ((JDKClass) cc).typeCode = value;
47: return true;
48:
49: }
50:
51: public void setTypes() {
52: setType( /*NOI18N*/"java/lang/Void", Const.T_VOID);
53: setType( /*NOI18N*/"java/lang/Boolean", Const.T_BOOLEAN);
54: setType( /*NOI18N*/"java/lang/Character", Const.T_CHAR);
55: setType( /*NOI18N*/"java/lang/Byte", Const.T_BYTE);
56: setType( /*NOI18N*/"java/lang/Short", Const.T_SHORT);
57: setType( /*NOI18N*/"java/lang/Integer", Const.T_INT);
58: setType( /*NOI18N*/"java/lang/Long", Const.T_LONG);
59: setType( /*NOI18N*/"java/lang/Float", Const.T_FLOAT);
60: setType( /*NOI18N*/"java/lang/Double", Const.T_DOUBLE);
61: }
62:
63: public ConstantPool makeResolvable(ConstantPool cp,
64: Hashtable missingClasses) {
65: //
66: // we use a LocalConstantPool to manage the pool we're re-building.
67: // Because order matters, we collect the new entries to add at end.
68: //
69: System.err
70: .println(Localizer
71: .getString("classclass.warning_it_has_an_impure_shared_constant_pool"));
72: return JDKClass.makeResolvable(cp.getConstants(),
73: missingClasses);
74: }
75: }
|