本文整理汇总了Java中com.sun.squawk.util.Assert.always方法的典型用法代码示例。如果您正苦于以下问题:Java Assert.always方法的具体用法?Java Assert.always怎么用?Java Assert.always使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.squawk.util.Assert
的用法示例。
在下文中一共展示了Assert.always方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: save
import com.sun.squawk.util.Assert; //导入方法依赖的package包/类
/**
* Serializes the object graph rooted by this suite and writes it to a given stream.
*
* @param dos the DataOutputStream to which the serialized suite should be written
* @param uri the URI identifier of the serialized suite
* @param bigEndian the endianess to be used when serializing this suite
*
* @return if hosted, returns the objectMemory that suite was saved to
* @throws OutOfMemoryError if there was insufficient memory to do the save
* @throws IOException if there was some IO problem while writing the output
*/
public ObjectMemory save(DataOutputStream dos, String uri, boolean bigEndian) throws HostedPragma, java.io.IOException, OutOfMemoryError {
stripClassesLater = null; // don't save this...
ObjectMemorySerializer.ControlBlock cb = VM.copyObjectGraph(this);
ObjectMemory parentMemory = null;
if (!isBootstrap()) {
parentMemory = parent.getReadOnlyObjectMemory();
Assert.always(parentMemory != null); // "parent not found: " + parent
}
checkSuite();
ObjectMemorySerializer.save(dos, uri, cb, parentMemory, bigEndian);
ObjectMemory objectMemory;
/*if[ENABLE_HOSTED]*/
if (VM.isHosted()) {
objectMemory = saveHosted(uri, cb, parentMemory);
} else
/*end[ENABLE_HOSTED]*/
{
objectMemory = null;
}
return objectMemory;
}
示例2: 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();
}
}
示例3: setStream
import com.sun.squawk.util.Assert; //导入方法依赖的package包/类
/**
* Sets the stream for the VM.print... methods to one of the STREAM_... constants.
*
* @param stream the stream to use for the print... methods
* @return the current stream used for VM printing
*/
public static int setStream(int stream) {
/*if[FLASH_MEMORY]*/
Assert.always(stream >= STREAM_STDOUT && stream <= STREAM_STDERR); // "invalid stream specifier"
/*else[FLASH_MEMORY]*/
// Assert.always(stream >= STREAM_STDOUT && stream <= STREAM_SYMBOLS); // "invalid stream specifier"
/*end[FLASH_MEMORY]*/
return setStream0(stream);
}
示例4: setStream
import com.sun.squawk.util.Assert; //导入方法依赖的package包/类
/**
* Sets the stream for the VM.print... methods to one of the STREAM_... constants.
*
* @param stream the stream to use for the print... methods
* @return old stream
*/
public static int setStream(int stream) {
Assert.always(stream >= STREAM_STDOUT && stream <= STREAM_HEAPTRACE, "invalid stream specifier");
int old = VM.stream;
VM.stream = stream;
return old;
}
示例5: check
import com.sun.squawk.util.Assert; //导入方法依赖的package包/类
/**
* Give error if cs is not really global array.
*/
public static void check(Object cs) throws AllowInlinedPragma {
if (DEBUG) {
Assert.always(cs != null);
if (GC.isSafeToSwitchThreads()) {
Assert.always(GC.getKlass(cs).getSystemID() == CID.GLOBAL_ARRAY);
if (NativeUnsafe.getObject(cs, CS.klass) != null) {
Assert.always(GC.getKlass(NativeUnsafe.getObject(cs, CS.klass) ).getSystemID() == CID.KLASS);
}
if (NativeUnsafe.getObject(cs, CS.next) != null) {
Assert.always(GC.getKlass(NativeUnsafe.getObject(cs, CS.next) ).getSystemID() == CID.GLOBAL_ARRAY);
}
}
}
}
示例6: pruneIsolateList
import com.sun.squawk.util.Assert; //导入方法依赖的package包/类
/**
* Prunes the entries for dead isolates from the weakly linked list of isolates.
*/
static void pruneIsolateList() {
Assert.always(isolates != null);
//VM.println("VM::pruneIsolateList --- start --");
WeakIsolateListEntry head = null;
WeakIsolateListEntry last = null;
WeakIsolateListEntry entry = isolates;
isolates = null;
while (entry != null) {
//VM.print("VM::pruneIsolateList - entry = ");
//VM.printAddress(entry);
if (entry.get() != null) {
//VM.print(" entry.isolate = ");
//VM.printAddress(entry.get());
//VM.print(" [");
//VM.print(((Isolate)entry.get()).getMainClassName());
//VM.println("]");
if (head == null) {
head = last = entry;
} else {
last.nextIsolateRef = entry;
last = entry;
}
} else {
//VM.println(" entry.isolate = null");
}
entry = entry.nextIsolateRef;
}
// At least the primordial isolate must be alive
Assert.always(last != null);
last.nextIsolateRef = null;
isolates = head;
//VM.println("VM::pruneIsolateList --- start --");
}
示例7: doCheck
import com.sun.squawk.util.Assert; //导入方法依赖的package包/类
private void doCheck() {
didCheck = true;
int sysFD_SIZE = NativeLibrary.getDefaultInstance().getGlobalVariableAddress("sysFD_SIZE", 4).getInt(0);
Assert.always(select.FD_SETSIZE == (sysFD_SIZE * 8), "select.FD_SETSIZE: " + select.FD_SETSIZE + " sysFD_SIZE: " + sysFD_SIZE);
Assert.always(select.fd_set_SIZEOF == sysFD_SIZE, "fd_set_SIZEOF: " + select.fd_set_SIZEOF);
}
示例8: close
import com.sun.squawk.util.Assert; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public void close(int suiteType) throws NoClassDefFoundError {
long time = 0;
this.suiteType = suiteType;
if (verbose()) {
Tracer.trace("[Translator: computing closure...");
time = System.currentTimeMillis();
}
computeClosure();
if (translationStrategy == BY_SUITE || translationStrategy == BY_TRANSLATION) {
if (verbose()) {
time = System.currentTimeMillis() - time;
Tracer.traceln(time + "ms.]");
Tracer.trace("[Translator: whole-suite optimizing and inlining...");
time = System.currentTimeMillis();
}
// bytecode optimizations and inlining go here
if (Arg.get(Arg.DEAD_METHOD_ELIMINATION).getBool()) {
dme = new DeadMethodEliminator(this);
dme.computeMethodsUsed();
}
if (Arg.get(Arg.DEAD_CLASS_ELIMINATION).getBool()) {
dce = new DeadClassEliminator(this);
dce.computeClassesUsed();
}
if (Arg.get(Arg.DEAD_METHOD_ELIMINATION).getBool()) {
dme = new DeadMethodEliminator(this);
dme.computeMethodsUsed();
}
if (verbose()) {
time = System.currentTimeMillis() - time;
Tracer.traceln(time + "ms.]");
Tracer.trace("[Translator: phase2...");
time = System.currentTimeMillis();
}
for (int cno = 0; cno < suite.getClassCount(); cno++) {
Klass klass = suite.getKlass(cno);
Assert.always(Arg.get(Arg.DEAD_CLASS_ELIMINATION).getBool() || (klass != null));
if (klass != null) {
convertPhase2(klass);
}
}
}
classFiles.clear();
if (verbose()) {
time = System.currentTimeMillis() - time;
Tracer.traceln(time + "ms.]");
/*if[ENABLE_VERBOSE]*/
if (VM.isVeryVerbose()) {
InstructionEmitter.printUncalledNativeMethods();
}
/*end[ENABLE_VERBOSE]*/
}
Assert.always(lastClassNameStack.empty());
}
示例9: reifyStack0
import com.sun.squawk.util.Assert; //导入方法依赖的package包/类
/**
* Returns an array of stack trace elements, each representing one stack frame in the current call stack.
* The zeroth element of the array represents the top of the stack, which is the frame of the caller's
* method. The last element of the array represents the bottom of the stack, which is the first method
* invocation in the sequence.
*
* NOTE: This method may retun null ExecutionPoints in the aray if an error occurs while decoding the stack.
*
* @param thread the thread to inspect
* @param count how many frames from the stack to reify, starting from the frame
* of the method that called this one. A negative value specifies that
* all frames are to be reified.
* @return the reified call stack
*/
private static ExecutionPoint[] reifyStack0(VMThread thread, Address fpBase, int count) {
Object stack = thread.getStack();
if (fpBase.isZero() || insaneFP(stack, fpBase)) {
return new ExecutionPoint[0];
}
/*
* Count the number of frames and allocate the array.
*/
Assert.always(stack != null);
Offset fpBaseOffset = fpBase.diff(Address.fromObject(stack));
int frames = 0;
Address fp;
/*
* Count the number of frames in GC free zone.
*/
fp = fpBase;
// Skip frame for this method
fp = VM.getPreviousFP(fp);
while (!fp.isZero()) {
frames++;
fp = VM.getPreviousFP(fp);
}
// GC might invalidate these ocasionally, so let's do it explicitly:
fpBase = Address.zero();
fp = Address.zero();
// Skip unrequested frames
if (count >= 0 && count < frames) {
frames = count;
}
if (frames <= 0) {
return new ExecutionPoint[0];
}
// WARNING: Allocation may cause GC, which will invalidate all Addresses.
ExecutionPoint[] trace = new ExecutionPoint[frames];
fp = Address.fromObject(stack).addOffset(fpBaseOffset); // recompute Address
for (int i = 0; i != frames; ++i) {
Address ip = VM.getPreviousIP(fp);
fp = VM.getPreviousFP(fp);
if (insaneFP(stack, fp)) {
return trace;
}
Object mp = VM.getMP(fp);
Offset bci = ip.diff(Address.fromObject(mp));
// The allocation of the ExecutionPoint object may cause
// a collection and so the fp need's to be saved as a
// stack offset and restored after the allocation
Offset fpOffset = fp.diff(Address.fromObject(stack));
fp = Address.zero(); // GC might invalidate this ocasionally, so let's do it explicitly:
trace[i] = new ExecutionPoint(fpOffset, bci, mp);
fp = Address.fromObject(stack).addOffset(fpOffset);
}
return trace;
}
示例10: createArrayBuffer
import com.sun.squawk.util.Assert; //导入方法依赖的package包/类
/**
* Create a native buffer pointing to either the array data directly,
* or to a copy of the array data.
* bytes
* The returned pointer can be released when not needed.
*
* WARNING: You MUST call preCheckArrayBuffer() on "array", "offset", "number"
* before calling createArrayBuffer(), because it is too late to throw an exception now.
*
* WARNING: You MUST have called setUpArrayStateBuffer before calling createArrayBuffer().
*
* @param array the array to access
* @param offset index of the first element to access
* @param number number of elements to access
* @return Pointer the C-accessible version of the array data
*/
public static Address createArrayBuffer(Object array, int offset, int number) {
Assert.always(GC.setGCEnabled(false) == false);
Assert.that(GC.getKlass(array).isArray());
Klass klass = GC.getKlass(array);
int elemsize = klass.getComponentType().getDataSize();
return Address.fromObject(array).add(offset * elemsize);
}
示例11: createArrayBuffer
import com.sun.squawk.util.Assert; //导入方法依赖的package包/类
/**
* Create a native buffer pointing to either the array data directly,
* or to a copy of the array data.
* The returned pointer can be released when not needed.
*
* WARNING: You MUST call preCheckArrayBuffer() on "array"
* before calling createArrayBuffer(), because it is too late to throw an exception now.
*
* WARNING: You MUST have called setUpArrayStateBuffer before calling createArrayBuffer().
*
* @param array the array to access
* @return Pointer the C-accessible version of the array data
*/
public static Address createArrayBuffer(Object array) {
Assert.always(GC.setGCEnabled(false) == false);
Assert.that(GC.getKlass(array).isArray());
return Address.fromObject(array);
}