### Question:
LogManagerProperties extends Properties { static boolean isStaticUtilityClass(String name) throws Exception { final Class<?> c = findClass(name); final Class<?> obj = Object.class; Method[] methods; boolean util; if (c != obj && (methods = c.getMethods()).length != 0) { util = true; for (Method m : methods) { if (m.getDeclaringClass() != obj && !Modifier.isStatic(m.getModifiers())) { util = false; break; } } } else { util = false; } return util; } LogManagerProperties(final Properties parent, final String prefix); @Override @SuppressWarnings("CloneDoesntCallSuperClone") synchronized Object clone(); @Override synchronized String getProperty(final String key); @Override String getProperty(final String key, final String def); @Override synchronized Object get(final Object key); @Override synchronized Object put(final Object key, final Object value); @Override Object setProperty(String key, String value); @Override synchronized boolean containsKey(final Object key); @Override synchronized Object remove(final Object key); @Override Enumeration<?> propertyNames(); @Override boolean equals(final Object o); @Override int hashCode();  }### Answer:
@Test public void testIsStaticUtilityClass() throws Exception { boolean nullCheck; try { LogManagerProperties.isStaticUtilityClass((String) null); nullCheck = false; } catch (NullPointerException expect) { nullCheck = true; } if (!nullCheck) { fail("Null check"); } String[] utils = { "java.lang.System", "java.nio.channels.Channels", "java.util.Collections", "jakarta.mail.internet.MimeUtility", "org.junit.Assert" }; testIsStaticUtilityClass(utils, true); String[] obj = { "java.lang.Exception", "java.lang.Object", "java.lang.Runtime", "java.io.Serializable" }; testIsStaticUtilityClass(obj, false); String[] enumerations = { "java.util.concurrent.TimeUnit" }; testIsStaticUtilityClass(enumerations, false); String[] fail = { "badClassName" }; for (String name : fail) { boolean pass; try { LogManagerProperties.isStaticUtilityClass(name); pass = false; } catch (ClassNotFoundException expect) { pass = true; } if (!pass) { fail(name); } } }
@Test public void testIsStaticUtilityClass() throws Exception { boolean nullCheck; try { LogManagerProperties.isStaticUtilityClass((String) null); nullCheck = false; } catch (NullPointerException expect) { nullCheck = true; } if (!nullCheck) { fail("Null check"); } String[] utils = { "java.lang.System", "java.nio.channels.Channels", "java.util.Collections", "javax.mail.internet.MimeUtility", "org.junit.Assert" }; testIsStaticUtilityClass(utils, true); String[] obj = { "java.lang.Exception", "java.lang.Object", "java.lang.Runtime", "java.io.Serializable" }; testIsStaticUtilityClass(obj, false); String[] enumerations = { "java.util.concurrent.TimeUnit" }; testIsStaticUtilityClass(enumerations, false); String[] fail = { "badClassName" }; for (String name : fail) { boolean pass; try { LogManagerProperties.isStaticUtilityClass(name); pass = false; } catch (ClassNotFoundException expect) { pass = true; } if (!pass) { fail(name); } } }