From 54f522553094a44ee7805004ad30132622262cf7 Mon Sep 17 00:00:00 2001 From: LexManos Date: Tue, 23 Oct 2012 13:32:02 -0700 Subject: [PATCH] Add some null checks, and throw descriptive exception when SideTransformer prevents a class from loading. --- .../mods/fml/common/asm/transformers/AccessTransformer.java | 1 + .../mods/fml/common/asm/transformers/MarkerTransformer.java | 1 + .../cpw/mods/fml/common/asm/transformers/SideTransformer.java | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/fml/common/cpw/mods/fml/common/asm/transformers/AccessTransformer.java b/fml/common/cpw/mods/fml/common/asm/transformers/AccessTransformer.java index 65a04619c..bc1a376ef 100644 --- a/fml/common/cpw/mods/fml/common/asm/transformers/AccessTransformer.java +++ b/fml/common/cpw/mods/fml/common/asm/transformers/AccessTransformer.java @@ -145,6 +145,7 @@ public class AccessTransformer implements IClassTransformer @Override public byte[] transform(String name, byte[] bytes) { + if (bytes == null) { return null; } if (!modifiers.containsKey(name)) { return bytes; } ClassNode classNode = new ClassNode(); diff --git a/fml/common/cpw/mods/fml/common/asm/transformers/MarkerTransformer.java b/fml/common/cpw/mods/fml/common/asm/transformers/MarkerTransformer.java index 6551b03b8..f9a2985a7 100644 --- a/fml/common/cpw/mods/fml/common/asm/transformers/MarkerTransformer.java +++ b/fml/common/cpw/mods/fml/common/asm/transformers/MarkerTransformer.java @@ -89,6 +89,7 @@ public class MarkerTransformer implements IClassTransformer @Override public byte[] transform(String name, byte[] bytes) { + if (bytes == null) { return null; } if (!markers.containsKey(name)) { return bytes; } ClassNode classNode = new ClassNode(); diff --git a/fml/common/cpw/mods/fml/common/asm/transformers/SideTransformer.java b/fml/common/cpw/mods/fml/common/asm/transformers/SideTransformer.java index 27b89c60a..87716bbd0 100644 --- a/fml/common/cpw/mods/fml/common/asm/transformers/SideTransformer.java +++ b/fml/common/cpw/mods/fml/common/asm/transformers/SideTransformer.java @@ -23,6 +23,8 @@ public class SideTransformer implements IClassTransformer @Override public byte[] transform(String name, byte[] bytes) { + if (bytes == null) { return null; } + ClassNode classNode = new ClassNode(); ClassReader classReader = new ClassReader(bytes); classReader.accept(classNode, 0); @@ -33,7 +35,7 @@ public class SideTransformer implements IClassTransformer { System.out.println(String.format("Attempted to load class %s for invalid side %s", classNode.name, SIDE)); } - return null; + throw new RuntimeException(String.format("Attempted to load class %s for invalid side %s", classNode.name, SIDE)); } Iterator fields = classNode.fields.iterator();