/** * The routine which actually does the real bytecode transformation. this is public because it needs to be * callable from the type checker script. In normal running the javaagent is the only class which has a handle * on the registered transformer so it is the only one which can reach this point. * @param ruleScript the script * @param loader the loader of the class being injected into * @param className the name of the class being injected into * @param targetClassBytes the current class bytecode * @return the transformed bytecode or NULL if no transform was applied */ public byte[] transform(RuleScript ruleScript, ClassLoader loader, String className, byte[] targetClassBytes) { TransformContext transformContext = new TransformContext(this, ruleScript, className, loader, helperManager, accessEnabler); return transformContext.transform(targetClassBytes); }
protected String getCommonSuperClass(final String type1, final String type2) { // if we always return Object we cannot go wrong return context.findLeastCommonSuper(type1, type2); } };
/** * called by a trigger adapter to find a rule specific to a given trigger method, * expects to find a rule created by the corresponding check adapter. if no rule is * found then injection must be bypassed for this method * @param triggerMethodName the name of a candidate method for injection * @param triggerMethodDescriptor the descriptor of a candidate method for injection * @return the rule if it exists or NULL if not */ public Rule lookupRule(String triggerMethodName, String triggerMethodDescriptor) { String key = getRuleKey(triggerMethodName, triggerMethodDescriptor); return ruleMap.get(key); }
parseRule(); } catch (ParseException pe) { Helper.verbose("org.jboss.byteman.agent.Transformer : error parsing rule " + ruleName + "\n" + pe); Helper.verboseTraceException(pe); recordFailedTransform(pe); return targetClassBytes; } catch (Throwable th) { Helper.verbose("org.jboss.byteman.agent.Transformer : unexpected error parsing rule " + ruleName + "\n" + th); Helper.verboseTraceException(th); recordFailedTransform(th); return targetClassBytes; ClassWriter dummy = getNonLoadingClassWriter(0); RuleCheckAdapter checkAdapter = handlerLocation.getRuleCheckAdapter(dummy, this); try { Helper.verboseTraceException(th); recordFailedTransform(th); return targetClassBytes; ClassWriter cw = getNonLoadingClassWriter(ClassWriter.COMPUTE_MAXS|ClassWriter.COMPUTE_FRAMES); RuleTriggerAdapter adapter = handlerLocation.getRuleAdapter(cw, this); recordFailedTransform(th); return targetClassBytes; if (!notifyRules()) {
purgeRules(); String triggerMethodName = getKeyTriggerMethodName(key); String triggerMethodDescriptor = getKeyTriggerMethodDescriptor(key); Rule rule = ruleMap.get(key); if(!ruleScript.recordTransform(loader, triggerClassName, triggerMethodName, triggerMethodDescriptor, rule, null)) { purgeRules();
LinkedList<String> interfaces2 = listInterfaces(checker2); if (interfaces2.contains(type1)) { return t1; } else { LinkedList<String> interfaces1 = listInterfaces(checker1); while (!interfaces1.isEmpty()) { String next = interfaces1.pop(); LinkedList<String> interfaces2 = listInterfaces(checker2); if (interfaces2.contains(type1)) { LinkedList<String> interfaces1 = listInterfaces(checker1); while (!interfaces1.isEmpty()) { String next = interfaces1.pop(); LinkedList<String> interfaces1 = listInterfaces(checker1); if (interfaces1.contains(type2)) { LinkedList<String> interfaces2 = listInterfaces(checker2); while (!interfaces2.isEmpty()) { String next = interfaces2.pop(); LinkedList<String> supers2 = listSupers(checker2); if (supers2.contains(type1)) { LinkedList<String> supers1 = listSupers(checker1); while (!supers1.isEmpty()) { String next = supers1.pop();
RuleCheckMethodAdapter(MethodVisitor mv, TransformContext transformContext, int access, String name, String descriptor) { super(mv, transformContext, access, name, descriptor, transformContext.createRule(name, descriptor)); this.triggerPoints = null; this.returnBindingType = Type.parseMethodReturnType(descriptor); }
protected boolean injectIntoMethod(String name, String desc) { // if the check adapter matched successfully then there will be a rule in place // for this method and descriptor return (transformContext.injectIntoMethod(name, desc)); }
public String getTriggerClassName() { return transformContext.getTriggerClassName(); }
parseRule(); } catch (ParseException pe) { Helper.verbose("org.jboss.byteman.agent.Transformer : error parsing rule " + ruleName + "\n" + pe); Helper.verboseTraceException(pe); recordFailedTransform(pe); return targetClassBytes; } catch (Throwable th) { Helper.verbose("org.jboss.byteman.agent.Transformer : unexpected error parsing rule " + ruleName + "\n" + th); Helper.verboseTraceException(th); recordFailedTransform(th); return targetClassBytes; ClassWriter dummy = getNonLoadingClassWriter(0); RuleCheckAdapter checkAdapter = handlerLocation.getRuleCheckAdapter(dummy, this); try { Helper.verboseTraceException(th); recordFailedTransform(th); return targetClassBytes; ClassWriter cw = getNonLoadingClassWriter(ClassWriter.COMPUTE_MAXS|ClassWriter.COMPUTE_FRAMES); RuleTriggerAdapter adapter = handlerLocation.getRuleAdapter(cw, this); recordFailedTransform(th); return targetClassBytes; if (!notifyRules()) {
purgeRules(); String triggerMethodName = getKeyTriggerMethodName(key); String triggerMethodDescriptor = getKeyTriggerMethodDescriptor(key); Rule rule = ruleMap.get(key); if(!ruleScript.recordTransform(loader, triggerClassName, triggerMethodName, triggerMethodDescriptor, rule, null)) { purgeRules();
LinkedList<String> interfaces2 = listInterfaces(checker2); if (interfaces2.contains(type1)) { return t1; } else { LinkedList<String> interfaces1 = listInterfaces(checker1); while (!interfaces1.isEmpty()) { String next = interfaces1.pop(); LinkedList<String> interfaces2 = listInterfaces(checker2); if (interfaces2.contains(type1)) { LinkedList<String> interfaces1 = listInterfaces(checker1); while (!interfaces1.isEmpty()) { String next = interfaces1.pop(); LinkedList<String> interfaces1 = listInterfaces(checker1); if (interfaces1.contains(type2)) { LinkedList<String> interfaces2 = listInterfaces(checker2); while (!interfaces2.isEmpty()) { String next = interfaces2.pop(); LinkedList<String> supers2 = listSupers(checker2); if (supers2.contains(type1)) { LinkedList<String> supers1 = listSupers(checker1); while (!supers1.isEmpty()) { String next = supers1.pop();
RuleCheckMethodAdapter(MethodVisitor mv, TransformContext transformContext, int access, String name, String descriptor) { super(mv, transformContext, access, name, descriptor, transformContext.createRule(name, descriptor)); this.triggerPoints = null; this.returnBindingType = Type.parseMethodReturnType(descriptor); }
protected boolean injectIntoMethod(String name, String desc) { // if the check adapter matched successfully then there will be a rule in place // for this method and descriptor return (transformContext.injectIntoMethod(name, desc)); }
public String getTriggerClassName() { return transformContext.getTriggerClassName(); }
/** * called by a trigger adapter to find a rule specific to a given trigger method, * expects to find a rule created by the corresponding check adapter. if no rule is * found then injection must be bypassed for this method * @param triggerMethodName the name of a candidate method for injection * @param triggerMethodDescriptor the descriptor of a candidate method for injection * @return the rule if it exists or NULL if not */ public Rule lookupRule(String triggerMethodName, String triggerMethodDescriptor) { String key = getRuleKey(triggerMethodName, triggerMethodDescriptor); return ruleMap.get(key); }
/** * The routine which actually does the real bytecode transformation. this is public because it needs to be * callable from the type checker script. In normal running the javaagent is the only class which has a handle * on the registered transformer so it is the only one which can reach this point. * @param ruleScript the script * @param loader the loader of the class being injected into * @param className the name of the class being injected into * @param targetClassBytes the current class bytecode * @return the transformed bytecode or NULL if no transform was applied */ public byte[] transform(RuleScript ruleScript, ClassLoader loader, String className, byte[] targetClassBytes) { TransformContext transformContext = new TransformContext(this, ruleScript, className, loader, helperManager, accessEnabler); return transformContext.transform(targetClassBytes); }
protected String getCommonSuperClass(final String type1, final String type2) { // if we always return Object we cannot go wrong return context.findLeastCommonSuper(type1, type2); } };
/** * called by a check adapter to create a rule specific to a given trigger method. * the first such call reuses the rule created by the intiial parse. subsequent calls * create a new rule. * @param triggerMethodName the name of a candidate method for injection * @param triggerMethodDescriptor the descriptor of a candidate method for injection * @return the new rule */ public Rule createRule(String triggerMethodName, String triggerMethodDescriptor) { String key = getRuleKey(triggerMethodName, triggerMethodDescriptor); // use the initially parsed rule if we can otherwise create one Rule rule = ruleMap.remove(triggerClassName); if (rule == null) { try { rule = Rule.create(ruleScript, loader, helperManager, accessEnabler); } catch(Throwable th) { // will not happen } } ruleMap.put(key, rule); return rule; }
/** * called by a check adapter to create a rule specific to a given trigger method. * the first such call reuses the rule created by the intiial parse. subsequent calls * create a new rule. * @param triggerMethodName the name of a candidate method for injection * @param triggerMethodDescriptor the descriptor of a candidate method for injection * @return the new rule */ public Rule createRule(String triggerMethodName, String triggerMethodDescriptor) { String key = getRuleKey(triggerMethodName, triggerMethodDescriptor); // use the initially parsed rule if we can otherwise create one Rule rule = ruleMap.remove(triggerClassName); if (rule == null) { try { rule = Rule.create(ruleScript, loader, helperManager, accessEnabler); } catch(Throwable th) { // will not happen } } ruleMap.put(key, rule); return rule; }