Skip to content

No warning about use of static method of a deprecated Java class #10752

@dhs3000

Description

@dhs3000

It seems that deprecation information of a static method of a Java class that itself is marked as deprecated is not reported -- for a Scala object it works as expected.

Example:
Given these Java and Scala classes

@Deprecated
public class JavaDeprecatedClassWithStaticMethod {
    public static void someMethod() {
    }
}
public class JavaClassWithDeprecatedStaticMethod {
    @Deprecated
    public static void someMethod() {
    }
}
@deprecated("", "")
object ScalaDeprecatedClassWithStaticMethod {
  def someMethod(): Unit = ()
}
object ScalaClassWithDeprecatedStaticMethod {
  @deprecated("", "")
  def someMethod(): Unit = ()
}

Compiling this:

object UseDeprecatedMethods {
  JavaDeprecatedClassWithStaticMethod.someMethod()
  JavaClassWithDeprecatedStaticMethod.someMethod()

  ScalaDeprecatedClassWithStaticMethod.someMethod()
  ScalaClassWithDeprecatedStaticMethod.someMethod()
}

produces the following warnings:

Warning: method someMethod in object JavaClassWithDeprecatedStaticMethod is deprecated: see corresponding Javadoc for more information.
JavaClassWithDeprecatedStaticMethod.someMethod()
Warning: object ScalaDeprecatedClassWithStaticMethod in package test is deprecated:
ScalaDeprecatedClassWithStaticMethod.someMethod()
Warning: method someMethod in object ScalaClassWithDeprecatedStaticMethod is deprecated:
ScalaClassWithDeprecatedStaticMethod.someMethod()

I don't get a warning from JavaDeprecatedClassWithStaticMethod. (I tried different things like making changes to the files, cleaning...)

I have the same issue with a Java class in a library that is deprecated and the use of is not reported either.

Scala: 2.12.4
JVM: JDK 1.8.0_162
SBT: 0.13.13

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions