Skip to content

Commit b8a8cc3

Browse files
authored
K2 Compiler. Overview (#954)
* KTLN-507 source code * KTLN-507 Core review fixes * K2 Compiler overview * Added missing import
1 parent f308113 commit b8a8cc3

File tree

5 files changed

+48
-0
lines changed

5 files changed

+48
-0
lines changed

k2-compiler/pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
5+
<modelVersion>4.0.0</modelVersion>
6+
<artifactId>k2-compiler</artifactId>
7+
<name>k2-compiler</name>
8+
9+
<parent>
10+
<groupId>com.baeldung</groupId>
11+
<artifactId>kotlin-modules</artifactId>
12+
<version>1.0.0-SNAPSHOT</version>
13+
</parent>
14+
15+
<properties>
16+
<kotlin.version>2.0.0</kotlin.version>
17+
</properties>
18+
19+
</project>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class ChildClass : ParentClass() {
2+
fun greeting(s: String) = hello(s)
3+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import java.lang.reflect.InvocationTargetException
2+
3+
fun translateExecution(exception: Throwable?): Throwable? {
4+
val isInvocationTargetException = exception is InvocationTargetException
5+
6+
if (isInvocationTargetException) {
7+
return (exception as InvocationTargetException).targetException
8+
}
9+
10+
return exception
11+
}
12+
13+
fun translateExecutionV2(exception: Throwable?) : Throwable? {
14+
val isInvocationTargetException = exception is InvocationTargetException
15+
16+
if (isInvocationTargetException) {
17+
return exception.targetException
18+
}
19+
20+
return exception
21+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
open class ParentClass {
2+
internal fun hello(s: String) = println("Hello, $s!")
3+
}

pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@
385385
<module>core-kotlin-modules</module>
386386
<!-- <module>gradle-kotlin-dsl</module> --> <!-- not a Maven module -->
387387
<!-- <module>jee-kotlin</module> --> <!-- Can't upgrade this project. Arquillian not maintained anymore.-->
388+
<module>k2-compiler</module>
388389
<module>koin-guide</module>
389390
<module>kotlin-kotest</module>
390391
<module>kotlin-apache-kafka</module>
@@ -464,6 +465,7 @@
464465
<module>core-kotlin-modules</module>
465466
<!-- <module>gradle-kotlin-dsl</module> --> <!-- not a Maven module -->
466467
<!-- <module>jee-kotlin</module> --> <!-- Can't upgrade this project. Arquillian not maintained anymore.-->
468+
<module>k2-compiler</module>
467469
<module>koin-guide</module>
468470
<module>kotlin-kotest</module>
469471
<module>kotlin-apache-kafka</module>

0 commit comments

Comments
 (0)