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


Java VM类代码示例

本文整理汇总了Java中sun.misc.VM的典型用法代码示例。如果您正苦于以下问题:Java VM类的具体用法?Java VM怎么用?Java VM使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: runFinalization

import sun.misc.VM; //导入依赖的package包/类
static void runFinalization() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f = (Finalizer)queue.poll();
                if (f == null) break;
                f.runFinalizer(jla);
            }
        }
    });
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:Finalizer.java

示例2: runAllFinalizers

import sun.misc.VM; //导入依赖的package包/类
static void runAllFinalizers() {
    if (!VM.isBooted()) {
        return;
    }

    forkSecondaryFinalizer(new Runnable() {
        private volatile boolean running;
        public void run() {
            if (running)
                return;
            final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
            running = true;
            for (;;) {
                Finalizer f;
                synchronized (lock) {
                    f = unfinalized;
                    if (f == null) break;
                    unfinalized = f.next;
                }
                f.runFinalizer(jla);
            }}});
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:Finalizer.java

示例3: checkProxyAccess

import sun.misc.VM; //导入依赖的package包/类
private static void checkProxyAccess(Class<?> caller,
                                     ClassLoader loader,
                                     Class<?>... interfaces)
{
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        ClassLoader ccl = caller.getClassLoader();
        if (VM.isSystemDomainLoader(loader) && !VM.isSystemDomainLoader(ccl)) {
            sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
        }
        ReflectUtil.checkProxyPackageAccess(ccl, interfaces);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:Proxy.java

示例4: arraycopy

import sun.misc.VM; //导入依赖的package包/类
public static void arraycopy(Object srcTaint, Object src, int srcPosTaint, int srcPos, Object destTaint, Object dest, int destPosTaint, int destPos, int lengthTaint, int length) {
	System.arraycopy(src, srcPos, dest, destPos, length);
	if (VM.isBooted$$PHOSPHORTAGGED(new TaintedBooleanWithIntTag()).val && srcTaint != null && destTaint != null) {
		if(((LazyArrayIntTags)srcTaint).taints == null && ((LazyArrayIntTags)destTaint).taints == null)
		{
			return;
		}
		else if(((LazyArrayIntTags)srcTaint).taints != null)
		{
			if(((LazyArrayIntTags)destTaint).taints == null)
				((LazyArrayIntTags)destTaint).taints = new int[Array.getLength(dest)];
			System.arraycopy(((LazyArrayIntTags)srcTaint).taints, srcPos, ((LazyArrayIntTags)destTaint).taints, destPos, length);
		}
		else
		{
			if(((LazyArrayIntTags)destTaint).taints == null)
				((LazyArrayIntTags)destTaint).taints = new int[Array.getLength(dest)];
			else {
				int[] empty = new int[length];
				System.arraycopy(empty, 0, ((LazyArrayIntTags)destTaint).taints, destPos, length);
			}
		}
	}
}
 
开发者ID:gmu-swe,项目名称:phosphor,代码行数:25,代码来源:TaintUtils.java

示例5: DirectByteBuffer

import sun.misc.VM; //导入依赖的package包/类
DirectByteBuffer(int cap) {                   // package-private

        super(-1, 0, cap, cap);
        boolean pa = VM.isDirectMemoryPageAligned();
        int ps = Bits.pageSize();
        long size = Math.max(1L, (long)cap + (pa ? ps : 0));
        Bits.reserveMemory(size, cap);

        long base = 0;
        try {
            base = unsafe.allocateMemory(size);
        } catch (OutOfMemoryError x) {
            Bits.unreserveMemory(size, cap);
            throw x;
        }
        unsafe.setMemory(base, size, (byte) 0);
        if (pa && (base % ps != 0)) {
            // Round up to page boundary
            address = base + ps - (base & (ps - 1));
        } else {
            address = base;
        }
        cleaner = Cleaner.create(this, new Deallocator(base, size, cap));
        att = null;



    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:DirectByteBuffer.java

示例6: checkName

import sun.misc.VM; //导入依赖的package包/类
private boolean checkName(String name) {
    if ((name == null) || (name.length() == 0))
        return true;
    if ((name.indexOf('/') != -1)
        || (!VM.allowArraySyntax() && (name.charAt(0) == '[')))
        return false;
    return true;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:ClassLoader.java

示例7: reserveMemory

import sun.misc.VM; //导入依赖的package包/类
static void reserveMemory(long size, int cap) {
    synchronized (Bits.class) {
        if (!memoryLimitSet && VM.isBooted()) {
            maxMemory = VM.maxDirectMemory();
            memoryLimitSet = true;
        }
        // -XX:MaxDirectMemorySize limits the total capacity rather than the
        // actual memory usage, which will differ when buffers are page
        // aligned.
        if (cap <= maxMemory - totalCapacity) {
            reservedMemory += size;
            totalCapacity += cap;
            count++;
            return;
        }
    }

    System.gc();
    try {
        Thread.sleep(100);
    } catch (InterruptedException x) {
        // Restore interrupt status
        Thread.currentThread().interrupt();
    }
    synchronized (Bits.class) {
        if (totalCapacity + cap > maxMemory)
            throw new OutOfMemoryError("Direct buffer memory");
        reservedMemory += size;
        totalCapacity += cap;
        count++;
    }

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:Bits.java

示例8: checkName

import sun.misc.VM; //导入依赖的package包/类
static boolean checkName(String name) {
    if ((name == null) || (name.length() == 0))
        return true;
    if ((name.indexOf('/') != -1)
        || (!VM.allowArraySyntax() && (name.charAt(0) == '[')))
        return false;
    return true;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:ClassLoader.java

示例9: checkName

import sun.misc.VM; //导入依赖的package包/类
private boolean checkName(String name) {
if ((name == null) || (name.length() == 0))
  	    return true;
if ((name.indexOf('/') != -1)
    || (!VM.allowArraySyntax() && (name.charAt(0) == '[')))
  	    return false;
	return true;
   }
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:9,代码来源:ClassLoader.java

示例10: reserveMemory

import sun.misc.VM; //导入依赖的package包/类
static void reserveMemory(long size) {

	synchronized (Bits.class) {
	    if (!memoryLimitSet && VM.isBooted()) {
		maxMemory = VM.maxDirectMemory();
		memoryLimitSet = true;
	    }
	    if (size <= maxMemory - reservedMemory) {
		reservedMemory += size;
		return;
	    }
	}

	System.gc();
	try {
	    Thread.sleep(100);
	} catch (InterruptedException x) {
	    // Restore interrupt status
	    Thread.currentThread().interrupt();
	}
	synchronized (Bits.class) {
	    if (reservedMemory + size > maxMemory)
		throw new OutOfMemoryError("Direct buffer memory");
	    reservedMemory += size;
	}

    }
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:28,代码来源:Bits.java


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