void (Consumer<? super String> consumer) { try { final Class<?> aClass = Class.forName("java.lang.CharacterName"); final Method initNamePool = ReflectionUtil.getDeclaredMethod(aClass, "initNamePool"); if (initNamePool != null) { // jdk 8 byte[] namePool = (byte[])initNamePool.invoke(null); // initializes "lookup" field final int[][] lookup2d = ReflectionUtil.getStaticFieldValue(aClass, int[][].class, "lookup"); if (lookup2d == null) { return; } for (int[] indexes : lookup2d) { if (indexes != null) { for (int index : indexes) { if (index != 0) { final String name = new String(namePool, index >>> 8, index & 0xff, StandardCharsets.US_ASCII); consumer.accept(name); } } } } } else { final Method instance = ReflectionUtil.getDeclaredMethod(aClass, "getInstance"); final Field field1 = ReflectionUtil.getDeclaredField(aClass, "strPool"); final Field field2 = ReflectionUtil.getDeclaredField(aClass, "lookup"); if (instance != null && field1 != null && field2 != null) { // jdk 9 final Object characterName = instance.invoke(null); byte[] namePool = (byte[])field1.get(characterName); final int[] lookup = (int[])field2.get(characterName); for (int index : lookup) { if (index != 0) { final String name = new String(namePool, index >>> 8, index & 0xff, StandardCharsets.US_ASCII); consumer.accept(name); } } } } } catch (ClassNotFoundException | InvocationTargetException | IllegalAccessException e) { throw new RuntimeException(e); } }