Package java.lang.reflect

Examples of java.lang.reflect.Constructor.newInstance()


        if (conConsoleInput != null) {
          String comm = commands.getOptionValue('c');
          comm+="\nlogout\n";
          Object params[] = {commands.getOptionValue('c'), UIConst.getAzureusCore(), new StringReader(comm), System.out, Boolean.FALSE};
          try {
            conConsoleInput.newInstance(params);
          } catch (Exception e) {
            Logger.getLogger("azureus2").error("Error invocating the script processor: "+e.toString());
          }
        } else
          Logger.getLogger("azureus2").error("ConsoleInput class not found. You need the console ui package to use '-e'");
View Full Code Here


        {
            Class[] ctrArgs = new Class[] {Class.class, keyType};
            Constructor ctr = idType.getConstructor(ctrArgs);

            Object[] args = new Object[] {pcType, value};
            id = (SingleFieldIdentity)ctr.newInstance(args);
        }
        catch (Exception e)
        {
            JPOXLogger.PERSISTENCE.error("Error encountered while creating SingleFieldIdentity instance of type \"" + idType.getName() + "\"");
            JPOXLogger.PERSISTENCE.error(e);
View Full Code Here

      Constructor c;
      try {
        c = Class.forName(acceptorClass).getDeclaredConstructor(
            Utils.EMPTY_CLASSES);
        c.setAccessible(true);
        acceptor = (Acceptor) c.newInstance(Utils.EMPTY_OBJECTS);
      } catch (Exception e1) {
        log("TJWS: Acceptor is not accessable or can't be instantiated, the Server is inoperable",
            e);
      }
    } catch (ClassNotFoundException e) {
View Full Code Here

      return null;
    try {
      Class cs = image.getClass();
      Constructor constructor = cs
          .getDeclaredConstructor(new Class[] { Image.class });
      return (Image) constructor.newInstance(new Object[] { image });
    } catch (Exception e) {
      throw new ExceptionConverter(e);
    }
  }
View Full Code Here

                }
            }
            CodeItem codeItem;
            try
            {
                codeItem = (CodeItem) constructor.newInstance(new Object[]{op, msv});
            }
            catch (Exception ex)
            {
                throw new RuntimeException(ex);
            }
View Full Code Here

    }

    try {
      if (Calendar.class.isAssignableFrom(destClass)) {
        Constructor constructor = destClass.getConstructor();
        Calendar result = (Calendar) constructor.newInstance();
        result.setTimeInMillis(time);
        return result;
      }
      Constructor constructor = destClass.getConstructor(Long.TYPE);
      Object result = constructor.newInstance(time);
View Full Code Here

        Calendar result = (Calendar) constructor.newInstance();
        result.setTimeInMillis(time);
        return result;
      }
      Constructor constructor = destClass.getConstructor(Long.TYPE);
      Object result = constructor.newInstance(time);
      if (nanos != 0 && (Timestamp.class.isAssignableFrom(destClass))) {
        ((Timestamp) result).setNanos(nanos);
      }
      return result;
    } catch (Exception e) {
View Full Code Here

      final ClassLoader classLoader = ObjectUtilities.getClassLoader(AbstractActionPlugin.class);
      try
      {
        final Class aClass = Class.forName(className, true, classLoader);
        final Constructor constructor = aClass.getConstructor(new Class[]{Frame.class});
        return (ExportDialog) constructor.newInstance(new Object[]{proxy});
      }
      catch (Exception e)
      {
        AbstractExportActionPlugin.logger.error(messages.getErrorString(
            "AbstractExportActionPlugin.ERROR_0001_FAILED_EXPORT_DIALOG_CREATION", className)); //$NON-NLS-1$
View Full Code Here

      final ClassLoader classLoader = ObjectUtilities.getClassLoader(AbstractActionPlugin.class);
      try
      {
        final Class aClass = Class.forName(className, true, classLoader);
        final Constructor constructor = aClass.getConstructor(new Class[]{Dialog.class});
        return (ExportDialog) constructor.newInstance(new Object[]{proxy});
      }
      catch (Exception e)
      {
        AbstractExportActionPlugin.logger.error(messages.getErrorString(
            "AbstractExportActionPlugin.ERROR_0002_FAILED_EXPORT_DIALOG_CREATION", className), e); //$NON-NLS-1$
View Full Code Here

    FileInputStream fileInputHandle = new FileInputStream(f);

    // use reflection to avoid hard dependency
    Class<?> clazz = Class.forName( "LZMA.LzmaInputStream" );
    Constructor constructor = clazz.getDeclaredConstructor(InputStream.class);
    InputStream inputHandle = (InputStream) constructor.newInstance(fileInputHandle);

    OutputStream outputHandle;
    outputHandle = new FileOutputStream(out);

    byte [] buffer = new byte [1<<14];
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.