Java Code Examples for com.sun.tools.classfile.AccessFlags#is()

The following examples show how to use com.sun.tools.classfile.AccessFlags#is() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Options.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Checks access of class, field or method.
 */
public boolean checkAccess(AccessFlags flags){

    boolean isPublic = flags.is(AccessFlags.ACC_PUBLIC);
    boolean isProtected = flags.is(AccessFlags.ACC_PROTECTED);
    boolean isPrivate = flags.is(AccessFlags.ACC_PRIVATE);
    boolean isPackage = !(isPublic || isProtected || isPrivate);

    if ((showAccess == AccessFlags.ACC_PUBLIC) && (isProtected || isPrivate || isPackage))
        return false;
    else if ((showAccess == AccessFlags.ACC_PROTECTED) && (isPrivate || isPackage))
        return false;
    else if ((showAccess == 0) && (isPrivate))
        return false;
    else
        return true;
}
 
Example 2
Source File: Options.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Checks access of class, field or method.
 */
public boolean checkAccess(AccessFlags flags){

    boolean isPublic = flags.is(AccessFlags.ACC_PUBLIC);
    boolean isProtected = flags.is(AccessFlags.ACC_PROTECTED);
    boolean isPrivate = flags.is(AccessFlags.ACC_PRIVATE);
    boolean isPackage = !(isPublic || isProtected || isPrivate);

    if ((showAccess == AccessFlags.ACC_PUBLIC) && (isProtected || isPrivate || isPackage))
        return false;
    else if ((showAccess == AccessFlags.ACC_PROTECTED) && (isPrivate || isPackage))
        return false;
    else if ((showAccess == 0) && (isPrivate))
        return false;
    else
        return true;
}
 
Example 3
Source File: Options.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Checks access of class, field or method.
 */
public boolean checkAccess(AccessFlags flags){

    boolean isPublic = flags.is(AccessFlags.ACC_PUBLIC);
    boolean isProtected = flags.is(AccessFlags.ACC_PROTECTED);
    boolean isPrivate = flags.is(AccessFlags.ACC_PRIVATE);
    boolean isPackage = !(isPublic || isProtected || isPrivate);

    if ((showAccess == AccessFlags.ACC_PUBLIC) && (isProtected || isPrivate || isPackage))
        return false;
    else if ((showAccess == AccessFlags.ACC_PROTECTED) && (isPrivate || isPackage))
        return false;
    else if ((showAccess == 0) && (isPrivate))
        return false;
    else
        return true;
}
 
Example 4
Source File: Options.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Checks access of class, field or method.
 */
public boolean checkAccess(AccessFlags flags){

    boolean isPublic = flags.is(AccessFlags.ACC_PUBLIC);
    boolean isProtected = flags.is(AccessFlags.ACC_PROTECTED);
    boolean isPrivate = flags.is(AccessFlags.ACC_PRIVATE);
    boolean isPackage = !(isPublic || isProtected || isPrivate);

    if ((showAccess == AccessFlags.ACC_PUBLIC) && (isProtected || isPrivate || isPackage))
        return false;
    else if ((showAccess == AccessFlags.ACC_PROTECTED) && (isPrivate || isPackage))
        return false;
    else if ((showAccess == 0) && (isPrivate))
        return false;
    else
        return true;
}
 
Example 5
Source File: ModuleFlagTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws IOException, ConstantPoolException {
    Path outdir = Paths.get(".");
    ToolBox tb = new ToolBox();
    final Path moduleInfo = Paths.get("module-info.java");
    tb.writeFile(moduleInfo, "module test_module{}");
    new JavacTask(tb)
            .outdir(outdir)
            .files(moduleInfo)
            .run();

    AccessFlags accessFlags = ClassFile.read(outdir.resolve("module-info.class"))
            .access_flags;
    if (!accessFlags.is(AccessFlags.ACC_MODULE)) {
        throw new RuntimeException("Classfile doesn't have module access flag");
    }
}
 
Example 6
Source File: Options.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Checks access of class, field or method.
 */
public boolean checkAccess(AccessFlags flags){

    boolean isPublic = flags.is(AccessFlags.ACC_PUBLIC);
    boolean isProtected = flags.is(AccessFlags.ACC_PROTECTED);
    boolean isPrivate = flags.is(AccessFlags.ACC_PRIVATE);
    boolean isPackage = !(isPublic || isProtected || isPrivate);

    if ((showAccess == AccessFlags.ACC_PUBLIC) && (isProtected || isPrivate || isPackage))
        return false;
    else if ((showAccess == AccessFlags.ACC_PROTECTED) && (isPrivate || isPackage))
        return false;
    else if ((showAccess == 0) && (isPrivate))
        return false;
    else
        return true;
}
 
Example 7
Source File: ClassWriter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
String adjustVarargs(AccessFlags flags, String params) {
    if (flags.is(ACC_VARARGS)) {
        int i = params.lastIndexOf("[]");
        if (i > 0)
            return params.substring(0, i) + "..." + params.substring(i+2);
    }

    return params;
}
 
Example 8
Source File: JdepsTask.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private boolean matches(String classname, AccessFlags flags) {
    if (options.apiOnly && !flags.is(AccessFlags.ACC_PUBLIC)) {
        return false;
    } else if (options.includePattern != null) {
        return options.includePattern.matcher(classname.replace('/', '.')).matches();
    } else {
        return true;
    }
}
 
Example 9
Source File: ClassWriter.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
String adjustVarargs(AccessFlags flags, String params) {
    if (flags.is(ACC_VARARGS)) {
        int i = params.lastIndexOf("[]");
        if (i > 0)
            return params.substring(0, i) + "..." + params.substring(i+2);
    }

    return params;
}
 
Example 10
Source File: JdepsTask.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tests if the given class matches the pattern given in the -include option
 * or if it's a public class if -apionly option is specified
 */
private boolean matches(String classname, AccessFlags flags) {
    if (options.apiOnly && !flags.is(AccessFlags.ACC_PUBLIC)) {
        return false;
    } else if (options.includePattern != null) {
        return options.includePattern.matcher(classname.replace('/', '.')).matches();
    } else {
        return true;
    }
}
 
Example 11
Source File: ClassWriter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
String adjustVarargs(AccessFlags flags, String params) {
    if (flags.is(ACC_VARARGS)) {
        int i = params.lastIndexOf("[]");
        if (i > 0)
            return params.substring(0, i) + "..." + params.substring(i+2);
    }

    return params;
}
 
Example 12
Source File: DependencyFinder.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean accept(Archive archive, String cn, AccessFlags accessFlags) {
    int i = cn.lastIndexOf('.');
    String pn = i > 0 ? cn.substring(0, i) : "";

    // if -apionly is specified, analyze only exported and public types
    // All packages are exported in unnamed module.
    return apiOnly ? archive.getModule().isExported(pn) &&
                         accessFlags.is(AccessFlags.ACC_PUBLIC)
                   : true;
}
 
Example 13
Source File: ClassWriter.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
String adjustVarargs(AccessFlags flags, String params) {
    if (flags.is(ACC_VARARGS) && !options.compat) {
        int i = params.lastIndexOf("[]");
        if (i > 0)
            return params.substring(0, i) + "..." + params.substring(i+2);
    }

    return params;
}
 
Example 14
Source File: JdepsTask.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tests if the given class matches the pattern given in the -include option
 * or if it's a public class if -apionly option is specified
 */
private boolean matches(String classname, AccessFlags flags) {
    if (options.apiOnly && !flags.is(AccessFlags.ACC_PUBLIC)) {
        return false;
    } else if (options.includePattern != null) {
        return options.includePattern.matcher(classname.replace('/', '.')).matches();
    } else {
        return true;
    }
}
 
Example 15
Source File: JdepsTask.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tests if the given class matches the pattern given in the -include option
 * or if it's a public class if -apionly option is specified
 */
private boolean matches(String classname, AccessFlags flags) {
    if (options.apiOnly && !flags.is(AccessFlags.ACC_PUBLIC)) {
        return false;
    } else if (options.includePattern != null) {
        return options.includePattern.matcher(classname.replace('/', '.')).matches();
    } else {
        return true;
    }
}
 
Example 16
Source File: JdepsTask.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private boolean matches(String classname, AccessFlags flags) {
    if (options.apiOnly && !flags.is(AccessFlags.ACC_PUBLIC)) {
        return false;
    } else if (options.includePattern != null) {
        return options.includePattern.matcher(classname.replace('/', '.')).matches();
    } else {
        return true;
    }
}
 
Example 17
Source File: ClassWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
String adjustVarargs(AccessFlags flags, String params) {
    if (flags.is(ACC_VARARGS)) {
        int i = params.lastIndexOf("[]");
        if (i > 0)
            return params.substring(0, i) + "..." + params.substring(i+2);
    }

    return params;
}
 
Example 18
Source File: JdepsTask.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tests if the given class matches the pattern given in the -include option
 * or if it's a public class if -apionly option is specified
 */
private boolean matches(String classname, AccessFlags flags) {
    if (options.apiOnly && !flags.is(AccessFlags.ACC_PUBLIC)) {
        return false;
    } else if (options.includePattern != null) {
        return options.includePattern.matcher(classname.replace('/', '.')).matches();
    } else {
        return true;
    }
}
 
Example 19
Source File: JdepsTask.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tests if the given class matches the pattern given in the -include option
 * or if it's a public class if -apionly option is specified
 */
private boolean matches(String classname, AccessFlags flags) {
    if (options.apiOnly && !flags.is(AccessFlags.ACC_PUBLIC)) {
        return false;
    } else if (options.includePattern != null) {
        return options.includePattern.matcher(classname.replace('/', '.')).matches();
    } else {
        return true;
    }
}
 
Example 20
Source File: ClassWriter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
String adjustVarargs(AccessFlags flags, String params) {
    if (flags.is(ACC_VARARGS)) {
        int i = params.lastIndexOf("[]");
        if (i > 0)
            return params.substring(0, i) + "..." + params.substring(i+2);
    }

    return params;
}