0

I'm following a tutorial, which at some point use this code.

ClassLoader.class.getDeclaredField("usr_paths").

Why it throws exception

java.lang.NoSuchFieldException: usr_paths

Classloader class decompiled definition shows that is has.

private static String usr_paths[];

I'm using: java 12.0.1 2019-04-16 Java(TM) SE Runtime Environment (build 12.0.1+12) Java HotSpot(TM) 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)

thmmy95
  • 361
  • 2
  • 18
  • 1
    Related: [Get declared fields of java.lang.reflect.Fields in jdk12](https://stackoverflow.com/questions/56039341/get-declared-fields-of-java-lang-reflect-fields-in-jdk12). The `ClassLoader` class is filtered from core reflection, same as `Field`. You can use a similar solution as shown in the the Q&A I linked, but note that they're filtering certain classes for a reason. – Slaw Oct 13 '19 at 07:51
  • 2
    A tutorial that involves hacking a private member of a JDK class doesn't sound like a good thing. Which tutorial is this? – Alan Bateman Oct 13 '19 at 14:42

0 Answers0