public void addSupperClass(String name){ if (name.endsWith(CLASS_EXTENSION)) { classNames.add(name.substring(0, name.length() - CLASS_EXTENSION.length())); } if (name.endsWith(CLASS_EXTENSION)) { DirectClassFile classFile; try { classFile = path.getClass(name); CstType superClass = classFile.getSuperclass(); if (superClass != null) { String superClassName=superClass.getClassType().getClassName(); classNames.add(superClassName); } } catch (FileNotFoundException e) { // throw new IOException("Class " + name + // " is missing form original class path " + path, e); } } } public void addRootsV2(String name){
addClassWithHierachy(superClass.getClassType().getClassName()); int interfaceNumber = interfaceList.size(); for (int i = 0; i < interfaceNumber; i++) { addClassWithHierachy(interfaceList.getType(i).getClassName());
private void addClassWithHierachy(String classBinaryName) { if (classNames.contains(classBinaryName)) { return; } try { DirectClassFile classFile = path.getClass(classBinaryName + CLASS_EXTENSION); classNames.add(classBinaryName); CstType superClass = classFile.getSuperclass(); if (superClass != null) { addClassWithHierachy(superClass.getClassType().getClassName()); } TypeList interfaceList = classFile.getInterfaces(); int interfaceNumber = interfaceList.size(); for (int i = 0; i < interfaceNumber; i++) { addClassWithHierachy(interfaceList.getType(i).getClassName()); } } catch (FileNotFoundException e) { // Ignore: The referenced type is not in the path it must be part of the libraries. } } }
/** {@inheritDoc} */ public String toHuman() { switch (basicType) { case BT_VOID: return "void"; case BT_BOOLEAN: return "boolean"; case BT_BYTE: return "byte"; case BT_CHAR: return "char"; case BT_DOUBLE: return "double"; case BT_FLOAT: return "float"; case BT_INT: return "int"; case BT_LONG: return "long"; case BT_SHORT: return "short"; case BT_OBJECT: break; default: return descriptor; } if (isArray()) { return getComponentType().toHuman() + "[]"; } // Remove the "L...;" around the type and convert "/" to ".". return getClassName().replace("/", "."); }
/** {@inheritDoc} */ public String toHuman() { switch (basicType) { case BT_VOID: return "void"; case BT_BOOLEAN: return "boolean"; case BT_BYTE: return "byte"; case BT_CHAR: return "char"; case BT_DOUBLE: return "double"; case BT_FLOAT: return "float"; case BT_INT: return "int"; case BT_LONG: return "long"; case BT_SHORT: return "short"; case BT_OBJECT: break; default: return descriptor; } if (isArray()) { return getComponentType().toHuman() + "[]"; } // Remove the "L...;" around the type and convert "/" to ".". return getClassName().replace("/", "."); }
/** {@inheritDoc} */ @Override public String toHuman() { switch (basicType) { case BT_VOID: return "void"; case BT_BOOLEAN: return "boolean"; case BT_BYTE: return "byte"; case BT_CHAR: return "char"; case BT_DOUBLE: return "double"; case BT_FLOAT: return "float"; case BT_INT: return "int"; case BT_LONG: return "long"; case BT_SHORT: return "short"; case BT_OBJECT: break; default: return descriptor; } if (isArray()) { return getComponentType().toHuman() + "[]"; } // Remove the "L...;" around the type and convert "/" to ".". return getClassName().replace("/", "."); }
/** {@inheritDoc} */ public String toHuman() { switch (basicType) { case BT_VOID: return "void"; case BT_BOOLEAN: return "boolean"; case BT_BYTE: return "byte"; case BT_CHAR: return "char"; case BT_DOUBLE: return "double"; case BT_FLOAT: return "float"; case BT_INT: return "int"; case BT_LONG: return "long"; case BT_SHORT: return "short"; case BT_OBJECT: break; default: return descriptor; } if (isArray()) { return getComponentType().toHuman() + "[]"; } // Remove the "L...;" around the type and convert "/" to ".". return getClassName().replace("/", "."); }
/** {@inheritDoc} */ @Override public String toHuman() { switch (basicType) { case BT_VOID: return "void"; case BT_BOOLEAN: return "boolean"; case BT_BYTE: return "byte"; case BT_CHAR: return "char"; case BT_DOUBLE: return "double"; case BT_FLOAT: return "float"; case BT_INT: return "int"; case BT_LONG: return "long"; case BT_SHORT: return "short"; case BT_OBJECT: break; default: return descriptor; } if (isArray()) { return getComponentType().toHuman() + "[]"; } // Remove the "L...;" around the type and convert "/" to ".". return getClassName().replace("/", "."); }
/** {@inheritDoc} */ public String toHuman() { switch (basicType) { case BT_VOID: return "void"; case BT_BOOLEAN: return "boolean"; case BT_BYTE: return "byte"; case BT_CHAR: return "char"; case BT_DOUBLE: return "double"; case BT_FLOAT: return "float"; case BT_INT: return "int"; case BT_LONG: return "long"; case BT_SHORT: return "short"; case BT_OBJECT: break; default: return descriptor; } if (isArray()) { return getComponentType().toHuman() + "[]"; } // Remove the "L...;" around the type and convert "/" to ".". return getClassName().replace("/", "."); }
/** {@inheritDoc} */ public String toHuman() { switch (basicType) { case BT_VOID: return "void"; case BT_BOOLEAN: return "boolean"; case BT_BYTE: return "byte"; case BT_CHAR: return "char"; case BT_DOUBLE: return "double"; case BT_FLOAT: return "float"; case BT_INT: return "int"; case BT_LONG: return "long"; case BT_SHORT: return "short"; case BT_OBJECT: break; default: return descriptor; } if (isArray()) { return getComponentType().toHuman() + "[]"; } // Remove the "L...;" around the type and convert "/" to ".". return getClassName().replace("/", "."); }
/** {@inheritDoc} */ @Override public String toHuman() { switch (basicType) { case BT_VOID: return "void"; case BT_BOOLEAN: return "boolean"; case BT_BYTE: return "byte"; case BT_CHAR: return "char"; case BT_DOUBLE: return "double"; case BT_FLOAT: return "float"; case BT_INT: return "int"; case BT_LONG: return "long"; case BT_SHORT: return "short"; case BT_OBJECT: break; default: return descriptor; } if (isArray()) { return getComponentType().toHuman() + "[]"; } // Remove the "L...;" around the type and convert "/" to ".". return getClassName().replace("/", "."); }
private void addClassWithHierachy(String classBinaryName) { if (toKeep.contains(classBinaryName)) { return; } String fileName = classBinaryName + CLASS_EXTENSION; try { DirectClassFile classFile = path.getClass(fileName); toKeep.add(classBinaryName); CstType superClass = classFile.getSuperclass(); if (superClass != null) { addClassWithHierachy(superClass.getClassType().getClassName()); } TypeList interfaceList = classFile.getInterfaces(); int interfaceNumber = interfaceList.size(); for (int i = 0; i < interfaceNumber; i++) { addClassWithHierachy(interfaceList.getType(i).getClassName()); } } catch (FileNotFoundException e) { // Ignore: The referenced type is not in the path it must be part of the libraries. } }
/** * Inspects a class annotation. * * @param cf {@code non-null;} class file * @param ann {@code non-null;} annotation */ private void visitClassAnnotation(DirectClassFile cf, BaseAnnotations ann) { if (!args.eTypes.contains(ElementType.TYPE)) { return; } for (Annotation anAnn : ann.getAnnotations().getAnnotations()) { String annClassName = anAnn.getType().getClassType().getClassName(); if (args.aclass.equals(annClassName)) { printMatch(cf); } } }
/** * Inspects a class annotation. * * @param cf {@code non-null;} class file * @param ann {@code non-null;} annotation */ private void visitClassAnnotation(DirectClassFile cf, BaseAnnotations ann) { if (!args.eTypes.contains(ElementType.TYPE)) { return; } for (Annotation anAnn : ann.getAnnotations().getAnnotations()) { String annClassName = anAnn.getType().getClassType().getClassName(); if (args.aclass.equals(annClassName)) { printMatch(cf); } } }
/** * Inspects a class annotation. * * @param cf {@code non-null;} class file * @param ann {@code non-null;} annotation */ private void visitClassAnnotation(DirectClassFile cf, BaseAnnotations ann) { if (!args.eTypes.contains(ElementType.TYPE)) { return; } for (Annotation anAnn : ann.getAnnotations().getAnnotations()) { String annClassName = anAnn.getType().getClassType().getClassName(); if (args.aclass.equals(annClassName)) { printMatch(cf); } } }
private void addClassWithHierachy(String classBinaryName) { if (classNames.contains(classBinaryName)) { return; } try { DirectClassFile classFile = path.getClass(classBinaryName + CLASS_EXTENSION); classNames.add(classBinaryName); CstType superClass = classFile.getSuperclass(); if (superClass != null) { addClassWithHierachy(superClass.getClassType().getClassName()); } TypeList interfaceList = classFile.getInterfaces(); int interfaceNumber = interfaceList.size(); for (int i = 0; i < interfaceNumber; i++) { addClassWithHierachy(interfaceList.getType(i).getClassName()); } } catch (FileNotFoundException e) { // Ignore: The referenced type is not in the path it must be part of the libraries. } }
/** * Inspects a class annotation. * * @param cf {@code non-null;} class file * @param ann {@code non-null;} annotation */ private void visitClassAnnotation(DirectClassFile cf, BaseAnnotations ann) { if (!args.eTypes.contains(ElementType.TYPE)) { return; } for (Annotation anAnn : ann.getAnnotations().getAnnotations()) { String annClassName = anAnn.getType().getClassType().getClassName(); if (args.aclass.equals(annClassName)) { printMatch(cf); } } }
private void addClassWithHierarchy(String classBinaryName) { if (classNames.contains(classBinaryName)) { return; } try { DirectClassFile classFile = path.getClass(classBinaryName + CLASS_EXTENSION); if (CLASS_TO_CHECK != null && classBinaryName.contains(CLASS_TO_CHECK)) { found(); } classNames.add(classBinaryName); CstType superClass = classFile.getSuperclass(); if (superClass != null) { addClassWithHierarchy(superClass.getClassType().getClassName()); } TypeList interfaceList = classFile.getInterfaces(); int interfaceNumber = interfaceList.size(); for (int i = 0; i < interfaceNumber; i++) { addClassWithHierarchy(interfaceList.getType(i).getClassName()); } } catch (FileNotFoundException e) { // Ignore: The referenced type is not in the path it must be part of the libraries. } }
/** * Inspects a class annotation. * * @param cf {@code non-null;} class file * @param ann {@code non-null;} annotation */ private void visitClassAnnotation(DirectClassFile cf, BaseAnnotations ann) { if (!args.eTypes.contains(ElementType.TYPE)) { return; } for (Annotation anAnn : ann.getAnnotations().getAnnotations()) { String annClassName = anAnn.getType().getClassType().getClassName(); if (args.aclass.equals(annClassName)) { printMatch(cf); } } }
private static Annotation getAnnotation(AttributeList attrs, Class<?> annotationClazz) { BaseAnnotations a= (BaseAnnotations) attrs.findFirst(AttRuntimeInvisibleAnnotations.ATTRIBUTE_NAME); if (a != null) { String annotationName= getClassWithSlashes(annotationClazz); for (Annotation an : a.getAnnotations().getAnnotations()) { if (an.getType().getClassType().getClassName().equals(annotationName)) { return an; } } } return null; }