# Setting jvmTarget to 11 breaks DSL

**URL:** <https://discuss.kotlinlang.org/t/setting-jvmtarget-to-11-breaks-dsl/16837>\
**Category:** Support\
**Created:** [March 25, 2020, 9:22am UTC](https://discuss.kotlinlang.org/t/setting-jvmtarget-to-11-breaks-dsl/16837 "2020-03-25T09:22:54Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![lburgazzoli](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/lburgazzoli/32/5536_2.png) [@lburgazzoli](https://discuss.kotlinlang.org/u/lburgazzoli)\
**Post date:** [March 25, 2020, 9:22am UTC](https://discuss.kotlinlang.org/t/setting-jvmtarget-to-11-breaks-dsl/16837/1 "2020-03-25T09:22:54Z")

</div>

I’m migrating a project from Java 8 to Java 11 and when setting the jvmTarget to 11 in the kotlin plugin, my DSL does not work anymore, the project is here:

```
https://github.com/lburgazzoli/camel-kotlin-runner

```

When I change the property kotlin.jvm.target from 1.8 to 11, then the tests fails like none of the methods of my dsl are invoked anymore.

Note that the DSL is consumed by a kotlin script

---

<div class="post-metadata">

**Author:** ![darksnake](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/darksnake/32/2479_2.png) [@darksnake](https://discuss.kotlinlang.org/u/darksnake)\
**Post date:** [March 26, 2020, 7:33am UTC](https://discuss.kotlinlang.org/t/setting-jvmtarget-to-11-breaks-dsl/16837/2 "2020-03-26T07:33:19Z")

</div>

You should provide the actual error. Otherwise, it is hard to understand what exactly is broken.

---

<div class="post-metadata">

**Author:** ![lburgazzoli](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/lburgazzoli/32/5536_2.png) [@lburgazzoli](https://discuss.kotlinlang.org/u/lburgazzoli)\
**Post date:** [March 26, 2020, 8:24am UTC](https://discuss.kotlinlang.org/t/setting-jvmtarget-to-11-breaks-dsl/16837/3 "2020-03-26T08:24:25Z")

</div>

I don’t actually have a real error but a failure in a unit test, so I define a kotlin script like:

```
@KotlinScript(
    fileExtension = "kts", 
    compilationConfiguration = KotlinCompilationConfiguration::class)
abstract class IntegrationConfiguration(
    private val builder : EndpointRouteBuilder) 
    : BuilderSupport(builder.context), Support, EndpointBuilderFactory {

    fun rest(): RestDefinition {
        return builder.rest()
    }

    fun camel(block: CamelConfiguration.() -> Unit) {
        CamelConfiguration(context).block()
    }
}

```

then I have a test that validates the `camel` block and by setting the `jvmTarget` to 1.8, all of them succeed but when switching to Java 11 as `jvmTarget`, they start to fail.

adding some log or trying to debug them shows that the `camel` method is not invoked at all when `jvmTarget` is set to 11

---

<div class="post-metadata">

**Author:** ![rnentjes.1](https://avatars.discourse-cdn.com/v4/letter/r/e47774/32.png) [@rnentjes.1](https://discuss.kotlinlang.org/u/rnentjes.1)\
**Post date:** [April 1, 2020, 9:17am UTC](https://discuss.kotlinlang.org/t/setting-jvmtarget-to-11-breaks-dsl/16837/4 "2020-04-01T09:17:14Z")

</div>

You still didn’t tell us what breaks.

What failure in a unit test? What’s the output? What’s the difference between expected and actual values. etc.

---

<div class="post-metadata">

**Author:** ![lburgazzoli](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/lburgazzoli/32/5536_2.png) [@lburgazzoli](https://discuss.kotlinlang.org/u/lburgazzoli)\
**Post date:** [April 1, 2020, 9:55am UTC](https://discuss.kotlinlang.org/t/setting-jvmtarget-to-11-breaks-dsl/16837/5 "2020-04-01T09:55:15Z")

</div>

The tests defines this script:

```
camel {
        components {
            component<org.apache.camel.component.seda.SedaComponent>("seda") {
                queueSize = 1234
                concurrentConsumers = 12
            }            
            component<org.apache.camel.component.seda.SedaComponent>("mySeda") {
                queueSize = 4321
                concurrentConsumers = 21
        }
    }
}

```

And checks that the components named “seda” and “mySeda” have the right values, but when switching to java 11 as jvmTarget it fails with:

```
[ERROR] KotlinRouteLoaderTest.load routes with components configuration:51 
Expecting
    <org.apache.camel.component.seda.SedaComponent@1af38873>
to have a property or a field named <"queueSize"> with value
   <1234>
but value was:
   <1000>

```

Note that 1000 is the default value.

So there’s no “technical error” like i.e. an incompatible class or method but just a unit test failing so the script engine seems to fails silently to interpret the DSL.

---

<div class="post-metadata">

**Author:** ![rnentjes.1](https://avatars.discourse-cdn.com/v4/letter/r/e47774/32.png) [@rnentjes.1](https://discuss.kotlinlang.org/u/rnentjes.1)\
**Post date:** [April 1, 2020, 11:08am UTC](https://discuss.kotlinlang.org/t/setting-jvmtarget-to-11-breaks-dsl/16837/6 "2020-04-01T11:08:53Z")

</div>

That is interesting, and the approach (script configuration) is interesting.

But I am not able to reproduce the problem, works with 1.8, 11, and 13.

This is on linux with openjdk, did you different version of the jdk?

---

<div class="post-metadata">

**Author:** ![rnentjes.1](https://avatars.discourse-cdn.com/v4/letter/r/e47774/32.png) [@rnentjes.1](https://discuss.kotlinlang.org/u/rnentjes.1)\
**Post date:** [April 1, 2020, 11:40am UTC](https://discuss.kotlinlang.org/t/setting-jvmtarget-to-11-breaks-dsl/16837/7 "2020-04-01T11:40:36Z")

</div>

Ok, I’am able to reproduce the problem. Looks to me like the script is not being evaluated at all, but I have no idea why either.

---

<div class="post-metadata">

**Author:** ![lburgazzoli](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/lburgazzoli/32/5536_2.png) [@lburgazzoli](https://discuss.kotlinlang.org/u/lburgazzoli)\
**Post date:** [April 1, 2020, 11:44am UTC](https://discuss.kotlinlang.org/t/setting-jvmtarget-to-11-breaks-dsl/16837/8 "2020-04-01T11:44:17Z")

</div>

I do have other tests in another project and it looks like only the “blocks” like

```
fun camel(block: CamelConfiguration.() -> Unit) 

```

Are not evaluated, methods with simple types, such as

```
fun from(uri: String): RouteDefinition

```

Are instead ok

---

<div class="post-metadata">

**Author:** ![mbogdanov](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@mbogdanov](https://discuss.kotlinlang.org/u/mbogdanov)\
**Post date:** [July 17, 2020, 6:38pm UTC](https://discuss.kotlinlang.org/t/setting-jvmtarget-to-11-breaks-dsl/16837/9 "2020-07-17T18:38:24Z")

</div>

Please process ‘eval’ results in KotlinRouteLoader:52

They will point to

```auto
2 = {ScriptDiagnostic@11868} "ERROR Cannot inline bytecode built with JVM target 9 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option (script.kts:3:9)"
3 = {ScriptDiagnostic@11869} "ERROR Cannot inline bytecode built with JVM target 9 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option (script.kts:7:9)"

```

Script targets should be also increased

---

<div class="post-metadata">

**Author:** ![lburgazzoli](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/lburgazzoli/32/5536_2.png) [@lburgazzoli](https://discuss.kotlinlang.org/u/lburgazzoli)\
**Post date:** [July 18, 2020, 11:50am UTC](https://discuss.kotlinlang.org/t/setting-jvmtarget-to-11-breaks-dsl/16837/10 "2020-07-18T11:50:35Z")

</div>

> [@lburgazzoli](#):
>
> `https://github.com/lburgazzoli/camel-kotlin-runner`

@mbogdanov do you have any example about how to do it ?

---

<div class="post-metadata">

**Author:** ![lburgazzoli](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/lburgazzoli/32/5536_2.png) [@lburgazzoli](https://discuss.kotlinlang.org/u/lburgazzoli)\
**Post date:** [July 18, 2020, 12:15pm UTC](https://discuss.kotlinlang.org/t/setting-jvmtarget-to-11-breaks-dsl/16837/11 "2020-07-18T12:15:30Z")

</div>

nevermind, found it:

```
KotlinCompilationConfiguration : ScriptCompilationConfiguration {
    jvm {
        compilerOptions.append("-jvm-target")
        compilerOptions.append("11")
    }
}

```
