SteamWar/SpigotCore
Archiviert
13
0

Unsafe allocation > MC 1.15
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Lixfel 2022-02-03 10:01:06 +01:00
Ursprung afef1a6a22
Commit 9d04c2049c

Datei anzeigen

@ -1,6 +1,7 @@
package com.comphenix.tinyprotocol; package com.comphenix.tinyprotocol;
import de.steamwar.core.Core; import de.steamwar.core.Core;
import jdk.internal.misc.Unsafe;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
@ -367,7 +368,11 @@ public final class Reflection {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static Object newInstance(Class<?> clazz) { public static Object newInstance(Class<?> clazz) {
try { try {
return clazz.newInstance(); if (Core.getVersion() > 15) {
return Unsafe.getUnsafe().allocateInstance(clazz);
} else {
return clazz.newInstance();
}
} catch (InstantiationException | IllegalAccessException e) { } catch (InstantiationException | IllegalAccessException e) {
throw new SecurityException("Could not create object", e); throw new SecurityException("Could not create object", e);
} }