Add some null checks, and throw descriptive exception when SideTransformer prevents a class from loading.
This commit is contained in:
parent
190c71eeb5
commit
54f5225530
3 changed files with 5 additions and 1 deletions
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<FieldNode> fields = classNode.fields.iterator();
|
||||
|
|
Loading…
Reference in a new issue