58 case FIELD_BUILD_INFO:
59 return vm.getVMInternalInfo();
60 case FIELD_CPU:
61 return vm.getCPU();
62 case FIELD_FLAGS:
63 return getFlags();
64 case FIELD_HEAP:
65 return getHeap();
66 case FIELD_OS:
67 return vm.getOS();
68 case FIELD_SYS_PROPS:
69 return getSysProps();
70 case FIELD_THREADS:
71 return getThreads();
72 case FIELD_TYPE:
73 return getType();
74 case FIELD_VERSION:
75 return vm.getVMRelease();
76 case FIELD_CLASS_PATH:
77 return getClassPath();
78 case FIELD_BOOT_CLASS_PATH:
79 return getBootClassPath();
80 case FIELD_USER_DIR:
81 return getUserDir();
82 case FIELD_UNDEFINED:
83 default:
84 return super.get(name);
85 }
86 }
87
88 public Object[] getIds() {
89 Object[] superIds = super.getIds();
90 Object[] tmp = fields.keySet().toArray();
91 Object[] res = new Object[superIds.length + tmp.length];
92 System.arraycopy(tmp, 0, res, 0, tmp.length);
93 System.arraycopy(superIds, 0, res, tmp.length, superIds.length);
94 return res;
95 }
96
97 public boolean has(String name) {
98 if (getFieldID(name) != FIELD_UNDEFINED) {
99 return true;
126 fields.put(name, new Integer(fieldId));
127 }
128
129 private static int getFieldID(String name) {
130 Integer res = (Integer) fields.get(name);
131 return (res != null)? res.intValue() : FIELD_UNDEFINED;
132 }
133
134 static {
135 addField("addressSize", FIELD_ADDRESS_SIZE);
136 addField("buildInfo", FIELD_BUILD_INFO);
137 addField("cpu", FIELD_CPU);
138 addField("flags", FIELD_FLAGS);
139 addField("heap", FIELD_HEAP);
140 addField("os", FIELD_OS);
141 addField("sysProps", FIELD_SYS_PROPS);
142 addField("threads", FIELD_THREADS);
143 addField("type", FIELD_TYPE);
144 addField("version", FIELD_VERSION);
145 addField("classPath", FIELD_CLASS_PATH);
146 addField("bootClassPath", FIELD_BOOT_CLASS_PATH);
147 addField("userDir", FIELD_USER_DIR);
148 }
149
150 private long getVMBit() {
151 // address size in bits
152 return vm.getAddressSize() * 8;
153 }
154
155 private synchronized JSMap getFlags() {
156 if (flagsCache == null) {
157 VM.Flag[] flags = vm.getCommandLineFlags();
158 Map map = new HashMap();
159 if (flags != null) {
160 for (int f = 0; f < flags.length; f++) {
161 VM.Flag flag = flags[f];
162 map.put(flag.getName(), flag.getValue());
163 }
164 }
165 flagsCache = factory.newJSMap(map);
166 }
198 while (jthread != null) {
199 threads.add(jthread);
200 jthread = jthread.next();
201 }
202 }
203 return threadsCache;
204 }
205
206 private String getType() {
207 if (vm.isClientCompiler()) {
208 return "Client";
209 } else if (vm.isServerCompiler()) {
210 return "Server";
211 } else {
212 return "Core";
213 }
214 }
215
216 private String getClassPath() {
217 return vm.getSystemProperty("java.class.path");
218 }
219
220 private String getBootClassPath() {
221 return vm.getSystemProperty("sun.boot.class.path");
222 }
223
224 private String getUserDir() {
225 return vm.getSystemProperty("user.dir");
226 }
227
228 private JSMap flagsCache;
229 private JSJavaHeap heapCache;
230 private JSMap sysPropsCache;
231 private JSList threadsCache;
232 private final JSJavaFactory factory;
233 private final VM vm;
234 }
|
58 case FIELD_BUILD_INFO:
59 return vm.getVMInternalInfo();
60 case FIELD_CPU:
61 return vm.getCPU();
62 case FIELD_FLAGS:
63 return getFlags();
64 case FIELD_HEAP:
65 return getHeap();
66 case FIELD_OS:
67 return vm.getOS();
68 case FIELD_SYS_PROPS:
69 return getSysProps();
70 case FIELD_THREADS:
71 return getThreads();
72 case FIELD_TYPE:
73 return getType();
74 case FIELD_VERSION:
75 return vm.getVMRelease();
76 case FIELD_CLASS_PATH:
77 return getClassPath();
78 case FIELD_USER_DIR:
79 return getUserDir();
80 case FIELD_UNDEFINED:
81 default:
82 return super.get(name);
83 }
84 }
85
86 public Object[] getIds() {
87 Object[] superIds = super.getIds();
88 Object[] tmp = fields.keySet().toArray();
89 Object[] res = new Object[superIds.length + tmp.length];
90 System.arraycopy(tmp, 0, res, 0, tmp.length);
91 System.arraycopy(superIds, 0, res, tmp.length, superIds.length);
92 return res;
93 }
94
95 public boolean has(String name) {
96 if (getFieldID(name) != FIELD_UNDEFINED) {
97 return true;
124 fields.put(name, new Integer(fieldId));
125 }
126
127 private static int getFieldID(String name) {
128 Integer res = (Integer) fields.get(name);
129 return (res != null)? res.intValue() : FIELD_UNDEFINED;
130 }
131
132 static {
133 addField("addressSize", FIELD_ADDRESS_SIZE);
134 addField("buildInfo", FIELD_BUILD_INFO);
135 addField("cpu", FIELD_CPU);
136 addField("flags", FIELD_FLAGS);
137 addField("heap", FIELD_HEAP);
138 addField("os", FIELD_OS);
139 addField("sysProps", FIELD_SYS_PROPS);
140 addField("threads", FIELD_THREADS);
141 addField("type", FIELD_TYPE);
142 addField("version", FIELD_VERSION);
143 addField("classPath", FIELD_CLASS_PATH);
144 addField("userDir", FIELD_USER_DIR);
145 }
146
147 private long getVMBit() {
148 // address size in bits
149 return vm.getAddressSize() * 8;
150 }
151
152 private synchronized JSMap getFlags() {
153 if (flagsCache == null) {
154 VM.Flag[] flags = vm.getCommandLineFlags();
155 Map map = new HashMap();
156 if (flags != null) {
157 for (int f = 0; f < flags.length; f++) {
158 VM.Flag flag = flags[f];
159 map.put(flag.getName(), flag.getValue());
160 }
161 }
162 flagsCache = factory.newJSMap(map);
163 }
195 while (jthread != null) {
196 threads.add(jthread);
197 jthread = jthread.next();
198 }
199 }
200 return threadsCache;
201 }
202
203 private String getType() {
204 if (vm.isClientCompiler()) {
205 return "Client";
206 } else if (vm.isServerCompiler()) {
207 return "Server";
208 } else {
209 return "Core";
210 }
211 }
212
213 private String getClassPath() {
214 return vm.getSystemProperty("java.class.path");
215 }
216
217 private String getUserDir() {
218 return vm.getSystemProperty("user.dir");
219 }
220
221 private JSMap flagsCache;
222 private JSJavaHeap heapCache;
223 private JSMap sysPropsCache;
224 private JSList threadsCache;
225 private final JSJavaFactory factory;
226 private final VM vm;
227 }
|