admin@glassfish.java.net

Re: trying to use method.invoke() on MXBean

From: Lloyd Chambers <Lloyd.Chambers_at_Sun.COM>
Date: Thu, 04 Sep 2008 16:40:00 -0700

Jennifer,

Why are you introspecting the method?

java.lang.management.ClassLoadingMXBean clBean =
ManagementFactory.getClassLoadingMXBean();
int count = clBean.getLoadedClassCount();

?

Lloyd



On Sep 4, 2008, at 4:17 PM, Jennifer Chou wrote:

> Hi,
>
> I'm trying use method.invoke(..) on the MXBeans but I'm getting
> IllegalAccessException on some but not all the MXBeans. Anybody
> know why? And how to get around this problem?
>
> java.lang.management.ClassLoadingMXBean clBean =
> ManagementFactory.getClassLoadingMXBean();
> java.lang.reflect.Method method =
> clBean.getClass().getMethod("getLoadedClassCount", (Class[]) null);
> method.invoke(clBean, (Object[]) null);
>
> These get IllegalAccessException:
> ClassLoadingMXBean
> CompilationMXBean
> GarbageCollectorMXBean
> MemoryMXBean
> MemoryMXBean
>
> These allow me to use method.invoke():
> OperatingSystemMXBean
> MemoryUsage
>
> Jennifer
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: admin-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: admin-help_at_glassfish.dev.java.net
>