本文整理汇总了Java中com.sun.squawk.NativeUnsafe类的典型用法代码示例。如果您正苦于以下问题:Java NativeUnsafe类的具体用法?Java NativeUnsafe怎么用?Java NativeUnsafe使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NativeUnsafe类属于com.sun.squawk包,在下文中一共展示了NativeUnsafe类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compareToIgnoreCase
import com.sun.squawk.NativeUnsafe; //导入依赖的package包/类
public int compareToIgnoreCase(String anotherString) {
int len1 = length();
int len2 = anotherString.length();
int lth = len1 < len2 ? len1 : len2;
for (int i = 0 ; i < lth ; i++) {
char c1 = NativeUnsafe.charAt(this, i);
char c2 = NativeUnsafe.charAt(anotherString, i);
if (c1 != c2) {
c1 = Character.toUpperCase(c1);
c2 = Character.toUpperCase(c2);
if (c1 != c2) {
c1 = Character.toLowerCase(c1);
c2 = Character.toLowerCase(c2);
if (c1 != c2) {
return c1 - c2;
}
}
}
}
return len1 - len2;
}
示例2: contentEquals
import com.sun.squawk.NativeUnsafe; //导入依赖的package包/类
/**
* Compares this string to the specified {@code CharSequence}. The result
* is {@code true} if and only if this {@code String} represents the same
* sequence of char values as the specified sequence.
*
* @param cs
* The sequence to compare this {@code String} against
*
* @return {@code true} if this {@code String} represents the same
* sequence of char values as the specified sequence, {@code
* false} otherwise
*
* @since 1.5
*/
public boolean contentEquals(CharSequence cs) {
if (length() != cs.length()) {
return false;
}
if (cs instanceof String) {
return ((String)cs).equals(this);
}
int lth = length();
for (int i = 0 ; i < lth ; i++) {
if (NativeUnsafe.charAt(this, i) != cs.charAt(i)) {
return false;
}
}
return true;
}
示例3: call8
import com.sun.squawk.NativeUnsafe; //导入依赖的package包/类
public int call8(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8) {
if (DEBUG) {
preamble();
}
TaskExecutor te = getTE();
Address ntask = te.runBlockingFunction(funcAddr, i1, i2, i3, i4, i5, i6, i7, i8, 0, 0);
int result = NativeUnsafe.waitForBlockingFunction(ntask);
if (DEBUG) {
postscript(result);
}
te.cleanup();
return result;
}
示例4: equals
import com.sun.squawk.NativeUnsafe; //导入依赖的package包/类
/**
* Compares this string to the specified object.
* The result is <code>true</code> if and only if the argument is not
* <code>null</code> and is a <code>String</code> object that represents
* the same sequence of characters as this object.
*
* @param anObject the object to compare this <code>String</code>
* against.
* @return <code>true</code> if the <code>String </code>are equal;
* <code>false</code> otherwise.
* @see java.lang.String#compareTo(java.lang.String)
* @see java.lang.String#equalsIgnoreCase(java.lang.String)
*/
public boolean equals(Object anObject) {
if (this == anObject) {
return true;
}
if (anObject instanceof String) {
String anotherString = (String)anObject;
int lth = length();
if (lth == anotherString.length()) {
if (isEightBit() && anotherString.isEightBit()) {
for (int i = 0 ; i < lth ; i++) {
if (NativeUnsafe.getByte(this, i) != NativeUnsafe.getByte(anotherString, i)) {
return false;
}
}
} else {
for (int i = 0 ; i < lth ; i++) {
if (NativeUnsafe.charAt(this, i) != NativeUnsafe.charAt(anotherString, i)) {
return false;
}
}
}
return true;
}
}
return false;
}
示例5: lastIndexOf
import com.sun.squawk.NativeUnsafe; //导入依赖的package包/类
public int lastIndexOf(String str, int fromIndex) {
int targetCount = str.length();
int rightIndex = this.length() - targetCount;
if (fromIndex < 0) {
return -1;
}
if (fromIndex > rightIndex) {
fromIndex = rightIndex;
}
/* Empty string always matches. */
if (targetCount == 0) {
return fromIndex;
}
int strLastIndex = targetCount - 1;
char strLastChar = NativeUnsafe.charAt(str, strLastIndex);
int min = targetCount - 1;
int i = min + fromIndex;
startSearchForLastChar:
while (true) {
while (i >= min && NativeUnsafe.charAt(this, i) != strLastChar) {
i--;
}
if (i < min) {
return -1;
}
int j = i - 1;
int start = j - (targetCount - 1);
int k = strLastIndex - 1;
while (j > start) {
if (NativeUnsafe.charAt(this, j--) != NativeUnsafe.charAt(str, k--)) {
i--;
continue startSearchForLastChar;
}
}
return start - 1;
}
}
示例6: release
import com.sun.squawk.NativeUnsafe; //导入依赖的package包/类
/**
* Free the backing native memory for this pointer if this pointer was created by allocating memory.
* If this pointer points to a subset of another buffer, or points to a "pinned" object, do nothing.
* After releasing the pointer,
* all accesses to memory through this pointer will throw an exception.
*
* @throws java.lang.IllegalStateException if release has already been called on this pointer.
*/
public final void release() throws IllegalStateException {
Address addr = getAddress();
if (addr.isZero()) {
throw new IllegalStateException();
}
if (wasMalloced()) {
NativeUnsafe.free(addr);
}
invalidate();
}
示例7: deleteTaskExecutor
import com.sun.squawk.NativeUnsafe; //导入依赖的package包/类
/**
* Delete the native resources behind this TaskExecutor.
* Must call cancelTaskExecutor() first. If the TaskExecutor hasn't finished cleaning up,
* return error code.
*
* @return zero on success
*/
public int deleteTaskExecutor() {
checkTaskExecutor();
int result = NativeUnsafe.deleteTaskExecutor(te);
if (result == 0) {
te = Address.zero();
}
return result;
}
示例8: runBlockingFunction
import com.sun.squawk.NativeUnsafe; //导入依赖的package包/类
Address runBlockingFunction(Address fptr,
int arg1, int arg2, int arg3, int arg4, int arg5,
int arg6, int arg7, int arg8, int arg9, int arg10) {
//VM.println("DefaultTaskExecutor.runBlockingFunction()");
checkTaskExecutor();
return NativeUnsafe.runBlockingFunctionOn(te, fptr, arg1, arg2, arg3, arg4, arg5,
arg6, arg7, arg8, arg9, arg10);
}
示例9: call1
import com.sun.squawk.NativeUnsafe; //导入依赖的package包/类
public int call1(int i1) {
if (DEBUG) {
preamble();
}
TaskExecutor te = getTE();
Address ntask = te.runBlockingFunction(funcAddr, i1, 0, 0, 0, 0, 0, 0, 0, 0, 0);
int result = NativeUnsafe.waitForBlockingFunction(ntask);
if (DEBUG) {
postscript(result);
}
te.cleanup();
return result;
}
示例10: call7
import com.sun.squawk.NativeUnsafe; //导入依赖的package包/类
public int call7(int i1, int i2, int i3, int i4, int i5, int i6, int i7) {
if (DEBUG) {
preamble();
}
TaskExecutor te = getTE();
Address ntask = te.runBlockingFunction(funcAddr, i1, i2, i3, i4, i5, i6, i7, 0, 0, 0);
int result = NativeUnsafe.waitForBlockingFunction(ntask);
if (DEBUG) {
postscript(result);
}
te.cleanup();
return result;
}
示例11: call5
import com.sun.squawk.NativeUnsafe; //导入依赖的package包/类
public int call5(int i1, int i2, int i3, int i4, int i5) {
if (DEBUG) {
preamble();
}
TaskExecutor te = getTE();
Address ntask = te.runBlockingFunction(funcAddr, i1, i2, i3, i4, i5, 0, 0, 0, 0, 0);
int result = NativeUnsafe.waitForBlockingFunction(ntask);
if (DEBUG) {
postscript(result);
}
te.cleanup();
return result;
}
示例12: call9
import com.sun.squawk.NativeUnsafe; //导入依赖的package包/类
public int call9(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9) {
if (DEBUG) {
preamble();
}
TaskExecutor te = getTE();
Address ntask = te.runBlockingFunction(funcAddr, i1, i2, i3, i4, i5, i6, i7, i8, i9, 0);
int result = NativeUnsafe.waitForBlockingFunction(ntask);
if (DEBUG) {
postscript(result);
}
te.cleanup();
return result;
}
示例13: call3
import com.sun.squawk.NativeUnsafe; //导入依赖的package包/类
public int call3(int i1, int i2, int i3) {
if (DEBUG) {
preamble();
}
// VM.setBlocked(true);
int result = NativeUnsafe.call3(funcAddr, i1, i2, i3);
if (DEBUG) {
postscript(result);
}
// VM.setBlocked(false);
return result;
}
示例14: call1
import com.sun.squawk.NativeUnsafe; //导入依赖的package包/类
public int call1(int i1) {
if (DEBUG) {
preamble();
}
// VM.setBlocked(true);
int result = NativeUnsafe.call1(funcAddr, i1);
if (DEBUG) {
postscript(result);
}
// VM.setBlocked(false);
return result;
}
示例15: call2
import com.sun.squawk.NativeUnsafe; //导入依赖的package包/类
public int call2(int i1, int i2) {
if (DEBUG) {
preamble();
}
// VM.setBlocked(true);
int result = NativeUnsafe.call2(funcAddr, i1, i2);
if (DEBUG) {
postscript(result);
}
// VM.setBlocked(false);
return result;
}