Is there a way to suppress the warning of using java.lang.Object?


#1

I can't seem to find a list/overview I can feed into the @suppress anotation. What string do I use to suppress the cast to java.lang.Object warning?

 
private val waitingThreads = AtomicInteger(0)

@suppress("<what goes here?>")
private val mutex = waitingThreads as Object


#2

Try to search from here: https://github.com/JetBrains/kotlin/blob/master/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java


#3

@suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")

Actually, there should be quick fix available, did you try to press Alt+Enter on a warning?


#4

I'd advice to use Any instead of Object, like:

private val mutex = waitingThreads as Any
//or  
private val mutex: Any = waitingThreads

Anyway You can use quick fix to fix or suppress any warning, like:


#5

Thanks.

Yes, I did press altl-enter (OSX version, Idea 14 latest stable), doesn’t seem to have the option to disable it.


#6

Thanks, that's really helpful!


#7

In general I agree with you, that's why I think it's important the warning is there.

In this case I want to use of the wait/notify methods that come with this.
I don’t want to use classes like Locks and Semaphores because it would introduce extra instances and thus extra garbage. This is all for my promises library where I want/need to keep the garbage per promise as low as possible in order to be a viable solution on platforms like android where things like this seriously matter (to much garbage collections seriously degrades interface performance on android).


#8

I had a similar issue at the end of yellow code and I created KT-8417, but I don't sure that it's the same. Could you please provide more information (e.g. plugin version, simple steps or simple project to reproduce).


#9

Intellij Ultimate 14.1.4 Kotlin plugin: 0.12.613.Idea141.7 OSX 10.10.4

It doesn’t matter where I put the caret, simply doesn’t work. I use the previous mentioned code to reproduce it.