Skip to content

Commit

Permalink
Merge pull request frohoff#149 from Alexandre-Bartel/jdk12_setAccessible
Browse files Browse the repository at this point in the history
Just call setAccessible with Java > 12
  • Loading branch information
frohoff committed Jan 5, 2021
2 parents 4df2ee2 + fc577c0 commit 750168c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main/java/ysoserial/payloads/util/Reflections.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,18 @@
public class Reflections {

public static void setAccessible(AccessibleObject member) {
// quiet runtime warnings from JDK9+
Permit.setAccessible(member);
String versionStr = System.getProperty("java.version");
int javaVersion = Integer.parseInt(versionStr.split("\\.")[0]);
if (javaVersion < 12) {
// quiet runtime warnings from JDK9+
Permit.setAccessible(member);
} else {
// not possible to quiet runtime warnings anymore...
// see https://bugs.openjdk.java.net/browse/JDK-8210522
// to understand impact on Permit (i.e. it does not work
// anymore with Java >= 12)
member.setAccessible(true);
}
}

public static Field getField(final Class<?> clazz, final String fieldName) {
Expand Down

0 comments on commit 750168c

Please sign in to comment.