Package org.apache.bcel.classfile

Examples of org.apache.bcel.classfile.JavaClass


        String refName = getComponentClass(refSig);
        if (refName.equals("java.lang.Object")) {
            return 0.99;
        }

        JavaClass refJavaClass;
        try {
            refJavaClass = Repository.lookupClass(refName);
            return Analyze.deepInstanceOf(refJavaClass, remote);
        } catch (ClassNotFoundException e) {
            return 0.99;
View Full Code Here


        }



        for (ClassDescriptor subtype : directSubtypes) {
            JavaClass subJavaClass = Repository.lookupClass(subtype.getDottedClassName());
            result = Math.max(result, confidence * Analyze.deepInstanceOf(subJavaClass, serializable));

            // result = Math.max(result, confidence * isDeepSerializable(subJavaClass));
            if (result >= 0.9) {
                return result;
View Full Code Here

    @Override
    public void visitClassContext(ClassContext classContext) {
        try {
            ByteCodePattern pattern = getPattern();
            JavaClass jclass = classContext.getJavaClass();
            Method[] methodList = jclass.getMethods();

            for (Method method : methodList) {
                if (method.isAbstract() || method.isNative()) {
                    continue;
                }

                if (METHOD != null && !method.getName().equals(METHOD)) {
                    continue;
                }

                if (DEBUG) {
                    System.out.print("=====================================================================\n" + "Method "
                            + jclass.getClassName() + "." + method.getName() + "\n"
                            + "=====================================================================\n");
                }

                if (!prescreen(method, classContext)) {
                    continue;
View Full Code Here

                } else {
                    throw new IllegalStateException("impossible");
                }

                if (!m.isStatic() && !m.getName().equals("<init>")) {
                    JavaClass c = Repository.lookupClass(className);
                    // get inherited annotation
                    TreeSet<AnnotationEnum> inheritedAnnotations = new TreeSet<AnnotationEnum>();
                    if (c.getSuperclassNameIndex() > 0) {

                        n = lookInOverriddenMethod(o, c.getSuperclassName(), m, getMinimal);
                        if (n != null) {
                            inheritedAnnotations.add(n);
                        }
                    }
                    for (String implementedInterface : c.getInterfaceNames()) {
                        n = lookInOverriddenMethod(o, implementedInterface, m, getMinimal);
                        if (n != null) {
                            inheritedAnnotations.add(n);
                        }
                    }
                    if (DEBUG) {
                        System.out.println("# of inherited annotations : " + inheritedAnnotations.size());
                    }
                    if (!inheritedAnnotations.isEmpty()) {
                        if (inheritedAnnotations.size() == 1) {
                            return inheritedAnnotations.first();
                        }
                        if (!getMinimal) {
                            return inheritedAnnotations.last();
                        }

                        AnnotationEnum min = inheritedAnnotations.first();
                        if (min.getIndex() == 0) {
                            inheritedAnnotations.remove(min);
                            min = inheritedAnnotations.first();
                        }
                        return min;
                    }
                    // check to see if method is defined in this class;
                    // if not, on't consider default annotations
                    if (!classDefinesMethod(c, m)) {
                        return null;
                    }
                    if (DEBUG) {
                        System.out.println("looking for default annotations: " + c.getClassName() + " defines " + m);
                    }
                } // if not static
            } // associated with method
            else if (o instanceof XField) {

                className = ((XField) o).getClassName();
                kind = Target.FIELD;
            } else if (o instanceof String) {
                assert false;
                className = (String) o;
                kind = Target.CLASS;
            } else {
                throw new IllegalArgumentException("Can't look up annotation for " + o.getClass().getName());
            }

            // <init> method parameters for inner classes don't inherit default
            // annotations
            // since some of them are synthetic
            if (isParameterToInitMethodofAnonymousInnerClass) {
                return null;
            }

            // synthetic elements should not inherit default annotations
            if (isSyntheticMethod) {
                return null;
            }
            try {
                XClass c = Global.getAnalysisCache().getClassAnalysis(XClass.class,
                        DescriptorFactory.createClassDescriptorFromDottedClassName(className));

                if (c != null && c.isSynthetic()) {
                    return null;
                }
            } catch (CheckedAnalysisException e) {
                assert true;
            }
View Full Code Here

    @Override
    public void storeClass(JavaClass javaClass) {
        if (DEBUG) {
            System.out.println("Storing class " + javaClass.getClassName() + " in repository");
        }
        JavaClass previous = nameToClassMap.put(javaClass.getClassName(), javaClass);
        if (DEBUG && previous != null) {
            System.out.println("\t==> A previous class was evicted!");
            dumpStack();
        }
        Repository tmp = org.apache.bcel.Repository.getRepository();
View Full Code Here

    public JavaClass loadClass(/*@Nonnull*/ String className) throws ClassNotFoundException {
        if (className == null) {
            throw new IllegalArgumentException("className is null");
        }
        // if (className.indexOf('/') >= 0) throw new IllegalStateException();
        JavaClass javaClass = findClass(className);
        if (javaClass == null) {
            if (DEBUG) {
                System.out.println("Looking up " + className + " on classpath");
                dumpStack();
            }
View Full Code Here

        if (args.length != 2) {
            System.err.println("Usage: " + ClassFeatureSet.class.getName() + " <class 1> <class 2>");
            System.exit(1);
        }

        JavaClass a = Repository.lookupClass(args[0]);
        JavaClass b = Repository.lookupClass(args[1]);

        ClassFeatureSet aFeatures = new ClassFeatureSet().initialize(a);
        ClassFeatureSet bFeatures = new ClassFeatureSet().initialize(b);

        System.out.println("Similarity is " + similarity(aFeatures, bFeatures));
View Full Code Here

                if (!entry.getName().endsWith(".class")) {
                    continue;
                }

                ClassParser parser = new ClassParser(zipFile.getInputStream(entry), entry.getName());
                JavaClass javaClass = parser.parse();

                Repository.addClass(javaClass);
                classList.add(javaClass);
            }
        }
View Full Code Here

        }
    }

    @Override
    public void visitClassContext(ClassContext classContext) {
        JavaClass jclass = classContext.getJavaClass();

        Method[] methodList = jclass.getMethods();
        for (Method method : methodList) {
            MethodGen methodGen = classContext.getMethodGen(method);
            if (methodGen == null) {
                continue;
            }
View Full Code Here

    }

    @Override
    public void visitClassContext(ClassContext classContext) {
        JavaClass javaClass = classContext.getJavaClass();
        Method[] methodList = javaClass.getMethods();

        for (Method method : methodList) {
            if (method.getCode() == null) {
                continue;
            }

            try {
                analyzeMethod(classContext, method);
            } catch (MethodUnprofitableException e) {
                assert true; // move along; nothing to see
            } catch (CFGBuilderException e) {
                String msg = "Detector " + this.getClass().getName() + " caught exception while analyzing "
                        + javaClass.getClassName() + "." + method.getName() + " : " + method.getSignature();
                bugReporter.logError(msg, e);
            } catch (DataflowAnalysisException e) {
                String msg = "Detector " + this.getClass().getName() + " caught exception while analyzing "
                        + javaClass.getClassName() + "." + method.getName() + " : " + method.getSignature();
                bugReporter.logError(msg, e);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.bcel.classfile.JavaClass

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.