A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/1860 below:

[ant] Reflective access warnings on java

From #584 :

I also receive the following warning message while running the Java Ant Task:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by net.sourceforge.pmd.ant.Formatter (file:/data/data/com.termux/files/home/LearnJava/lib/pmd-core-6.15.0.jar) to field java.io.Console.cs
WARNING: Please consider reporting this to the maintainers of net.sourceforge.pmd.ant.Formatter WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release.

I'm running Ant against an Open Jdk 1.10 version on Arch Linux on Termux.

Here's the relevant code:

private static String getConsoleEncoding() { Console console = System.console(); // in case of pipe or redirect, no interactive console. if (console != null) { try { Field f = Console.class.getDeclaredField("cs"); f.setAccessible(true); Object res = f.get(console); if (res instanceof Charset) { return ((Charset) res).name(); } } catch (ReflectiveOperationException ignored) { // fall-through } return getNativeConsoleEncoding(); } return null; } private static String getNativeConsoleEncoding() { try { Method m = Console.class.getDeclaredMethod("encoding"); m.setAccessible(true); Object res = m.invoke(null); if (res instanceof String) { return (String) res; } } catch (ReflectiveOperationException ignored) { // fall-through } return null; } }

Maybe there's a better way to fetch that?


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4