Force load more util classes to prevent further LinkageErrors.
This commit is contained in:
parent
6aee300cbe
commit
db59c7b2a1
@ -104,9 +104,19 @@ import com.massivecraft.massivecore.store.ModificationPollerLocal;
|
||||
import com.massivecraft.massivecore.store.ModificationPollerRemote;
|
||||
import com.massivecraft.massivecore.test.TestTypeEnchantment;
|
||||
import com.massivecraft.massivecore.util.BoardUtil;
|
||||
import com.massivecraft.massivecore.util.ContainerUtil;
|
||||
import com.massivecraft.massivecore.util.EventUtil;
|
||||
import com.massivecraft.massivecore.util.IdUtil;
|
||||
import com.massivecraft.massivecore.util.IntervalUtil;
|
||||
import com.massivecraft.massivecore.util.InventoryUtil;
|
||||
import com.massivecraft.massivecore.util.MUtil;
|
||||
import com.massivecraft.massivecore.util.PeriodUtil;
|
||||
import com.massivecraft.massivecore.util.PlayerUtil;
|
||||
import com.massivecraft.massivecore.util.RecipeUtil;
|
||||
import com.massivecraft.massivecore.util.ReflectionUtil;
|
||||
import com.massivecraft.massivecore.util.SignUtil;
|
||||
import com.massivecraft.massivecore.util.SmokeUtil;
|
||||
import com.massivecraft.massivecore.util.TimeDiffUtil;
|
||||
import com.massivecraft.massivecore.util.TimeUnit;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
import com.massivecraft.massivecore.xlib.gson.Gson;
|
||||
@ -229,8 +239,21 @@ public class MassiveCore extends MassivePlugin
|
||||
@Override
|
||||
public void onLoadInner()
|
||||
{
|
||||
// Attempting to fix a race condition within the class asynchronous class loader.
|
||||
System.out.println(TimeUnit.DAY);
|
||||
// These util classes are not automatically loaded/resolved when MassiveCore is being loaded.
|
||||
// However they need to be loaded to ensure async safety.
|
||||
// This fixes a race condition within the asynchronous class loader (LinkageError).
|
||||
ReflectionUtil.forceLoadClasses(
|
||||
ContainerUtil.class,
|
||||
EventUtil.class,
|
||||
IntervalUtil.class,
|
||||
InventoryUtil.class,
|
||||
PeriodUtil.class,
|
||||
RecipeUtil.class,
|
||||
SignUtil.class,
|
||||
SmokeUtil.class,
|
||||
TimeUnit.class,
|
||||
TimeDiffUtil.class
|
||||
);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
@ -465,4 +465,27 @@ public class ReflectionUtil
|
||||
private static int versionRelease = Integer.valueOf(getVersionRawPart(2).substring(1));
|
||||
public static int getVersionRelease() { return versionRelease; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// FORCE LOAD CLASSES
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static void forceLoadClasses(Class<?>... classes)
|
||||
{
|
||||
for (Class<?> clazz : classes)
|
||||
{
|
||||
forceLoadClass(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
// We chose this "weird" string in startsWith to avoid getting optimized away by the JIT compiler.
|
||||
// It will never start with this string, but the JIT can't be sure of that.
|
||||
public static void forceLoadClass(Class<?> clazz)
|
||||
{
|
||||
String className = clazz.getSimpleName();
|
||||
if (className.startsWith("Spaces are not allowed in class names."))
|
||||
{
|
||||
System.out.println(className);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user