Remove unneeded workaround for IBM JDK and older intellij-core

The underlying problem (IDEA-206446) was fixed a long time ago and the
compiler is no longer affected by it.

 #KT-37286 Fixed
This commit is contained in:
Alexander Udalov
2020-03-06 17:42:34 +01:00
parent f113c22450
commit 4d2ee279c0
@@ -517,8 +517,6 @@ class KotlinCoreEnvironment private constructor(
}
private fun registerApplicationExtensionPointsAndExtensionsFrom(configuration: CompilerConfiguration, configFilePath: String) {
workaroundIbmJdkStaxReportCdataEventIssue()
fun File.hasConfigFile(configFile: String): Boolean =
if (isDirectory) File(this, "META-INF" + File.separator + configFile).exists()
else try {
@@ -542,38 +540,6 @@ class KotlinCoreEnvironment private constructor(
registerExtensionPointAndExtensionsEx(pluginRoot, configFilePath, Extensions.getRootArea())
}
private fun workaroundIbmJdkStaxReportCdataEventIssue() {
if (!SystemInfo.isIbmJvm) return
// On IBM JDK, XMLInputFactory does not support "report-cdata-event" property, but JDOMUtil sets it unconditionally in the
// static XML_INPUT_FACTORY field and fails with an exception (Logger.error throws exception in the compiler) if unsuccessful.
// Until this is fixed in the platform, we workaround the issue by setting that field to a value that does not attempt
// to set the unsupported property.
// See IDEA-206446 for more information
val field = JDOMUtil::class.java.getDeclaredField("XML_INPUT_FACTORY")
field.isAccessible = true
Field::class.java.getDeclaredField("modifiers")
.apply { isAccessible = true }
.setInt(field, field.modifiers and Modifier.FINAL.inv())
field.set(null, object : NotNullLazyValue<XMLInputFactory>() {
override fun compute(): XMLInputFactory {
val factory: XMLInputFactory = try {
// otherwise wst can be used (in tests/dev run)
val clazz = Class.forName("com.sun.xml.internal.stream.XMLInputFactoryImpl")
clazz.newInstance() as XMLInputFactory
} catch (e: Exception) {
// ok, use random
XMLInputFactory.newFactory()
}
factory.setProperty(XMLInputFactory.IS_COALESCING, true)
factory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false)
factory.setProperty(XMLInputFactory.SUPPORT_DTD, false)
return factory
}
})
}
@JvmStatic
@Suppress("MemberVisibilityCanPrivate") // made public for CLI Android Lint
fun registerPluginExtensionPoints(project: MockProject) {