Package ceylon.modules

Examples of ceylon.modules.CeylonRuntimeException


            throw err;
        } catch (RuntimeException e) {
            // get around a class loader issue
            if(e instanceof CeylonRuntimeException == false
                    && e.getClass().getName().equals("ceylon.modules.CeylonRuntimeException"))
                throw new CeylonRuntimeException(e.getMessage());
            throw e;
        } catch (Throwable t) {
            throw new RuntimeException(t);
        }
    }
View Full Code Here


*/
public abstract class AbstractJBossRuntime extends AbstractRuntime {
    public ClassLoaderHolder createClassLoader(String name, String version, Configuration conf) throws Exception {
        if (RepositoryManager.DEFAULT_MODULE.equals(name)) {
            if (version != null) {
                throw new CeylonRuntimeException("Invalid module identifier: default module should not have any version");
            }
        } else {
            if (version == null) {
                StringBuilder sb = new StringBuilder("Invalid module identifier: missing required version");
                sb.append(" (should be of the form ");
                sb.append(name);
                sb.append("/version)");
                throw new CeylonRuntimeException(sb.toString());
            }
        }

        ModuleIdentifier moduleIdentifier;
        try {
            moduleIdentifier = ModuleIdentifier.fromString(name + ":" + version);
        } catch (IllegalArgumentException x) {
            CeylonRuntimeException cre = new CeylonRuntimeException("Invalid module name or version: contains invalid characters");
            cre.initCause(x);
            throw cre;
        }
        try {
            ModuleLoader moduleLoader = createModuleLoader(conf);
            Module module = moduleLoader.loadModule(moduleIdentifier);
            return new ClassLoaderHolderImpl(module);
        } catch (ModuleNotFoundException e) {
            String spec = e.getMessage().replace(':', '/');
            final CeylonRuntimeException cre = new CeylonRuntimeException("Could not find module: " + spec + " (invalid version?)");
            cre.initCause(e);
            throw cre;
        }
    }
View Full Code Here

                String msg = String.format("Could not find toplevel %s '%s'.", type, runClassName);
                if (!moduleName.equals(Constants.DEFAULT.toString()) && !runClassName.contains(".")) {
                    msg += String.format(" Class and method names need to be fully qualified, maybe you meant '%s'?", moduleName + "::" + runClassName);
                }
                //msg += " [" + clh + "]";
                throw new CeylonRuntimeException(msg);
            }

            try {
                SecurityActions.invokeRun(runClass, args);
            } catch (NoSuchMethodException ex) {
                String type = (Character.isUpperCase(runClassName.charAt(0)) ? "class" : "method");
                String msg = String.format("Cannot run toplevel %s '%s': it should have no parameters or they should all have default values.", type, runClassName);
                throw new CeylonRuntimeException(msg);
            }
        } finally {
            SecurityActions.setContextClassLoader(oldClassLoader);
        }
    }
View Full Code Here

    public void execute(Configuration conf) throws Exception {
        String exe = conf.module;
        // FIXME: argument checks could be done earlier
        if (exe == null) {
            throw new CeylonRuntimeException("No initial module defined");
        }

        int p = exe.indexOf("/");
        if (p == 0) {
            throw new CeylonRuntimeException("Missing runnable info: " + exe);
        }
        if (p == exe.length() - 1) {
            throw new CeylonRuntimeException("Missing version info: " + exe);
        }

        String name = exe.substring(0, p > 0 ? p : exe.length());
        String mv = (p > 0 ? exe.substring(p + 1) : null);

        final ClassLoaderHolder clh = createClassLoader(name, mv, conf);

        mv = clh.getVersion();
        final ClassLoader cl = clh.getClassLoader();

        Module runtimeModule = loadModuleMetaData(cl, name);
        if (runtimeModule != null) {
            final String mn = runtimeModule.name();
            if (name.equals(mn) == false) {
                throw new CeylonRuntimeException("Input module name doesn't match module's name: " + name + " != " + mn);
            }

            final String version = runtimeModule.version();
            if (mv.equals(version) == false && Constants.DEFAULT.toString().equals(name) == false) {
                throw new CeylonRuntimeException("Input module version doesn't match module's version: " + mv + " != " + version);
            }
        } else if (Constants.DEFAULT.toString().equals(name) == false) {
            // Don't throw, we might be executing a plain Java module!
            //throw new CeylonRuntimeException("Missing module.class info: " + name); // TODO -- dump some more useful msg
        }
View Full Code Here

TOP

Related Classes of ceylon.modules.CeylonRuntimeException

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.