private boolean embeddedNameMismatch(ZipFile zipInputFile, ZipEntry ze) throws IOException { InputStream zipIn = zipInputFile.getInputStream(ze); String name = ze.getName(); JavaClass j = new ClassParser(zipIn, name).parse(); zipIn.close(); String className = j.getClassName(); String computedFileName = ClassName.toSlashedClassName(className)+".class"; if (name.charAt(0) == '1') { System.out.println(name); System.out.println(" " + className); } if (computedFileName.equals(name)) { return false; } System.out.println("In " + name + " found " + className); return true; }
/** * Constructor. * * @param fileName * name of the class file */ public RepositoryClassParser(String fileName) { classParser = new ClassParser(fileName); }
/** * Parse the class file into a JavaClass object. If successful, the new * JavaClass is entered into the Repository. * * @return the parsed JavaClass * @throws IOException * if the class cannot be parsed */ public JavaClass parse() throws IOException { JavaClass jclass = classParser.parse(); Repository.addClass(jclass); return jclass; } }
readID(); readVersion(); readConstantPool(); readClassInfo(); readInterfaces(); readFields(); readMethods(); readAttributes();
/** * Constructor. * * @param inputStream * the input stream from which to read the class file * @param fileName * filename of the class file */ public RepositoryClassParser(InputStream inputStream, String fileName) { classParser = new ClassParser(inputStream, fileName); }
private static void printClass(ClassParser parser) throws IOException { JavaClass java_class; java_class = parser.parse(); if (superClasses) { try { while (java_class != null) { System.out.print(java_class.getClassName() + " "); java_class = java_class.getSuperClass(); } } catch (ClassNotFoundException e) { System.out.println(e.getMessage()); } System.out.println(); return; } if (constants || code) { System.out.println(java_class); // Dump the contents } if (constants) { System.out.println(java_class.getConstantPool()); } if (code) { printCode(java_class.getMethods()); } }
readID(); readVersion(); readConstantPool(); readClassInfo(); readInterfaces(); readFields(); readMethods(); readAttributes();
ClassParser classParser = new ClassParser(in, resourceName); JavaClass javaClass = classParser.parse(); parsedClass = true;
/** * Constructor. * * @param zipFile * name of a zip file containing the class * @param fileName * name of the zip entry within the class */ public RepositoryClassParser(String zipFile, String fileName) { classParser = new ClassParser(zipFile, fileName); }
/** * Parse the class file into a JavaClass object. If succesful, the new * JavaClass is entered into the Repository. * * @return the parsed JavaClass * @throws IOException * if the class cannot be parsed */ public JavaClass parse() throws IOException { JavaClass jclass = classParser.parse(); Repository.addClass(jclass); return jclass; } }
public RegenerateClassFeatures execute() throws IOException { bugCollection.clearClassFeatures(); ArrayList<JavaClass> classList = new ArrayList<>(); try (ZipFile zipFile = new ZipFile(jarFile)){ // Add all classes to repository (for hierarchy queries) Enumeration<? extends ZipEntry> entries = zipFile.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); 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); } } for (JavaClass javaClass : classList) { ClassFeatureSet classFeatureSet = new ClassFeatureSet().initialize(javaClass); bugCollection.setClassFeatureSet(classFeatureSet); } return this; }
printClass(new ClassParser(z.getInputStream(ze), name)); for (int i = 0; i < files; i++) { if (file_name[i].endsWith(".class")) { printClass(new ClassParser(file_name[i]));
private static void printClass(ClassParser parser) throws IOException { JavaClass java_class; java_class = parser.parse(); if (superClasses) { try { while (java_class != null) { System.out.print(java_class.getClassName() + " "); java_class = java_class.getSuperClass(); } } catch (ClassNotFoundException e) { System.out.println(e.getMessage()); } System.out.println(); return; } if (constants || code) { System.out.println(java_class); // Dump the contents } if (constants) { System.out.println(java_class.getConstantPool()); } if (code) { printCode(java_class.getMethods()); } }
ClassParser classparser = new ClassParser(in, doc.get(QueryBuilder.PATH)); StringWriter xout = new StringWriter(); getContent(xout, fout, classparser.parse(), defs, refs, full); String xref = xout.toString();
/** * Constructor. * * @param inputStream * the input stream from which to read the class file * @param fileName * filename of the class file */ public RepositoryClassParser(InputStream inputStream, String fileName) { classParser = new ClassParser(inputStream, fileName); }
@Override public JavaClass analyze(IAnalysisCache analysisCache, ClassDescriptor descriptor) throws CheckedAnalysisException { try { ClassData classData = analysisCache.getClassAnalysis(ClassData.class, descriptor); JavaClass javaClass = new ClassParser(classData.getInputStream(), descriptor.toResourceName()).parse(); // Make sure that the JavaClass object knows the repository // it was loaded from. javaClass.setRepository(Repository.getRepository()); if (DEBUG_MISSING_CLASSES && !(javaClass.getRepository() instanceof AnalysisCacheToRepositoryAdapter)) { throw new IllegalStateException("this should not happen"); } return javaClass; } catch (RuntimeException e) { throw new RuntimeException("Unable to parse classfile for " + descriptor, e); } catch (IOException e) { throw new ResourceNotFoundException(descriptor.toResourceName(), e); } }
/** * Constructor. * * @param fileName * name of the class file */ public RepositoryClassParser(String fileName) { classParser = new ClassParser(fileName); }
JavaClass jclass = new ClassParser(argv[0]).parse(); ClassGen classGen = new ClassGen(jclass);
/** * Constructor. * * @param zipFile * name of a zip file containing the class * @param fileName * name of the zip entry within the class */ public RepositoryClassParser(String zipFile, String fileName) { classParser = new ClassParser(zipFile, fileName); }
/** * Returns the Bcel Class corresponding to the given class filename * * @param filename * the absolute file name of the class * @return the Bcel Class. * @throws IOException */ public static JavaClass getBcelClass(final String filename) throws IOException { final ClassParser parser = new ClassParser(filename); return parser.parse(); }