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


Java VM.isInternal方法代码示例

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


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

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

示例2: isExternallyVisible

import com.sun.squawk.VM; //导入方法依赖的package包/类
/**
 * Given the method's access, the defining class' access, and the suite type,
 * determine the final accessibility of the method outside of this suite.
 * 
 * Note that we are talking about the accessibility of a particular method, 
 * not all of the methods that override a super method. There are cases where
 * a super method is not accessible, but an override is. A latter check for overriding
 * will mark the super method as used.
 * 
 * @param mw the MMethodDB.Entry
 * @return true if an external suite could possibly access this method.
 */
public boolean isExternallyVisible(MethodDB.Entry mw) {
    Method m = mw.m;
    int modifiers = m.getModifiers();
    int suiteType = translator.getSuiteType();
    boolean sealedPackages = (suiteType == Suite.LIBRARY) || (suiteType == Suite.APPLICATION);

    if (Modifier.isPrivate(modifiers)) {
        return false;
    } else if (translator.getSuite().isBootstrap() && VM.isInternal(m)) {
        // if the symbol is stripped, and it wasn't marked as "CrossSuitePrivate" 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));
        
        // Check visibility upwards through parent suites:
        if (!m.isStatic()) {
            // This could be an override of a method in another suite.
            // If so, it might be called and we can't tell, so return true
            if (isSuperMethodDefinedOustideOfSuite(mw)) {
                return true;
            }
        }
        
        // Check visibility downwards through child suites. Look for cases where a child suite
        // could call this protected or public method. Or conversley,
        // cases when there is no way a child suite could call this method.
        switch (suiteType) {
            case Suite.APPLICATION:
                // no possible child suite:
                return false;
                
            case Suite.LIBRARY: {
                // The complicated case:
                
                // check the methods's modifier
                if (Modifier.isPackagePrivate(modifiers)) {
                    // child suites can't call this package-private method
                    return false;
                } else if (Modifier.isProtected(modifiers)) {
                     if (m.getDefiningClass().isFinal() // there can be no subclass, so has same effect as package-private:
                         || !m.getDefiningClass().isPublic()) { // there can be no external subclass, so has same effect as package-private:
                        return false;
                    }
                    return true;
                } else /* Modifier.isPublic(modifiers) */ {
                    Assert.that(Modifier.isPublic(modifiers));
                    if (!m.getDefiningClass().isPublic()) {
                        return false;
                    }
                    return true;
                }
            }
            
            default:
                // extendable and debuggable suites leave all symbols externally visible.
                return true;
        }
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:74,代码来源:MethodDB.java


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