Questions tagged [kotlin-interop]

Usage of Kotlin together with other languages, most notably Java. e.g. Calling Kotlin functions from Java, or using Java classes from Kotlin.

117 questions
0
votes
2 answers

How to access Kotlin object from JavaScript

I'm using kotlin2js to generate JS library from Kotlin code. I'm then using this library in Javascript (not Kotlin). The code has some Kotlin objects and some normal classes. I can access normal classes from Javascript, but I can't access the…
David Vávra
  • 18,446
  • 7
  • 48
  • 56
0
votes
1 answer

Passing null as part of vararg parameter to Java method from Kotlin

I have something similar to this method declaration in Java. Let's say the class is named JavaClass: public T execute(String s, Function f, Object... args) {} If I want to call this from Kotlin (my version is 1.2.21), I could write something…
Joshua
  • 2,932
  • 2
  • 24
  • 40
0
votes
2 answers

How to properly test web socket connection with KotlinJS

I'm unable to test my code that uses a native WebSocket. This is the body of the test function: val webSocket = WebSocket("ws://localhost:8888") window.setTimeout({ assertEquals(WebSocket.OPEN, webSocket.readyState) }, 1000) I'm using Karma…
Czyzby
  • 2,999
  • 1
  • 22
  • 40
0
votes
1 answer

Kotlin and Spring Data JPA produces PropertyReferenceException

I am currently using Kotlin 1.2 and Spring Boot 2.0 M7 with Spring Data JPA. In this project I am using a custom base repository instead of JPARepository or PagingAndSortingRepository (really doesn't matter) Here is the base…
Robby F
  • 397
  • 1
  • 2
  • 13
0
votes
0 answers

Java -> Kotlin conversion with raw types

I'm writing CRaSH plugin, which in Java looks like public class AuthPlugin extends CRaSHPlugin implements AuthenticationPlugin { @Override public String getName() { return "auth"; } @Override public Class
M4ks
  • 11,744
  • 7
  • 27
  • 48
0
votes
4 answers

How do i make a loop like mentioned below in kotlin programming language?

How can I make it in kotlin using for loop? for (double i = 0; i < 10.0; i += 0.25) { System.out.println("value is:" + i); }
0
votes
1 answer

Mocking Kotlin methods with Java + Mockito

So I'm migrating a small Java codebase to Kotlin just for fun, and I've migrated this Java class: public class Inputs { private String engineURL; private Map parameters; public Inputs(String engineURL, Map
felipecao
  • 993
  • 1
  • 10
  • 23
0
votes
1 answer

'x' is not a function when passing parameters in Kotlin Javascript

I keep getting this error: TypeError: Scraper.dumpTitle is not a function And I can't figure out why... Index.html Kotlin JS Demo
ycomp
  • 8,316
  • 19
  • 57
  • 95
0
votes
2 answers

Kotlin java abstract class IllegalAccessError

I am having a issue with java interop and Kotlin I have a package protected java abstract class, AbstractTest, which is used as a member in another class, TestHolder. When I create a derived instance of the abstract class , Test, and try to use it…
Manish V
  • 325
  • 3
  • 18
0
votes
0 answers

Kotlin, project structure

I am writing a kotlin port of glm and I'm gonna use it also for java projects. In these java projects, I'd like to call, for example, glm.mul(...): where mul() is a function of the mat2x2_operators interface Now, if I have glm declared as an…
elect
  • 6,765
  • 10
  • 53
  • 119
0
votes
1 answer

JUnit, @ControllerAdvice and lack of checked exceptions in Kotlin

I wrote a validation advisor in Kotlin which throws EntityValidationException when validation fails: @Aspect @Named class ValidationAdvisor @Inject constructor(val validator: EntityValidator) { @Around(EVERY_SAVE_AND_UPDATE_TO_DATABASE) fun…
Radek Anuszewski
  • 1,812
  • 8
  • 34
  • 62
-2
votes
2 answers

For loop misbehave in Kotlin

I am trying to iterate through for loop but when I try to get value from 2D array and add that value then for loop misbehave. Here is the code I am sharing... var max_sum = 0 var total : Int = 0 val arr = Array(6) { IntArray(6) } for…
1 2 3 4 5 6 7
8