Cope with null classname to transformer (#138)

This commit is contained in:
Andy Clement
2016-01-18 22:57:28 -08:00
parent bfb55e4c0e
commit f83b82d7cb
2 changed files with 34 additions and 0 deletions

View File

@@ -1906,4 +1906,33 @@ public class Utils implements Opcodes, Constants {
public static String getProtectedFieldSetterName(String fieldname) {
return "r$setProtField_" + fieldname;
}
private static class ClassnameDiscoveryVisitor extends ClassVisitor {
public String classname;
public ClassnameDiscoveryVisitor() {
super(ASM5);
}
@Override
public void visit(int version, int access, String name, String signature, String superName,
String[] interfaces) {
this.classname = name;
}
}
/**
* Discover the classname specified in the supplied bytecode and return it.
*
* @param classbytes the bytecode for the class
* @return the classname recovered from the bytecode
*/
public static String discoverClassname(byte[] classbytes) {
ClassReader cr = new ClassReader(classbytes);
ClassnameDiscoveryVisitor v = new ClassnameDiscoveryVisitor();
cr.accept(v, 0);
return v.classname;
}
}

View File

@@ -122,6 +122,11 @@ public class SpringLoadedPreProcessor implements Constants {
return bytes;
}
if (slashedClassName == null && bytes != null) {
// The lambda meta factory can spin up classes that come through here with no class name specified
// slashedClassName = Utils.discoverClassname(bytes);
}
// TODO need configurable debug here, ability to dump any code before/after
for (Plugin plugin : getGlobalPlugins()) {
if (plugin instanceof LoadtimeInstrumentationPlugin) {