JDK-8011928 : Need to a public API to get Console charset
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.io
  • Priority: P3
  • Status: Resolved
  • Resolution: Duplicate
  • Submitted: 2013-03-04
  • Updated: 2022-08-19
  • Resolved: 2022-08-19
Description
A DESCRIPTION OF THE REQUEST :
The Console charset is actually present in java.io.Console, with the field named 'cs', the problem is it's private, there should be a public API to get it.

JUSTIFICATION :
Console charset is necessary to correctly read console input.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
need a method like
    java.io.Console#getCharset()
to get the console charset
ACTUAL -
java.io.Console.cs is private and there's no public API to get it.

CUSTOMER SUBMITTED WORKAROUND :
use reflection to access Console.cs by setting it accessible.
Comments
Console::charset was added by JDK-8264208.
19-08-2022