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

Question

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

Answers 1
Added at 2017-01-04 07:01
Tags
Question

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..

Answers
nr: #1 dodano: 2017-01-04 10:01

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.

Source Show
◀ Wstecz