本文整理汇总了Java中com.sun.squawk.VM类的典型用法代码示例。如果您正苦于以下问题:Java VM类的具体用法?Java VM怎么用?Java VM使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VM类属于com.sun.squawk包,在下文中一共展示了VM类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: allocateMemory
import com.sun.squawk.VM; //导入依赖的package包/类
/**
* Attempt to allocate backing memory for the structure.
*
* @param size in bytes ito allocate
* @throws IllegalArgumentException if the requested size is smaller than the default size
* @throws OutOfMemoryError if backing native memory cannot be allocated.
* @throws IllegalStateException if this structure already has memory allocated
*/
public void allocateMemory(int size) throws OutOfMemoryError {
int defaultsize = size();
if (size < defaultsize) {
throw new IllegalArgumentException();
}
if (backingNativeMemory != null &&
backingNativeMemory.isValid()) {
throw new IllegalStateException();
}
backingNativeMemory = new Pointer(size);
if (DEBUG) {
VM.print("Allocated memory of special size for ");
VMprintStruct();
}
}
开发者ID:tomatsu,项目名称:squawk,代码行数:24,代码来源:Structure.java
示例2: getFunction0
import com.sun.squawk.VM; //导入依赖的package包/类
/**
* Dynamically look up a native function address by name.
* Look up the symbol in the specified library
*
* @param funcName
* @return address of the function
* @throws RuntimeException if there is no function by that name.
*/
private Address getFunction0(String funcName) {
Address result = getSymbolAddress(funcName);
if (DEBUG) {
VM.print("Function Lookup for ");
VM.print(funcName);
VM.print(" = ");
VM.printAddress(result);
VM.println();
}
if (result.isZero()) {
if (Platform.getPlatform().isWindows()) {
if (funcName.charAt(funcName.length() - 1) != 'A') {
return getFunction0(funcName + 'A');
}
} else if (funcName.charAt(0) != '_') {
return getFunction0("_" + funcName);
}
throw new RuntimeException("Can't find native symbol " + funcName + ". OS Error: " + errorStr());
}
return result;
}
开发者ID:tomatsu,项目名称:squawk,代码行数:30,代码来源:NativeLibrary.java
示例3: dispose
import com.sun.squawk.VM; //导入依赖的package包/类
/**
* Close the library, as in dlclose.
* @throws RuntimeException if dlcose fails
*/
public void dispose() {
if (closed || ptr.isZero()) {
throw new RuntimeException("closed or RTLD_DEFAULT");
}
if (DEBUG) {
VM.print("Calling DLCLOSE on ");
VM.println(name);
}
Pointer name0 = Pointer.createStringBuffer(name);
int result = VM.execSyncIO(ChannelConstants.DLCLOSE, ptr.toUWord().toInt(), 0, 0, 0, 0, 0, 0, null, null);
name0.free();
if (result != 0) {
throw new RuntimeException("Error on dlclose: " + errorStr());
}
closed = true;
}
开发者ID:tomatsu,项目名称:squawk,代码行数:21,代码来源:NativeLibrary.java
示例4: makePlatform
import com.sun.squawk.VM; //导入依赖的package包/类
private static Platform makePlatform() {
if (DEBUG) {
VM.println("Making Platform...");
}
Platform result = (Platform) getInstance(getNativePlatformName());
if (result == null) {
result = (Platform) getInstance("Posix");
}
if (result != null) {
if (DEBUG) {
VM.println(" created platform: " + result);
}
return result;
}
VM.println("Error in makePlatform for " + getNativePlatformName() + ". Exiting...");
VM.haltVM(1);
return null;
}
开发者ID:tomatsu,项目名称:squawk,代码行数:19,代码来源:Platform.java
示例5: getSuiteVerifiedFlagAddress
import com.sun.squawk.VM; //导入依赖的package包/类
private static int getSuiteVerifiedFlagAddress(int suiteAddress) throws IllegalArgumentException {
int slotSize = VM.execSyncIO(ChannelConstants.GET_ALLOCATED_FILE_SIZE, suiteAddress);
if (slotSize <=0 ) {
String errorMessage = "suiteAddress 0x" + Integer.toHexString(suiteAddress) + " is not pointing to a mapped file";
if (SignatureVerifier.DEBUG) {
System.out.println(errorMessage);
}
throw new IllegalArgumentException(errorMessage);
}
int verifiedFlagAddress = suiteAddress + slotSize - 1;
if (SignatureVerifier.DEBUG) {
System.out.println("verifiedFlagAddres for suite address " + Integer.toHexString(suiteAddress) + " is "
+ Integer.toHexString(verifiedFlagAddress));
}
return verifiedFlagAddress;
}
开发者ID:tomatsu,项目名称:squawk,代码行数:17,代码来源:SignatureVerifier.java
示例6: getGlobalVariableAddress
import com.sun.squawk.VM; //导入依赖的package包/类
/**
* Dynamically look up a native variable by name.
*
* Look up the symbol in the default list of loaded libraries.
*
* @param varName
* @param size the size of the variable in bytes
* @return a Pointer that can be used to get/set the variable
* @throws RuntimeException if there is no function by that name.
*/
public VarPointer getGlobalVariableAddress(String varName, int size) {
Address result = getSymbolAddress(varName);
if (DEBUG) {
VM.print("Var Lookup for ");
VM.print(varName);
VM.print(", size: ");
VM.print(size);
VM.print(" returned ");
VM.printAddress(result);
VM.println();
}
if (result.isZero()) {
if (varName.charAt(0) != '_') {
return getGlobalVariableAddress("_" + varName, size);
}
throw new RuntimeException("Can't find native symbol " + varName + ". OS Error: " + errorStr());
}
return new VarPointer(varName, result, size);
}
开发者ID:tomatsu,项目名称:squawk,代码行数:30,代码来源:NativeLibrary.java
示例7: printTable
import com.sun.squawk.VM; //导入依赖的package包/类
public static void printTable(SquawkHashtable table) {
HashtableEntry[] array = table.entryTable;
for (int i = 0; i < array.length; i++) {
HashtableEntry entry = array[i];
if (entry != null) {
VM.print(" key: ");
if (entry.key != null) {
GC.printObject(entry.key);
} else {
VM.print("null");
}
VM.print(" value: ");
if (entry.value != null) {
GC.printObject(entry.value);
} else {
VM.print("null");
}
}
}
}
开发者ID:tomatsu,项目名称:squawk,代码行数:21,代码来源:SquawkHashtable.java
示例8: getNorFlashSectors
import com.sun.squawk.VM; //导入依赖的package包/类
/**
*
* @param purpose One of INorFlashMemorySector.USER_PURPOSED, RMS_PURPOSED, or SYSTEM_PURPOSED.
* @return Vector<INorFlashMemorySector>
*/
public static Vector getNorFlashSectors(int purpose) {
// Get all user purposed flash memory sectors
INorFlashSectorAllocator allocator = (INorFlashSectorAllocator) VM.getPeripheralRegistry().getSingleton(INorFlashSectorAllocator.class);
if (allocator == null) {
throw new IllegalStateException(
/*if[VERBOSE_EXCEPTIONS]*/
"No INorFlashSectorAllocator available"
/*end[VERBOSE_EXCEPTIONS]*/
);
}
INorFlashSector[] allFlashMemorySectors;
try {
allFlashMemorySectors = allocator.getInitialSectors(purpose);
} catch (IOException e) {
throw new UnexpectedException(e);
}
Vector userSectors = new Vector(allFlashMemorySectors.length);
for (int i=0, max=allFlashMemorySectors.length; i < max; i++) {
userSectors.addElement(allFlashMemorySectors[i]);
}
return userSectors;
}
开发者ID:tomatsu,项目名称:squawk,代码行数:29,代码来源:NorFlashMemoryHeap.java
示例9: setString
import com.sun.squawk.VM; //导入依赖的package包/类
/**
* Copy string value to the location at <code>offset</code>. Convert the data in <code>value</code> to a
* NULL-terminated C string, converted to native encoding.
*
* @param offset the byte offset of the c string from the base of this pointer
* @param value the string to copy
*/
public final void setString(int offset, String value) {
// optimize for 8-bit strings.
if (GC.getKlass(value).getSystemID() == CID.STRING_OF_BYTES) {
int len = value.length();
checkMultiWrite(offset, len + 1, 1);
VM.setData(getAddress(), offset, value, 0, len, 1);
setByte((long) len, (byte) 0); // null terminate
} else {
setString(offset, value.getBytes());
}
}
开发者ID:tomatsu,项目名称:squawk,代码行数:19,代码来源:Pointer.java
示例10: create
import com.sun.squawk.VM; //导入依赖的package包/类
/**
* Creates a Mailbox with the given name and registers it with the system.
*
* <code>create</code> may immediately begin receiving messages.
* The <code>handler</code> will be used to initiate and close the logical connection to a client.
*
* @param name the name that this Mailbox can be looked up under.
* @param handler the class used to manage clients opening and closing new logical connections to the new Mailbox.
* @return the new Mailbox.
* @throws MailboxInUseException if there is already a mailbox registered under the name <code>name</code>.
*/
public static Mailbox create(String name, MailboxHandler handler) throws MailboxInUseException {
if (name == null) throw new IllegalArgumentException();
Mailbox box = new Mailbox(name, handler);
if (VM.registerMailbox(name, box)) {
box.registered = true;
return box;
} else {
box.close();
throw new MailboxInUseException(name);
}
}
开发者ID:tomatsu,项目名称:squawk,代码行数:25,代码来源:Mailbox.java
示例11: setSystemClockMock
import com.sun.squawk.VM; //导入依赖的package包/类
static void setSystemClockMock(long newTime) {
System.out.println("-----------------------------");
printLog("setting time to : " + newTime);
VM.setSystemClockMock(newTime);
printLog("time now set");
System.out.println("-----------------------------");
}
开发者ID:tomatsu,项目名称:squawk,代码行数:8,代码来源:ThreadTest.java
示例12: clear
import com.sun.squawk.VM; //导入依赖的package包/类
/**
* Zero the first "size" bytes of memory
* @param size number of bytes
*/
public void clear(int size) {
Address addr = getAddress();
if (size().lo(UWord.fromPrimitive(size))) {
throw new IllegalArgumentException();
}
if (addr.isZero()) {
throw new IllegalStateException();
}
VM.setBytes(addr, (byte)0, size);
}
开发者ID:tomatsu,项目名称:squawk,代码行数:15,代码来源:Pointer.java
示例13: write
import com.sun.squawk.VM; //导入依赖的package包/类
public void write(byte b[], int off, int len) throws IOException {
Arrays.boundsCheck(b.length, off, len);
if (len == 0) {
return;
}
int old;
if (err) {
old = VM.setStream(VM.STREAM_STDERR);
} else {
old = VM.setStream(VM.STREAM_STDOUT);
}
VM.printBytes(b, off, len);
VM.setStream(old);
}
开发者ID:tomatsu,项目名称:squawk,代码行数:15,代码来源:System.java
示例14: clear
import com.sun.squawk.VM; //导入依赖的package包/类
/**
* Zero memory
*/
public void clear() {
Address addr = getAddress();
if (addr.isZero()) {
throw new IllegalStateException();
}
VM.setBytes(addr, (byte) 0, getSize());
}
开发者ID:tomatsu,项目名称:squawk,代码行数:11,代码来源:Pointer.java
示例15: isExternallyVisible
import com.sun.squawk.VM; //导入依赖的package包/类
/**
* Given the classes's access and the suite type,
* determine the final accessibility of the class outside of this suite.
*
* @param klass the klass
* @return true if an external suite could possibly access this klass.
*/
public boolean isExternallyVisible(Klass klass) {
int modifiers = klass.getModifiers();
int suiteType = translator.getSuiteType();
if (VM.isDynamic(klass)) {
// if "dynamic", then class may be loaded by Class.findClass(), so we have to assume that it is used.
Assert.always(!VM.isInternal(klass));
return true;
} else if (VM.isInternal(klass)) {
// if the symbol wasn't marked as "export" or "dynamic" in the library.proprties file,
// then there is no way that this is externally visible.
return false;
} else {
// It's declared externally visible, but is it really?
Assert.that(Modifier.isPackagePrivate(modifiers) || Modifier.isProtected(modifiers) || Modifier.isPublic(modifiers));
switch (suiteType) {
case Suite.APPLICATION:
return false;
case Suite.LIBRARY:
// what can we do here
if (Modifier.isPackagePrivate(modifiers)) {
// treat as internal:
/*if[ENABLE_VERBOSE]*/
if (VM.isVerbose()) {
System.out.println("### FYI - Found package-private class: " + klass);
}
/*end[ENABLE_VERBOSE]*/
return false;
}
return true;
default:
// extendable and debuggable suites leave all symbols externally visible.
return true;
}
}
}
开发者ID:tomatsu,项目名称:squawk,代码行数:45,代码来源:DeadClassEliminator.java
示例16: postscript
import com.sun.squawk.VM; //导入依赖的package包/类
protected void postscript(int result) {
VM.print("DONE: ");
VM.print(name);
VM.print(".blockingCall returned: ");
VM.print(result);
VM.println();
}
开发者ID:tomatsu,项目名称:squawk,代码行数:8,代码来源:BlockingFunction.java
示例17: VMprintStruct
import com.sun.squawk.VM; //导入依赖的package包/类
/** Debug utility */
private void VMprintStruct() {
VM.print("Structure(");
VM.print(Klass.asKlass(getClass()).getInternalName());
VM.print(" size: ");
VM.print(size());
if (backingNativeMemory == null) {
VM.println(" memory never allocated)");
} else {
VM.print(" Pointer(");
VM.printAddress(getPointer().address());
VM.println("))");
}
}
开发者ID:tomatsu,项目名称:squawk,代码行数:15,代码来源:Structure.java
示例18: setSuiteVerifiedFlag
import com.sun.squawk.VM; //导入依赖的package包/类
private static void setSuiteVerifiedFlag(int suiteAddress) throws IllegalArgumentException {
int verifiedFlagAddress = getSuiteVerifiedFlagAddress(suiteAddress);
// if (SignatureVerifier.DEBUG)
// System.out
// .println("Setting suiteVerifiedFlag.\n\tCurrent value"
// + suiteVerifiedFlag + "\n\tShould be"
// + suiteVerifiedFlag + "\n\tSet to "
// + SUITE_VERIFIED + "\n\tsuiteaddress:"
// + suiteAddress + "\n\tverifiedFlagAddress:"
// + (verifiedFlagAddress));
// Set the suiteVerifiedFlag to verified.
byte[] tb = new byte[2];
// Ensure to flash at an even address.
// Not doing so just hangs the SPOT.
if (verifiedFlagAddress % 2 == 0) {
tb[0] = (byte) SUITE_VERIFIED;
tb[1] = (byte) (Unsafe.getByte(Address.zero().add(verifiedFlagAddress + 1), 0) & (0xff));
if (SignatureVerifier.DEBUG) {
System.out.println("Address even. writing: "
+ HexEncoding.hexEncode(tb) + " to "
+ verifiedFlagAddress);
}
VM.execSyncIO(ChannelConstants.FLASH_WRITE, verifiedFlagAddress, 2, 0, 0, 0, 0, tb, null);
} else {
tb[0] = (byte) (Unsafe.getByte(Address.zero().add(verifiedFlagAddress - 1), 0) & (0xff));
tb[1] = (byte) SUITE_VERIFIED;
if (SignatureVerifier.DEBUG) {
System.out.println("Address uneven. writing: "
+ HexEncoding.hexEncode(tb) + " to "
+ (verifiedFlagAddress - 1));
}
VM.execSyncIO(ChannelConstants.FLASH_WRITE, verifiedFlagAddress - 1, 2, 0, 0, 0, 0, tb, null);
}
if (!getSuiteVerifiedFlag(suiteAddress)) {
System.out.println("Warning: Setting suite verified flag failed.");
}
}
开发者ID:tomatsu,项目名称:squawk,代码行数:40,代码来源:SignatureVerifier.java
示例19: waitForWriteEvent
import com.sun.squawk.VM; //导入依赖的package包/类
public void waitForWriteEvent(int fd) {
if (DEBUG) { VM.println("waitForWriteEvent fd: " + fd); }
Assert.that(fd >= 0 && fd < Select.FD_SETSIZE);
writeSet.add(fd);
updateSets();
cancelSelectCall();
VMThread.waitForOSEvent(fd);// write is ready, select will remove fd from writeSet
}
开发者ID:tomatsu,项目名称:squawk,代码行数:9,代码来源:SystemEventsImpl.java
示例20: freeMemory
import com.sun.squawk.VM; //导入依赖的package包/类
/**
* Free the backing memory for the structure.
*
* @throws IllegalStateException if the memory has already been freed.
*/
public void freeMemory() throws IllegalStateException {
if (DEBUG) {
VM.print("Freeing memory for ");
VMprintStruct();
}
backingNativeMemory.free();
backingNativeMemory = null;
}
开发者ID:tomatsu,项目名称:squawk,代码行数:14,代码来源:Structure.java
注:本文中的com.sun.squawk.VM类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论