public static byte[] getJigsawClassBytes(String s) { byte[] bytes = null; if(s.startsWith(BYTEMAN_JIGSAW_PACKAGE_NAME)) { String name = s.substring(BYTEMAN_JIGSAW_PACKAGE_NAME_LEN); switch (name) { case "JigsawAccessEnabler.class": bytes = getJigsawAccessEnablerClassBytes(); break; case "JigsawAccessibleConstructorInvoker.class": bytes = getJigsawAccessibleConstructorInvokerClassBytes(); break; case "JigsawAccessibleMethodInvoker.class": bytes = getJigsawAccessibleMethodInvokerClassBytes(); break; case "JigsawAccessibleFieldGetter.class": bytes = getJigsawAccessibleFieldGetterClassBytes(); break; case "JigsawAccessibleFieldSetter.class": bytes = getJigsawAccessibleFieldSetterClassBytes(); break; } } if (bytes != null) { String name = s.substring(0, s.length() - ".class".length()).replace('/', '.'); Transformer.maybeDumpClass(name, bytes); } return bytes; }
public static byte[] getJigsawClassBytes(String s) { byte[] bytes = null; if(s.startsWith(BYTEMAN_JIGSAW_PACKAGE_NAME)) { String name = s.substring(BYTEMAN_JIGSAW_PACKAGE_NAME_LEN); switch (name) { case "JigsawAccessEnabler.class": bytes = getJigsawAccessEnablerClassBytes(); break; case "JigsawAccessibleConstructorInvoker.class": bytes = getJigsawAccessibleConstructorInvokerClassBytes(); break; case "JigsawAccessibleMethodInvoker.class": bytes = getJigsawAccessibleMethodInvokerClassBytes(); break; case "JigsawAccessibleFieldGetter.class": bytes = getJigsawAccessibleFieldGetterClassBytes(); break; case "JigsawAccessibleFieldSetter.class": bytes = getJigsawAccessibleFieldSetterClassBytes(); break; } } if (bytes != null) { String name = s.substring(0, s.length() - ".class".length()).replace('/', '.'); Transformer.maybeDumpClass(name, bytes); } return bytes; }
public static Class getHelperAdapter(Rule rule, Class helperClass, String compiledHelperName, boolean compileToBytecode) throws CompileException { // ok we have to create the adapter class // n.b. we don't bother synchronizing here -- if another rule is racing to create an adapter // in parallel we don't really care about generating two of them -- we can use whichever // one gets installed last try { String helperName = Type.getInternalName(helperClass); byte[] classBytes = compileBytes(rule, helperClass, helperName, compiledHelperName, compileToBytecode); String externalName = compiledHelperName.replace('/', '.'); // dump the compiled class bytes if required Transformer.maybeDumpClass(externalName, classBytes); // ensure the class is loaded // think we need to load the generated helper using the class loader of the trigger class ClassLoader loader = rule.getHelperLoader(); return rule.getModuleSystem().loadHelperAdapter(loader, externalName, classBytes); } catch(CompileException ce) { throw ce; } catch (Throwable th) { if (compileToBytecode) { throw new CompileException("Compiler.createHelperAdapter : exception creating compiled helper adapter for " + helperClass.getName(), th); } else { throw new CompileException("Compiler.createHelperAdapter : exception creating interpreted helper adapter for " + helperClass.getName(), th); } } }
public static Class getHelperAdapter(Rule rule, Class helperClass, String compiledHelperName, boolean compileToBytecode) throws CompileException { // ok we have to create the adapter class // n.b. we don't bother synchronizing here -- if another rule is racing to create an adapter // in parallel we don't really care about generating two of them -- we can use whichever // one gets installed last try { String helperName = Type.getInternalName(helperClass); byte[] classBytes = compileBytes(rule, helperClass, helperName, compiledHelperName, compileToBytecode); String externalName = compiledHelperName.replace('/', '.'); // dump the compiled class bytes if required Transformer.maybeDumpClass(externalName, classBytes); // ensure the class is loaded // think we need to load the generated helper using the class loader of the trigger class ClassLoader loader = rule.getHelperLoader(); return rule.getModuleSystem().loadHelperAdapter(loader, externalName, classBytes); } catch(CompileException ce) { throw ce; } catch (Throwable th) { if (compileToBytecode) { throw new CompileException("Compiler.createHelperAdapter : exception creating compiled helper adapter for " + helperClass.getName(), th); } else { throw new CompileException("Compiler.createHelperAdapter : exception creating interpreted helper adapter for " + helperClass.getName(), th); } } }
maybeDumpClass(internalName, newBuffer); newBuffer = maybeVerifyTransformedBytes(originalLoader, internalName, protectionDomain, newBuffer); return newBuffer;
maybeDumpClass(internalName, newBuffer); newBuffer = maybeVerifyTransformedBytes(originalLoader, internalName, protectionDomain, newBuffer); return newBuffer;
bytes = transformer.transform(script, loader, targetClass.getName(), bytes); Transformer.maybeDumpClass(targetClass.getName(), bytes);
bytes = transformer.transform(script, loader, targetClass.getName(), bytes); Transformer.maybeDumpClass(targetClass.getName(), bytes);