Created
October 8, 2023 14:49
-
-
Save MaksimDmitriev/cfea491b64333a9a31f2ce9ab9cfc28a to your computer and use it in GitHub Desktop.
JvmField, JvmName, JvmOverloads, JvmStatic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package ru.maksim.sample | |
| class Foo { | |
| @JvmField | |
| val a = 1 | |
| @JvmName("getStr") | |
| fun getB() = a.toString() | |
| @JvmOverloads | |
| fun bar( | |
| k: Int = -1, | |
| l: String = "abc", | |
| m: Int = 1, | |
| ) { | |
| println("k = $k, l = $l, m = $m") | |
| } | |
| companion object { | |
| @JvmStatic | |
| val CONST = 1 | |
| @JvmStatic | |
| fun baz() { | |
| println("baz") | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package ru.maksim.sample; | |
| import org.junit.jupiter.api.Test; | |
| public class SampleJavaTest { | |
| @Test | |
| public void test() { | |
| final Foo foo = new Foo(); | |
| foo.bar(1); | |
| foo.getStr(); | |
| Foo.Companion.baz(); | |
| Foo.baz(); | |
| System.out.println(Foo.getCONST()); | |
| } | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package ru.maksim.sample | |
| import org.junit.jupiter.api.Test | |
| class SampleKotlinTest { | |
| @Test | |
| fun foo() { | |
| val foo = Foo() | |
| foo.getB() | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment