SurpSG / Kombi

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kotlin-related error when working on a java project

resmaeilbeigi opened this issue · comments

I installed the library using your maven instructions below:

<repositories>
    <repository>
        <id>jcenter</id>
        <url>https://jcenter.bintray.com/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
      <groupId>com.sgnatiuk</groupId>
      <artifactId>kombi</artifactId>
      <version>2.2</version>
    </dependency>
</dependencies>

I get an error when I compile the following example provided in the project homepage:

List<List<Integer>> data = Arrays.asList(
            Arrays.asList(1, 2, 3),
            Arrays.asList(4, 5),
            Arrays.asList(6)
    );
    
        CartesianProduct<List<Integer>> cartesianProduct = CartesianBuilder.cartesianProductOf(data, false);
        cartesianProduct.forEach(System.out::println);

The error is:

java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
        at com.sgnatiuk.cartesian.CartesianBuilder.cartesianProductOf(CartesianBuilders.kt)
        at io.dropwizard.cli.EnvironmentCommand.run(EnvironmentCommand.java:43)
        at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:87)
        at io.dropwizard.cli.Cli.run(Cli.java:78)
        at io.dropwizard.Application.run(Application.java:93)
Caused by: java.lang.ClassNotFoundException: kotlin.jvm.internal.Intrinsics
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        ... 12 more

I do not use any Kotlin in my project. How to resolve this issue?

Hi @Rasul-Esmaeilbeigi
To solve the issue you should add kotlin std lib dependency.

<dependencies>
        <dependency>
            <groupId>com.sgnatiuk</groupId>
            <artifactId>kombi</artifactId>
            <version>2.2</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib</artifactId>
            <version>1.3.61</version>
        </dependency>
    </dependencies>

Consider this fix as a temporary workaround. I'll update the readme.
Also, I'm working on fixing the library configuration to be able to add kotlin std lib as a transitive dependency. Possibly, the lib will be rewritten with Java that will avoid adding kotlin std lib to a project.
Thank you!

The issue was fixed with the latest v3.0.0.
The library was completely migrated to java to avoid extra dependency. Also, the latest version contains some performance improvements
#7