migrate to the new annotations syntax

This commit is contained in:
Ilya Chernikov
2015-09-10 13:07:41 +02:00
parent 473ff00940
commit cbaa981aab
7 changed files with 28 additions and 41 deletions
@@ -36,7 +36,7 @@ public object KotlinCompilerClient {
// TODO: remove jvmStatic after all use sites will switch to kotlin
jvmStatic
@JvmStatic
public fun connectToCompileService(compilerId: CompilerId,
daemonJVMOptions: DaemonJVMOptions,
daemonOptions: DaemonOptions,
@@ -117,7 +117,7 @@ public object KotlinCompilerClient {
// TODO: remove jvmStatic after all use sites will switch to kotlin
jvmStatic
@JvmStatic
public fun incrementalCompile(compiler: CompileService, args: Array<out String>, caches: Map<TargetId, IncrementalCache>, compilerOut: OutputStream, daemonOut: OutputStream): Int {
val compilerOutStreamServer = RemoteOutputStreamServer(compilerOut)
@@ -143,7 +143,7 @@ public object KotlinCompilerClient {
}
jvmStatic public fun main(vararg args: String) {
@JvmStatic public fun main(vararg args: String) {
val compilerId = CompilerId()
val daemonOptions = DaemonOptions()
val daemonLaunchingOptions = DaemonJVMOptions()
@@ -351,13 +351,13 @@ public object KotlinCompilerClient {
makeRunFilenameString(timestamp = "lock",
digest = compilerId.compilerClasspath.map { File(it).absolutePath }.distinctStringsDigest(),
port = "0"))
private volatile var locked = acquireLockFile(lockFile)
private @Volatile var locked = acquireLockFile(lockFile)
private val channel = if (locked) RandomAccessFile(lockFile, "rw").channel else null
private val lock = channel?.lock()
public fun isLocked(): Boolean = locked
synchronized public fun release(): Unit {
@Synchronized public fun release(): Unit {
if (locked) {
lock?.release()
channel?.close()
@@ -366,7 +366,7 @@ public object KotlinCompilerClient {
}
}
synchronized private fun acquireLockFile(lockFile: File): Boolean {
@Synchronized private fun acquireLockFile(lockFile: File): Boolean {
val maxAttempts = COMPILE_DAEMON_STARTUP_LOCK_TIMEOUT_MS / COMPILE_DAEMON_STARTUP_LOCK_TIMEOUT_CHECK_MS + 1
var attempt = 0L
while (true) {
@@ -28,35 +28,35 @@ public interface CompileService : Remote {
}
public interface RemoteIncrementalCache : Remote {
throws(RemoteException::class)
@Throws(RemoteException::class)
public fun getObsoletePackageParts(): Collection<String>
throws(RemoteException::class)
@Throws(RemoteException::class)
public fun getPackagePartData(fqName: String): ByteArray?
throws(RemoteException::class)
@Throws(RemoteException::class)
public fun getModuleMappingData(): ByteArray?
throws(RemoteException::class)
@Throws(RemoteException::class)
public fun registerInline(fromPath: String, jvmSignature: String, toPath: String)
throws(RemoteException::class)
@Throws(RemoteException::class)
fun getClassFilePath(internalClassName: String): String
throws(RemoteException::class)
@Throws(RemoteException::class)
public fun close()
}
throws(RemoteException::class)
@Throws(RemoteException::class)
public fun getCompilerId(): CompilerId
throws(RemoteException::class)
@Throws(RemoteException::class)
public fun getUsedMemory(): Long
throws(RemoteException::class)
@Throws(RemoteException::class)
public fun shutdown()
throws(RemoteException::class)
@Throws(RemoteException::class)
public fun remoteCompile(
args: Array<out String>,
compilerOutputStream: RemoteOutputStream,
@@ -64,7 +64,7 @@ public interface CompileService : Remote {
serviceOutputStream: RemoteOutputStream
): Int
throws(RemoteException::class)
@Throws(RemoteException::class)
public fun remoteIncrementalCompile(
args: Array<out String>,
caches: Map<TargetId, RemoteIncrementalCache>,
@@ -239,14 +239,14 @@ fun updateEntryDigest(entry: File, md: MessageDigest) {
}
}
jvmName("getFilesClasspathDigest_Files")
@JvmName("getFilesClasspathDigest_Files")
fun Iterable<File>.getFilesClasspathDigest(): String {
val md = MessageDigest.getInstance(COMPILER_ID_DIGEST)
this.forEach { updateEntryDigest(it, md) }
return md.digest().joinToString("", transform = { "%02x".format(it) })
}
jvmName("getFilesClasspathDigest_Strings")
@JvmName("getFilesClasspathDigest_Strings")
fun Iterable<String>.getFilesClasspathDigest(): String = map { File(it) }.getFilesClasspathDigest()
fun Iterable<String>.distinctStringsDigest(): String =
@@ -271,9 +271,9 @@ public data class CompilerId(
}
companion object {
public jvmStatic fun makeCompilerId(vararg paths: File): CompilerId = makeCompilerId(paths.asIterable())
public @JvmStatic fun makeCompilerId(vararg paths: File): CompilerId = makeCompilerId(paths.asIterable())
public jvmStatic fun makeCompilerId(paths: Iterable<File>): CompilerId =
public @JvmStatic fun makeCompilerId(paths: Iterable<File>): CompilerId =
CompilerId(compilerClasspath = paths.map { it.absolutePath }, compilerDigest = paths.getFilesClasspathDigest())
}
}
@@ -53,14 +53,14 @@ public object LoopbackNetworkInterface {
data class ServerLoopbackSocketFactory : RMIServerSocketFactory, Serializable {
throws(IOException::class)
@Throws(IOException::class)
override fun createServerSocket(port: Int): ServerSocket = ServerSocket(port, SERVER_SOCKET_BACKLOG_SIZE, InetAddress.getByName(loopbackInetAddressName))
}
data class ClientLoopbackSocketFactory : RMIClientSocketFactory, Serializable {
throws(IOException::class)
@Throws(IOException::class)
override fun createSocket(host: String, port: Int): Socket = Socket(InetAddress.getByName(loopbackInetAddressName), port)
}
}
@@ -22,12 +22,12 @@ import java.rmi.RemoteException
public interface RemoteOutputStream : Remote {
throws(IOException::class, RemoteException::class)
@Throws(IOException::class, RemoteException::class)
public fun close()
throws(IOException::class, RemoteException::class)
@Throws(IOException::class, RemoteException::class)
public fun write(data: ByteArray, offset: Int, length: Int)
throws(IOException::class, RemoteException::class)
@Throws(IOException::class, RemoteException::class)
public fun write(dataByte: Int)
}
@@ -88,7 +88,7 @@ public object CompileDaemon {
return null
}
jvmStatic public fun main(args: Array<String>) {
@JvmStatic public fun main(args: Array<String>) {
log.info("Kotlin compiler daemon version " + (loadVersionFromResource() ?: "<unknown>"))
log.info("daemon JVM args: " + ManagementFactory.getRuntimeMXBean().inputArguments.joinToString(" "))
@@ -91,7 +91,7 @@ class CompileServiceImpl<Compiler: CLICompiler<*>>(
// internal implementation stuff
private volatile var _lastUsedSeconds = nowSeconds()
private @Volatile var _lastUsedSeconds = nowSeconds()
public val lastUsedSeconds: Long get() = if (rwlock.isWriteLocked || rwlock.readLockCount - rwlock.readHoldCount > 0) nowSeconds() else _lastUsedSeconds
val log by lazy { Logger.getLogger("compiler") }
@@ -161,19 +161,6 @@ class CompileServiceImpl<Compiler: CLICompiler<*>>(
return (rt.totalMemory() - rt.freeMemory())
}
// TODO: consider using version as a part of compiler ID or drop this function
private fun loadKotlinVersionFromResource(): String {
(javaClass.classLoader as? URLClassLoader)
?.findResource("META-INF/MANIFEST.MF")
?.let {
try {
return Manifest(it.openStream()).mainAttributes.getValue("Implementation-Version") ?: ""
}
catch (e: IOException) {}
}
return ""
}
fun ThreadMXBean.threadCpuTime() = if (isCurrentThreadCpuTimeSupported) currentThreadCpuTime else 0L
fun ThreadMXBean.threadUserTime() = if (isCurrentThreadCpuTimeSupported) currentThreadUserTime else 0L