Java Code Examples for com.sun.tools.classfile.Descriptor#InvalidDescriptor

The following examples show how to use com.sun.tools.classfile.Descriptor#InvalidDescriptor . 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: CheckACC_STRICTFlagOnclinitTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
void check(String dir, String... fileNames)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    for (String fileName : fileNames) {
        ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));

        for (Method method : classFileToCheck.methods) {
            if ((method.access_flags.flags & ACC_STRICT) == 0) {
                errors.add(String.format(offendingMethodErrorMessage,
                        method.getName(classFileToCheck.constant_pool),
                        classFileToCheck.getName()));
            }
        }
    }
}
 
Example 2
Source File: CheckACC_STRICTFlagOnDefaultMethodTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
void check(String dir, String... fileNames)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    for (String fileName : fileNames) {
        ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));

        for (Method method : classFileToCheck.methods) {
            if ((method.access_flags.flags & ACC_STRICT) == 0) {
                errors.add(String.format(offendingMethodErrorMessage,
                        method.getName(classFileToCheck.constant_pool),
                        classFileToCheck.getName()));
            }
        }
    }
}
 
Example 3
Source File: CheckACC_STRICTFlagOnclinitTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
void check(String dir, String... fileNames)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    for (String fileName : fileNames) {
        ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));

        for (Method method : classFileToCheck.methods) {
            if ((method.access_flags.flags & ACC_STRICT) == 0) {
                errors.add(String.format(offendingMethodErrorMessage,
                        method.getName(classFileToCheck.constant_pool),
                        classFileToCheck.getName()));
            }
        }
    }
}
 
Example 4
Source File: CheckACC_STRICTFlagOnDefaultMethodTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
void check(String dir, String... fileNames)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    for (String fileName : fileNames) {
        ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));

        for (Method method : classFileToCheck.methods) {
            if ((method.access_flags.flags & ACC_STRICT) == 0) {
                errors.add(String.format(offendingMethodErrorMessage,
                        method.getName(classFileToCheck.constant_pool),
                        classFileToCheck.getName()));
            }
        }
    }
}
 
Example 5
Source File: CheckACC_STRICTFlagOnclinitTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
void check(String dir, String... fileNames)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    for (String fileName : fileNames) {
        ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));

        for (Method method : classFileToCheck.methods) {
            if ((method.access_flags.flags & ACC_STRICT) == 0) {
                errors.add(String.format(offendingMethodErrorMessage,
                        method.getName(classFileToCheck.constant_pool),
                        classFileToCheck.getName()));
            }
        }
    }
}
 
Example 6
Source File: CheckACC_STRICTFlagOnclinitTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
void check(String dir, String... fileNames)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    for (String fileName : fileNames) {
        ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));

        for (Method method : classFileToCheck.methods) {
            if ((method.access_flags.flags & ACC_STRICT) == 0) {
                errors.add(String.format(offendingMethodErrorMessage,
                        method.getName(classFileToCheck.constant_pool),
                        classFileToCheck.getName()));
            }
        }
    }
}
 
Example 7
Source File: CheckACC_STRICTFlagOnDefaultMethodTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
void check(String dir, String... fileNames)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    for (String fileName : fileNames) {
        ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));

        for (Method method : classFileToCheck.methods) {
            if ((method.access_flags.flags & ACC_STRICT) == 0) {
                errors.add(String.format(offendingMethodErrorMessage,
                        method.getName(classFileToCheck.constant_pool),
                        classFileToCheck.getName()));
            }
        }
    }
}
 
Example 8
Source File: CheckACC_STRICTFlagOnclinitTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
void check(String dir, String... fileNames)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    for (String fileName : fileNames) {
        ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));

        for (Method method : classFileToCheck.methods) {
            if ((method.access_flags.flags & ACC_STRICT) == 0) {
                errors.add(String.format(offendingMethodErrorMessage,
                        method.getName(classFileToCheck.constant_pool),
                        classFileToCheck.getName()));
            }
        }
    }
}
 
Example 9
Source File: CheckACC_STRICTFlagOnclinitTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
void check(String dir, String... fileNames)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    for (String fileName : fileNames) {
        ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));

        for (Method method : classFileToCheck.methods) {
            if ((method.access_flags.flags & ACC_STRICT) == 0) {
                errors.add(String.format(offendingMethodErrorMessage,
                        method.getName(classFileToCheck.constant_pool),
                        classFileToCheck.getName()));
            }
        }
    }
}
 
Example 10
Source File: CheckACC_STRICTFlagOnDefaultMethodTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
void check(String dir, String... fileNames)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    for (String fileName : fileNames) {
        ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));

        for (Method method : classFileToCheck.methods) {
            if ((method.access_flags.flags & ACC_STRICT) == 0) {
                errors.add(String.format(offendingMethodErrorMessage,
                        method.getName(classFileToCheck.constant_pool),
                        classFileToCheck.getName()));
            }
        }
    }
}
 
Example 11
Source File: DetectMutableStaticFields.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
void analyzeClassFile(ClassFile classFileToCheck)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    boolean enumClass =
            (classFileToCheck.access_flags.flags & ACC_ENUM) != 0;
    boolean nonFinalStaticEnumField;
    boolean nonFinalStaticField;

    currentFieldsToIgnore =
            classFieldsToIgnoreMap.get(classFileToCheck.getName());

    for (Field field : classFileToCheck.fields) {
        if (ignoreField(field.getName(classFileToCheck.constant_pool))) {
            continue;
        }
        nonFinalStaticEnumField =
                (field.access_flags.flags & (ACC_ENUM | ACC_FINAL)) == 0;
        nonFinalStaticField =
                (field.access_flags.flags & ACC_STATIC) != 0 &&
                (field.access_flags.flags & ACC_FINAL) == 0;
        if (enumClass ? nonFinalStaticEnumField : nonFinalStaticField) {
            errors.add("There is a mutable field named " +
                    field.getName(classFileToCheck.constant_pool) +
                    ", at class " +
                    classFileToCheck.getName());
        }
    }
}
 
Example 12
Source File: CheckACC_STRICTFlagOnPkgAccessClassTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
void check()
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    ClassFile classFileToCheck = ClassFile.read(new File("Test.class"));

    for (Method method : classFileToCheck.methods) {
        if ((method.access_flags.flags & ACC_STRICT) == 0) {
            errors.add(String.format(offendingMethodErrorMessage,
                    method.getName(classFileToCheck.constant_pool),
                    classFileToCheck.getName()));
        }
    }
}
 
Example 13
Source File: DetectMutableStaticFields.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
void analyzeClassFile(ClassFile classFileToCheck)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    boolean enumClass =
            (classFileToCheck.access_flags.flags & ACC_ENUM) != 0;
    boolean nonFinalStaticEnumField;
    boolean nonFinalStaticField;

    currentFieldsToIgnore =
            classFieldsToIgnoreMap.get(classFileToCheck.getName());

    for (Field field : classFileToCheck.fields) {
        if (ignoreField(field.getName(classFileToCheck.constant_pool))) {
            continue;
        }
        nonFinalStaticEnumField =
                (field.access_flags.flags & (ACC_ENUM | ACC_FINAL)) == 0;
        nonFinalStaticField =
                (field.access_flags.flags & ACC_STATIC) != 0 &&
                (field.access_flags.flags & ACC_FINAL) == 0;
        if (enumClass ? nonFinalStaticEnumField : nonFinalStaticField) {
            errors.add("There is a mutable field named " +
                    field.getName(classFileToCheck.constant_pool) +
                    ", at class " +
                    classFileToCheck.getName());
        }
    }
}
 
Example 14
Source File: CheckACC_STRICTFlagOnPkgAccessClassTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
void check()
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    ClassFile classFileToCheck = ClassFile.read(new File("Test.class"));

    for (Method method : classFileToCheck.methods) {
        if ((method.access_flags.flags & ACC_STRICT) == 0) {
            errors.add(String.format(offendingMethodErrorMessage,
                    method.getName(classFileToCheck.constant_pool),
                    classFileToCheck.getName()));
        }
    }
}
 
Example 15
Source File: CheckACC_STRICTFlagOnPkgAccessClassTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
void check()
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    ClassFile classFileToCheck = ClassFile.read(new File("Test.class"));

    for (Method method : classFileToCheck.methods) {
        if ((method.access_flags.flags & ACC_STRICT) == 0) {
            errors.add(String.format(offendingMethodErrorMessage,
                    method.getName(classFileToCheck.constant_pool),
                    classFileToCheck.getName()));
        }
    }
}
 
Example 16
Source File: CheckACC_STRICTFlagOnPkgAccessClassTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
void check()
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    ClassFile classFileToCheck = ClassFile.read(new File("Test.class"));

    for (Method method : classFileToCheck.methods) {
        if ((method.access_flags.flags & ACC_STRICT) == 0) {
            errors.add(String.format(offendingMethodErrorMessage,
                    method.getName(classFileToCheck.constant_pool),
                    classFileToCheck.getName()));
        }
    }
}
 
Example 17
Source File: CheckACC_STRICTFlagOnPkgAccessClassTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
void check()
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    ClassFile classFileToCheck = ClassFile.read(new File("Test.class"));

    for (Method method : classFileToCheck.methods) {
        if ((method.access_flags.flags & ACC_STRICT) == 0) {
            errors.add(String.format(offendingMethodErrorMessage,
                    method.getName(classFileToCheck.constant_pool),
                    classFileToCheck.getName()));
        }
    }
}
 
Example 18
Source File: DetectMutableStaticFields.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
void analyzeClassFile(ClassFile classFileToCheck)
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    boolean enumClass =
            (classFileToCheck.access_flags.flags & ACC_ENUM) != 0;
    boolean nonFinalStaticEnumField;
    boolean nonFinalStaticField;

    currentFieldsToIgnore =
            classFieldsToIgnoreMap.get(classFileToCheck.getName());

    for (Field field : classFileToCheck.fields) {
        if (ignoreField(field.getName(classFileToCheck.constant_pool))) {
            continue;
        }
        nonFinalStaticEnumField =
                (field.access_flags.flags & (ACC_ENUM | ACC_FINAL)) == 0;
        nonFinalStaticField =
                (field.access_flags.flags & ACC_STATIC) != 0 &&
                (field.access_flags.flags & ACC_FINAL) == 0;
        if (enumClass ? nonFinalStaticEnumField : nonFinalStaticField) {
            errors.add("There is a mutable field named " +
                    field.getName(classFileToCheck.constant_pool) +
                    ", at class " +
                    classFileToCheck.getName());
        }
    }
}
 
Example 19
Source File: CheckACC_STRICTFlagOnPkgAccessClassTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
void check()
    throws
        IOException,
        ConstantPoolException,
        Descriptor.InvalidDescriptor {
    ClassFile classFileToCheck = ClassFile.read(new File("Test.class"));

    for (Method method : classFileToCheck.methods) {
        if ((method.access_flags.flags & ACC_STRICT) == 0) {
            errors.add(String.format(offendingMethodErrorMessage,
                    method.getName(classFileToCheck.constant_pool),
                    classFileToCheck.getName()));
        }
    }
}
 
Example 20
Source File: AnnotationsTestBase.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public abstract void test(TestCase testCase, Map<String, ? extends JavaFileObject> classes)
throws IOException, ConstantPoolException, Descriptor.InvalidDescriptor;