Package java.lang.reflect

Examples of java.lang.reflect.Constructor$ConstructorData


                return (T) Proxy.newProxyInstance(c.getClassLoader(), interfaces, ih);
            }
        }
        try {
            Class<?> pc = ProxyCodeGenerator.getClassProxy(c);
            Constructor cons = pc.getConstructor(new Class<?>[] { InvocationHandler.class });
            return (T) cons.newInstance(new Object[] { ih });
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here


                props=readProps(filePath);
                String classname=props.getProperty(filePersistMgr);
                if(classname != null)
                {
                    Class cl=Util.loadClass(classname, this.getClass());
                    Constructor ctor=cl.getConstructor(new Class[]{String.class});
                    _manager=(PersistenceManager)ctor.newInstance(new Object[]{filePath});
                }
                else
                {
                    _manager = new FilePersistenceManager(filePath);
                }
View Full Code Here

                // create an unconnected socket instance
                Socket sock = (Socket) Socket.class.newInstance();

                // need an InetSocketAddress instance for connect()
                Class inetSocketAddress = Class.forName("java.net.InetSocketAddress");
                Constructor inetSocketAddressCtr =
                    inetSocketAddress.getConstructor(
                            new Class[] { InetAddress.class, int.class });
                Object address = inetSocketAddressCtr.newInstance(
                        new Object[] { host, new Integer(port) });

                // now invoke the connect method with the timeout
                log.debug("Invoking connect with timeout=" + timeout);
                connectMethod.invoke(sock, new Object[]{address, new Integer(timeout)});
View Full Code Here

                // try to get the constructor matching our arguments
                Class[] argsTypes = new Class[args.length];
                for (int i=0; i<argsTypes.length; i++) {
                    argsTypes[i] = args[i] == null ? null : args[i].getClass();
                }
                Constructor cnst = clazz.getConstructor(argsTypes);
                // crate a new instance using the constructor
                Object obj = cnst.newInstance(args);
                return Context.toObject(obj, core.global);
            } catch (Exception x) {
                System.err.println("Error in Java constructor: "+x);
                throw new EvaluatorException(x.toString());
            }
View Full Code Here

    public static String[] convertStringList(Collection<String> list) {
        return list.toArray(new String[list.size()]);
    }

    public static <T> Constructor<T> getConstructor(Class<T> aClass) throws NoSuchMethodException {
        Constructor constr = aClass.getDeclaredConstructor();
        try {
            constr.setAccessible(true);
            return constr;
        } catch (Exception ex) {
            return aClass.getConstructor();
        }
    }
View Full Code Here

          return 0;
        }

        if (!clazz.isInterface()) {
            try {
                Constructor c = clazz.getDeclaredConstructor(new Class[] {});
                if (c != null) {
                  try {
                    return c.newInstance(new Object[] {});
                  } catch (InvocationTargetException e) {
                    throw e.getTargetException();
                  }
                }
            } catch (NoSuchMethodException e) {
View Full Code Here

     
        // This *has* to be done first as it sets system properties that are read and cached by Java
     
      COConfigurationManager.preInitialise();

      Constructor constructor = null;
      try {
        Class az3Class = Class.forName("com.aelitis.azureus.ui.swt.Initializer");

        constructor = az3Class.getConstructor(new Class[] {
            AzureusCore.class,
            StartServer.class,
            String[].class
        });
      } catch (ClassNotFoundException cnfe) {
        System.err.println(cnfe.toString() + "\nDid you include the azureus3 module?");
        return;
      } catch (Throwable t) {

        t.printStackTrace();

        return;
      }

     
      String  mi_str = System.getProperty( PR_MULTI_INSTANCE );
     
      boolean mi = mi_str != null && mi_str.equalsIgnoreCase("true");
     
      startServer = new StartServer();

       
 
      boolean debugGUI = Boolean.getBoolean("debug");
     
      if( mi || debugGUI){
       
        // create a MainWindow regardless to the server state
       
      AzureusCore    core = AzureusCoreFactory.create();

        constructor.newInstance(new Object[] {
          core,
          startServer,
          args
        });

        return;
      }
     
     
      if ( processParams(args, startServer) ){
 
        AzureusCore    core = AzureusCoreFactory.create();
       
        startServer.pollForConnections(core);
 
        constructor.newInstance(new Object[] {
          core,
          startServer,
          args
        });
       
View Full Code Here

      public TableColumnCore createTableColumnCore(Class forDataSourceType,
          String tableID, String columnID) {
        cInfo info = (cInfo) c.get(columnID);

        try {
          Constructor constructor = info.cla.getDeclaredConstructor(new Class[] {
            String.class
          });
          TableColumnCore column = (TableColumnCore) constructor.newInstance(new Object[] {
            tableID
          });
          return column;
        } catch (Exception e) {
          Debug.out(e);
View Full Code Here

    // either !asked or forceAsked at this point

    try {

      final Constructor constructor = uiswClass.getConstructor(new Class[] {});

      Object object = constructor.newInstance(new Object[] {});

      Method method = uiswClass.getMethod("open", new Class[] {});

      method.invoke(object, new Object[] {});
View Full Code Here

      uis = UIConst.UIS.values().iterator();
      while (uis.hasNext())
        ((IUserInterface) uis.next()).startUI();
          
      Class clConsoleInput;
      Constructor conConsoleInput =null;
      try {
        clConsoleInput = Class.forName("org.gudy.azureus2.ui.console.ConsoleInput");
       
          // change this and you'll need to change the parameters below....
       
        Class params[] = {String.class, AzureusCore.class, Reader.class, PrintStream.class, Boolean.class};
       
        conConsoleInput=clConsoleInput.getConstructor(params);
      } catch (Exception e) {
        e.printStackTrace();
      }
      if (commands.hasOption('e')) {
        if (conConsoleInput != null) {
          try {
            Object params[] = {commands.getOptionValue('e'), new_core, new FileReader(commands.getOptionValue('e')), System.out, Boolean.FALSE};
            conConsoleInput.newInstance(params);
          } catch (java.io.FileNotFoundException e) {
            Logger.getLogger("azureus2").error("Script file not found: "+e.toString());
          } 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'");
      }
     
      if (commands.hasOption('c')) {
        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

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.