Changeset 7401


Ignore:
Timestamp:
Aug 28, 2017, 2:46:43 PM (5 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #2095: Compile error with Eclipse Oxygen (Eclipse 4.7)

Location:
trunk/src/core/net/sf/basedb/util
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/util/ClassUtil.java

    r6875 r7401  
    106106
    107107 
    108   @SuppressWarnings("unchecked")
    109   public static <C> Class<? extends C> checkAndLoadClass(ClassLoader loader, String name,
    110     boolean publicNoArgConstructor, Class<C> iface, Class<?>... interfaces)
    111     throws ClassNotFoundException, NoSuchMethodException, ClassCastException
    112   {
    113     if (loader == null) loader = ClassUtil.class.getClassLoader();
    114     Class<?> clazz = loader.loadClass(name);
    115     checkClass(clazz, publicNoArgConstructor, iface);
    116     if (interfaces != null && interfaces.length > 0)
    117     {
    118       checkClass(clazz, publicNoArgConstructor, interfaces);
    119     }
    120     return (Class<? extends C>)clazz;
    121   }
    122  
    123  
    124108  /**
    125109    Check if a specified class exists and, optionally, if it has public no-argument
     
    139123    @since 2.5
    140124  */
    141   public static Class<?> checkAndLoadClass(ClassLoader loader, String name,
    142     boolean publicNoArgConstructor, Class<?>... interfaces)
     125  @SuppressWarnings("unchecked")
     126  public static <C> Class<? extends C> checkAndLoadClass(ClassLoader loader, String name,
     127    boolean publicNoArgConstructor, Class<C> iface, Class<?>... interfaces)
    143128    throws ClassNotFoundException, NoSuchMethodException, ClassCastException
    144129  {
    145130    if (loader == null) loader = ClassUtil.class.getClassLoader();
    146131    Class<?> clazz = loader.loadClass(name);
    147     checkClass(clazz, publicNoArgConstructor, interfaces);
    148     return clazz;
     132    checkClass(clazz, publicNoArgConstructor, iface);
     133    if (interfaces != null && interfaces.length > 0)
     134    {
     135      checkClass(clazz, publicNoArgConstructor, interfaces);
     136    }
     137    return (Class<? extends C>)clazz;
    149138  }
     139 
    150140 
    151141  /**
  • trunk/src/core/net/sf/basedb/util/overview/extensions/ReflectValidationRuleActionFactory.java

    r6875 r7401  
    8383      try
    8484      {
    85         Class<?> clazz = ClassUtil.checkAndLoadClass(context.getClassLoader(), clazzName, false);
     85        Class<?> clazz = ClassUtil.checkAndLoadClass(context.getClassLoader(), clazzName, false, null);
    8686        Field ruleField = clazz.getField(fieldName);
    8787        rule = (ValidationRuleAction)ruleField.get(null);
Note: See TracChangeset for help on using the changeset viewer.