本文整理汇总了Java中com.sun.squawk.util.Assert类的典型用法代码示例。如果您正苦于以下问题:Java Assert类的具体用法?Java Assert怎么用?Java Assert使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Assert类属于com.sun.squawk.util包,在下文中一共展示了Assert类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
示例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;
}
示例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;
}
}
}
示例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;
}
示例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;
}
}
示例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;
}
}
}
示例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);
}
}
}
示例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...
}
}
示例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;
}
示例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();
}
示例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);
}
}
}
示例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();
}
*/
}
}
示例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;
}
}
示例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);
}
}
}
示例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);
}
}
}
}