Package org.jruby

Examples of org.jruby.Ruby.newTypeError()


    @JRubyMethod(backtrace = true, visibility = Visibility.PRIVATE)
    public static IRubyObject implement(ThreadContext context, IRubyObject self, IRubyObject clazz) {
        Ruby runtime = context.getRuntime();

        if (!(clazz instanceof RubyModule)) {
            throw runtime.newTypeError(clazz, runtime.getModule());
        }

        RubyModule targetModule = (RubyModule)clazz;
        JavaClass javaClass = (JavaClass)self.getInstanceVariables().fastGetInstanceVariable("@java_class");
       
View Full Code Here


        Ruby runtime = context.getRuntime();

        // not allowed for existing Java interface modules
        if (module.getInstanceVariables().fastHasInstanceVariable("@java_class") &&
                module.getInstanceVariables().fastGetInstanceVariable("@java_class").isTrue()) {
            throw runtime.newTypeError("can not add Java interface to existing Java interface");
        }
       
        // To turn a module into an "interface collection" we add a class instance
        // variable to hold the list of interfaces, and modify append_features
        // for this module to call append_features on each of those interfaces as
View Full Code Here

    @JRubyMethod(module = true)
    public static IRubyObject coerce_to(ThreadContext context, IRubyObject self, IRubyObject object, IRubyObject clazz, IRubyObject method) {
        Ruby ruby = object.getRuntime();
        if (!(clazz instanceof RubyClass)) {
            throw ruby.newTypeError(clazz, ruby.getClassClass());
        }
        if (!(method instanceof RubySymbol)) {
            throw ruby.newTypeError(method, ruby.getSymbol());
        }
        RubyClass rubyClass = (RubyClass) clazz;
View Full Code Here

        Ruby ruby = object.getRuntime();
        if (!(clazz instanceof RubyClass)) {
            throw ruby.newTypeError(clazz, ruby.getClassClass());
        }
        if (!(method instanceof RubySymbol)) {
            throw ruby.newTypeError(method, ruby.getSymbol());
        }
        RubyClass rubyClass = (RubyClass) clazz;
        RubySymbol methodSym = (RubySymbol) method;
        return TypeConverter.convertToTypeOrRaise(object, rubyClass, methodSym.asJavaString());
    }
View Full Code Here

    @JRubyMethod(name = "basic_word_break_characters=", module = true, visibility = PRIVATE)
    public static IRubyObject s_set_basic_word_break_character(IRubyObject recv, IRubyObject achar) {
        Ruby runtime = recv.getRuntime();
        if (!achar.respondsTo("to_str")) {
            throw runtime.newTypeError("can't convert " + achar.getMetaClass() + " into String");
        }
        ProcCompletor.setDelimiter(achar.convertToString().toString());
        return achar;
    }
View Full Code Here

            if (maybeThrowable instanceof Throwable) {
                // yes, we're cheating here.
                UnsafeFactory.getUnsafe().throwException((Throwable)maybeThrowable);
                return recv; // not reached
            } else {
                throw runtime.newTypeError("can't raise a non-Throwable Java object");
            }
        } else {
            return RubyKernel.raise(context, recv, args, block);
        }
    }
View Full Code Here

    @JRubyMethod(meta = true)
    public static RubyObject get_with_class(IRubyObject recv, IRubyObject obj) {
        Ruby runtime = recv.getRuntime();
       
        if (!(obj instanceof RubyClass)) {
            throw runtime.newTypeError(obj, runtime.getClassClass());
        }
       
        RubyClass clazz = (RubyClass)obj;
       
        // Let's only generate methods for those the user may actually
View Full Code Here

                // get JavaClass if this is the new proxy class; verify it
                // matches if this is a superclass proxy.
                IRubyObject var = ancestor.getInstanceVariables().fastGetInstanceVariable("@java_class");
                if (var == null) {
                    throw runtime.newTypeError(
                            "no java_class defined for proxy (or ancestor): " + ancestor);
                } else if (!(var instanceof JavaClass)) {
                    throw runtime.newTypeError(
                            "invalid java_class defined for proxy (or ancestor): " +
                            ancestor + ": " + var);
View Full Code Here

                IRubyObject var = ancestor.getInstanceVariables().fastGetInstanceVariable("@java_class");
                if (var == null) {
                    throw runtime.newTypeError(
                            "no java_class defined for proxy (or ancestor): " + ancestor);
                } else if (!(var instanceof JavaClass)) {
                    throw runtime.newTypeError(
                            "invalid java_class defined for proxy (or ancestor): " +
                            ancestor + ": " + var);
                }
                if (javaClass == null) {
                    javaClass = (JavaClass)var;
View Full Code Here

                            ancestor + ": " + var);
                }
                if (javaClass == null) {
                    javaClass = (JavaClass)var;
                } else if (javaClass != var) {
                    throw runtime.newTypeError(
                            "java_class defined for " + clazz + " (" + javaClass +
                            ") does not match java_class for ancestor " + ancestor +
                            " (" + var + ")");
                }
                // get any included interfaces
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.