equal
deleted
inserted
replaced
74 try { |
74 try { |
75 Class cl = Class.forName("com.sun.management.GcInfo"); |
75 Class cl = Class.forName("com.sun.management.GcInfo"); |
76 Field f = cl.getDeclaredField("builder"); |
76 Field f = cl.getDeclaredField("builder"); |
77 f.setAccessible(true); |
77 f.setAccessible(true); |
78 return (GcInfoBuilder)f.get(info); |
78 return (GcInfoBuilder)f.get(info); |
79 } catch(ClassNotFoundException e) { |
79 } catch(ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) { |
80 return null; |
|
81 } catch(NoSuchFieldException e) { |
|
82 return null; |
|
83 } catch(IllegalAccessException e) { |
|
84 return null; |
80 return null; |
85 } |
81 } |
86 } |
82 } |
87 }); |
83 }); |
88 final Object[] extAttr = AccessController.doPrivileged (new PrivilegedAction<Object[]>() { |
84 final Object[] extAttr = AccessController.doPrivileged (new PrivilegedAction<Object[]>() { |
90 try { |
86 try { |
91 Class cl = Class.forName("com.sun.management.GcInfo"); |
87 Class cl = Class.forName("com.sun.management.GcInfo"); |
92 Field f = cl.getDeclaredField("extAttributes"); |
88 Field f = cl.getDeclaredField("extAttributes"); |
93 f.setAccessible(true); |
89 f.setAccessible(true); |
94 return (Object[])f.get(info); |
90 return (Object[])f.get(info); |
95 } catch(ClassNotFoundException e) { |
91 } catch(ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) { |
96 return null; |
|
97 } catch(NoSuchFieldException e) { |
|
98 return null; |
|
99 } catch(IllegalAccessException e) { |
|
100 return null; |
92 return null; |
101 } |
93 } |
102 } |
94 } |
103 }); |
95 }); |
104 GcInfoCompositeData gcicd = |
96 GcInfoCompositeData gcicd = |
178 static { |
170 static { |
179 try { |
171 try { |
180 Method m = GcInfo.class.getMethod("getMemoryUsageBeforeGc"); |
172 Method m = GcInfo.class.getMethod("getMemoryUsageBeforeGc"); |
181 memoryUsageMapType = |
173 memoryUsageMapType = |
182 MappedMXBeanType.getMappedType(m.getGenericReturnType()); |
174 MappedMXBeanType.getMappedType(m.getGenericReturnType()); |
183 } catch (NoSuchMethodException e) { |
175 } catch (NoSuchMethodException | OpenDataException e) { |
184 // Should never reach here |
|
185 throw new AssertionError(e); |
|
186 } catch (OpenDataException e) { |
|
187 // Should never reach here |
176 // Should never reach here |
188 throw new AssertionError(e); |
177 throw new AssertionError(e); |
189 } |
178 } |
190 } |
179 } |
191 |
180 |
195 |
184 |
196 private static OpenType[] baseGcInfoItemTypes = null; |
185 private static OpenType[] baseGcInfoItemTypes = null; |
197 static synchronized OpenType[] getBaseGcInfoItemTypes() { |
186 static synchronized OpenType[] getBaseGcInfoItemTypes() { |
198 if (baseGcInfoItemTypes == null) { |
187 if (baseGcInfoItemTypes == null) { |
199 OpenType<?> memoryUsageOpenType = memoryUsageMapType.getOpenType(); |
188 OpenType<?> memoryUsageOpenType = memoryUsageMapType.getOpenType(); |
200 baseGcInfoItemTypes = new OpenType[] { |
189 baseGcInfoItemTypes = new OpenType<?>[] { |
201 SimpleType.LONG, |
190 SimpleType.LONG, |
202 SimpleType.LONG, |
191 SimpleType.LONG, |
203 SimpleType.LONG, |
192 SimpleType.LONG, |
204 SimpleType.LONG, |
193 SimpleType.LONG, |
205 |
194 |
223 public static Map<String, MemoryUsage> |
212 public static Map<String, MemoryUsage> |
224 getMemoryUsageBeforeGc(CompositeData cd) { |
213 getMemoryUsageBeforeGc(CompositeData cd) { |
225 try { |
214 try { |
226 TabularData td = (TabularData) cd.get(MEMORY_USAGE_BEFORE_GC); |
215 TabularData td = (TabularData) cd.get(MEMORY_USAGE_BEFORE_GC); |
227 return cast(memoryUsageMapType.toJavaTypeData(td)); |
216 return cast(memoryUsageMapType.toJavaTypeData(td)); |
228 } catch (InvalidObjectException e) { |
217 } catch (InvalidObjectException | OpenDataException e) { |
229 // Should never reach here |
|
230 throw new AssertionError(e); |
|
231 } catch (OpenDataException e) { |
|
232 // Should never reach here |
218 // Should never reach here |
233 throw new AssertionError(e); |
219 throw new AssertionError(e); |
234 } |
220 } |
235 } |
221 } |
236 |
222 |
242 getMemoryUsageAfterGc(CompositeData cd) { |
228 getMemoryUsageAfterGc(CompositeData cd) { |
243 try { |
229 try { |
244 TabularData td = (TabularData) cd.get(MEMORY_USAGE_AFTER_GC); |
230 TabularData td = (TabularData) cd.get(MEMORY_USAGE_AFTER_GC); |
245 //return (Map<String,MemoryUsage>) |
231 //return (Map<String,MemoryUsage>) |
246 return cast(memoryUsageMapType.toJavaTypeData(td)); |
232 return cast(memoryUsageMapType.toJavaTypeData(td)); |
247 } catch (InvalidObjectException e) { |
233 } catch (InvalidObjectException | OpenDataException e) { |
248 // Should never reach here |
|
249 throw new AssertionError(e); |
|
250 } catch (OpenDataException e) { |
|
251 // Should never reach here |
234 // Should never reach here |
252 throw new AssertionError(e); |
235 throw new AssertionError(e); |
253 } |
236 } |
254 } |
237 } |
255 |
238 |