Search in sources :

Example 1 with ConfigurationType

use of com.oracle.svm.configure.config.ConfigurationType in project graal by oracle.

the class TypeMethodsWithFlagsTest method doTestMethods.

private static void doTestMethods(TypeConfiguration typeConfig) {
    ConfigurationType methodTestType = getConfigTypeOrFail(typeConfig, "MethodAndFieldTest");
    Assert.assertNull(ConfigurationType.TestBackdoor.getMethodInfoIfPresent(methodTestType, new ConfigurationMethod("<init>", "(I)V")));
    Assert.assertNotNull(ConfigurationType.TestBackdoor.getMethodInfoIfPresent(methodTestType, new ConfigurationMethod("method", "()V")));
}
Also used : ConfigurationType(com.oracle.svm.configure.config.ConfigurationType) ConfigurationMethod(com.oracle.svm.configure.config.ConfigurationMethod)

Example 2 with ConfigurationType

use of com.oracle.svm.configure.config.ConfigurationType in project graal by oracle.

the class TypeMethodsWithFlagsTest method populateConfig.

void populateConfig() {
    ConfigurationType oldType = new ConfigurationType(ConfigurationCondition.alwaysTrue(), getTypeName());
    setFlags(oldType);
    previousConfig.add(oldType);
    ConfigurationType newType = new ConfigurationType(ConfigurationCondition.alwaysTrue(), getTypeName());
    for (Map.Entry<ConfigurationMethod, ConfigurationMemberDeclaration> methodEntry : methodsThatMustExist.entrySet()) {
        newType.addMethod(methodEntry.getKey().getName(), methodEntry.getKey().getInternalSignature(), methodEntry.getValue());
    }
    for (Map.Entry<ConfigurationMethod, ConfigurationMemberDeclaration> methodEntry : methodsThatMustNotExist.entrySet()) {
        newType.addMethod(methodEntry.getKey().getName(), methodEntry.getKey().getInternalSignature(), methodEntry.getValue());
    }
    currentConfig.add(newType);
}
Also used : ConfigurationType(com.oracle.svm.configure.config.ConfigurationType) ConfigurationMethod(com.oracle.svm.configure.config.ConfigurationMethod) ConfigurationMemberDeclaration(com.oracle.svm.configure.config.ConfigurationMemberInfo.ConfigurationMemberDeclaration) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with ConfigurationType

use of com.oracle.svm.configure.config.ConfigurationType in project graal by oracle.

the class TypeMethodsWithFlagsTest method doTestFields.

private static void doTestFields(TypeConfiguration typeConfig) {
    ConfigurationType fieldTestType = getConfigTypeOrFail(typeConfig, "MethodAndFieldTest");
    Assert.assertNull(ConfigurationType.TestBackdoor.getFieldInfoIfPresent(fieldTestType, "SimpleField"));
    Assert.assertNull(ConfigurationType.TestBackdoor.getFieldInfoIfPresent(fieldTestType, "AllowWriteField"));
    FieldInfo newField = ConfigurationType.TestBackdoor.getFieldInfoIfPresent(fieldTestType, "NewField");
    Assert.assertFalse(newField.isFinalButWritable());
    FieldInfo newWritableField = getFieldInfoOrFail(fieldTestType, "NewAllowWriteField");
    Assert.assertTrue(newWritableField.isFinalButWritable());
    FieldInfo newlyWritableField = getFieldInfoOrFail(fieldTestType, "NewNowWritableField");
    Assert.assertTrue(newlyWritableField.isFinalButWritable());
}
Also used : ConfigurationType(com.oracle.svm.configure.config.ConfigurationType) FieldInfo(com.oracle.svm.configure.config.FieldInfo)

Example 4 with ConfigurationType

use of com.oracle.svm.configure.config.ConfigurationType in project graal by oracle.

the class TypeMethodsWithFlagsTest method doTest.

void doTest() {
    TypeConfiguration currentConfigWithoutPrevious = TypeConfiguration.copyAndSubtract(currentConfig, previousConfig);
    String name = getTypeName();
    ConfigurationType configurationType = currentConfigWithoutPrevious.get(ConfigurationCondition.alwaysTrue(), name);
    if (methodsThatMustExist.size() == 0) {
        Assert.assertNull("Generated configuration type " + name + " exists. Expected it to be cleared as it is empty.", configurationType);
    } else {
        Assert.assertNotNull("Generated configuration type " + name + " does not exist. Has the test code changed?", configurationType);
        for (Map.Entry<ConfigurationMethod, ConfigurationMemberDeclaration> methodEntry : methodsThatMustExist.entrySet()) {
            ConfigurationMemberDeclaration kind = ConfigurationType.TestBackdoor.getMethodInfoIfPresent(configurationType, methodEntry.getKey()).getDeclaration();
            Assert.assertNotNull("Method " + methodEntry.getKey() + " unexpectedly NOT found in the new configuration.", kind);
            Assert.assertEquals("Method " + methodEntry.getKey() + " contains a different kind than expected in the new configuration.", kind, methodEntry.getValue());
        }
        for (Map.Entry<ConfigurationMethod, ConfigurationMemberDeclaration> methodEntry : methodsThatMustNotExist.entrySet()) {
            ConfigurationMemberInfo kind = ConfigurationType.TestBackdoor.getMethodInfoIfPresent(configurationType, methodEntry.getKey());
            Assert.assertNull("Method " + methodEntry.getKey() + " unexpectedly found in the new configuration.", kind);
        }
    }
}
Also used : ConfigurationType(com.oracle.svm.configure.config.ConfigurationType) ConfigurationMethod(com.oracle.svm.configure.config.ConfigurationMethod) ConfigurationMemberInfo(com.oracle.svm.configure.config.ConfigurationMemberInfo) ConfigurationMemberDeclaration(com.oracle.svm.configure.config.ConfigurationMemberInfo.ConfigurationMemberDeclaration) TypeConfiguration(com.oracle.svm.configure.config.TypeConfiguration) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with ConfigurationType

use of com.oracle.svm.configure.config.ConfigurationType in project graal by oracle.

the class TypeMethodsWithFlagsTest method doTestTypeFlags.

private static void doTestTypeFlags(TypeConfiguration typeConfig) {
    ConfigurationType flagTestHasDeclaredType = getConfigTypeOrFail(typeConfig, "FlagTestC");
    Assert.assertTrue(ConfigurationType.TestBackdoor.haveAllDeclaredClasses(flagTestHasDeclaredType) || ConfigurationType.TestBackdoor.haveAllDeclaredFields(flagTestHasDeclaredType) || ConfigurationType.TestBackdoor.getAllDeclaredConstructors(flagTestHasDeclaredType) == ConfigurationMemberAccessibility.ACCESSED);
    ConfigurationType flagTestHasPublicType = getConfigTypeOrFail(typeConfig, "FlagTestD");
    Assert.assertTrue(ConfigurationType.TestBackdoor.haveAllPublicClasses(flagTestHasPublicType) || ConfigurationType.TestBackdoor.haveAllPublicFields(flagTestHasPublicType) || ConfigurationType.TestBackdoor.getAllPublicConstructors(flagTestHasPublicType) == ConfigurationMemberAccessibility.ACCESSED);
}
Also used : ConfigurationType(com.oracle.svm.configure.config.ConfigurationType)

Aggregations

ConfigurationType (com.oracle.svm.configure.config.ConfigurationType)6 ConfigurationMethod (com.oracle.svm.configure.config.ConfigurationMethod)3 ConfigurationMemberDeclaration (com.oracle.svm.configure.config.ConfigurationMemberInfo.ConfigurationMemberDeclaration)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ConfigurationMemberInfo (com.oracle.svm.configure.config.ConfigurationMemberInfo)1 FieldInfo (com.oracle.svm.configure.config.FieldInfo)1 TypeConfiguration (com.oracle.svm.configure.config.TypeConfiguration)1