mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-26 15:03:04 +00:00
Clean up uses of deprecated library functions (#4130)
Avoid catching and rethrowing runtime exceptions Append error messages to exceptions instead of the log
This commit is contained in:
1 parent
ead0e81025
commit
0fde64ac38
44 files changed
+118
-232
No files matched your search
@@ -27,9 +27,6 @@ import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
@@ -73,9 +70,8 @@ class ObjectHolderRef
|
||||
this.injectedObject = ((IForgeRegistryEntry)existing).getRegistryName();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
Throwables.throwIfUnchecked(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
@@ -92,9 +88,8 @@ class ObjectHolderRef
|
||||
{
|
||||
FinalFieldHelper.makeWritable(field);
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (ReflectiveOperationException e)
|
||||
{
|
||||
Throwables.throwIfUnchecked(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
@@ -150,7 +145,7 @@ class ObjectHolderRef
|
||||
{
|
||||
FinalFieldHelper.setField(field, null, thing);
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (IllegalArgumentException | ReflectiveOperationException e)
|
||||
{
|
||||
FMLLog.log.warn("Unable to set {} with value {} ({})", this.field, thing, this.injectedObject, e);
|
||||
}
|
||||
@@ -162,7 +157,8 @@ class ObjectHolderRef
|
||||
private static Object reflectionFactory;
|
||||
private static Method newFieldAccessor;
|
||||
private static Method fieldAccessorSet;
|
||||
static Field makeWritable(Field f) throws Exception
|
||||
|
||||
static Field makeWritable(Field f) throws ReflectiveOperationException
|
||||
{
|
||||
f.setAccessible(true);
|
||||
if (modifiersField == null)
|
||||
@@ -178,8 +174,7 @@ class ObjectHolderRef
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
static void setField(Field field, @Nullable Object instance, Object thing) throws Exception
|
||||
static void setField(Field field, @Nullable Object instance, Object thing) throws ReflectiveOperationException
|
||||
{
|
||||
Object fieldAccessor = newFieldAccessor.invoke(reflectionFactory, field, false);
|
||||
fieldAccessorSet.invoke(fieldAccessor, instance, thing);
|
||||
|
||||
@@ -33,7 +33,6 @@ import net.minecraftforge.fml.common.discovery.ASMDataTable.ASMData;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
@@ -105,10 +104,9 @@ public enum ObjectHolderRegistry
|
||||
clazz = Class.forName(className, extractFromValue, getClass().getClassLoader());
|
||||
classCache.put(className, clazz);
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (ClassNotFoundException ex)
|
||||
{
|
||||
// unpossible?
|
||||
Throwables.throwIfUnchecked(ex);
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
@@ -133,10 +131,9 @@ public enum ObjectHolderRegistry
|
||||
Field f = clazz.getDeclaredField(annotationTarget);
|
||||
addHolderReference(new ObjectHolderRef(f, new ResourceLocation(value), extractFromValue));
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (NoSuchFieldException ex)
|
||||
{
|
||||
// unpossible?
|
||||
Throwables.throwIfUnchecked(ex);
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user