public static boolean isMonomorphic(Class<?> targetType) {
    if (targetType.isArray()) {
      return isMonomorphic(targetType.getComponentType());
    }
    // Although enum itself can be non-final, but it's subclass can only be anonymous
    // inner class, which is final, and we serialize enum by value, which already
    // identify the actual class, so we can take enum as monomorphic.
    return targetType.isEnum() || Modifier.isFinal(targetType.getModifiers());
  }
@Test
  public void testMonomorphic() {
    Assert.assertTrue(ReflectionUtils.isMonomorphic(MonomorphicTestEnum1.class));
    Assert.assertTrue(ReflectionUtils.isMonomorphic(MonomorphicTestEnum2.class));
    Assert.assertTrue(ReflectionUtils.isMonomorphic(MonomorphicTestEnum1[].class));
    Assert.assertTrue(ReflectionUtils.isMonomorphic(MonomorphicTestEnum2[].class));
  }