Package org.jboss.byteman.rule

Examples of org.jboss.byteman.rule.Rule


    {
        if (transformed != null) {
            int count = transformed.size();
            for (int i =  0; i < count; i++) {
                Transform transform = transformed.get(i);
                Rule rule = transform.getRule();
                if (rule != null) {
                    rule.purge();
                }
            }
        }
    }
View Full Code Here


            if (script.hasTransform(targetClass)) {
                List<Transform> transforms = script.getTransformed();
                int numTransforms = transforms.size();
                for (Transform transform : transforms) {
                    Throwable throwable = transform.getThrowable();
                    Rule rule = transform.getRule();

                    if (throwable != null) {
                        errorCount++;
                        if (throwable  instanceof ParseException) {
                            System.out.println("TestScript : Failed to parse rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine());
                            System.out.println();
                            parseErrorCount++;
                        } else if (throwable instanceof TypeException) {
                            System.out.println("TestScript : Failed to type check rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine());
                            System.out.println();
                            typeErrorCount++;
                        } else {
                            System.out.println("TestScript : Error transforming class " + targetClassName + " using  rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine());
                            System.out.println();
                        }
                        throwable.printStackTrace(System.out);
                        System.out.println();
                        continue;
                    }

                    System.out.println("parsed rule \"" + script.getName() + "\" for class " + transform.getInternalClassName());

                    if (verbose) {
                        System.out.println("# File " + script.getFile() + " line " + script.getLine());
                        System.out.println(rule);
                    }

                    // ok, now see if we can type check the rule

                    try {
                        rule.typeCheck();
                    } catch (TypeException te) {
                        System.out.println("TestScript : Failed to type check rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine());
                        typeErrorCount++;
                        te.printStackTrace(System.out);
                        System.out.println();
                        continue;
                    }

                    if (script.isOverride()) {
                        System.out.println("type checked overriding rule \"" + script.getName() + "\" against method in declared class");
                    } else {
                        System.out.println("type checked rule \"" + script.getName() + "\"");
                    }
                    System.out.println();
                }
            } else if (targetClass.isInterface() || script.isOverride()) {
                // ok, not necessarily a surprise - let's see if we can create a rule and parse/type check it
                final Rule rule;
                try {
                    rule = Rule.create(script, loader, null);
                } catch (ParseException pe) {
                    System.out.println("TestScript : Failed to type check rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine());
                    parseErrorCount++;
View Full Code Here

    }

    public void parseRule() throws Throwable
    {
        try {
            Rule rule = Rule.create(ruleScript, loader, helperManager);
            // stash this rule away under the class name so we can reuse it for the first matching method
            ruleMap.put(triggerClass, rule);
        } catch (Throwable th) {
            recordFailedTransform(th);
            throw th;
View Full Code Here

    }

    public Rule getRule(String triggerMethodName, String triggerMethodDescriptor)
    {
        String key = getRuleKey(triggerMethodName, triggerMethodDescriptor);
        Rule rule = ruleMap.get(key);
        if (rule != null) {
            return rule;
        }

        // no existign rule -- use the initially parsed rule if we can otherwise create one
View Full Code Here

        ruleMap.clear();
    }

    public void recordMethodTransform(String triggerMethodName, String triggerMethodDescriptor)
    {
        Rule rule = removeRule(triggerMethodName, triggerMethodDescriptor);

        ruleScript.recordMethodTransform(loader, triggerClass, triggerMethodName, triggerMethodDescriptor, rule);
    }
View Full Code Here

            if (script.hasTransform(targetClass)) {
                List<Transform> transforms = script.getTransformed();
                int numTransforms = transforms.size();
                for (Transform transform : transforms) {
                    Throwable throwable = transform.getThrowable();
                    Rule rule = transform.getRule();
                    String methodName = transform.getTriggerMethodName();

                    if (throwable != null) {
                        if (throwable  instanceof ParseException) {
                            System.out.println("ERROR : Failed to parse rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine());
                            parseErrorCount++;
                            errorCount++;
                        } else if (throwable instanceof TypeWarningException) {
                            System.out.println("WARNING : Warning type checking rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine() + (methodName == null ? "" : " against method " + methodName));
                            typeWarningCount++;
                            warningCount++;
                        } else if (throwable instanceof TypeException) {
                            System.out.println("ERROR : Failed to type check rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine() + (methodName == null ? "" : " against method " + methodName));
                            typeErrorCount++;
                            errorCount++;
                        } else {
                            System.out.println("ERROR : Unexpected exception transforming class " + targetClassName + " using  rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine() + (methodName == null ? "" : " against method " + methodName));
                            errorCount++;
                        }
                        System.out.println(throwable);
                        System.out.println();
                        continue;
                    }

                    System.out.println("parsed rule \"" + script.getName() + "\" for class " + transform.getInternalClassName());

                    if (verbose) {
                        System.out.println("# File " + script.getFile() + " line " + script.getLine());
                        System.out.println(rule);
                    }

                    // ok, now see if we can type check the rule

                    try {
                        rule.typeCheck();
                    } catch (TypeWarningException te) {
                        System.out.println("WARNING : Unable to type check rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine() + (methodName == null ? "" : " against method " + methodName));
                        typeWarningCount++;
                        warningCount++;
                        System.out.println(te);
                        System.out.println();
                        continue;
                    } catch (TypeException te) {
                        System.out.println("ERROR : Failed to type check rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine() + (methodName == null ? "" : " against method " + methodName));
                        typeErrorCount++;
                        errorCount++;
                        System.out.println(te);
                        System.out.println();
                        continue;
                    }

                    if (script.isOverride()) {
                        System.out.println("type checked overriding rule \"" + script.getName() + "\" against method in declared class");
                    } else {
                        System.out.println("type checked rule \"" + script.getName() + "\"");
                    }
                    System.out.println();
                }
            } else if (targetClass.isInterface() || script.isOverride()) {
                // ok, not necessarily a surprise - let's see if we can create a rule and parse/type check it
                final Rule rule;
                try {
                    rule = Rule.create(script, loader, null);
                } catch (ParseException pe) {
                    System.out.println("ERROR : Failed to type check rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine());
                    parseErrorCount++;
View Full Code Here

            if (script.hasTransform(targetClass)) {
                List<Transform> transforms = script.getTransformed();
                int numTransforms = transforms.size();
                for (Transform transform : transforms) {
                    Throwable throwable = transform.getThrowable();
                    Rule rule = transform.getRule();

                    if (throwable != null) {
                        errorCount++;
                        if (throwable  instanceof ParseException) {
                            System.out.println("TestScript : Failed to parse rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine());
                            System.out.println();
                            parseErrorCount++;
                        } else if (throwable instanceof TypeException) {
                            System.out.println("TestScript : Failed to type check rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine());
                            System.out.println();
                            typeErrorCount++;
                        } else {
                            System.out.println("TestScript : Error transforming class " + targetClassName + " using  rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine());
                            System.out.println();
                        }
                        throwable.printStackTrace(System.out);
                        System.out.println();
                        continue;
                    }

                    System.out.println("parsed rule \"" + script.getName() + "\" for class " + transform.getInternalClassName());

                    if (verbose) {
                        System.out.println("# File " + script.getFile() + " line " + script.getLine());
                        System.out.println(rule);
                    }

                    // ok, now see if we can type check the rule

                    try {
                        rule.typeCheck();
                    } catch (TypeException te) {
                        System.out.println("TestScript : Failed to type check rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine());
                        typeErrorCount++;
                        te.printStackTrace(System.out);
                        System.out.println();
                        continue;
                    }

                    if (script.isOverride()) {
                        System.out.println("type checked overriding rule \"" + script.getName() + "\" against method in declared class");
                    } else {
                        System.out.println("type checked rule \"" + script.getName() + "\"");
                    }
                    System.out.println();
                }
            } else if (targetClass.isInterface() || script.isOverride()) {
                // ok, not necessarily a surprise - let's see if we can create a rule and parse/type check it
                final Rule rule;
                try {
                    rule = Rule.create(script, loader, null);
                } catch (ParseException pe) {
                    System.out.println("TestScript : Failed to type check rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine());
                    parseErrorCount++;
View Full Code Here

            return cw.toByteArray();
        }
    }

    public void parseRule() throws Exception {
        Rule rule = Rule.create(ruleScript, loader, helperManager);
        // stash this rule away under the class name so we can reuse it for the first matching method
        ruleMap.put(triggerClassName, rule);
        // keep a handle on the first rule
        firstRule = rule;
    }
View Full Code Here

    {
        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);
            } catch(Throwable th) {
View Full Code Here

     */
    public void warn(String triggerMethodName, String triggerMethodDescriptor, String warningMessage)
    {
        // remove the rule so that we don't try to inject into this method
        String key = getRuleKey(triggerMethodName, triggerMethodDescriptor);
        Rule rule = ruleMap.remove(key);
        // now attach an exception to the rule script
        String message = warningMessage + " for method " + triggerMethodName + TypeHelper.internalizeDescriptor(triggerMethodDescriptor);
        TypeWarningException tw = new TypeWarningException(message);
        ruleScript.recordTransform(loader, triggerClassName, triggerMethodName, triggerMethodDescriptor, rule, tw);
    }
View Full Code Here

TOP

Related Classes of org.jboss.byteman.rule.Rule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.