Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i get all the classes of sun.font in jdk9

Tags:

java

java-9

I have my old codebase which currently uses java8.

I am migrating my codebase to use jdk9-ea. But it looks like all the sun.font classes are now not available like the way they used to be earlier

error: package sun.font does not exist

More specifically i am using

  • CompositeFont
  • Font2D
  • FontDesignMetrics
  • FontManager
  • FontManagerFactory
  • SunFontManager

and more..

like image 709
Manish Jindal Avatar asked Jan 04 '17 06:01

Manish Jindal


1 Answers

A feature of the module system is that it allows library developers to strongly encapsulate implementation details due to the new accessibility rules. In a nutshell, most types in sun.* and com.sun.* packages will no longer be accessible. This is in line with Sun and later Oracle stating that these packages are not meant for public consumption.

A workaround is to export these packages at compile and launch time with a command line flag:

--add-exports java.desktop/sun.font=ALL-UNNAMED

This exports the package sun.font from the module java.desktop to all modules including the unnamed module, which is the one that collects all classes on the class path.

like image 148
Nicolai Parlog Avatar answered Nov 20 '22 16:11

Nicolai Parlog