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?
From #584 :
Here's the relevant code:
pmd/pmd-core/src/main/java/net/sourceforge/pmd/ant/Formatter.java
Lines 197 to 229 in 89bb73f
Maybe there's a better way to fetch that?