Package org.jboss.byteman.agent.check

Examples of org.jboss.byteman.agent.check.ClassChecker


                return null;
            }

            // we will need the super class name any outer class name and the name of the interfaces the class implements

            ClassChecker checker = getClassChecker(newBuffer);// new ClassChecker(newBuffer);

            if (checker.isInterface()) {
                return null;
            }

            /*
            if (checker.hasOuterClass()) {
                // we don't transform inner classes for now
                // TODO -- see if we can match and transform inner classes via the outer class
                return null;
            }
            */

            // TODO-- reconsider this as it is a bit dodgy as far as security is concerned
       
            if (loader == null) {
                loader = ClassLoader.getSystemClassLoader();
            }

            // ok, we need to check whether there are any class scripts associated with this class and if so
            // we will consider transforming the byte code

            // TODO -- there are almost certainly concurrency issues to deal with here if rules are being loaded/unloaded

            newBuffer = tryTransform(newBuffer, internalName, loader, internalName, false);

            int dotIdx = internalName.lastIndexOf('.');

            if (dotIdx > 0) {
                newBuffer = tryTransform(newBuffer, internalName, loader, internalName.substring(dotIdx + 1), false);
            }

            if (scriptRepository.checkInterfaces()) {
                // now we need to do the same for any interface scripts
                // n.b. resist the temptation to call classBeingRedefined.getInterfaces() as this will
                // cause the class to be resolved, losing any changes we install

                int interfaceCount = checker.getInterfaceCount();

                for (int i = 0; i < interfaceCount; i++) {
                    String interfaceName = checker.getInterface(i);
                    String internalInterfaceName = TypeHelper.internalizeClass(interfaceName);
                    newBuffer = tryTransform(newBuffer, internalName, loader, internalInterfaceName, true);
                    dotIdx = internalInterfaceName.lastIndexOf('.');
                    if (dotIdx >= 0) {
                        newBuffer = tryTransform(newBuffer, internalName, loader, internalInterfaceName.substring(dotIdx + 1), true);
                    }
                }
            }

            // checking supers is expensive so we obey the switch which disables it
           
            if (!skipOverrideRules()) {
                // ok, now check the superclass for this class and so on

                String superName = checker.getSuper();

                while (superName != null) {
                    // we need to check the super class structure
                    // n.b. we use the original loader here because we don't want to search the system loader
                    // when we have a class in the bootstrap loader
                    checker = getClassChecker(superName, originalLoader);

                    if (checker == null || checker.hasOuterClass()) {
                        // we don't transform inner classes for now
                        // TODO -- see if we can match and transform inner classes via the outer class
                    }

                    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);
                    }

                    int interfaceCount = checker.getInterfaceCount();

                    for (int i = 0; i < interfaceCount; i++) {
                        String interfaceName = checker.getInterface(i);
                        // TODO -- do we ever find that a super declares an interface also declared by its subclass
                        // TODO -- we probably don't want to inject twice in such cases so we ought to remember whether
                        // TODO -- we have seen an interface before
                        newBuffer = tryTransform(newBuffer, internalName, loader, interfaceName, true, true);
                        dotIdx = interfaceName.lastIndexOf('.');
                        if (dotIdx >= 0) {
                            newBuffer = tryTransform(newBuffer, internalName, loader, interfaceName.substring(dotIdx + 1), true, true);
                        }
                    }

                    // move on to the next super
                    superName = checker.getSuper();
                }
            }

            if (newBuffer != classfileBuffer) {
                // see if we need to dump the transformed bytecode for checking
View Full Code Here


                return null;
            }

            // we will need the super class name any outer class name and the name of the interfaces the class implements

            ClassChecker checker = getClassChecker(newBuffer);// new ClassChecker(newBuffer);

            if (checker.isInterface()) {
                return null;
            }

            /*
            if (checker.hasOuterClass()) {
                // we don't transform inner classes for now
                // TODO -- see if we can match and transform inner classes via the outer class
                return null;
            }
            */

            // TODO-- reconsider this as it is a bit dodgy as far as security is concerned
       
            if (loader == null) {
                loader = ClassLoader.getSystemClassLoader();
            }

            // if we need to traverse the interfaces then we have a DAG to deal with so
            // we had better find a way to avoid doing things twice

            LinkedList<String> toVisit = null;
            HashSet<String> visited = null;

            // ok, we need to check whether there are any class scripts associated with this class and if so
            // we will consider transforming the byte code

            // TODO -- there are almost certainly concurrency issues to deal with here if rules are being loaded/unloaded

            newBuffer = tryTransform(newBuffer, internalName, loader, internalName, false);

            int dotIdx = internalName.lastIndexOf('.');

            if (dotIdx > 0) {
                newBuffer = tryTransform(newBuffer, internalName, loader, internalName.substring(dotIdx + 1), false);
            }

            if (scriptRepository.checkInterfaces()) {
                // now we need to do the same for any interface scripts
                // n.b. resist the temptation to call classBeingRedefined.getInterfaces() as this will
                // cause the class to be resolved, losing any changes we install

                // we need to check the transitive closure of the binary links
                // Class implements Interface and Interface extends Interface for this class
                // which in general is a DAG.

                toVisit = new LinkedList<String>();
                visited = new HashSet<String>();

                // we start with the original list of implemented interfaces

                int interfaceCount = checker.getInterfaceCount();
                for (int i = 0; i < interfaceCount; i++) {
                    String interfaceName = checker.getInterface(i);
                    toVisit.add(interfaceName);
                }

                // ok now check each interface in turn while pushing its super interfaces
                // until we no longer have any new interfaces to check

                while (!toVisit.isEmpty()) {
                    String interfaceName = toVisit.pop();
                    String internalInterfaceName = TypeHelper.internalizeClass(interfaceName);
                    if (!visited.contains(interfaceName)) {
                        // avoid visiting  this interface again
                        visited.add(interfaceName);
                        // now see if we have any rules for this interface
                        newBuffer = tryTransform(newBuffer, internalName, loader, internalInterfaceName, true);
                        dotIdx = internalInterfaceName.lastIndexOf('.');
                        if (dotIdx >= 0) {
                            newBuffer = tryTransform(newBuffer, internalName, loader, internalInterfaceName.substring(dotIdx + 1), true);
                        }
                        // check the extends list of this interface for new interfaces to consider
                        ClassChecker newChecker = getClassChecker(interfaceName, originalLoader);
                        interfaceCount = newChecker.getInterfaceCount();
                        for (int i = 0; i < interfaceCount; i++) {
                            interfaceName = newChecker.getInterface(i);
                            toVisit.add(interfaceName);
                        }
                    }
                }
            }

            // checking supers is expensive so we obey the switch which disables it
           
            if (!skipOverrideRules()) {
                // ok, now check the superclass for this class and so on

                String superName = checker.getSuper();

                while (superName != null) {
                    // we need to check the super class structure
                    // n.b. we use the original loader here because we don't want to search the system loader
                    // when we have a class in the bootstrap loader
                    checker = getClassChecker(superName, originalLoader);

                    if (checker == null || checker.hasOuterClass()) {
                        // we don't transform inner classes for now
                        // TODO -- see if we can match and transform inner classes via the outer class
                    }

                    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);
                    }

                    if (scriptRepository.checkInterfaces()) {
                        // we need to do another DAG visit but only for interfaces not already considered

                        int interfaceCount = checker.getInterfaceCount();
                        for (int i = 0; i < interfaceCount; i++) {
                            String interfaceName = checker.getInterface(i);
                            toVisit.add(interfaceName);
                        }
                       
                        // ok now check each interface in turn while pushing its super interfaces
                        // until we no longer have any new interfaces to check

                        while(!toVisit.isEmpty()) {
                            String interfaceName = toVisit.pop();
                            String internalInterfaceName = TypeHelper.internalizeClass(interfaceName);
                            if (!visited.contains(interfaceName)) {
                                // avoid visiting  this interface again
                                visited.add(interfaceName);
                                // now see if we have any rules for this interface
                                newBuffer = tryTransform(newBuffer, internalName, loader, internalInterfaceName, true, true);
                                dotIdx = interfaceName.lastIndexOf('.');
                                if (dotIdx >= 0) {
                                    newBuffer = tryTransform(newBuffer, internalName, loader, internalInterfaceName.substring(dotIdx + 1), true, true);
                                }
                                // check the extends list of this interface for new interfaces to consider
                                ClassChecker newChecker = getClassChecker(interfaceName, originalLoader);
                                interfaceCount = newChecker.getInterfaceCount();
                                for (int i = 0; i < interfaceCount; i++) {
                                    interfaceName = newChecker.getInterface(i);
                                    toVisit.add(interfaceName);
                                }
                            }
                        }
                    }
View Full Code Here

                return null;
            }

            // we will need the super class name any outer class name and the name of the interfaces the class implements

            ClassChecker checker = getClassChecker(newBuffer);// new ClassChecker(newBuffer);

            if (checker == null || checker.isInterface()) {
                return null;
            }

            /*
            if (checker.hasOuterClass()) {
                // we don't transform inner classes for now
                // TODO -- see if we can match and transform inner classes via the outer class
                return null;
            }
            */

            // TODO-- reconsider this as it is a bit dodgy as far as security is concerned
       
            if (loader == null) {
                loader = ClassLoader.getSystemClassLoader();
            }

            // if we need to traverse the interfaces then we have a DAG to deal with so
            // we had better find a way to avoid doing things twice

            LinkedList<String> toVisit = null;
            HashSet<String> visited = null;

            // ok, we need to check whether there are any class scripts associated with this class and if so
            // we will consider transforming the byte code

            // TODO -- there are almost certainly concurrency issues to deal with here if rules are being loaded/unloaded

            newBuffer = tryTransform(newBuffer, internalName, loader, internalName, false);

            int dotIdx = internalName.lastIndexOf('.');

            if (dotIdx > 0) {
                newBuffer = tryTransform(newBuffer, internalName, loader, internalName.substring(dotIdx + 1), false);
            }

            if (scriptRepository.checkInterfaces()) {
                // now we need to do the same for any interface scripts
                // n.b. resist the temptation to call classBeingRedefined.getInterfaces() as this will
                // cause the class to be resolved, losing any changes we install

                // we need to check the transitive closure of the binary links
                // Class implements Interface and Interface extends Interface for this class
                // which in general is a DAG.

                toVisit = new LinkedList<String>();
                visited = new HashSet<String>();

                // we start with the original list of implemented interfaces

                int interfaceCount = checker.getInterfaceCount();
                for (int i = 0; i < interfaceCount; i++) {
                    String interfaceName = checker.getInterface(i);
                    toVisit.add(interfaceName);
                }

                // ok now check each interface in turn while pushing its super interfaces
                // until we no longer have any new interfaces to check

                while (!toVisit.isEmpty()) {
                    String interfaceName = toVisit.pop();
                    String internalInterfaceName = TypeHelper.internalizeClass(interfaceName);
                    if (!visited.contains(interfaceName)) {
                        // avoid visiting  this interface again
                        visited.add(interfaceName);
                        // now see if we have any rules for this interface
                        newBuffer = tryTransform(newBuffer, internalName, loader, internalInterfaceName, true);
                        dotIdx = internalInterfaceName.lastIndexOf('.');
                        if (dotIdx >= 0) {
                            newBuffer = tryTransform(newBuffer, internalName, loader, internalInterfaceName.substring(dotIdx + 1), true);
                        }
                        // check the extends list of this interface for new interfaces to consider
                        ClassChecker newChecker = getClassChecker(interfaceName, originalLoader);
                        if (newChecker != null) {
                            interfaceCount = newChecker.getInterfaceCount();
                            for (int i = 0; i < interfaceCount; i++) {
                                interfaceName = newChecker.getInterface(i);
                                toVisit.add(interfaceName);
                            }
                        }
                    }
                }
            }

            // checking supers is expensive so we obey the switch which disables it
           
            if (!skipOverrideRules()) {
                // ok, now check the superclass for this class and so on

                String superName = checker.getSuper();

                while (superName != null) {
                    // we need to check the super class structure
                    // n.b. we use the original loader here because we don't want to search the system loader
                    // when we have a class in the bootstrap loader
                    checker = getClassChecker(superName, originalLoader);

                    if (checker == null || checker.hasOuterClass()) {
                        // we don't transform inner classes for now
                        // TODO -- see if we can match and transform inner classes via the outer class
                        break;
                    }

                    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);
                    }

                    if (scriptRepository.checkInterfaces()) {
                        // we need to do another DAG visit but only for interfaces not already considered

                        int interfaceCount = checker.getInterfaceCount();
                        for (int i = 0; i < interfaceCount; i++) {
                            String interfaceName = checker.getInterface(i);
                            toVisit.add(interfaceName);
                        }
                       
                        // ok now check each interface in turn while pushing its super interfaces
                        // until we no longer have any new interfaces to check

                        while(!toVisit.isEmpty()) {
                            String interfaceName = toVisit.pop();
                            String internalInterfaceName = TypeHelper.internalizeClass(interfaceName);
                            if (!visited.contains(interfaceName)) {
                                // avoid visiting  this interface again
                                visited.add(interfaceName);
                                // now see if we have any rules for this interface
                                newBuffer = tryTransform(newBuffer, internalName, loader, internalInterfaceName, true, true);
                                dotIdx = interfaceName.lastIndexOf('.');
                                if (dotIdx >= 0) {
                                    newBuffer = tryTransform(newBuffer, internalName, loader, internalInterfaceName.substring(dotIdx + 1), true, true);
                                }
                                // check the extends list of this interface for new interfaces to consider
                                ClassChecker newChecker = getClassChecker(interfaceName, originalLoader);
                                if (newChecker != null) {
                                    interfaceCount = newChecker.getInterfaceCount();
                                    for (int i = 0; i < interfaceCount; i++) {
                                        interfaceName = newChecker.getInterface(i);
                                        toVisit.add(interfaceName);
                                    }
                                }
                            }
                        }
View Full Code Here

        // checking against names found in bytecode but ensure the returned
        // name contains "/"

        String type1 = t1.replaceAll("/", ".");
        String type2 = t2.replaceAll("/", ".");
        ClassChecker checker1 = transformer.getClassChecker(type1, loader);

        if (checker1 == null) {
            return TOFU;
        }

        ClassChecker checker2 = transformer.getClassChecker(type2, loader);

        if (checker2 == null) {
            return TOFU;
        }

        if (checker1.isInterface()) {
            if (checker2.isInterface()) {
                // both are interfaces so find the first common parent interface
                // (including the original interfaces) or return Object
                LinkedList<String> interfaces2 = listInterfaces(checker2);
                if (interfaces2.contains(type1)) {
                    return t1;
                } else {
                    LinkedList<String> interfaces1 = listInterfaces(checker1);
                    while (!interfaces1.isEmpty()) {
                        String next = interfaces1.pop();
                        if (next.equals(type2)) {
                            return t2;
                        }
                        if (interfaces2.contains(next)) {
                            return next.replaceAll("\\.", "/");
                        }
                    }
                    return TOFU;
                }
            } else {
                // type1 is an interface but type2 is a class so return the
                // first parent interface of type2 which implements either type1 or
                // one of type1's parent interfaces or return Object
                LinkedList<String> interfaces2 = listInterfaces(checker2);
                if (interfaces2.contains(type1)) {
                    // type1 is an interface of type2
                    return t1;
                } else {
                    LinkedList<String> interfaces1 = listInterfaces(checker1);
                    while (!interfaces1.isEmpty()) {
                        String next = interfaces1.pop();
                        if (interfaces2.contains(next)) {
                            return next.replaceAll("\\.", "/");
                        }
                    }
                    return TOFU;
                }
            }
        } else {
            if (checker2.isInterface()) {
                // type2 is an interface but type1 is a class so return the
                // first parent interface of type1 which implements either type1 or
                // one of type1's parent interfaces or return Object
                LinkedList<String> interfaces1 = listInterfaces(checker1);
                if (interfaces1.contains(type2)) {
View Full Code Here

    }

    private LinkedList<String> listInterfaces(ClassChecker checker)
    {
        LinkedList<String> interfaces = new LinkedList<String>();
        ClassChecker current = checker;
        while (current != null) {
            LinkedList<String> toCheck = new LinkedList<String>();
            int count = current.getInterfaceCount();
            for (int i = 0; i < count; i++) {
                toCheck.add(current.getInterface(i));
            }
            // now recursively work through unchecked interfaces adding them
            // if not already processed and including the interfaces they extend
            // in the toCheck list.
            while (!toCheck.isEmpty()) {
                String next = toCheck.pop();
                if (!interfaces.contains(next)) {
                    interfaces.add(next);
                    ClassChecker newChecker = transformer.getClassChecker(next, loader);
                    if (newChecker != null) {
                        count = newChecker.getInterfaceCount();
                        for (int i = 0; i < count; i++) {
                            toCheck.add(newChecker.getInterface(i));
                        }
                    }
                }
            }
            // repeat for the next super in line up to java/lang/Object
View Full Code Here

    }

    private LinkedList<String> listSupers(ClassChecker checker)
    {
        LinkedList<String> supers = new LinkedList<String>();
        ClassChecker current = checker;
        while (current != null) {
            String superType = current.getSuper();
            if (superType != null) {
                supers.add(superType);
                current = transformer.getClassChecker(superType, loader);
            } else {
                current = null;
View Full Code Here

                return null;
            }

            // we will need the super class name any outer class name and the name of the interfaces the class implements

            ClassChecker checker = getClassChecker(newBuffer);// new ClassChecker(newBuffer);

            if (checker.isInterface()) {
                return null;
            }

            /*
            if (checker.hasOuterClass()) {
                // we don't transform inner classes for now
                // TODO -- see if we can match and transform inner classes via the outer class
                return null;
            }
            */

            // TODO-- reconsider this as it is a bit dodgy as far as security is concerned
       
            if (loader == null) {
                loader = ClassLoader.getSystemClassLoader();
            }

            // if we need to traverse the interfaces then we have a DAG to deal with so
            // we had better find a way to avoid doing things twice

            LinkedList<String> toVisit = null;
            HashSet<String> visited = null;

            // ok, we need to check whether there are any class scripts associated with this class and if so
            // we will consider transforming the byte code

            // TODO -- there are almost certainly concurrency issues to deal with here if rules are being loaded/unloaded

            newBuffer = tryTransform(newBuffer, internalName, loader, internalName, false);

            int dotIdx = internalName.lastIndexOf('.');

            if (dotIdx > 0) {
                newBuffer = tryTransform(newBuffer, internalName, loader, internalName.substring(dotIdx + 1), false);
            }

            if (scriptRepository.checkInterfaces()) {
                // now we need to do the same for any interface scripts
                // n.b. resist the temptation to call classBeingRedefined.getInterfaces() as this will
                // cause the class to be resolved, losing any changes we install

                // we need to check the transitive closure of the binary links
                // Class implements Interface and Interface extends Interface for this class
                // which in general is a DAG.

                toVisit = new LinkedList<String>();
                visited = new HashSet<String>();

                // we start with the original list of implemented interfaces

                int interfaceCount = checker.getInterfaceCount();
                for (int i = 0; i < interfaceCount; i++) {
                    String interfaceName = checker.getInterface(i);
                    toVisit.add(interfaceName);
                }

                // ok now check each interface in turn while pushing its super interfaces
                // until we no longer have any new interfaces to check

                while (!toVisit.isEmpty()) {
                    String interfaceName = toVisit.pop();
                    String internalInterfaceName = TypeHelper.internalizeClass(interfaceName);
                    if (!visited.contains(interfaceName)) {
                        // avoid visiting  this interface again
                        visited.add(interfaceName);
                        // now see if we have any rules for this interface
                        newBuffer = tryTransform(newBuffer, internalName, loader, internalInterfaceName, true);
                        dotIdx = internalInterfaceName.lastIndexOf('.');
                        if (dotIdx >= 0) {
                            newBuffer = tryTransform(newBuffer, internalName, loader, internalInterfaceName.substring(dotIdx + 1), true);
                        }
                        // check the extends list of this interface for new interfaces to consider
                        ClassChecker newChecker = getClassChecker(interfaceName, originalLoader);
                        interfaceCount = newChecker.getInterfaceCount();
                        for (int i = 0; i < interfaceCount; i++) {
                            interfaceName = newChecker.getInterface(i);
                            toVisit.add(interfaceName);
                        }
                    }
                }
            }

            // checking supers is expensive so we obey the switch which disables it
           
            if (!skipOverrideRules()) {
                // ok, now check the superclass for this class and so on

                String superName = checker.getSuper();

                while (superName != null) {
                    // we need to check the super class structure
                    // n.b. we use the original loader here because we don't want to search the system loader
                    // when we have a class in the bootstrap loader
                    checker = getClassChecker(superName, originalLoader);

                    if (checker == null || checker.hasOuterClass()) {
                        // we don't transform inner classes for now
                        // TODO -- see if we can match and transform inner classes via the outer class
                    }

                    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);
                    }

                    if (scriptRepository.checkInterfaces()) {
                        // we need to do another DAG visit but only for interfaces not already considered

                        int interfaceCount = checker.getInterfaceCount();
                        for (int i = 0; i < interfaceCount; i++) {
                            String interfaceName = checker.getInterface(i);
                            toVisit.add(interfaceName);
                        }
                       
                        // ok now check each interface in turn while pushing its super interfaces
                        // until we no longer have any new interfaces to check

                        while(!toVisit.isEmpty()) {
                            String interfaceName = toVisit.pop();
                            String internalInterfaceName = TypeHelper.internalizeClass(interfaceName);
                            if (!visited.contains(interfaceName)) {
                                // avoid visiting  this interface again
                                visited.add(interfaceName);
                                // now see if we have any rules for this interface
                                newBuffer = tryTransform(newBuffer, internalName, loader, internalInterfaceName, true, true);
                                dotIdx = interfaceName.lastIndexOf('.');
                                if (dotIdx >= 0) {
                                    newBuffer = tryTransform(newBuffer, internalName, loader, internalInterfaceName.substring(dotIdx + 1), true, true);
                                }
                                // check the extends list of this interface for new interfaces to consider
                                ClassChecker newChecker = getClassChecker(interfaceName, originalLoader);
                                interfaceCount = newChecker.getInterfaceCount();
                                for (int i = 0; i < interfaceCount; i++) {
                                    interfaceName = newChecker.getInterface(i);
                                    toVisit.add(interfaceName);
                                }
                            }
                        }
                    }
View Full Code Here

                return null;
            }

            // we will need the super class name any outer class name and the name of the interfaces the class implements

            ClassChecker checker = getClassChecker(newBuffer);// new ClassChecker(newBuffer);

            if (checker.isInterface()) {
                return null;
            }

            /*
            if (checker.hasOuterClass()) {
                // we don't transform inner classes for now
                // TODO -- see if we can match and transform inner classes via the outer class
                return null;
            }
            */

            // TODO-- reconsider this as it is a bit dodgy as far as security is concerned
       
            if (loader == null) {
                loader = ClassLoader.getSystemClassLoader();
            }

            // ok, we need to check whether there are any class scripts associated with this class and if so
            // we will consider transforming the byte code

            // TODO -- there are almost certainly concurrency issues to deal with here if rules are being loaded/unloaded

            newBuffer = tryTransform(newBuffer, internalName, loader, internalName, false);

            int dotIdx = internalName.lastIndexOf('.');

            if (dotIdx > 0) {
                newBuffer = tryTransform(newBuffer, internalName, loader, internalName.substring(dotIdx + 1), false);
            }

            if (scriptRepository.checkInterfaces()) {
                // now we need to do the same for any interface scripts
                // n.b. resist the temptation to call classBeingRedefined.getInterfaces() as this will
                // cause the class to be resolved, losing any changes we install

                int interfaceCount = checker.getInterfaceCount();

                for (int i = 0; i < interfaceCount; i++) {
                    String interfaceName = checker.getInterface(i);
                    String internalInterfaceName = TypeHelper.internalizeClass(interfaceName);
                    newBuffer = tryTransform(newBuffer, internalName, loader, internalInterfaceName, true);
                    dotIdx = internalInterfaceName.lastIndexOf('.');
                    if (dotIdx >= 0) {
                        newBuffer = tryTransform(newBuffer, internalName, loader, internalInterfaceName.substring(dotIdx + 1), true);
                    }
                }
            }

            // checking supers is expensive so we obey the switch which disables it
           
            if (!skipOverrideRules()) {
                // ok, now check the superclass for this class and so on

                String superName = checker.getSuper();

                while (superName != null) {
                    // we need to check the super class structure
                    // n.b. we use the original loader here because we don't want to search the system loader
                    // when we have a class in the bootstrap loader
                    checker = getClassChecker(superName, originalLoader);

                    if (checker == null || checker.hasOuterClass()) {
                        // we don't transform inner classes for now
                        // TODO -- see if we can match and transform inner classes via the outer class
                    }

                    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);
                    }

                    int interfaceCount = checker.getInterfaceCount();

                    for (int i = 0; i < interfaceCount; i++) {
                        String interfaceName = checker.getInterface(i);
                        // TODO -- do we ever find that a super declares an interface also declared by its subclass
                        // TODO -- we probably don't want to inject twice in such cases so we ought to remember whether
                        // TODO -- we have seen an interface before
                        newBuffer = tryTransform(newBuffer, internalName, loader, interfaceName, true, true);
                        dotIdx = interfaceName.lastIndexOf('.');
                        if (dotIdx >= 0) {
                            newBuffer = tryTransform(newBuffer, internalName, loader, interfaceName.substring(dotIdx + 1), true, true);
                        }
                    }

                    // move on to the next super
                    superName = checker.getSuper();
                }
            }

            if (newBuffer != classfileBuffer) {
                // see if we need to dump the transformed bytecode for checking
View Full Code Here

TOP

Related Classes of org.jboss.byteman.agent.check.ClassChecker

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.