Soong build Error: this class can only be used as an annotation or as an argument to #UseExperimental - kotlin

I am Using soong build system with kotlin and want to opt in for experimental APIs to be used in the code
I have added #file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) in kotling file but upon compiling I get error stated as
error: this class can only be used as an annotation or as an argument to #UseExperim
ental
#file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)
Can anyone tell me what additional things I need to do to make it work ?

Related

How to print the JIT compilation messages for all the methods get compiled to native code of a given class

I know I could use -XX:+UnlockDiagnosticVMOptions along with -XX:CompileCommand=print,*TheGivenClass.TheGivenMethod' to output the log for TheGivenMethod of the class: TheGivenClass when it is compiled into native code by JIT.
But what if I would like JVM to output the messages for any method of TheGivenClass as long as those methods get compiled into native code? thanks for the answer.
If by "JIT compilation messages" you mean the generated assembly code for all methods of the given class, use the following syntax:
-XX:CompileCommand=print,org.pkg.TheGivenClass::*

How to modify the singleton object in kotlin native

I am adding Kotlin native linuxX64 target support to some existing library. Library is compiled successfuly but while running the test cases, I am getting following runtime error:
kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen kotlin.Array#1249428
at kfun:kotlin.Exception.<init>(kotlin.String?)kotlin.Exception (0x271205)
at kfun:kotlin.RuntimeException.<init>(kotlin.String?)kotlin.RuntimeException (0x2711c5)
at kfun:kotlin.native.concurrent.InvalidMutabilityException.<init>(kotlin.String)kotlin.native.concurrent.InvalidMutabilityException (0x272595)
at ThrowInvalidMutabilityException (0x3b0b53)
at (0x3b5733)
Even the Object example given in Kotlin language tutorial is not working on giving the similar runtime exception.
I know the problem is due to the frozen objects. But I could not find the proper way to modify the frozen members of singleton object.
After searching a bit I got the answer. We can update the frozen object using the Atomic Reference.

use of undeclared identifier 'git_diff_perfdata' with libgit2

I'm trying to write some code that uses git_diff_perfdata from the Libgit2 library.
git_diff_perfdata s;
However, when compiling on my Mac I get the error:
use of undeclared identifier 'git_diff_perfdata'
My understanding is that Libgit2 is meant to be used exclusively through the inclusion of git2.h. Is that correct?
git_diff_perfdata is defined in sys/diff.h and used in status.h
Should I be including sys/diff.h directly. If so, why? Alternatively, what errors might I be making? Looking at the header code I'm unable to see how sys/diff.h is included through anything that is included by git2.h.
Additionally, from what I can tell git_diff_perfdata isn't meant to be an opaque data type (i.e. only the pointer is defined).
I'm using the code downloaded from:
https://github.com/libgit2/libgit2/archive/v0.26.0.zip
The headers in sys are part of the public API, but they're a bit lower level. You can think of them as internal implementation details that have been made public because they might be useful to application developers. If you want to use them, include them directly.

Warnings while using a plugin and static library in a cocoa project

I have a scenario where I need to use a plugin as well as a static library into my xcode project. The plugin will be dynamically loaded into the system. Now, the static library is also getting used in creation of the plugin.
While executing my project I am getting a warning saying :
Class A is getting referenced from /staticLibraryPath and plugin. One of them will be used.
Please let me know, how to resolve the warning or a better way of implementing the scenario.
The issue is a name class of the two ClassA types found in both plugin and library
I assume you have control over the source of either plugin / library.
.. rename Class A in one instance to make the names not clash -- I don't think there is another way to get rid of the warning/error

Morphia Gives "Possible Heterogeneous Collection" Warning For Non-Collection Field

This is a follow-up question to Manual Conversion of 3rd Party Class With Morphia
I've an #Entity class which has a field of type javax.activation.MimeType. When I run my application I see a warning message in the output window, telling
WARNING: The multi-valued field
'javax.activation.MimeTypeParameterList.parameters' is a possible
heterogeneous collection. It cannot be verified. Please declare a
valid type to get rid of this warning. class java.lang.Object
I've already written and registered a type converter class for the type "MimeType", which effectively just ignores its 'parameters' field. But the warning keeps coming.I debugged it and saw that the warning was issued when datastore.ensureIndexes(); is called.
I tried writing a type converter for "MimeTypeParameterList" type but it didn't supress the warning. I can't just go and put a #Transient annotation over the field declaration because it's third party code (Java SE core!), not mine.
Is there an "elegant" way to eliminate this warning?
I just pushed a change to morphia's github repo that suppresses that logging for you. It'll be in 0.108 or you can build it locally if you want to try it out.