Package ceylon.language

Examples of ceylon.language.AssertionError


        return ret;
    }
   
    public static <T> T checkNull(T t) {
        if(t == null)
            throw new AssertionError("null value returned from native call not assignable to Object");
        return t;
    }
View Full Code Here


   
    public static <T> Sequence<T> asSequence(Sequential<T> sequential) {
        if (sequential instanceof Sequence) {
            return (Sequence<T>) sequential;
        } else {
            throw new AssertionError("Assertion failed: Sequence expected");
        }
    }
View Full Code Here

            if (newcapacity < MIN_CAPACITY) {
                newcapacity = MIN_CAPACITY;
            } else if (newcapacity > MAX_CAPACITY) {
                newcapacity = requestedCapacity;
                if (newcapacity > MAX_CAPACITY) {
                    throw new AssertionError("can't allocate array bigger than " + MAX_CAPACITY);
                }
            }
           
            A newArray = allocate(newcapacity);
            System.arraycopy(this.array, 0, newArray, 0, this.size);
View Full Code Here

                Metamodel.annotations($reifiedValue, programElement);
        boolean optional = OptionalAnnotation.class
            .isAssignableFrom(getReflectedAnnotationClass(annotationType));
    if (optional) {
            if (results.getSize() > 1L) {
                throw new AssertionError("optional annotation occurs more than once");
            }
            Object singleResult =
                    results instanceof Sequence ?
                            ((Sequence<?>) results).getFirst() :
                            null;
View Full Code Here

    protected AbstractArrayIterable(TypeDescriptor $reified$Element,
            ArrayType array, int start, int len, int step) {
        super($reified$Element, Null.$TypeDescriptor$);
       
        if (start < 0) {
            throw new AssertionError("start must be non-negative");
        }
        if (len < 0) {
            throw new AssertionError("len must be non-negative");
        }
        if (step <= 0) {
            throw new AssertionError("step size must be greater than zero");
        }

        this.array = array;
        this.$reified$Element = $reified$Element;
        this.start = start;
View Full Code Here

            // MemberClass<Container, Type, Arguments>
            clazz = (java.lang.Class)((TypeDescriptor.Class)typeArguments[1]).getKlass();
            outerClass = ((TypeDescriptor.Class)typeArguments[0]).getKlass();
            outer = context.leakReferred(outerReference.getId());
        } else {
            throw new AssertionError("unexpected class model: "
                    + (classModel != null ? classModel.getClass().getName() : "null"));
        }
        // Construct arrays for types and arguments for reflective instantiation
        // of the serialization constructor
        Collection<?> typeArgs = classModel.getTypeArguments().getItems();
        Class<?>[] types = new Class[(outerClass != null ? 2 : 1) + Util.toInt(typeArgs.getSize())];
        Object[] args = new Object[(outer != null ? 2 : 1) + Util.toInt(typeArgs.getSize())];
        int ii = 0;
        if (outerClass != null) {
            types[ii] = outerClass;
            args[ii] = outer;
            ii++;
        }
        types[ii] = $Serialization$.class;
        args[ii] = null;
        ii++;
        for (int jj = 0 ; jj < typeArgs.getSize(); ii++, jj++) {
            types[ii] = TypeDescriptor.class;
            args[ii] = Metamodel.getTypeDescriptor((Type)typeArgs.getFromFirst(jj));
        }
       
        try {
            Constructor<Instance> ctor = clazz.getDeclaredConstructor(types);
            ctor.setAccessible(true);
            // Actually we need to pass something equivalent to the type descriptors here
            // because the companion instances can require those. But we don't have the deconstructed yet!
            // This means we have to obtain the type descriptors from the class model
            return ctor.newInstance(args);// Pass a null $Serialization$
        } catch (NoSuchMethodException e) {
            throw new AssertionError("class is not serializable " + classModel);
        } catch (InvocationTargetException e) {
            throw new AssertionError("error thrown during instantiation of " + classModel+ (e.getMessage() != null ? ": " + e.getMessage() : ""));
        } catch (SecurityException e) {
            // Should never happen
            throw new RuntimeException(e);
        } catch (InstantiationException|IllegalAccessException|IllegalArgumentException e) {
            // Should never happen
View Full Code Here

     */
    @Override
    public RealizableReference<Instance> deserialize(Deconstructed deconstructed) {
        this.deconstructed = deconstructed;
        if (getState() != ST_STATELESS) {
            throw new AssertionError("reference has already been deserialized: " + this);
        }
        this.state = ST_UNINITIALIZED;
        return this;
    }
View Full Code Here

        case ST_UNINITIALIZED_REFS:
            return "RealizableReference(" + id + "~>" + deconstructed + ")";
        case ST_INITIALIZED:
            return "RealizableReference(" + id + "->" + instance + ")";
        }
        throw new AssertionError("Illegal state " + getState());
    }
View Full Code Here

     * Reconstructs this instance
     */
    @Override
    public Object reconstruct() {
        if (getState() == ST_ERROR) {
            throw new AssertionError("broken graph");
        }
        IdentityHashMap<DeserializingReference<?>, Object> i = new IdentityHashMap<DeserializingReference<?>, Object>();
        try {
            if (getState() != ST_INITIALIZED) {
                LinkedList<DeserializingReference<?>> queue = new LinkedList<DeserializingReference<?>>();
                queue.addLast(this);
                while (!queue.isEmpty()) {
                    DeserializingReference<?> r = queue.removeFirst();
                    i.put(r,  null);
                    if (r.getState() == ST_UNINITIALIZED) {
                        ((Serializable)r.instance).$deserialize$(r.deconstructed);
                        r.state = ST_UNINITIALIZED_REFS;
                    }
                    if (r.getState() == ST_UNINITIALIZED_REFS) {
                        for (DeserializingReference<Object> referred : r.references()) {
                            if (referred.getState() == ST_STATELESS) {
                                throw new AssertionError("reference " + referred.getId() + " has not been deserialized");
                            }
                            DeserializingReference<?> statefulReferred = (DeserializingReference<?>)referred;
                            if (statefulReferred.getState() != ST_INITIALIZED) {
                                queue.addLast(statefulReferred);
                            }
View Full Code Here

        return new FunctionOrValue(klass, typeArguments);
    }

    public static TypeDescriptor union(TypeDescriptor... members){
        if(members == null || members.length == 0)
            throw new AssertionError("members can't be null or empty");
        members = flattenUnionOrIntersection(members, true);
        TypeDescriptor single = getSingleTypeDescriptorIfUnique(members);
        if(single != null)
            return single;
        members = removeDuplicates(members);
View Full Code Here

TOP

Related Classes of ceylon.language.AssertionError

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.