Package java.net

Examples of java.net.URLClassLoader.loadClass()


  public String execClass(String className) {
    if (TEST_IN_SAME_PROCESS) {
      try {
        ClassLoader loader = new URLClassLoader(new URL[] { new File(tmpdir).toURI().toURL() }, ClassLoader.getSystemClassLoader());
                final Class<?> mainClass = (Class<?>)loader.loadClass(className);
        final Method mainMethod = mainClass.getDeclaredMethod("main", String[].class);
        PipedInputStream stdoutIn = new PipedInputStream();
        PipedInputStream stderrIn = new PipedInputStream();
        PipedOutputStream stdoutOut = new PipedOutputStream(stdoutIn);
        PipedOutputStream stderrOut = new PipedOutputStream(stderrIn);
View Full Code Here


  }

    protected ParserFactory getParserFactory(String lexerName, String parserName, String listenerName, final String entryPoint) {
        try {
            ClassLoader loader = new URLClassLoader(new URL[] { new File(tmpdir).toURI().toURL() }, ClassLoader.getSystemClassLoader());
            final Class<? extends Lexer> lexerClass = loader.loadClass(lexerName).asSubclass(Lexer.class);
            final Class<? extends Parser> parserClass = loader.loadClass(parserName).asSubclass(Parser.class);
            final Class<? extends ParseTreeListener> listenerClass = loader.loadClass(listenerName).asSubclass(ParseTreeListener.class);

            final Constructor<? extends Lexer> lexerCtor = lexerClass.getConstructor(CharStream.class);
            final Constructor<? extends Parser> parserCtor = parserClass.getConstructor(TokenStream.class);
View Full Code Here

    protected ParserFactory getParserFactory(String lexerName, String parserName, String listenerName, final String entryPoint) {
        try {
            ClassLoader loader = new URLClassLoader(new URL[] { new File(tmpdir).toURI().toURL() }, ClassLoader.getSystemClassLoader());
            final Class<? extends Lexer> lexerClass = loader.loadClass(lexerName).asSubclass(Lexer.class);
            final Class<? extends Parser> parserClass = loader.loadClass(parserName).asSubclass(Parser.class);
            final Class<? extends ParseTreeListener> listenerClass = loader.loadClass(listenerName).asSubclass(ParseTreeListener.class);

            final Constructor<? extends Lexer> lexerCtor = lexerClass.getConstructor(CharStream.class);
            final Constructor<? extends Parser> parserCtor = parserClass.getConstructor(TokenStream.class);
View Full Code Here

    protected ParserFactory getParserFactory(String lexerName, String parserName, String listenerName, final String entryPoint) {
        try {
            ClassLoader loader = new URLClassLoader(new URL[] { new File(tmpdir).toURI().toURL() }, ClassLoader.getSystemClassLoader());
            final Class<? extends Lexer> lexerClass = loader.loadClass(lexerName).asSubclass(Lexer.class);
            final Class<? extends Parser> parserClass = loader.loadClass(parserName).asSubclass(Parser.class);
            final Class<? extends ParseTreeListener> listenerClass = loader.loadClass(listenerName).asSubclass(ParseTreeListener.class);

            final Constructor<? extends Lexer> lexerCtor = lexerClass.getConstructor(CharStream.class);
            final Constructor<? extends Parser> parserCtor = parserClass.getConstructor(TokenStream.class);

            // construct initial instances of the lexer and parser to deserialize their ATNs
View Full Code Here

  public Class<?> loadClassFromTempDir(String name) throws Exception {
    ClassLoader loader =
      new URLClassLoader(new URL[] { new File(tmpdir).toURI().toURL() },
                 ClassLoader.getSystemClassLoader());
    return loader.loadClass(name);
  }

  public Class<? extends Lexer> loadLexerClassFromTempDir(String name) throws Exception {
    return loadClassFromTempDir(name).asSubclass(Lexer.class);
  }
View Full Code Here

  public String execClass(String className) {
    if (TEST_IN_SAME_PROCESS) {
      try {
        ClassLoader loader = new URLClassLoader(new URL[] { new File(tmpdir).toURI().toURL() }, ClassLoader.getSystemClassLoader());
                final Class<?> mainClass = (Class<?>)loader.loadClass(className);
        final Method mainMethod = mainClass.getDeclaredMethod("main", String[].class);
        PipedInputStream stdoutIn = new PipedInputStream();
        PipedInputStream stderrIn = new PipedInputStream();
        PipedOutputStream stdoutOut = new PipedOutputStream(stdoutIn);
        PipedOutputStream stderrOut = new PipedOutputStream(stderrIn);
View Full Code Here

  }

  private Class<?> loadClassAtPath(String baseDir, String path) {
    try {
      ClassLoader classLoader = new URLClassLoader(new URL[] {new File(baseDir).toURI().toURL()});
      return classLoader.loadClass(getBinaryName(path));
    } catch (Throwable t) {
      return null;
    }
  }
View Full Code Here

           }
       }

       // Now setup our classloader..
       URLClassLoader loader = new URLClassLoader(urls.toArray(new URL[urls.size()]));
       Class<?> clazz = loader.loadClass(mainClass);
       Method method = clazz.getMethod("main", args.getClass());
       try {
           method.invoke(null, (Object)mainArgs);
       } catch (InvocationTargetException e) {
           throw e.getTargetException();
View Full Code Here

                }
            }
            URLClassLoader loader = new URLClassLoader(list.toArray(new URL[list.size()]),
                    DatabasePoolPortlet.class.getClassLoader());
            try {
                return loader.loadClass(data.driverClass);
            } catch (ClassNotFoundException e) {
                return null;
            }
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

                ClassLoader loader = new URLClassLoader(new URL[0], ClassLoader.getSystemClassLoader());
                Method m = ClassLoader.class.getDeclaredMethod("defineClass", String.class,
                                                               byte[].class, Integer.TYPE, Integer.TYPE);
                ReflectionUtil.setAccessible(m).invoke(loader, ReferencingAuthenticator.class.getName(),
                                                       b, 0, b.length);
                Class<?> cls = loader.loadClass(ReferencingAuthenticator.class.getName());
                Authenticator auth = (Authenticator)cls.getConstructor(Authenticator.class, Authenticator.class)
                    .newInstance(INSTANCE, wrapped);
               
                Authenticator.setDefault(auth);
            } catch (Throwable t) {
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.