4

JDK 11 (well 9) no longer allows me to place a new class into the java.net package (which is necessary to extend classes existing there to gain access to package-private members).

How can I achieve this?

mirabilos
  • 5,123
  • 2
  • 46
  • 72

1 Answers1

0

I just found that this is not possible anyway:

I’ve changed the code a little and built it under JDK 8 (digging out an ancient Debian oldstable system for this), but it then fails at runtime with JRE 8:

Exception in thread "main" java.lang.SecurityException: Prohibited package name: java.net

Turns out that it’s not permitted to access JVM “internals”. Not even for useful, and presumably permittable, extensions with a ready-made API for them.

(I’ve had the same job doing this for Android, and, with some use of reflection, it worked there… mostly… so I thought it would work even better in OpenJDK, but… evidently not.)

mirabilos
  • 5,123
  • 2
  • 46
  • 72