From 499ff87b31ad4714acfc7b160a89494547ad55a4 Mon Sep 17 00:00:00 2001 From: SciWhiz12 Date: Sat, 15 May 2021 12:03:09 +0800 Subject: Remove ModifierAccess and java9 source set/project --- .../artifactural/gradle/ModifierAccess.java | 57 ---------------------- 1 file changed, 57 deletions(-) delete mode 100644 src/java9/net/minecraftforge/artifactural/gradle/ModifierAccess.java (limited to 'src/java9/net') diff --git a/src/java9/net/minecraftforge/artifactural/gradle/ModifierAccess.java b/src/java9/net/minecraftforge/artifactural/gradle/ModifierAccess.java deleted file mode 100644 index cf6f65f..0000000 --- a/src/java9/net/minecraftforge/artifactural/gradle/ModifierAccess.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Artifactural - * Copyright (c) 2018. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.artifactural.gradle; - -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodHandles.Lookup; -import java.lang.invoke.VarHandle; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; - -public class ModifierAccess { - private static VarHandle MODIFIER_ACCESS = null; - private static boolean accessAttempted = false; - - public static synchronized boolean definalize(Field target) { - if ((target.getModifiers() & Modifier.FINAL) == 0) { - return true; - } - - if (MODIFIER_ACCESS == null && !accessAttempted) { - try { - Lookup lookup = MethodHandles.privateLookupIn(Field.class, MethodHandles.lookup()); - MODIFIER_ACCESS = lookup.findVarHandle(Field.class, "modifiers", int.class); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new RuntimeException("Could not access Field.modifiers to definalize reflection object. Use Java 8, current version: " + System.getProperty("java.version"), e); - } - accessAttempted = true; - } - if (MODIFIER_ACCESS != null) { - try { - MODIFIER_ACCESS.set(target, target.getModifiers() & ~Modifier.FINAL); - } catch (IllegalArgumentException e) { - throw new RuntimeException("Could not definalize field " + target.getDeclaringClass().getName() + "." + target.getName(), e); - } - return true; - } - return false; - } - -} -- cgit