Package java.lang.reflect

Examples of java.lang.reflect.Constructor$ConstructorData


      Class claDisplay = Class.forName("org.eclipse.swt.widgets.Display");
      if (display != null) {
        display = claDisplay.newInstance();
      }
      Class claShell = Class.forName("org.eclipse.swt.widgets.Shell");
      Constructor shellConstruct = claShell.getConstructor(new Class[] {
        claDisplay,
      });
      Object shell = shellConstruct.newInstance(new Object[] {
        display
      });

      Class claBrowser = Class.forName("org.eclipse.swt.browser.Browser");
      Constructor[] constructors = claBrowser.getConstructors();
View Full Code Here


        }

        try
        {
            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

      acceptor = (Acceptor) Class.forName(acceptorClass).newInstance();
    } catch (InstantiationException e) {
      log("TJWS: Couldn't instantiate Acceptor, the Server is inoperable",
          e);
    } catch (IllegalAccessException e) {
      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

  public static Image getInstance(Image image) {
    if (image == null)
      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

        ArrayList list = new ArrayList(operations.size());
        for (Iterator i = operations.iterator(); i.hasNext();)
        {
            Operation op = (Operation) i.next();
            String className = op.getClass().getName();
            Constructor constructor = (Constructor) op2constructor.get(className);
            if (constructor == null)
            {
                String shortClassName = className.substring(className.lastIndexOf('.') + 1);
                String newName = "ru.andrew.jclazz.decompiler.engine.ops." + shortClassName + "View";
                try
                {
                    constructor = Class.forName(newName).getConstructor(new Class[]{Operation.class, MethodSourceView.class});
                    op2constructor.put(className, constructor);
                }
                catch (ClassNotFoundException e)
                {
                    throw new RuntimeException(e);
                }
                catch (NoSuchMethodException e)
                {
                    throw new RuntimeException(e);
                }
            }
            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);
      if (nanos != 0 && (Timestamp.class.isAssignableFrom(destClass))) {
        ((Timestamp) result).setNanos(nanos);
      }
      return result;
    } catch (Exception e) {
View Full Code Here

  }

  public Object convert(Class destClass, Object srcObj) {
    String result = (String) stringConverter.convert(destClass, srcObj);
    try {
      Constructor constructor = destClass.getConstructor(String.class); // TODO Check, but not catch
      return constructor.newInstance(result);
    } catch (NoSuchMethodException e) {
      // just return the string
      return result;
    } catch (Exception e) {
      throw new ConversionException(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$
      }
    }
    else if (proxy instanceof Dialog)
    {
      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

  protected static boolean hasPublicDefaultConstructor(final Class c)
  {
    try
    {
      final Constructor constructor = c.getConstructor(EMPTY_PARAMETER);
      if (Modifier.isPublic(constructor.getModifiers()))
      {
        return true;
      }
      return false;
    }
View Full Code Here

    File f = new File(in);
    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

Related Classes of java.lang.reflect.Constructor$ConstructorData

Copyright © 2018 www.massapicom. 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.