Scala 2.12.4: Cannot access protected static Java method from another package anymore

Teimuraz

I have java class with protected static method:

package parent;

public class Parent {

    protected static void parentMethod() {
        System.out.println("I'm in parent static method");
    }

}

Before Scala 2.12.4 (2.12.3) I could call this method from another package like this:

package child

import parent.Parent

class Child extends Parent {

  def childMethod = {
    println("I'm in child method and calling parentMethod")
    Parent.parentMethod()
  }

}

But Scala 2.12.4 does not compile this code. I'm getting the error:

Error:(9, 12) method parentMethod in object Parent cannot be accessed in object parent.Parent Access to protected method parentMethod not permitted because prefix type parent.Parent.type does not conform to object Child in package child where the access takes place Parent.parentMethod()

This access pattern was very important for me because JOOQ code generation uses this.

What happened?

stefanobaghino

Nice catch, this is most likely a regression introduced by this PR, as part of a solution to this issue.

I've already opened a ticket for this that you can track. In the meanwhile, if this kind of access pattern is vital for your application, unfortunately I don't think you have much choice but to stick to Scala 2.12.3 for the time being.

Edit

The issue was already known and a fix has been already merged. As of the time of writing the patch is bound to be part of the 2.12.5 release.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Java - Why Child in another package cannot access parent's protected method through parent reference?

From Dev

How to access a protected variable from another package

From Dev

Cannot access method from another java class

From Dev

Cannot access parent's protected method in Java

From Java

Call a static java method of another package from native code

From Dev

Java - How to access static synchronized method from another Thread?

From Java

Why can't I call a protected method from an inheriting class in another package in Java?

From Java

What is protected method access level with regard to accessing from another object

From Dev

Calling a Java static method with generics from Scala

From Dev

Cannot access child static property from parent static method in PHP

From Java

How to access a Java static method from Scala given a type alias for that class it resides in

From Dev

Access variable in another method from static method in same class

From Java

How To Access A Field From A Static Method Java

From Dev

Kotlin cannot access protected abstract method

From Dev

Test in Kotlin cannot access protected method

From Dev

Access method from user defined package in java

From Dev

scala - How to call public static method defined in Java from Scala?

From Dev

Cannot access protected property -laravel 4

From Java

Access control -- protected members from outside the package

From Dev

Java non-static method cannot be refenced from a static context

From Dev

scala - Cannot override protected variable of java class

From Java

Function called from another package cannot access to parameters

From Dev

Cannot access protected member of another instance from derived type's scope

From Dev

Cannot access protected members from a derived class

From

Can't access method from another package by var.MethodName()

From Dev

scala - how to access a case class method from another class?

From Java

Cannot access a method call from non-static to non-static class/method

From Java

How to access a public static final member in a Java class from Scala?

From Dev

How to access protected variable of class inside static method of the same class?

Related Related

  1. 1

    Java - Why Child in another package cannot access parent's protected method through parent reference?

  2. 2

    How to access a protected variable from another package

  3. 3

    Cannot access method from another java class

  4. 4

    Cannot access parent's protected method in Java

  5. 5

    Call a static java method of another package from native code

  6. 6

    Java - How to access static synchronized method from another Thread?

  7. 7

    Why can't I call a protected method from an inheriting class in another package in Java?

  8. 8

    What is protected method access level with regard to accessing from another object

  9. 9

    Calling a Java static method with generics from Scala

  10. 10

    Cannot access child static property from parent static method in PHP

  11. 11

    How to access a Java static method from Scala given a type alias for that class it resides in

  12. 12

    Access variable in another method from static method in same class

  13. 13

    How To Access A Field From A Static Method Java

  14. 14

    Kotlin cannot access protected abstract method

  15. 15

    Test in Kotlin cannot access protected method

  16. 16

    Access method from user defined package in java

  17. 17

    scala - How to call public static method defined in Java from Scala?

  18. 18

    Cannot access protected property -laravel 4

  19. 19

    Access control -- protected members from outside the package

  20. 20

    Java non-static method cannot be refenced from a static context

  21. 21

    scala - Cannot override protected variable of java class

  22. 22

    Function called from another package cannot access to parameters

  23. 23

    Cannot access protected member of another instance from derived type's scope

  24. 24

    Cannot access protected members from a derived class

  25. 25

    Can't access method from another package by var.MethodName()

  26. 26

    scala - how to access a case class method from another class?

  27. 27

    Cannot access a method call from non-static to non-static class/method

  28. 28

    How to access a public static final member in a Java class from Scala?

  29. 29

    How to access protected variable of class inside static method of the same class?

HotTag

Archive