KT-52071 Fallback if sys prop read is blocked

If the Java Security Manager blocks reading the system property
`kotlin.ignore.old.metadata`, then continue gracefully with the
default value.
This commit is contained in:
Karl Wingblade
2022-06-29 11:00:17 -05:00
committed by Alexander Udalov
parent 7a9c516f68
commit 72e678ad69
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.constants.ClassLiteralValue;
import java.security.AccessControlException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -37,7 +38,16 @@ import static org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass.*;
import static org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader.Kind.*;
public class ReadKotlinClassHeaderAnnotationVisitor implements AnnotationVisitor {
private static final boolean IGNORE_OLD_METADATA = "true".equals(System.getProperty("kotlin.ignore.old.metadata"));
private static boolean IGNORE_OLD_METADATA;
static {
try {
IGNORE_OLD_METADATA = "true".equals(System.getProperty("kotlin.ignore.old.metadata"));
} catch (AccessControlException e) {
// Use default value if the Security Manager blocks reading system variables
IGNORE_OLD_METADATA = false;
}
}
private static final Map<ClassId, KotlinClassHeader.Kind> HEADER_KINDS = new HashMap<ClassId, KotlinClassHeader.Kind>();