Cope with null classname to transformer (#138)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user