Does `@file:JvmSynthetic` still work? I can still ...
# multiplatform
e
Does
@file:JvmSynthetic
still work? I can still access both the generated class and its methods in a Java project.
m
I usually put a
-
in the filename:
@file:JvmName("-foo")
I never really questioned why but I guess this might be because
@file:JvmSynthetic
is not working
e
Thanks Martin, I do remember seeing the
-
prefix in Apollo, and I was really wondering why you were using that too
๐Ÿ˜ 1
Was the
-
character choice random, or was it the only one to have the correct result?
m
It was stolen from okio ๐Ÿ˜„
e
Ah ๐Ÿ˜‚ Well, I'll steal from Apollo then
m
OSS is sharing ๐Ÿ™‚
I believe other chars could work too. Anything that is invalid in a Java class name
e
Answer from the Java specification regarding which char can be used as the first one for a class name:
The "Java letters" include uppercase and lowercase ASCII Latin letters A-Z (\u0041-\u005a), and a-z (\u0061-\u007a), and, for historical reasons, the ASCII underscore (_, or \u005f) and dollar sign ($, or \u0024). The $ character should be used only in mechanically generated source code or, rarely, to access pre-existing names on legacy systems.
The $ character should be used only in mechanically generated source code
Seems we could even go with $
m
Curious if we can do @file:JvmName("๐Ÿ™ƒ")
๐Ÿ˜‚ 1
j
A dollar sign is still usable from Java. You can even define classes with an explicit dollar sign.
The specification you want to look at is the class specification, not the Java specification. The point is to use a character which is valid in the class but not in Java.
โœ”๏ธ 2
๐Ÿ‘€ 1
e
Yeah you're right, although that would maybe follow a "convention" to identify generated stuff
The point is to use a character which is valid in the class but not in Java.
Noted, thanks
c
although that would maybe follow a "convention" to identify generated stuff
well, "anything that isn't a legal identifier in Java" has to be generated stuff already