Remove deprecated methods from daemon
diff --git a/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt b/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt
index 5ce0040..2ae18f1 100644
--- a/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt
+++ b/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt
@@ -18,6 +18,7 @@
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
+import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.daemon.common.*
import org.jetbrains.kotlin.incremental.components.LookupTracker
@@ -144,48 +145,6 @@
compilerService.releaseCompileSession(sessionId)
}
- @Suppress("DEPRECATION")
- @Deprecated("Use other compile method", ReplaceWith("compile"))
- fun compile(compilerService: CompileService,
- sessionId: Int,
- targetPlatform: CompileService.TargetPlatform,
- args: Array<out String>,
- out: OutputStream,
- port: Int = SOCKET_ANY_FREE_PORT,
- operationsTracer: RemoteOperationsTracer? = null
- ): Int {
- val outStrm = RemoteOutputStreamServer(out, port = port)
- return compilerService.remoteCompile(sessionId, targetPlatform, args, CompilerCallbackServicesFacadeServer(port = port), outStrm, CompileService.OutputFormat.PLAIN, outStrm, operationsTracer).get()
- }
-
-
- @Suppress("DEPRECATION")
- @Deprecated("Use non-deprecated compile method", ReplaceWith("compile"))
- fun incrementalCompile(compileService: CompileService,
- sessionId: Int,
- targetPlatform: CompileService.TargetPlatform,
- args: Array<out String>,
- callbackServices: CompilationServices,
- compilerOut: OutputStream,
- daemonOut: OutputStream,
- port: Int = SOCKET_ANY_FREE_PORT,
- profiler: Profiler = DummyProfiler(),
- operationsTracer: RemoteOperationsTracer? = null
- ): Int = profiler.withMeasure(this) {
- compileService.remoteIncrementalCompile(
- sessionId,
- targetPlatform,
- args,
- CompilerCallbackServicesFacadeServer(incrementalCompilationComponents = callbackServices.incrementalCompilationComponents,
- lookupTracker = callbackServices.lookupTracker,
- compilationCanceledStatus = callbackServices.compilationCanceledStatus,
- port = port),
- RemoteOutputStreamServer(compilerOut, port),
- CompileService.OutputFormat.XML,
- RemoteOutputStreamServer(daemonOut, port),
- operationsTracer).get()
- }
-
fun compile(compilerService: CompileService,
sessionId: Int,
targetPlatform: CompileService.TargetPlatform,
@@ -274,14 +233,43 @@
}
else -> {
println("Executing daemon compilation with args: " + filteredArgs.joinToString(" "))
- val outStrm = RemoteOutputStreamServer(System.out)
- val servicesFacade = CompilerCallbackServicesFacadeServer()
+ val messageCollector = object : MessageCollector {
+ override fun clear() {
+ TODO("Not yet implemented1")
+ }
+
+ override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageSourceLocation?) {
+ println("${severity.name}\t${location?.path ?: ""}:${location?.line ?: ""} \t$message")
+ }
+
+ override fun hasErrors(): Boolean {
+ TODO("Not yet implemented3")
+ }
+
+ }
+
+ val outputsCollector = { x: File, y: List<File> -> println("$x $y") }
+ val servicesFacade = BasicCompilerServicesWithResultsFacadeServer(messageCollector, outputsCollector)
try {
val memBefore = daemon.getUsedMemory().get() / 1024
val startTime = System.nanoTime()
- @Suppress("DEPRECATION")
- val res = daemon.remoteCompile(CompileService.NO_SESSION, CompileService.TargetPlatform.JVM, filteredArgs.toList().toTypedArray(), servicesFacade, outStrm, CompileService.OutputFormat.PLAIN, outStrm, null)
+ val compilationOptions = CompilationOptions(
+ CompilerMode.NON_INCREMENTAL_COMPILER,
+ CompileService.TargetPlatform.JVM,
+ arrayOf(ReportCategory.COMPILER_MESSAGE.code, ReportCategory.DAEMON_MESSAGE.code, ReportCategory.EXCEPTION.code, ReportCategory.OUTPUT_MESSAGE.code),
+ ReportSeverity.INFO.code,
+ emptyArray()
+ )
+
+
+ val res = daemon.compile(
+ CompileService.NO_SESSION,
+ filteredArgs.toList().toTypedArray(),
+ compilationOptions,
+ servicesFacade,
+ null
+ )
val endTime = System.nanoTime()
println("Compilation ${if (res.isGood) "succeeded" else "failed"}, result code: ${res.get()}")
@@ -292,7 +280,6 @@
finally {
// forcing RMI to unregister all objects and stop
UnicastRemoteObject.unexportObject(servicesFacade, true)
- UnicastRemoteObject.unexportObject(outStrm, true)
}
}
}
diff --git a/compiler/daemon/daemon-common/src/org/jetbrains/kotlin/daemon/common/CompileService.kt b/compiler/daemon/daemon-common/src/org/jetbrains/kotlin/daemon/common/CompileService.kt
index 591f161..2f59771 100644
--- a/compiler/daemon/daemon-common/src/org/jetbrains/kotlin/daemon/common/CompileService.kt
+++ b/compiler/daemon/daemon-common/src/org/jetbrains/kotlin/daemon/common/CompileService.kt
@@ -106,36 +106,6 @@
@Throws(RemoteException::class)
fun scheduleShutdown(graceful: Boolean): CallResult<Boolean>
- // TODO: consider adding async version of shutdown and release
-
- @Suppress("DEPRECATION")
- @Deprecated("The usages should be replaced with `compile` method", ReplaceWith("compile"))
- @Throws(RemoteException::class)
- fun remoteCompile(
- sessionId: Int,
- targetPlatform: TargetPlatform,
- args: Array<out String>,
- servicesFacade: CompilerCallbackServicesFacade,
- compilerOutputStream: RemoteOutputStream,
- outputFormat: OutputFormat,
- serviceOutputStream: RemoteOutputStream,
- operationsTracer: RemoteOperationsTracer?
- ): CallResult<Int>
-
- @Suppress("DEPRECATION")
- @Deprecated("The usages should be replaced with `compile` method", ReplaceWith("compile"))
- @Throws(RemoteException::class)
- fun remoteIncrementalCompile(
- sessionId: Int,
- targetPlatform: TargetPlatform,
- args: Array<out String>,
- servicesFacade: CompilerCallbackServicesFacade,
- compilerOutputStream: RemoteOutputStream,
- compilerOutputFormat: OutputFormat,
- serviceOutputStream: RemoteOutputStream,
- operationsTracer: RemoteOperationsTracer?
- ): CallResult<Int>
-
@Throws(RemoteException::class)
fun compile(
sessionId: Int,
@@ -154,50 +124,9 @@
@Throws(RemoteException::class)
fun clearJarCache()
- @Suppress("DEPRECATION")
- @Deprecated("The usages should be replaced with other `leaseReplSession` method", ReplaceWith("leaseReplSession"))
- @Throws(RemoteException::class)
- fun leaseReplSession(
- aliveFlagPath: String?,
- targetPlatform: CompileService.TargetPlatform,
- servicesFacade: CompilerCallbackServicesFacade,
- templateClasspath: List<File>,
- templateClassName: String,
- scriptArgs: Array<out Any?>?,
- scriptArgsTypes: Array<out Class<out Any>>?,
- compilerMessagesOutputStream: RemoteOutputStream,
- evalOutputStream: RemoteOutputStream?,
- evalErrorStream: RemoteOutputStream?,
- evalInputStream: RemoteInputStream?,
- operationsTracer: RemoteOperationsTracer?
- ): CallResult<Int>
-
@Throws(RemoteException::class)
fun releaseReplSession(sessionId: Int): CallResult<Nothing>
- @Deprecated("The usages should be replaced with `replCheck` method", ReplaceWith("replCheck"))
- @Throws(RemoteException::class)
- fun remoteReplLineCheck(
- sessionId: Int,
- codeLine: ReplCodeLine
- ): CallResult<ReplCheckResult>
-
- @Deprecated("The usages should be replaced with `replCompile` method", ReplaceWith("replCompile"))
- @Throws(RemoteException::class)
- fun remoteReplLineCompile(
- sessionId: Int,
- codeLine: ReplCodeLine,
- history: List<ReplCodeLine>?
- ): CallResult<ReplCompileResult>
-
- @Deprecated("Evaluation on daemon is not supported")
- @Throws(RemoteException::class)
- fun remoteReplLineEval(
- sessionId: Int,
- codeLine: ReplCodeLine,
- history: List<ReplCodeLine>?
- ): CallResult<ReplEvalResult>
-
@Throws(RemoteException::class)
fun leaseReplSession(
aliveFlagPath: String?,
diff --git a/compiler/daemon/daemon-tests/test/org/jetbrains/kotlin/daemon/CompilerDaemonTest.kt b/compiler/daemon/daemon-tests/test/org/jetbrains/kotlin/daemon/CompilerDaemonTest.kt
index 05df177..13c3f1b 100644
--- a/compiler/daemon/daemon-tests/test/org/jetbrains/kotlin/daemon/CompilerDaemonTest.kt
+++ b/compiler/daemon/daemon-tests/test/org/jetbrains/kotlin/daemon/CompilerDaemonTest.kt
@@ -723,51 +723,6 @@
}
}
- fun testDaemonCallbackConnectionProblems() {
- withFlagFile(getTestName(true), ".alive") { flagFile ->
- val daemonOptions = makeTestDaemonOptions(getTestName(true))
-
- withLogFile("kotlin-daemon-test") { logFile ->
- val daemonJVMOptions = makeTestDaemonJvmOptions(logFile)
-
- val daemon = KotlinCompilerClient.connectToCompileService(compilerId, flagFile, daemonJVMOptions, daemonOptions, DaemonReportingTargets(out = System.err), autostart = true)
- assertNotNull("failed to connect daemon", daemon)
- daemon?.registerClient(flagFile.absolutePath)
-
- val file = File(testTempDir, "largeKotlinFile.kt")
- file.writeText(generateLargeKotlinFile(10))
- val jar = File(testTempDir, "largeKotlinFile.jar").absolutePath
-
- var callbackServices: CompilerCallbackServicesFacadeServer? = null
- callbackServices = CompilerCallbackServicesFacadeServer(compilationCanceledStatus = object : CompilationCanceledStatus {
- override fun checkCanceled() {
- thread {
- Thread.sleep(10)
- UnicastRemoteObject.unexportObject(callbackServices, true)
- }
- }
- }, port = SOCKET_ANY_FREE_PORT)
- val strm = ByteArrayOutputStream()
- @Suppress("DEPRECATION")
- val code = daemon!!.remoteCompile(CompileService.NO_SESSION,
- CompileService.TargetPlatform.JVM,
- arrayOf("-include-runtime", file.absolutePath, "-d", jar),
- callbackServices,
- RemoteOutputStreamServer(strm, SOCKET_ANY_FREE_PORT),
- CompileService.OutputFormat.XML,
- RemoteOutputStreamServer(strm, SOCKET_ANY_FREE_PORT),
- null).get()
-
- TestCase.assertEquals(0, code)
-
- val compilerOutput = strm.toString()
- assertTrue("Expecting cancellation message in:\n$compilerOutput", compilerOutput.contains("Compilation was canceled"))
- logFile.assertLogContainsSequence("error communicating with host, assuming compilation canceled")
-
- }
- }
- }
-
fun testDaemonReplScriptingNotInClasspathError() {
withDaemon(compilerId) { daemon ->
var repl: KotlinRemoteReplCompilerClient? = null
diff --git a/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt b/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt
index 0970df7..6a21a92 100644
--- a/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt
+++ b/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt
@@ -736,58 +736,6 @@
CompileService.CallResult.Good(res)
}
- @Suppress("OverridingDeprecatedMember", "DEPRECATION", "OVERRIDE_DEPRECATION")
- override fun remoteCompile(
- sessionId: Int,
- targetPlatform: CompileService.TargetPlatform,
- args: Array<out String>,
- servicesFacade: CompilerCallbackServicesFacade,
- compilerOutputStream: RemoteOutputStream,
- outputFormat: CompileService.OutputFormat,
- serviceOutputStream: RemoteOutputStream,
- operationsTracer: RemoteOperationsTracer?
- ): CompileService.CallResult<Int> =
- doCompile(sessionId, args, compilerOutputStream, serviceOutputStream, operationsTracer) { printStream, eventManager, profiler ->
- when (outputFormat) {
- CompileService.OutputFormat.PLAIN -> compiler[targetPlatform].exec(printStream, *args)
- CompileService.OutputFormat.XML -> compiler[targetPlatform].execAndOutputXml(
- printStream,
- createCompileServices(
- servicesFacade,
- eventManager,
- profiler
- ),
- *args
- )
- }
- }
-
- @Suppress("OverridingDeprecatedMember", "DEPRECATION", "OVERRIDE_DEPRECATION")
- override fun remoteIncrementalCompile(
- sessionId: Int,
- targetPlatform: CompileService.TargetPlatform,
- args: Array<out String>,
- servicesFacade: CompilerCallbackServicesFacade,
- compilerOutputStream: RemoteOutputStream,
- compilerOutputFormat: CompileService.OutputFormat,
- serviceOutputStream: RemoteOutputStream,
- operationsTracer: RemoteOperationsTracer?
- ): CompileService.CallResult<Int> =
- doCompile(sessionId, args, compilerOutputStream, serviceOutputStream, operationsTracer) { printStream, eventManager, profiler ->
- when (compilerOutputFormat) {
- CompileService.OutputFormat.PLAIN -> throw NotImplementedError("Only XML output is supported in remote incremental compilation")
- CompileService.OutputFormat.XML -> compiler[targetPlatform].execAndOutputXml(
- printStream,
- createCompileServices(
- servicesFacade,
- eventManager,
- profiler
- ),
- *args
- )
- }
- }
-
override fun classesFqNamesByFiles(
sessionId: Int, sourceFiles: Set<File>
): CompileService.CallResult<Set<String>> =
@@ -819,54 +767,9 @@
}
- @Deprecated("The usages should be replaced with other `leaseReplSession` method", ReplaceWith("leaseReplSession"))
- override fun leaseReplSession(
- aliveFlagPath: String?,
- targetPlatform: CompileService.TargetPlatform,
- @Suppress("DEPRECATION") servicesFacade: CompilerCallbackServicesFacade,
- templateClasspath: List<File>,
- templateClassName: String,
- scriptArgs: Array<out Any?>?,
- scriptArgsTypes: Array<out Class<out Any>>?,
- compilerMessagesOutputStream: RemoteOutputStream,
- evalOutputStream: RemoteOutputStream?,
- evalErrorStream: RemoteOutputStream?,
- evalInputStream: RemoteInputStream?,
- operationsTracer: RemoteOperationsTracer?
- ): CompileService.CallResult<Int> = ifAlive(minAliveness = Aliveness.Alive) {
- if (targetPlatform != CompileService.TargetPlatform.JVM)
- CompileService.CallResult.Error("Sorry, only JVM target platform is supported now")
- else {
- val disposable = Disposer.newDisposable()
- val compilerMessagesStream = PrintStream(
- BufferedOutputStream(
- RemoteOutputStreamClient(compilerMessagesOutputStream, DummyProfiler()),
- REMOTE_STREAM_BUFFER_SIZE
- )
- )
- val messageCollector = KeepFirstErrorMessageCollector(compilerMessagesStream)
- val repl = KotlinJvmReplService(
- disposable, port, compilerId, templateClasspath, templateClassName,
- messageCollector, operationsTracer
- )
- val sessionId = state.sessions.leaseSession(ClientOrSessionProxy(aliveFlagPath, repl, disposable))
-
- CompileService.CallResult.Good(sessionId)
- }
- }
-
// TODO: add more checks (e.g. is it a repl session)
override fun releaseReplSession(sessionId: Int): CompileService.CallResult<Nothing> = releaseCompileSession(sessionId)
- @Suppress("OverridingDeprecatedMember", "OVERRIDE_DEPRECATION")
- override fun remoteReplLineCheck(sessionId: Int, codeLine: ReplCodeLine): CompileService.CallResult<ReplCheckResult> =
- ifAlive(minAliveness = Aliveness.Alive) {
- withValidRepl(sessionId) {
- @Suppress("DEPRECATION")
- CompileService.CallResult.Good(check(codeLine))
- }
- }
-
private fun createCompileServices(
@Suppress("DEPRECATION") facade: CompilerCallbackServicesFacade,
eventManager: EventManager,
@@ -904,29 +807,6 @@
return builder.build()
}
- @Suppress("OverridingDeprecatedMember", "OVERRIDE_DEPRECATION")
- override fun remoteReplLineCompile(
- sessionId: Int,
- codeLine: ReplCodeLine,
- history: List<ReplCodeLine>?
- ): CompileService.CallResult<ReplCompileResult> =
- ifAlive(minAliveness = Aliveness.Alive) {
- withValidRepl(sessionId) {
- @Suppress("DEPRECATION")
- CompileService.CallResult.Good(compile(codeLine, history))
- }
- }
-
- @Suppress("OverridingDeprecatedMember", "OVERRIDE_DEPRECATION")
- override fun remoteReplLineEval(
- sessionId: Int,
- codeLine: ReplCodeLine,
- history: List<ReplCodeLine>?
- ): CompileService.CallResult<ReplEvalResult> =
- ifAlive(minAliveness = Aliveness.Alive) {
- CompileService.CallResult.Error("Eval on daemon is not supported")
- }
-
override fun leaseReplSession(
aliveFlagPath: String?,
compilerArguments: Array<out String>,
@@ -1171,50 +1051,6 @@
return true
}
- // todo: remove after remoteIncrementalCompile is removed
- private fun doCompile(
- sessionId: Int,
- args: Array<out String>,
- compilerMessagesStreamProxy: RemoteOutputStream,
- serviceOutputStreamProxy: RemoteOutputStream,
- operationsTracer: RemoteOperationsTracer?,
- body: (PrintStream, EventManager, Profiler) -> ExitCode
- ): CompileService.CallResult<Int> =
- ifAlive {
- withValidClientOrSessionProxy(sessionId) {
- operationsTracer?.before("compile")
- val rpcProfiler = if (daemonOptions.reportPerf) WallAndThreadTotalProfiler() else DummyProfiler()
- val eventManger = EventManagerImpl()
- val compilerMessagesStream = PrintStream(
- BufferedOutputStream(
- RemoteOutputStreamClient(compilerMessagesStreamProxy, rpcProfiler),
- REMOTE_STREAM_BUFFER_SIZE
- )
- )
- val serviceOutputStream = PrintStream(
- BufferedOutputStream(
- RemoteOutputStreamClient(serviceOutputStreamProxy, rpcProfiler),
- REMOTE_STREAM_BUFFER_SIZE
- )
- )
- try {
- val compileServiceReporter = DaemonMessageReporterPrintStreamAdapter(serviceOutputStream)
- if (args.none())
- throw IllegalArgumentException("Error: empty arguments list.")
- log.info("Starting compilation with args: " + args.joinToString(" "))
- val exitCode = checkedCompile(compileServiceReporter, rpcProfiler) {
- body(compilerMessagesStream, eventManger, rpcProfiler).code
- }
- CompileService.CallResult.Good(exitCode)
- } finally {
- serviceOutputStream.flush()
- compilerMessagesStream.flush()
- eventManger.fireCompilationFinished()
- operationsTracer?.after("compile")
- }
- }
- }
-
init {
// assuming logicaly synchronized
try {
diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerWork.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerWork.kt
index 729ff0c..0a67400 100644
--- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerWork.kt
+++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerWork.kt
@@ -345,12 +345,6 @@
val res = exec.invoke(compiler.newInstance(), out, emptyServices, compilerArgs)
val exitCode = ExitCode.valueOf(res.toString())
- processCompilerOutput(
- messageCollector,
- OutputItemsCollectorImpl(),
- stream,
- exitCode
- )
try {
metrics.measure(BuildTime.CLEAR_JAR_CACHE) {
val coreEnvironment = Class.forName("org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment", true, classLoader)