use of org.jetbrains.kotlin.load.kotlin.JvmMetadataVersion in project kotlin by JetBrains.
the class KotlinSyntheticClassAnnotationTest method assertAnnotatedWithMetadata.
private void assertAnnotatedWithMetadata(@NotNull Class<?> aClass) {
String annotationFqName = METADATA_FQ_NAME.asString();
Class<? extends Annotation> annotationClass = loadAnnotationClassQuietly(annotationFqName);
assertTrue("No annotation " + annotationFqName + " found in " + aClass, aClass.isAnnotationPresent(annotationClass));
Annotation annotation = aClass.getAnnotation(annotationClass);
int[] version = (int[]) CodegenTestUtil.getAnnotationAttribute(annotation, METADATA_VERSION_FIELD_NAME);
assertNotNull(version);
assertTrue("Annotation " + annotationFqName + " is written with an unsupported format", new JvmMetadataVersion(version).isCompatible());
}
use of org.jetbrains.kotlin.load.kotlin.JvmMetadataVersion in project kotlin by JetBrains.
the class CompileKotlinAgainstCustomBinariesTest method doTestKotlinLibraryWithWrongMetadataVersion.
private void doTestKotlinLibraryWithWrongMetadataVersion(@NotNull String libraryName, @Nullable final Function2<String, Object, Object> additionalTransformation, @NotNull String... additionalOptions) throws Exception {
final int[] version = new JvmMetadataVersion(42, 0, 0).toArray();
File library = transformJar(compileLibrary(libraryName), new Function2<String, byte[], byte[]>() {
@Override
public byte[] invoke(String name, byte[] bytes) {
return WrongBytecodeVersionTest.Companion.transformMetadataInClassFile(bytes, new Function2<String, Object, Object>() {
@Override
public Object invoke(String name, Object value) {
if (additionalTransformation != null) {
Object result = additionalTransformation.invoke(name, value);
if (result != null)
return result;
}
return JvmAnnotationNames.METADATA_VERSION_FIELD_NAME.equals(name) ? version : null;
}
});
}
});
Pair<String, ExitCode> output = compileKotlin("source.kt", tmpdir, Arrays.asList(additionalOptions), library);
KotlinTestUtils.assertEqualsToFile(new File(getTestDataDirectory(), "output.txt"), normalizeOutput(output));
}
Aggregations