• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Assert类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sun.squawk.util.Assert的典型用法代码示例。如果您正苦于以下问题:Java Assert类的具体用法?Java Assert怎么用?Java Assert使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Assert类属于com.sun.squawk.util包,在下文中一共展示了Assert类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: stringcopy

import com.sun.squawk.util.Assert; //导入依赖的package包/类
private static void stringcopy(Object src, int src_position, Object dst, int dst_position, int totalLength) {
    final int MAXMOVE = 4096 * 2;
    Assert.that(GC.getKlass(src).isSquawkArray());
    Assert.that(GC.getKlass(dst).isSquawkArray());
    Assert.that((totalLength  >= 0) &&
                (src_position >= 0) &&
                (dst_position >= 0));
    Assert.that((totalLength == 0 || ((totalLength + src_position) >= 0 && (totalLength + dst_position) >= 0)) &&
                ((totalLength + src_position) <= GC.getArrayLength(src)) &&
                ((totalLength + dst_position) <= GC.getArrayLength(dst)));
    while (true) {
        int length = totalLength < MAXMOVE ? totalLength : MAXMOVE;
        GC.stringcopy(src, src_position, dst, dst_position, length);
        totalLength -= length;
        if (totalLength == 0) {
            break;
        }
        src_position += length;
        dst_position += length;
        com.sun.squawk.VMThread.yield();
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:23,代码来源:String.java


示例2: erase

import com.sun.squawk.util.Assert; //导入依赖的package包/类
public void erase(long sequence) throws RecordStoreException {
    flashSector.erase();
    ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(ERASED_HEADER_SIZE);
    DataOutputStream dataOut = new DataOutputStream(bytesOut);
    writeHead = 0;
    try {
        dataOut.write(NorFlashMemoryHeap.ERASED_VALUE_XOR);
        dataOut.write(NorFlashMemoryHeap.ERASED_VALUE_XOR);
        dataOut.write(ERASED_HEADER);
        dataOut.writeInt((int)sequence);
        dataOut.write(NorFlashMemoryHeap.ERASED_VALUE_XOR);
        dataOut.write(NorFlashMemoryHeap.ERASED_VALUE_XOR);
        //add 2 ERASED_VALUE_XOR
        dataOut.write(NorFlashMemoryHeap.ERASED_VALUE_XOR);
        dataOut.write(NorFlashMemoryHeap.ERASED_VALUE_XOR);
        Assert.that(bytesOut.size() == ERASED_HEADER_SIZE);
        dataOut.close();
    } catch (IOException e) {
        throw new RecordStoreException("Unexpected IO exception: " + e);
    }
    writeBytes(bytesOut.toByteArray(), 0, bytesOut.size());
    hasErasedHeader = true;
    freedBlockCount = 0;
    mallocedBlockCount = 0;
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:26,代码来源:NorFlashSectorState.java


示例3: getLocalTypeFor

import com.sun.squawk.util.Assert; //导入依赖的package包/类
/**
 * Gets the type of a local variable that is used to store a value of a
 * given class. This method partitions all classes into one of the
 * following categories:
 * <p><blockquote><pre>
 *
 *     Local Variable Type  |  Types
 *     ---------------------+-------
 *     INT                  | boolean, byte, short, int
 *     FLOAT                | float
 *     LONG                 | long
 *     DOUBLE               | double
 *     ADDRESS              | Address
 *     UWORD                | UWord
 *     OFFSET               | Offset
 *     REFERENCE            | types in java.lang.Object hierarchy
 *
 * </pre></blockquote><p>
 *
 * @param   type   the type of a value that will be stored in a local variable
 * @return  the local variable type for storing values of type <code>type</code>
 */
public static Klass getLocalTypeFor(Klass type) {
    switch (type.getSystemID()) {
        case CID.BOOLEAN:
        case CID.BYTE:
        case CID.SHORT:
        case CID.CHAR:
        case CID.INT: {
            return Klass.INT;
        }
        case CID.FLOAT:
        case CID.LONG:
        case CID.DOUBLE: {
            return type;
        }
        case CID.UWORD:
        case CID.OFFSET:
        case CID.ADDRESS: {
            return type;
        }
        default: {
            Assert.that(Klass.REFERENCE.isAssignableFrom(type));
            return Klass.REFERENCE;
        }
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:48,代码来源:Frame.java


示例4: parseSection

import com.sun.squawk.util.Assert; //导入依赖的package包/类
/**
 * Parses a single member section. The current parse position must be
 * at the section identifier byte.
 */
private int parseSection() {
    int section = buf[pos];
    Assert.that(section >= INSTANCE_FIELDS && section <= STATIC_METHODS);
    pos++;
    sectionStart[section] = (short)pos;
    sectionCount[section] = 0;
    while (pos < buf.length) {
        int lengthOrSection = buf[pos];
        /*
         * Is the length actually a new section header?
         */
        if (lengthOrSection >= 0 &&
            lengthOrSection <= STATIC_METHODS) {
            break;
        }
        lengthOrSection = readUnsignedShort();
        pos += lengthOrSection;
        sectionCount[section]++;
    }
    return section;
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:26,代码来源:SymbolParser.java


示例5: getCodeTable

import com.sun.squawk.util.Assert; //导入依赖的package包/类
/**
 * Extracts the bytecode arrays from a vector of
 * <code>ClassFileMethod</code>s and copies them into an array of
 * <code>Code</code>s.
 *
 * @param   methods  the vector of <code>ClassFileMethod</code>s
 * @return  an array of <code>Code</code>s corresponding to the bytecode
 *                   arrays of the contents of <code>methods</code>. The
 *                   entries for abstract or native methods will be null
 */
private Code[] getCodeTable(SquawkVector methods) {
    if (methods.isEmpty()) {
        return Code.NO_CODE;
    } else {
        Code[] table = new Code[methods.size()];
        int index = 0;
        for (Enumeration e = methods.elements(); e.hasMoreElements(); ) {
            ClassFileMethod method = (ClassFileMethod)e.nextElement();
            if (!PragmaException.isHosted(method.getPragmas()) && !method.isAbstract() && !method.isNative()) {
                byte[] code = method.getCode();
                Assert.that(code != null);
                table[index] = new Code(code);
            }
            ++index;
        }
        return table;
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:29,代码来源:ClassFileLoader.java


示例6: compare

import com.sun.squawk.util.Assert; //导入依赖的package包/类
public int compare(Object o1, Object o2) {
    if (o1 == o2) {
        return 0;
    }
    PseudoOpcode po1 = (PseudoOpcode)o1;
    PseudoOpcode po2 = (PseudoOpcode)o2;
    int tag1 = po1.tag;
    int tag2 = po2.tag;
    if (tag1 < tag2) {
        return -1;
    } else if (tag1 > tag2) {
        return 1;
    } else {
        Assert.that(tag1 == TRY || tag1 == TRYEND, "multiple incompatible pseudo opcodes at address");
        if (tag1 == TRY) {
            return po2.index - po1.index;
        } else {
            return po1.index - po2.index;
        }
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:22,代码来源:CodeParser.java


示例7: setSockOpt

import com.sun.squawk.util.Assert; //导入依赖的package包/类
/**
 * set a socket option
 * 
 * @param socket socket descriptor
 * @param level Socket.SOL_SOCKET, etc.
 * @param option_name
 * @param option_value new value
 * @throws IOException on error
 */
public void setSockOpt(int socket, int level, int option_name, int option_value) throws IOException {
    IntByReference value = new IntByReference(option_value);
    Assert.that(option_value == value.getValue());
    if (DEBUG) { System.out.println("setSockOpt(" + socket + ", " + level + ", " + option_name + ", " + option_value + ")"); }
    int err = sockets.setsockopt(socket, level, option_name, value, 4);

    Assert.that(option_value == value.getValue());
    value.free();
    LibCUtil.errCheckNeg(err);

    if (DEBUG) {
        int newValue = getSockOpt(socket, level, option_name);
        if (option_value != newValue) {
            System.out.println("FAILED: setSockOpt(" + socket + ", " + level + ", " + option_name + ", " + option_value + ")");
            System.err.println("   Ended with: " + newValue);

        }
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:29,代码来源:GCFSocketsImpl.java


示例8: close

import com.sun.squawk.util.Assert; //导入依赖的package包/类
/**
 * Sends a close message to the corresponding Mailbox, explaining that no more messages will be sent via this
 * MailboxAddress. Also closes otherAddress if it's open, to eagerly break connections between isolates.
 * Redundant closes on a Mailbox are ignored.
 *
 * Do NOT call while synchronized on "this". Can deadlock on otherAddress.close().
 *
 * @todo Rethink how to close otherAddress only semi-agressivly. Reaper thread, or close
 * dead Mailbox addresses before attampting a hibernate.
 */
public void close() {
    try {
        synchronized (this) {
            if (state != OPEN) {
                return;
            }
            Assert.that(mailbox != null, "mailbox is null");
            Assert.that(otherAddress != null, "otherAddress is null");
            Assert.that(owner != null, "owner is null");
            
            send(new AddressClosedEnvelope());
            closeLocalState();
        }
        
        if (otherAddress.isOpen()) {
            otherAddress.close();
        }
    } catch (AddressClosedException ex) {
        // send() will have closeLocalState() for us...
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:32,代码来源:MailboxAddress.java


示例9: getSockOpt

import com.sun.squawk.util.Assert; //导入依赖的package包/类
/**
 * get a socket option
 * 
 * @param socket socket descriptor
 * @param level Socket.SOL_SOCKET, etc.
 * @param option_name 
 * @return socket option value
 * @throws IOException on error
 */
public int getSockOpt(int socket, int level, int option_name) throws IOException {
    IntByReference value = new IntByReference(0);
    IntByReference opt_len = new IntByReference(4);
    if (DEBUG) { System.out.println("getsockopt(" + socket + ", " + level + ", " + option_name + ")"); }

    int err = sockets.getsockopt(socket, level, option_name, value, opt_len);
    if (DEBUG) { System.out.println("    returned value: " + value.getValue() + ", size: " + opt_len.getValue()); }

    int result = value.getValue();
    value.free();
    Assert.that(opt_len.getValue() == 4);
    opt_len.free();
    LibCUtil.errCheckNeg(err);
    return result;
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:25,代码来源:GCFSocketsImpl.java


示例10: opc_putstatic

import com.sun.squawk.util.Assert; //导入依赖的package包/类
/**
 * Processes an instruction that pops a value from the
 * operand stack and assigns it to a static field.
 *
 * @param field  the referenced field
 */
private void opc_putstatic(Field field) {
    if (field.hasConstant() && field.getType().isPrimitive()) {

        if (VM.getCurrentIsolate().getLeafSuite().contains(field.getDefiningClass())) {
            // Class structure can be modified so set the flag indicating that it
            // should reify its constant fields when it is initialized.
        	// Assume class defined in a parent suite to be read only
            field.getDefiningClass().updateModifiers(Modifier.COMPLETE_RUNTIME_STATICS);
        } else {
            throw Assert.shouldNotReachHere("writing to constant field of immutable class not supported");
        }
    }

    // java   putstatic stack ops: value -> ...  (stack usage: 1)
    // squawk putstatic stack ops: value -> ..., or class_object, value -> ....  (stack usage: 2)
    // so change maxstack, but after append.

    StackProducer value = frame.pop(field.getType());
    PutStatic instruction = new PutStatic(field, value);
    append(instruction);
    if (field.getDefiningClass() != method.getDefiningClass()) {
        frame.growMaxStack(1); // for the class_ version
    }
    frame.resetMaxStack();
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:32,代码来源:IRBuilder.java


示例11: emitStore

import com.sun.squawk.util.Assert; //导入依赖的package包/类
/**
 * Emit a store instruction.
 *
 * @param index the local
 */
private void emitStore(boolean isParm, boolean isLong, int index) {
    Assert.that(isParm || index != 0, "slot 0 is reserved for method pointer");
    if (isLong) {
        if (isParm) {
            emitUnsigned(OPC.STOREPARM_I2, index);
        } else {
            emitUnsigned(OPC.STORE_I2, index);
        }
    } else {
        if (isParm) {
            emitUnsigned(OPC.STOREPARM, index);
        } else {
            emitCompact(OPC.STORE, OPC.STORE_0, 16, index);
        }
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:22,代码来源:InstructionEmitter.java


示例12: registerChannelID

import com.sun.squawk.util.Assert; //导入依赖的package包/类
static void registerChannelID(ChannelID id) {
            synchronized (channelIDFinalizerLock) {
                // Set channelIDs prior to starting the Finalizer thread
                Assert.always(id.next == null);
                id.next = channelIDs;
                channelIDs = id;
/*
                if (channelIDFinalizer == null) {
                    channelIDFinalizer = new Finalizer();
                    VM.setAsDaemonThread(channelIDFinalizer);
                    channelIDFinalizer.setPriority(Thread.MIN_PRIORITY);
                    channelIDFinalizer.start();
                }
                */
            }
        }
 
开发者ID:tomatsu,项目名称:squawk,代码行数:17,代码来源:Protocol.java


示例13: push

import com.sun.squawk.util.Assert; //导入依赖的package包/类
/**
 * Pushes a value to the operand stack.
 *
 * @param producer the instruction producing the value being pushed
 */
public void push(StackProducer producer) {
    Klass type = producer.getType();
    Assert.that(type != Klass.VOID);

    /*
     * Check for overflow and push the producer.
     */
    if (sp == maxStack) {
        throw codeParser.verifyError("operand stack overflow");
    }
    stack[sp++] = producer;

    /*
     * For long and double check for overflow and then add a null word to the stack.
     */
    if (type.isDoubleWord()) {
        if (sp == maxStack) {
            throw codeParser.verifyError("operand stack overflow");
        }
        stack[sp++] = null;
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:28,代码来源:Frame.java


示例14: append

import com.sun.squawk.util.Assert; //导入依赖的package包/类
/**
 * Append a given instruction to the IR. If the instruction pushes a value
 * to the operand stack, then the push is also done here.
 *
 * @param instruction  the instruction to append
 */
private void append(Instruction instruction) {
    if (instruction.constrainsStack()) {
        frame.spillStack();
    }

    instruction.setBytecodeOffset(codeParser.getLastOpcodeAddress());
    ir.append(instruction);
    if (instruction instanceof StackProducer) {
        StackProducer producer = (StackProducer)instruction;
        if (producer.getType() != Klass.VOID) {
            frame.push(producer);
        } else {
            Assert.that(producer instanceof Invoke);
        }
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:23,代码来源:IRBuilder.java


示例15: mergeMethodsObjectTable

import com.sun.squawk.util.Assert; //导入依赖的package包/类
void mergeMethodsObjectTable(Translator translator, Code[] methodsCode, boolean isStatic) {
    for (int i = 0; i < methodsCode.length; i++) {
        Method method = definedClass.getMethod(i, isStatic);
        Code code = methodsCode[i];
        if (!method.isHosted() && !method.isAbstract() && !method.isNative()) {
            Assert.that(code != null);
            boolean unusedMethod = safeToDoDeadMethodElim && !translator.dme.isMarkedUsed(method);
            if (unusedMethod) {
                if (safeToDoDeadStringElim) {
                    if (Translator.TRACING_ENABLED && Tracer.isTracing("converting", method.toString())) {
                        Tracer.traceln("Ignoring objects used by unused method " + method);
                    }
                } else {
                    mergeObjectTable(code.getObjectTable(), true);
                }
            } else {
                mergeObjectTable(code.getObjectTable(), false);
            }
        }
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:22,代码来源:ObjectTable.java


示例16: append

import com.sun.squawk.util.Assert; //导入依赖的package包/类
/**
     * Append an instruction to the end of the instruction sequence represented
     * by this IR. The instruction sequence must not already contain
     * <code>instruction</code>.
     *
     * @param instruction  the instruction to append
     */
    public void append(Instruction instruction) {
        if (head == null) {
            Assert.that(tail == null);
            head = tail = instruction;
        } else {
            Assert.that(tail != null);
            Assert.that(!findInstruction(instruction), "instruction cannot be in IR twice");
            tail.next = instruction;
            instruction.previous = tail;
            instruction.next = null;
            tail = instruction;
        }
//Assert.that(findInstruction(instruction));
//Assert.that(findInstruction(head));
//Assert.that(findInstruction(tail));
    }
 
开发者ID:tomatsu,项目名称:squawk,代码行数:24,代码来源:IR.java


示例17: copyIntoFDSet

import com.sun.squawk.util.Assert; //导入依赖的package包/类
private static int copyIntoFDSet(IntSet src, Pointer fd_set) {
//System.err.println("Copying from " + src + " to " + fd_set);
        int num = src.size();
        int[] data = src.getElements();
        int localMax = 0;
        FD_ZERO(fd_set);
        for (int i = 0; i < num; i++) {
            int fd = data[i];
            Assert.that(fd > 0);
            Select.INSTANCE.FD_SET(fd, fd_set);
            if (fd > localMax) {
                localMax = fd;
            }
        }
        return localMax;
    }
 
开发者ID:tomatsu,项目名称:squawk,代码行数:17,代码来源:SystemEventsImpl.java


示例18: toString

import com.sun.squawk.util.Assert; //导入依赖的package包/类
/**
 * Gets the string representation of the pseudo opcode
 *
 * @return a string
 */
public String toString() {
    if (Assert.ASSERTS_ENABLED) {
        String str = null;
        switch (tag) {
            case TRY:      str = "try";         break;
            case TRYEND:   str = "tryend";      break;
            case CATCH:    str = "catch";       break;
            case TARGET:   str = "target";      break;
            case POSITION: str = "position";    break;
            default: Assert.shouldNotReachHere();
        }
        return "["+str +"] index = "+index+" context = "+context;
    } else {
       return super.toString();
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:22,代码来源:CodeParser.java


示例19: emitConstantObject

import com.sun.squawk.util.Assert; //导入依赖的package包/类
/**
     * Emit a load object instruction.
     *
     * @param object the object
     */
    private void emitConstantObject(Object object) {
/*if[TYPEMAP]*/
        byte savedResultType = resultType;
        resultType = AddressType.REF;
/*end[TYPEMAP]*/
        if (object == null) {
            emitOpcode(OPC.CONST_NULL);
        } else {
            try {
                int index = classFile.getObjectTable().getConstantObjectIndex(object, state == EMIT);
                Object o2 = classFile.getDefinedClass().getObject(index);
//                if (!object.equals(o2)) {
//                    byte[] a = (byte[])object;
//                    byte[] b = (byte[])o2;
//                    for (int i = 0; i < a.length; i++) {
//                        System.out.println("a: " + a[i] + " b: " + b[i]);
//                    }
//                }

                Assert.always((object.equals(o2) || ObjectTable.compareIgnoringCount(object, o2) == 0),
                        classFile.getDefinedClass() + " object = '" + object + "' index = " + index  + " object2 = " + o2);
                emitCompact(OPC.OBJECT, OPC.OBJECT_0, 16, index);
            } catch (java.util.NoSuchElementException ex) {
                throw new NoClassDefFoundError("no copy of object in class's object table: " + object);
            }
        }
/*if[TYPEMAP]*/
        resultType = savedResultType;
/*end[TYPEMAP]*/
    }
 
开发者ID:tomatsu,项目名称:squawk,代码行数:36,代码来源:InstructionEmitter.java


示例20: reportBreakpoint

import com.sun.squawk.util.Assert; //导入依赖的package包/类
/**
 * Called when current thread hits a breakpoint. The breakpoint is reported to
 * the event manager in the debugger. This thread is then suspended
 * until the debugger resumes it.
 *
 * @param hitFO   offset (in bytes) from top of stack of the frame reporting the breakpoint
 * @param hitBCI  the bytecode index of the instruction at which the breakpoint was set
 */
static void reportBreakpoint(Offset hitFO, Offset hitBCI) throws InterpreterInvokedPragma {
    VMThread thread = VMThread.currentThread();
    Debugger debugger = VM.getCurrentIsolate().getDebugger();
    Assert.always(debugger != null);
    try {
        thread.reportBreakpoint(hitFO, hitBCI, debugger);
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:19,代码来源:VM.java



注:本文中的com.sun.squawk.util.Assert类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DataAdapterService类代码示例发布时间:2022-05-16
下一篇:
Java WritableLongObjectInspector类代码示例发布时间:2022-05-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap