2

These languages differ from Java in significant ways, like OO system, type system (most notable).

The actual question is whether JVM keeps track of objects under the hood? Is there an object inside JVM? Is it responsibility of creators of such languages that they may interoperate with Java world, or it is achieved "by default"?

Anthony
  • 1,877
  • 17
  • 21
  • These languages all (AFAIK) ultimately compile down to byte code. Your question is no different than asking how is it possible to have Visual Basic and C++ both running on the Windows operating system. – Tim Biegeleisen Aug 18 '17 at 08:50

2 Answers2

3

The actual question is whether JVM keeps track of objects under the hood?

Yes, it does. Garbage collection is the responsibility of the JVM.

Is there an object inside JVM?

Yes, there are byte codes to create class instances. Also, dynamic dispatch of instance methods is done by the JVM.

Is it responsibility of creators of such languages that they may interoperate with Java world, or it is achieved "by default"?

It is low hanging fruit, and it would be foolish not to do it. Moreover, not all JVM languages reinvent the wheel and just use JRE classes when it is appropriate. This includes most probably String, the primitive types and their boxed forms and arrays.

Ingo
  • 36,037
  • 5
  • 53
  • 100
  • As an addition, all kind of explicit memory allocations available to Java bytecode lead to the creation of an object equivalent to Java’s objects, so if a JVM-language has a different idea of what an object is, it has to implement it atop of that. If the language has a concept of local objects, it might implement them atop local variables, if it doesn’t need references or address pointers for them. – Holger Dec 20 '17 at 11:24
1

All JVM languages compile to "Java Byte Code". Actually, the JVM does not have any idea of the programming language Java. The JVM spec specifies a "class file", which must fulfill certain rules. As long as you provide compliant class files, created by a compiler e.g., your code will run on a JVM. That's what Kotlin does for example.

s1m0nw1
  • 76,759
  • 17
  • 167
  • 196
  • If you like to read about it, I explained it on my blog: https://blog.simon-wirtz.de/kotlin-on-the-jvm-byte-code-generation/ – s1m0nw1 Aug 18 '17 at 09:12