Code cleanup - removing public modifier, obsolete constants, fixing typos, etc.

This commit is contained in:
Ilya Chernikov
2015-11-25 14:30:24 +01:00
parent 9869fc4305
commit 312e931582
15 changed files with 127 additions and 127 deletions
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.rmi.LoopbackNetworkInterface
import org.jetbrains.kotlin.rmi.SOCKET_ANY_FREE_PORT
public class CompilerCallbackServicesFacadeServer(
class CompilerCallbackServicesFacadeServer(
val incrementalCompilationComponents: IncrementalCompilationComponents? = null,
val compilationCancelledStatus: CompilationCanceledStatus? = null,
port: Int = SOCKET_ANY_FREE_PORT
@@ -29,13 +29,13 @@ import java.util.concurrent.TimeUnit
import kotlin.concurrent.thread
public class CompilationServices(
class CompilationServices(
val incrementalCompilationComponents: IncrementalCompilationComponents? = null,
val compilationCanceledStatus: CompilationCanceledStatus? = null
)
public object KotlinCompilerClient {
object KotlinCompilerClient {
val DAEMON_DEFAULT_STARTUP_TIMEOUT_MS = 10000L
val DAEMON_CONNECT_CYCLE_ATTEMPTS = 3
@@ -43,7 +43,7 @@ public object KotlinCompilerClient {
val verboseReporting = System.getProperty(COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY) != null
public fun connectToCompileService(compilerId: CompilerId,
fun connectToCompileService(compilerId: CompilerId,
daemonJVMOptions: DaemonJVMOptions,
daemonOptions: DaemonOptions,
reportingTargets: DaemonReportingTargets,
@@ -65,7 +65,7 @@ public object KotlinCompilerClient {
return connectToCompileService(compilerId, flagFile, daemonJVMOptions, daemonOptions, reportingTargets, autostart)
}
public fun connectToCompileService(compilerId: CompilerId,
fun connectToCompileService(compilerId: CompilerId,
clientAliveFlagFile: File,
daemonJVMOptions: DaemonJVMOptions,
daemonOptions: DaemonOptions,
@@ -97,18 +97,18 @@ public object KotlinCompilerClient {
}
public fun shutdownCompileService(compilerId: CompilerId, daemonOptions: DaemonOptions): Unit {
fun shutdownCompileService(compilerId: CompilerId, daemonOptions: DaemonOptions): Unit {
KotlinCompilerClient.connectToCompileService(compilerId, DaemonJVMOptions(), daemonOptions, DaemonReportingTargets(out = System.out), autostart = false, checkId = false)
?.shutdown()
}
public fun shutdownCompileService(compilerId: CompilerId): Unit {
fun shutdownCompileService(compilerId: CompilerId): Unit {
shutdownCompileService(compilerId, DaemonOptions())
}
public fun compile(compilerService: CompileService,
fun compile(compilerService: CompileService,
sessionId: Int,
targetPlatform: CompileService.TargetPlatform,
args: Array<out String>,
@@ -121,7 +121,7 @@ public object KotlinCompilerClient {
}
public fun incrementalCompile(compileService: CompileService,
fun incrementalCompile(compileService: CompileService,
sessionId: Int,
targetPlatform: CompileService.TargetPlatform,
args: Array<out String>,
@@ -145,9 +145,9 @@ public object KotlinCompilerClient {
operationsTracer).get()
}
public val COMPILE_DAEMON_CLIENT_OPTIONS_PROPERTY: String = "kotlin.daemon.client.options"
val COMPILE_DAEMON_CLIENT_OPTIONS_PROPERTY: String = "kotlin.daemon.client.options"
data class ClientOptions(
public var stop: Boolean = false
var stop: Boolean = false
) : OptionsGroup {
override val mappers: List<PropMapper<*, *, *>>
get() = listOf(BoolPropMapper(this, ClientOptions::stop))
@@ -168,7 +168,7 @@ public object KotlinCompilerClient {
@JvmStatic
public fun main(vararg args: String) {
fun main(vararg args: String) {
val compilerId = CompilerId()
val daemonOptions = configureDaemonOptions()
val daemonLaunchingOptions = configureDaemonJVMOptions(inheritMemoryLimits = true, inheritAdditionalProperties = true)
@@ -231,7 +231,7 @@ public object KotlinCompilerClient {
}
}
public fun detectCompilerClasspath(): List<String>? =
fun detectCompilerClasspath(): List<String>? =
System.getProperty("java.class.path")
?.split(File.pathSeparator)
?.map { File(it).parentFile }
@@ -339,9 +339,9 @@ public object KotlinCompilerClient {
}
public data class DaemonReportMessage(public val category: DaemonReportCategory, public val message: String)
data class DaemonReportMessage(public val category: DaemonReportCategory, public val message: String)
public class DaemonReportingTargets(public val out: PrintStream? = null, public val messages: MutableCollection<DaemonReportMessage>? = null)
class DaemonReportingTargets(public val out: PrintStream? = null, public val messages: MutableCollection<DaemonReportMessage>? = null)
internal fun isProcessAlive(process: Process) =
@@ -20,23 +20,23 @@ import java.io.Serializable
import java.rmi.Remote
import java.rmi.RemoteException
public interface CompileService : Remote {
interface CompileService : Remote {
public enum class OutputFormat : Serializable {
enum class OutputFormat : Serializable {
PLAIN,
XML
}
public enum class TargetPlatform : Serializable {
enum class TargetPlatform : Serializable {
JVM,
JS
}
companion object {
public val NO_SESSION: Int = 0
val NO_SESSION: Int = 0
}
public sealed class CallResult<out R> : Serializable {
sealed class CallResult<out R> : Serializable {
class Good<R>(val result: R) : CallResult<R>() {
override fun get(): R = result
@@ -66,41 +66,41 @@ public interface CompileService : Remote {
// TODO: remove!
@Throws(RemoteException::class)
public fun checkCompilerId(expectedCompilerId: CompilerId): Boolean
fun checkCompilerId(expectedCompilerId: CompilerId): Boolean
@Throws(RemoteException::class)
public fun getUsedMemory(): CallResult<Long>
fun getUsedMemory(): CallResult<Long>
@Throws(RemoteException::class)
public fun getDaemonOptions(): CallResult<DaemonOptions>
fun getDaemonOptions(): CallResult<DaemonOptions>
@Throws(RemoteException::class)
public fun getDaemonJVMOptions(): CallResult<DaemonJVMOptions>
fun getDaemonJVMOptions(): CallResult<DaemonJVMOptions>
@Throws(RemoteException::class)
public fun registerClient(aliveFlagPath: String?): CallResult<Nothing>
fun registerClient(aliveFlagPath: String?): CallResult<Nothing>
// TODO: consider adding another client alive checking mechanism, e.g. socket/port
@Throws(RemoteException::class)
public fun getClients(): CallResult<List<String>>
fun getClients(): CallResult<List<String>>
@Throws(RemoteException::class)
public fun leaseCompileSession(aliveFlagPath: String?): CallResult<Int>
fun leaseCompileSession(aliveFlagPath: String?): CallResult<Int>
@Throws(RemoteException::class)
public fun releaseCompileSession(sessionId: Int): CallResult<Nothing>
fun releaseCompileSession(sessionId: Int): CallResult<Nothing>
@Throws(RemoteException::class)
public fun shutdown(): CallResult<Nothing>
fun shutdown(): CallResult<Nothing>
@Throws(RemoteException::class)
public fun scheduleShutdown(graceful: Boolean): CallResult<Boolean>
fun scheduleShutdown(graceful: Boolean): CallResult<Boolean>
// TODO: consider adding async version of shutdown and release
@Throws(RemoteException::class)
public fun remoteCompile(
fun remoteCompile(
sessionId: Int,
targetPlatform: TargetPlatform,
args: Array<out String>,
@@ -112,7 +112,7 @@ public interface CompileService : Remote {
): CallResult<Int>
@Throws(RemoteException::class)
public fun remoteIncrementalCompile(
fun remoteIncrementalCompile(
sessionId: Int,
targetPlatform: TargetPlatform,
args: Array<out String>,
@@ -28,45 +28,45 @@ import java.rmi.RemoteException
* the reason for having common facade is attempt to reduce number of connections between client and daemon
* Note: non-standard naming convention used to denote combining several entities in one facade - prefix <entityName>_ is used for every function belonging to the entity
*/
public interface CompilerCallbackServicesFacade : Remote {
interface CompilerCallbackServicesFacade : Remote {
@Throws(RemoteException::class)
public fun hasIncrementalCaches(): Boolean
fun hasIncrementalCaches(): Boolean
@Throws(RemoteException::class)
public fun hasLookupTracker(): Boolean
fun hasLookupTracker(): Boolean
@Throws(RemoteException::class)
public fun hasCompilationCanceledStatus(): Boolean
fun hasCompilationCanceledStatus(): Boolean
// ----------------------------------------------------
// IncrementalCache
@Throws(RemoteException::class)
public fun incrementalCache_getObsoletePackageParts(target: TargetId): Collection<String>
fun incrementalCache_getObsoletePackageParts(target: TargetId): Collection<String>
@Throws(RemoteException::class)
public fun incrementalCache_getObsoleteMultifileClassFacades(target: TargetId): Collection<String>
fun incrementalCache_getObsoleteMultifileClassFacades(target: TargetId): Collection<String>
@Throws(RemoteException::class)
public fun incrementalCache_getMultifileFacade(target: TargetId, partInternalName: String): String?
fun incrementalCache_getMultifileFacade(target: TargetId, partInternalName: String): String?
@Throws(RemoteException::class)
public fun incrementalCache_getPackagePartData(target: TargetId, fqName: String): JvmPackagePartProto?
fun incrementalCache_getPackagePartData(target: TargetId, fqName: String): JvmPackagePartProto?
@Throws(RemoteException::class)
public fun incrementalCache_getModuleMappingData(target: TargetId): ByteArray?
fun incrementalCache_getModuleMappingData(target: TargetId): ByteArray?
@Throws(RemoteException::class)
public fun incrementalCache_registerInline(target: TargetId, fromPath: String, jvmSignature: String, toPath: String)
fun incrementalCache_registerInline(target: TargetId, fromPath: String, jvmSignature: String, toPath: String)
@Throws(RemoteException::class)
fun incrementalCache_getClassFilePath(target: TargetId, internalClassName: String): String
@Throws(RemoteException::class)
public fun incrementalCache_close(target: TargetId)
fun incrementalCache_close(target: TargetId)
@Throws(RemoteException::class)
public fun incrementalCache_getMultifileFacadeParts(target: TargetId, internalName: String): Collection<String>?
fun incrementalCache_getMultifileFacadeParts(target: TargetId, internalName: String): Collection<String>?
// ----------------------------------------------------
// LookupTracker
@@ -23,36 +23,33 @@ import java.lang.management.ManagementFactory
import java.security.MessageDigest
import java.util.*
import kotlin.reflect.KMutableProperty1
import kotlin.text.RegexOption
public val COMPILER_JAR_NAME: String = "kotlin-compiler.jar"
public val COMPILER_SERVICE_RMI_NAME: String = "KotlinJvmCompilerService"
public val COMPILER_DAEMON_CLASS_FQN: String = "org.jetbrains.kotlin.rmi.service.CompileDaemon"
public val COMPILE_DAEMON_FIND_PORT_ATTEMPTS: Int = 10
public val COMPILE_DAEMON_PORTS_RANGE_START: Int = 17001
public val COMPILE_DAEMON_PORTS_RANGE_END: Int = 18000
public val COMPILE_DAEMON_STARTUP_LOCK_TIMEOUT_MS: Long = 10000L
public val COMPILE_DAEMON_STARTUP_LOCK_TIMEOUT_CHECK_MS: Long = 100L
public val COMPILE_DAEMON_ENABLED_PROPERTY: String = "kotlin.daemon.enabled"
public val COMPILE_DAEMON_JVM_OPTIONS_PROPERTY: String = "kotlin.daemon.jvm.options"
public val COMPILE_DAEMON_OPTIONS_PROPERTY: String = "kotlin.daemon.options"
public val COMPILE_DAEMON_CLIENT_ALIVE_PATH_PROPERTY: String = "kotlin.daemon.client.alive.path"
public val COMPILE_DAEMON_LOG_PATH_PROPERTY: String = "kotlin.daemon.log.path"
public val COMPILE_DAEMON_REPORT_PERF_PROPERTY: String = "kotlin.daemon.perf"
public val COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY: String = "kotlin.daemon.verbose"
public val COMPILE_DAEMON_CMDLINE_OPTIONS_PREFIX: String = "--daemon-"
public val COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY: String = "kotlin.daemon.startup.timeout"
public val COMPILE_DAEMON_DEFAULT_FILES_PREFIX: String = "kotlin-daemon"
public val COMPILE_DAEMON_TIMEOUT_INFINITE_S: Int = 0
public val COMPILE_DAEMON_DEFAULT_IDLE_TIMEOUT_S: Int = 7200 // 2 hours
public val COMPILE_DAEMON_DEFAULT_UNUSED_TIMEOUT_S: Int = 60
public val COMPILE_DAEMON_DEFAULT_SHUTDOWN_DELAY_MS: Long = 1000L // 1 sec
public val COMPILE_DAEMON_MEMORY_THRESHOLD_INFINITE: Long = 0L
public val COMPILE_DAEMON_FORCE_SHUTDOWN_DEFAULT_TIMEOUT_MS: Long = 10000L // 10 secs
public val COMPILE_DAEMON_TIMEOUT_INFINITE_MS: Long = 0L
val COMPILER_JAR_NAME: String = "kotlin-compiler.jar"
val COMPILER_SERVICE_RMI_NAME: String = "KotlinJvmCompilerService"
val COMPILER_DAEMON_CLASS_FQN: String = "org.jetbrains.kotlin.rmi.service.CompileDaemon"
val COMPILE_DAEMON_FIND_PORT_ATTEMPTS: Int = 10
val COMPILE_DAEMON_PORTS_RANGE_START: Int = 17001
val COMPILE_DAEMON_PORTS_RANGE_END: Int = 18000
val COMPILE_DAEMON_ENABLED_PROPERTY: String = "kotlin.daemon.enabled"
val COMPILE_DAEMON_JVM_OPTIONS_PROPERTY: String = "kotlin.daemon.jvm.options"
val COMPILE_DAEMON_OPTIONS_PROPERTY: String = "kotlin.daemon.options"
val COMPILE_DAEMON_CLIENT_ALIVE_PATH_PROPERTY: String = "kotlin.daemon.client.alive.path"
val COMPILE_DAEMON_LOG_PATH_PROPERTY: String = "kotlin.daemon.log.path"
val COMPILE_DAEMON_REPORT_PERF_PROPERTY: String = "kotlin.daemon.perf"
val COMPILE_DAEMON_VERBOSE_REPORT_PROPERTY: String = "kotlin.daemon.verbose"
val COMPILE_DAEMON_CMDLINE_OPTIONS_PREFIX: String = "--daemon-"
val COMPILE_DAEMON_STARTUP_TIMEOUT_PROPERTY: String = "kotlin.daemon.startup.timeout"
val COMPILE_DAEMON_DEFAULT_FILES_PREFIX: String = "kotlin-daemon"
val COMPILE_DAEMON_TIMEOUT_INFINITE_S: Int = 0
val COMPILE_DAEMON_DEFAULT_IDLE_TIMEOUT_S: Int = 7200 // 2 hours
val COMPILE_DAEMON_DEFAULT_UNUSED_TIMEOUT_S: Int = 60
val COMPILE_DAEMON_DEFAULT_SHUTDOWN_DELAY_MS: Long = 1000L // 1 sec
val COMPILE_DAEMON_MEMORY_THRESHOLD_INFINITE: Long = 0L
val COMPILE_DAEMON_FORCE_SHUTDOWN_DEFAULT_TIMEOUT_MS: Long = 10000L // 10 secs
val COMPILE_DAEMON_TIMEOUT_INFINITE_MS: Long = 0L
public val COMPILE_DAEMON_DEFAULT_RUN_DIR_PATH: String get() =
val COMPILE_DAEMON_DEFAULT_RUN_DIR_PATH: String get() =
FileSystem.getRuntimeStateFilesPath("kotlin", "daemon")
val CLASSPATH_ID_DIGEST = "MD5"
@@ -173,22 +170,22 @@ fun Iterable<String>.filterExtractProps(propMappers: List<PropMapper<*, *, *>>,
}
public fun String.trimQuotes() = trim('"','\'')
fun String.trimQuotes() = trim('"','\'')
public interface OptionsGroup : Serializable {
public val mappers: List<PropMapper<*, *, *>>
interface OptionsGroup : Serializable {
val mappers: List<PropMapper<*, *, *>>
}
public fun Iterable<String>.filterExtractProps(vararg groups: OptionsGroup, prefix: String): Iterable<String> =
fun Iterable<String>.filterExtractProps(vararg groups: OptionsGroup, prefix: String): Iterable<String> =
filterExtractProps(groups.flatMap { it.mappers }, prefix)
public data class DaemonJVMOptions(
public var maxMemory: String = "",
public var maxPermSize: String = "",
public var reservedCodeCacheSize: String = "",
public var jvmParams: MutableCollection<String> = arrayListOf()
data class DaemonJVMOptions(
var maxMemory: String = "",
var maxPermSize: String = "",
var reservedCodeCacheSize: String = "",
var jvmParams: MutableCollection<String> = arrayListOf()
) : OptionsGroup {
override val mappers: List<PropMapper<*, *, *>>
@@ -202,15 +199,15 @@ public data class DaemonJVMOptions(
}
public data class DaemonOptions(
public var runFilesPath: String = COMPILE_DAEMON_DEFAULT_RUN_DIR_PATH,
public var autoshutdownMemoryThreshold: Long = COMPILE_DAEMON_MEMORY_THRESHOLD_INFINITE,
public var autoshutdownIdleSeconds: Int = COMPILE_DAEMON_DEFAULT_IDLE_TIMEOUT_S,
public var autoshutdownUnusedSeconds: Int = COMPILE_DAEMON_DEFAULT_UNUSED_TIMEOUT_S,
public var shutdownDelayMilliseconds: Long = COMPILE_DAEMON_DEFAULT_SHUTDOWN_DELAY_MS,
public var forceShutdownTimeoutMilliseconds: Long = COMPILE_DAEMON_FORCE_SHUTDOWN_DEFAULT_TIMEOUT_MS,
public var verbose: Boolean = false,
public var reportPerf: Boolean = false
data class DaemonOptions(
var runFilesPath: String = COMPILE_DAEMON_DEFAULT_RUN_DIR_PATH,
var autoshutdownMemoryThreshold: Long = COMPILE_DAEMON_MEMORY_THRESHOLD_INFINITE,
var autoshutdownIdleSeconds: Int = COMPILE_DAEMON_DEFAULT_IDLE_TIMEOUT_S,
var autoshutdownUnusedSeconds: Int = COMPILE_DAEMON_DEFAULT_UNUSED_TIMEOUT_S,
var shutdownDelayMilliseconds: Long = COMPILE_DAEMON_DEFAULT_SHUTDOWN_DELAY_MS,
var forceShutdownTimeoutMilliseconds: Long = COMPILE_DAEMON_FORCE_SHUTDOWN_DEFAULT_TIMEOUT_MS,
var verbose: Boolean = false,
var reportPerf: Boolean = false
) : OptionsGroup {
override val mappers: List<PropMapper<*, *, *>>
@@ -237,9 +234,9 @@ fun Iterable<String>.distinctStringsDigest(): ByteArray =
fun ByteArray.toHexString(): String = joinToString("", transform = { "%02x".format(it) })
public data class CompilerId(
public var compilerClasspath: List<String> = listOf(),
public var compilerVersion: String = ""
data class CompilerId(
var compilerClasspath: List<String> = listOf(),
var compilerVersion: String = ""
) : OptionsGroup {
override val mappers: List<PropMapper<*, *, *>>
@@ -248,19 +245,19 @@ public data class CompilerId(
companion object {
@JvmStatic
public fun makeCompilerId(vararg paths: File): CompilerId = makeCompilerId(paths.asIterable())
fun makeCompilerId(vararg paths: File): CompilerId = makeCompilerId(paths.asIterable())
@JvmStatic
public fun makeCompilerId(paths: Iterable<File>): CompilerId =
fun makeCompilerId(paths: Iterable<File>): CompilerId =
CompilerId(compilerClasspath = paths.map { it.absolutePath })
}
}
public fun isDaemonEnabled(): Boolean = System.getProperty(COMPILE_DAEMON_ENABLED_PROPERTY) != null
fun isDaemonEnabled(): Boolean = System.getProperty(COMPILE_DAEMON_ENABLED_PROPERTY) != null
public fun configureDaemonJVMOptions(opts: DaemonJVMOptions,
fun configureDaemonJVMOptions(opts: DaemonJVMOptions,
vararg additionalParams: String,
inheritMemoryLimits: Boolean,
inheritAdditionalProperties: Boolean
@@ -286,7 +283,7 @@ public fun configureDaemonJVMOptions(opts: DaemonJVMOptions,
}
public fun configureDaemonJVMOptions(vararg additionalParams: String,
fun configureDaemonJVMOptions(vararg additionalParams: String,
inheritMemoryLimits: Boolean,
inheritAdditionalProperties: Boolean
): DaemonJVMOptions =
@@ -296,7 +293,7 @@ public fun configureDaemonJVMOptions(vararg additionalParams: String,
inheritAdditionalProperties = inheritAdditionalProperties)
public fun configureDaemonOptions(opts: DaemonOptions): DaemonOptions {
fun configureDaemonOptions(opts: DaemonOptions): DaemonOptions {
System.getProperty(COMPILE_DAEMON_OPTIONS_PROPERTY)?.let {
val unrecognized = it.trimQuotes().split(",").filterExtractProps(opts.mappers, "")
if (unrecognized.any())
@@ -310,7 +307,7 @@ public fun configureDaemonOptions(opts: DaemonOptions): DaemonOptions {
}
public fun configureDaemonOptions(): DaemonOptions = configureDaemonOptions(DaemonOptions())
fun configureDaemonOptions(): DaemonOptions = configureDaemonOptions(DaemonOptions())
private val humanizedMemorySizeRegex = "(\\d+)([kmg]?)".toRegex()
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.rmi
import java.io.File
public enum class OSKind {
enum class OSKind {
Windows,
OSX,
Unix,
@@ -54,7 +54,7 @@ private fun String?.orDefault(v: String): String =
// unix (freedesktop): http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
// OS X: https://developer.apple.com/library/mac/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/AccessingFilesandDirectories/AccessingFilesandDirectories.html
public object FileSystem {
object FileSystem {
val userHomePath: String get() = System.getProperty("user.home")
val tempPath: String get() = System.getProperty("java.io.tmpdir")
@@ -29,9 +29,9 @@ import java.rmi.server.RMIServerSocketFactory
import java.util.*
public val SOCKET_ANY_FREE_PORT = 0
val SOCKET_ANY_FREE_PORT = 0
public object LoopbackNetworkInterface {
object LoopbackNetworkInterface {
val IPV4_LOOPBACK_INET_ADDRESS = "127.0.0.1"
val IPV6_LOOPBACK_INET_ADDRESS = "::1"
@@ -39,11 +39,11 @@ public object LoopbackNetworkInterface {
val SERVER_SOCKET_BACKLOG_SIZE = 10 // size of the requests queue for daemon services, so far seems that we don't need any big numbers here
// but if we'll start getting "connection refused" errors, that could be the first place to try to fix it
public val serverLoopbackSocketFactory by lazy { ServerLoopbackSocketFactory() }
public val clientLoopbackSocketFactory by lazy { ClientLoopbackSocketFactory() }
val serverLoopbackSocketFactory by lazy { ServerLoopbackSocketFactory() }
val clientLoopbackSocketFactory by lazy { ClientLoopbackSocketFactory() }
// TODO switch to InetAddress.getLoopbackAddress on java 7+
public val loopbackInetAddressName by lazy {
val loopbackInetAddressName by lazy {
try {
if (java.net.InetAddress.getLocalHost() is java.net.Inet6Address) IPV6_LOOPBACK_INET_ADDRESS else IPV4_LOOPBACK_INET_ADDRESS
}
@@ -59,6 +59,7 @@ public object LoopbackNetworkInterface {
class ServerLoopbackSocketFactory : RMIServerSocketFactory, Serializable {
override fun equals(other: Any?): Boolean = other === this || super.equals(other)
override fun hashCode(): Int = super.hashCode()
@Throws(IOException::class)
override fun createServerSocket(port: Int): ServerSocket = ServerSocket(port, SERVER_SOCKET_BACKLOG_SIZE, InetAddress.getByName(loopbackInetAddressName))
@@ -67,6 +68,7 @@ public object LoopbackNetworkInterface {
class ClientLoopbackSocketFactory : RMIClientSocketFactory, Serializable {
override fun equals(other: Any?): Boolean = other === this || super.equals(other)
override fun hashCode(): Int = super.hashCode()
@Throws(IOException::class)
override fun createSocket(host: String, port: Int): Socket = Socket(InetAddress.getByName(loopbackInetAddressName), port)
@@ -76,7 +78,7 @@ public object LoopbackNetworkInterface {
private val portSelectionRng = Random()
public fun findPortAndCreateRegistry(attempts: Int, portRangeStart: Int, portRangeEnd: Int) : Pair<Registry, Int> {
fun findPortAndCreateRegistry(attempts: Int, portRangeStart: Int, portRangeEnd: Int) : Pair<Registry, Int> {
var i = 0
var lastException: RemoteException? = null
@@ -19,11 +19,11 @@ package org.jetbrains.kotlin.rmi
import java.rmi.Remote
import java.rmi.RemoteException
public interface RemoteOperationsTracer : Remote {
interface RemoteOperationsTracer : Remote {
@Throws(RemoteException::class)
public fun before(id: String)
fun before(id: String)
@Throws(RemoteException::class)
public fun after(id: String)
fun after(id: String)
}
@@ -19,14 +19,14 @@ package org.jetbrains.kotlin.rmi
import java.rmi.Remote
import java.rmi.RemoteException
public interface RemoteOutputStream : Remote {
interface RemoteOutputStream : Remote {
@Throws(RemoteException::class)
public fun close()
fun close()
@Throws(RemoteException::class)
public fun write(data: ByteArray, offset: Int, length: Int)
fun write(data: ByteArray, offset: Int, length: Int)
@Throws(RemoteException::class)
public fun write(dataByte: Int)
fun write(dataByte: Int)
}
+3 -2
View File
@@ -8,9 +8,10 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="kotlin-runtime" level="project" />
<orderEntry type="module" module-name="util" />
<orderEntry type="module" module-name="frontend.java" />
<orderEntry type="module" module-name="cli" />
<orderEntry type="module" module-name="rmi-interface" />
<orderEntry type="module" module-name="frontend.java" />
<orderEntry type="module" module-name="util.runtime" />
<orderEntry type="module" module-name="util" />
</component>
</module>
@@ -55,7 +55,7 @@ class LogStream(name: String) : OutputStream() {
}
public object CompileDaemon {
object CompileDaemon {
init {
val logTime: String = SimpleDateFormat("yyyy-MM-dd.HH-mm-ss-SSS").format(Date())
@@ -90,7 +90,7 @@ public object CompileDaemon {
}
@JvmStatic
public fun main(args: Array<String>) {
fun main(args: Array<String>) {
log.info("Kotlin compiler daemon version " + (loadVersionFromResource() ?: "<unknown>"))
log.info("daemon JVM args: " + ManagementFactory.getRuntimeMXBean().inputArguments.joinToString(" "))
@@ -165,7 +165,7 @@ public object CompileDaemon {
System.setOut(PrintStream(LogStream("stdout")))
}
catch (e: Exception) {
System.err.println("Exception: " + e.getMessage())
System.err.println("Exception: " + e.message)
e.printStackTrace(System.err)
// repeating it to log for the cases when stderr is not redirected yet
log.log(Level.INFO, "Exception: ", e)
@@ -104,7 +104,7 @@ class CompileServiceImpl(
}
@Volatile private var _lastUsedSeconds = nowSeconds()
public val lastUsedSeconds: Long get() = if (rwlock.isWriteLocked || rwlock.readLockCount - rwlock.readHoldCount > 0) nowSeconds() else _lastUsedSeconds
val lastUsedSeconds: Long get() = if (rwlock.isWriteLocked || rwlock.readLockCount - rwlock.readHoldCount > 0) nowSeconds() else _lastUsedSeconds
private val log by lazy { Logger.getLogger("compiler") }
@@ -40,9 +40,9 @@ val DEFAULT_CLASSPATH_DIGEST_WATCH_PERIOD_MS = 300000L // 5 min
* poor-man watcher in the absence of NIO
* TODO: replace with NIO watching when switching to java 7+
*/
public class LazyClasspathWatcher(classpath: Iterable<String>,
val chackPeriod: Long = DEFAULT_CLASSPATH_WATCH_PERIOD_MS,
val digestCheckPeriod: Long = DEFAULT_CLASSPATH_DIGEST_WATCH_PERIOD_MS) {
class LazyClasspathWatcher(classpath: Iterable<String>,
val checkPeriod: Long = DEFAULT_CLASSPATH_WATCH_PERIOD_MS,
val digestCheckPeriod: Long = DEFAULT_CLASSPATH_DIGEST_WATCH_PERIOD_MS) {
private data class FileId(val file: File, val lastModified: Long, val digest: ByteArray)
@@ -78,10 +78,10 @@ public class LazyClasspathWatcher(classpath: Iterable<String>,
}
}
public val isChanged: Boolean get() {
val isChanged: Boolean get() {
if (lastChangedStatus.get()) return true
val nowMs = TimeUnit.MILLISECONDS.toMillis(System.nanoTime())
if (nowMs - lastUpdate.get() < chackPeriod) return false
if (nowMs - lastUpdate.get() < checkPeriod) return false
val checkDigest = nowMs - lastDigestUpdate.get() > digestCheckPeriod
// making sure that fieldIds are initialized
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.rmi.CompilerCallbackServicesFacade
import org.jetbrains.kotlin.rmi.DummyProfiler
import org.jetbrains.kotlin.rmi.Profiler
public class RemoteIncrementalCacheClient(val facade: CompilerCallbackServicesFacade, val target: TargetId, val profiler: Profiler = DummyProfiler()): IncrementalCache {
class RemoteIncrementalCacheClient(val facade: CompilerCallbackServicesFacade, val target: TargetId, val profiler: Profiler = DummyProfiler()): IncrementalCache {
override fun getObsoletePackageParts(): Collection<String> = profiler.withMeasure(this) { facade.incrementalCache_getObsoletePackageParts(target) }
@@ -23,7 +23,7 @@ import java.io.OutputStream
class RemoteOutputStreamClient(val remote: RemoteOutputStream, val profiler: Profiler = DummyProfiler()): OutputStream() {
override fun write(data: ByteArray) {
profiler.withMeasure(this) { remote.write(data, 0, data.size()) }
profiler.withMeasure(this) { remote.write(data, 0, data.size) }
}
override fun write(data: ByteArray, offset: Int, length: Int) {