当前位置: 首页>>代码示例>>Java>>正文


Java VM.execSyncIO方法代码示例

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


在下文中一共展示了VM.execSyncIO方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getInstance

import com.sun.squawk.VM; //导入方法依赖的package包/类
/**
 * Look up a native libray named "name". Load if not loaded. Name can be a path or a libray name.
 * The Library will be looked up in a platform-dependant manor.
 * 
 * @param name short library name, full file name, or path to the library file
 * @return NativeLibrary
 */
public static NativeLibrary getInstance(String name) {
    String nativeName = nativeLibraryName(name);
    Pointer name0 = Pointer.createStringBuffer(nativeName);
    if (DEBUG) {
        VM.print("Calling DLOPEN on ");
        VM.println(name);
    }
    int result = VM.execSyncIO(ChannelConstants.DLOPEN, name0.address().toUWord().toInt(), 0, 0, 0, 0, 0, null, null);
    Address r = Address.fromPrimitive(result);
    name0.free();
    if (r.isZero()) {
        throw new RuntimeException("Can't open library " + name + ". OS Error: " + errorStr());
    }
    return new NativeLibrary(name, r);
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:23,代码来源:NativeLibrary.java

示例2: 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

示例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: getSymbolAddress

import com.sun.squawk.VM; //导入方法依赖的package包/类
/**
 * getFunction a symbol's address by name (warpper around dlsym)
 * @param name
 * @return Address of symbol
 */
private Address getSymbolAddress(String name) {
    if (closed) {
        throw new IllegalStateException("closed");
    }
    if (DEBUG) {
        VM.print("Calling DLSYM on ");
        VM.println(name);
    }
    Pointer name0 = Pointer.createStringBuffer(name);
    int result = VM.execSyncIO(ChannelConstants.DLSYM, ptr.toUWord().toInt(), name0.address().toUWord().toInt(), 0, 0, 0, 0, null, null);
    name0.free();
    return Address.fromPrimitive(result);
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:19,代码来源:NativeLibrary.java

示例5: 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

示例6: errorStr

import com.sun.squawk.VM; //导入方法依赖的package包/类
/**
 * Get any error message provided by the platform (as in dlerror). If no error, then return null.
 * 
 * Note that calling this method clears the error state, so calling two times without calling any other 
 * platform getFunction method (getInstance(), getFunction(), getGlobalVariableAddress(), dispose()) will result in returning null.
 * @return String (may be null)
 */
public static String errorStr() {
    if (DEBUG) {
        VM.println("Calling DLERROR");
    }
    int result = VM.execSyncIO(ChannelConstants.DLERROR, 0, 0, 0, 0, 0, 0, null, null);
    Address r = Address.fromPrimitive(result);
    if (r.isZero()) {
        return null;
    } else {
        return Pointer.NativeUnsafeGetString(r);
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:20,代码来源:NativeLibrary.java

示例7: getNativePlatformName

import com.sun.squawk.VM; //导入方法依赖的package包/类
/**
 * Get the name of the package that contains the native implementation for this platform:
 */
private static String getNativePlatformName() {
    int result = VM.execSyncIO(ChannelConstants.INTERNAL_NATIVE_PLATFORM_NAME, 0, 0, 0, 0, 0, 0, null, null);
    Address r = Address.fromPrimitive(result);
    if (r.isZero()) {
        return null;
    } else {
        return Pointer.NativeUnsafeGetString(r);
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:13,代码来源:Platform.java

示例8: verify

import com.sun.squawk.VM; //导入方法依赖的package包/类
/**
	 * Verifies a buffer 
     * @param buffer 
     * @param bufferOffset 
     * @param bufferLength 
     * @param signature 
     * @param signatureOffset 
     * @param signatureLength
     * @todo javadoc
	 * @throws SignatureVerifierException
	 */
	public static void verify(byte[] buffer, int bufferOffset, int bufferLength, byte[] signature, int signatureOffset,
			int signatureLength) throws SignatureVerifierException {
		ensureInitialized();
		byte[] result = new byte[20];

/*if[NATIVE_VERIFICATION]*/
    	Address address=Address.fromObject((buffer));
    	address=address.addOffset(Offset.fromPrimitive(bufferOffset));
    	if (SignatureVerifier.DEBUG) {
    		System.out.println("verify using native SHA1.\n\t Address for compute hash : "+address.toUWord().toInt()+
    				"Includes Offset: "+bufferOffset);
        }
    	VM.execSyncIO(ChannelConstants.INTERNAL_COMPUTE_SHA1_FOR_MEMORY_REGION,address.toUWord().toInt(), bufferLength , 0, 0, 0, 0, result, null);
		
		result = Arrays.copy(result, 0, 20, 0, 20);
		if (SignatureVerifier.DEBUG) {
			System.out.println("Hash computed using NATIVE function: \n"+HexEncoding.hexEncode(result));
        }
/*else[NATIVE_VERIFICATION]*/	
//	md.reset();
//  md.doFinal(buffer, bufferOffset, bufferLength, result, 0);
//  if (SignatureVerifier.DEBUG)		
//			System.out.println("Hash computed using Java class: \n"+HexEncoding.hexEncode(result));
//		
/*end[NATIVE_VERIFICATION]*/
		if (!verifyMessageDigest(result, signature,signatureOffset,signatureLength)) {
			throw new SignatureVerifierException("Signature verification failed");
		}
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:41,代码来源:SignatureVerifier.java


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