protected static String getDumpGeneratedClassesDir() { if (allowConfigUpdate()) { synchronized (configLock) { return dumpGeneratedClassesDir; } } return dumpGeneratedClassesDir; }
/** * notify a change to an org.jboss.byteman.* system property so that the agent can choose to update its * configuration. n.b. this method is not synchronized because there is an implicit assumption that it is * called from the the listener thread immediately after it has updated the property and that no other * thread will modify org.jboss.byteman.* properties * @param property an org.jboss.byteman.* system property which has been updated. */ public void updateConfiguration(String property) { if (allowConfigUpdate() && property.startsWith(BYTEMAN_PACKAGE_PREFIX)) { checkConfiguration(property); } }
boolean value = computeVerbose(); synchronized (configLock) { verbose = value; boolean value = computeDebug(); synchronized (configLock) { debug = value; boolean value = computeCompileToBytecode(); synchronized (configLock) { compileToBytecode = value; boolean value = computeDumpGeneratedClasses(); synchronized (configLock) { dumpGeneratedClasses = value; String value = computeDumpGeneratedClassesDir(); synchronized (configLock) { dumpGeneratedClassesDir = value; boolean value = computeDumpGeneratedClassesIntermediate(); synchronized (configLock) { dumpGeneratedClassesIntermediate = value; boolean value = computeTransformAll(); synchronized (configLock) { transformAll = value; boolean value = computeDisallowDowncast();
if (isBytemanClass(internalName) || !isTransformable(internalName)) { return null; ClassChecker checker = getClassChecker(newBuffer);// new ClassChecker(newBuffer); newBuffer = tryTransform(newBuffer, internalName, loader, internalName, false); newBuffer = tryTransform(newBuffer, internalName, loader, internalName.substring(dotIdx + 1), false); newBuffer = tryTransform(newBuffer, internalName, loader, internalInterfaceName, true); dotIdx = internalInterfaceName.lastIndexOf('.'); if (dotIdx >= 0) { newBuffer = tryTransform(newBuffer, internalName, loader, internalInterfaceName.substring(dotIdx + 1), true); ClassChecker newChecker = getClassChecker(interfaceName, originalLoader); if (newChecker != null) { interfaceCount = newChecker.getInterfaceCount(); if (!skipOverrideRules()) { checker = getClassChecker(superName, originalLoader); newBuffer = tryTransform(newBuffer, internalName, loader, superName, false, true); dotIdx = superName.lastIndexOf('.'); if (dotIdx > 0) { newBuffer = tryTransform(newBuffer, internalName, loader, superName.substring(dotIdx + 1), false, true); newBuffer = tryTransform(newBuffer, internalName, loader, internalInterfaceName, true, true); dotIdx = interfaceName.lastIndexOf('.');
transformer = new Transformer(null, helperManager.getModuleSystem(), emptyInitialTexts, emptyInitialFiles, false); } catch (Exception e) { bytes = transformer.transform(script, loader, targetClass.getName(), bytes); Transformer.maybeDumpClass(targetClass.getName(), 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; }
boolean value = computeVerbose(); synchronized (configLock) { verbose = value; boolean value = computeDebug(); synchronized (configLock) { debug = value; boolean value = computeCompileToBytecode(); synchronized (configLock) { compileToBytecode = value; boolean value = computeDumpGeneratedClasses(); synchronized (configLock) { dumpGeneratedClasses = value; String value = computeDumpGeneratedClassesDir(); synchronized (configLock) { dumpGeneratedClassesDir = value; boolean value = computeDumpGeneratedClassesIntermediate(); synchronized (configLock) { dumpGeneratedClassesIntermediate = value; boolean value = computeTransformAll(); synchronized (configLock) { transformAll = value; boolean value = computeDisallowDowncast();
if (isBytemanClass(internalName) || !isTransformable(internalName)) { return null; ClassChecker checker = getClassChecker(newBuffer);// new ClassChecker(newBuffer); newBuffer = tryTransform(newBuffer, internalName, loader, internalName, false); newBuffer = tryTransform(newBuffer, internalName, loader, internalName.substring(dotIdx + 1), false); newBuffer = tryTransform(newBuffer, internalName, loader, internalInterfaceName, true); dotIdx = internalInterfaceName.lastIndexOf('.'); if (dotIdx >= 0) { newBuffer = tryTransform(newBuffer, internalName, loader, internalInterfaceName.substring(dotIdx + 1), true); ClassChecker newChecker = getClassChecker(interfaceName, originalLoader); if (newChecker != null) { interfaceCount = newChecker.getInterfaceCount(); if (!skipOverrideRules()) { checker = getClassChecker(superName, originalLoader); newBuffer = tryTransform(newBuffer, internalName, loader, superName, false, true); dotIdx = superName.lastIndexOf('.'); if (dotIdx > 0) { newBuffer = tryTransform(newBuffer, internalName, loader, superName.substring(dotIdx + 1), false, true); newBuffer = tryTransform(newBuffer, internalName, loader, internalInterfaceName, true, true); dotIdx = interfaceName.lastIndexOf('.');
transformer = new Transformer(null, helperManager.getModuleSystem(), emptyInitialTexts, emptyInitialFiles, false); } catch (Exception e) { bytes = transformer.transform(script, loader, targetClass.getName(), bytes); Transformer.maybeDumpClass(targetClass.getName(), 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; }
protected static boolean isDumpGeneratedClassesIntermediate() { if (allowConfigUpdate()) { synchronized (configLock) { return dumpGeneratedClassesIntermediate; } } return dumpGeneratedClassesIntermediate; }
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); } } }
/** * notify a change to an org.jboss.byteman.* system property so that the agent can choose to update its * configuration. n.b. this method is not synchronized because there is an implicit assumption that it is * called from the the listener thread immediately after it has updated the property and that no other * thread will modify org.jboss.byteman.* properties * @param property an org.jboss.byteman.* system property which has been updated. */ public void updateConfiguration(String property) { if (allowConfigUpdate() && property.startsWith(BYTEMAN_PACKAGE_PREFIX)) { checkConfiguration(property); } }
protected static boolean isDumpGeneratedClasses() { if (allowConfigUpdate()) { synchronized (configLock) { return dumpGeneratedClasses; } } return dumpGeneratedClasses; }
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); } } }
protected static boolean isDumpGeneratedClasses() { if (allowConfigUpdate()) { synchronized (configLock) { return dumpGeneratedClasses; } } return dumpGeneratedClasses; }
protected static String getDumpGeneratedClassesDir() { if (allowConfigUpdate()) { synchronized (configLock) { return dumpGeneratedClassesDir; } } return dumpGeneratedClassesDir; }
protected static boolean isDumpGeneratedClassesIntermediate() { if (allowConfigUpdate()) { synchronized (configLock) { return dumpGeneratedClassesIntermediate; } } return dumpGeneratedClassesIntermediate; }
/** * check whether verbose mode for rule processing is enabled or disabled * @return true if verbose mode is enabled etherwise false */ public static boolean isVerbose() { if (allowConfigUpdate()) { synchronized (configLock) { return verbose; } } return verbose; }
/** * check whether dumping of the control flow graph for the trigger class during construction is enabled * @return true if dumping is enabled etherwise false */ public static boolean isDumpCFGPartial() { if (allowConfigUpdate()) { synchronized (configLock) { return dumpCFGPartial; } } return dumpCFGPartial; }