Changeset 7517


Ignore:
Timestamp:
Nov 2, 2018, 11:25:05 AM (3 years ago)
Author:
Nicklas Nordborg
Message:

References #2129: Preparations for Java 11 support

Get rid of some more warnings warnings related to Class.newInstance().

Location:
trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/jobagent/net/sf/basedb/clients/jobagent/Agent.java

    r6898 r7517  
    538538        try
    539539        {
    540           handler = clazz.newInstance();
     540          handler = clazz.getDeclaredConstructor().newInstance();
    541541          handler.init(this);
    542542          created.put(clazz, handler);
     
    10791079    try
    10801080    {
    1081       executor = executorClass.newInstance();
     1081      executor = executorClass.getDeclaredConstructor().newInstance();
    10821082      executor.init(this);
    10831083    }
     
    11231123    try
    11241124    {
    1125       manager = slotManagerClass.newInstance();
     1125      manager = slotManagerClass.getDeclaredConstructor().newInstance();
    11261126      manager.init(this);
    11271127    }
  • trunk/src/clients/web/net/sf/basedb/clients/web/extensions/ServletWrapper.java

    r6898 r7517  
    2323
    2424import java.io.IOException;
     25import java.lang.reflect.InvocationTargetException;
    2526import java.util.Enumeration;
    2627import java.util.HashMap;
     
    7677    try
    7778    {
    78       Servlet servlet = servletClass.newInstance();
     79      Servlet servlet = servletClass.getDeclaredConstructor().newInstance();
    7980      servlet.init(this);
    8081      servlet.service(request, response);
    8182      servlet.destroy();
    8283    }
    83     catch (IllegalAccessException ex)
    84     {
    85       throw new ServletException(ex);
    86     }
    87     catch (InstantiationException ex)
     84    catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException ex)
    8885    {
    8986      throw new ServletException(ex);
  • trunk/src/clients/web/net/sf/basedb/clients/web/extensions/list/PropertyPathActionFactory.java

    r7435 r7517  
    242242      try
    243243      {
    244         formatter = (Formatter<V>)ClassUtil.checkAndLoadClass(context.getClassLoader(), className, true, Formatter.class).newInstance();
     244        formatter = (Formatter<V>)ClassUtil.checkAndLoadClass(context.getClassLoader(), className, true, Formatter.class).getDeclaredConstructor().newInstance();
    245245      }
    246246      catch (Exception ex)
  • trunk/src/install/net/sf/basedb/install/InitDB.java

    r6631 r7517  
    3939import net.sf.basedb.util.ConsoleProgressReporter;
    4040import net.sf.basedb.util.ChainedProgressReporter;
     41import net.sf.basedb.util.ClassUtil;
    4142
    4243/**
     
    204205    try
    205206    {
    206       final Driver driver = (Driver)Class.forName(jdbcDriver).newInstance();
     207      final Driver driver = (Driver)ClassUtil.newInstance(Class.forName(jdbcDriver));
    207208      driverVersion = "version " + driver.getMajorVersion() + "." + driver.getMinorVersion();
    208209    }
  • trunk/src/install/net/sf/basedb/install/OneTimeFix.java

    r7390 r7517  
    4141import net.sf.basedb.core.Update;
    4242import net.sf.basedb.core.authentication.LoginRequest;
     43import net.sf.basedb.util.ClassUtil;
    4344import net.sf.basedb.util.ConsoleProgressReporter;
    4445
     
    142143    try
    143144    {
    144       final Driver driver = (Driver)Class.forName(jdbcDriver).newInstance();
     145      final Driver driver = (Driver)ClassUtil.newInstance(Class.forName(jdbcDriver));
    145146      driverVersion = "version " + driver.getMajorVersion() + "." + driver.getMinorVersion();
    146147    }
  • trunk/src/plugins/core/net/sf/basedb/plugins/PackedFileExporter.java

    r7168 r7517  
    5858import net.sf.basedb.core.signal.ThreadSignalHandler;
    5959import net.sf.basedb.util.ChainedProgressReporter;
     60import net.sf.basedb.util.ClassUtil;
    6061import net.sf.basedb.util.FileUtil;
    6162import net.sf.basedb.util.ProgressInputStream;
     
    699700    throws Exception
    700701  {
    701     return (FilePacker)Class.forName(packerClass).newInstance();
     702    return (FilePacker)ClassUtil.newInstance(Class.forName(packerClass));
    702703  }
    703704 
  • trunk/src/test/TestJarClassLoader.java

    r7195 r7517  
    7474      cl.setDelegateFirst(delegateFirst);
    7575      Class<?> c = cl.loadClass(className);
    76       Object o = c.newInstance();
     76      Object o = c.getDeclaredConstructor().newInstance();
    7777      write_item(o);
    7878      ClassLoader loadedBy = o.getClass().getClassLoader();
  • trunk/src/test/TestUtil.java

    r6424 r7517  
    2929import net.sf.basedb.core.Version;
    3030import net.sf.basedb.core.authentication.LoginRequest;
     31import net.sf.basedb.util.ClassUtil;
    3132
    3233import java.io.File;
     
    267268    try
    268269    {
    269       final Driver driver = (Driver)Class.forName(jdbcDriver).newInstance();
     270      final Driver driver = (Driver)ClassUtil.newInstance(Class.forName(jdbcDriver));
    270271      driverVersion = "version " + driver.getMajorVersion() + "." + driver.getMinorVersion();
    271272      Properties p = new Properties();
  • trunk/src/test/net/sf/basedb/test/TestUtil.java

    r6424 r7517  
    3838import net.sf.basedb.core.SessionControl;
    3939import net.sf.basedb.core.authentication.LoginRequest;
     40import net.sf.basedb.util.ClassUtil;
    4041
    4142/**
     
    240241    try
    241242    {
    242       final Driver driver = (Driver)Class.forName(jdbcDriver).newInstance();
     243      final Driver driver = (Driver)ClassUtil.newInstance(Class.forName(jdbcDriver));
    243244      driverVersion = "version " + driver.getMajorVersion() + "." + driver.getMinorVersion();
    244245      Properties p = new Properties();
Note: See TracChangeset for help on using the changeset viewer.