1

Could you please help me to understand why this type not accessible is?

Versions:

Eclips / Photon Release (4.8.0)

selenium-java-3.14.0

JavaSE-10

screenshot

Arsen Papoyan
  • 21
  • 1
  • 4

1 Answers1

4

You shouldn't be using that Assert class in your code. It is internal to the Java compiler, and not intended for reuse.

There have been warnings in the Sun / Oracle documentation for many years that user code should not depend on the internal com.sun.* APIs. Starting with Java 9, access to these and other internal APIs have been closed off by the module system. It is possible to allow the access ... but you shouldn't if you have an alternative.

  • These APIs are undocumented, and may be withdrawn without any notice, causing portability problems when you upgrade your JVM to a newer release.
  • Some Java implementations don't implement these APIs, leading to portability problems when you try to use a JVM from a different vendor.

My bet is that you should be using Assert from the JUnit APIs, and that you have picked up the bogus import by accepting an (incorrect) auto-correction suggested by your IDE.

The best solution is to change your code to use org.junit.Assert or something equivalent.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216