Iterable<JavaClassFileModel> getFilesToDecompile(GraphContext context) { if (this.filesToDecompile == null) { filesToDecompile = getDefaultFilesToDecompile(context); } return filesToDecompile; }
@Override public void perform(GraphRewrite event, EvaluationContext context) { switch (getDecompilerType()) { case FERNFLOWER: new FernflowerDecompilerOperation().perform(event, context); break; case PROCYON: new ProcyonDecompilerOperation().perform(event, context); break; default: throw new WindupException("Failed to select decompiler due to unrecognized type: " + getDecompilerType()); } }
private DecompilerType getDecompilerType() { String decompilerProperty = System.getProperty(DECOMPILER_PROPERTY); if (StringUtils.isBlank(decompilerProperty)) return DecompilerType.FERNFLOWER; else { return DecompilerType.valueOf(decompilerProperty.toUpperCase()); } } }
private void markAsReportReportable(GraphRewrite event, EvaluationContext context, JavaClassModel reference) { AbstractJavaSourceModel originalSource = reference.getOriginalSource(); JavaSourceFileModel decompiledSource = reference.getDecompiledSource(); if (originalSource == null && decompiledSource == null && reference.getClassFile() != null && reference.getClassFile() instanceof JavaClassFileModel) { JavaClassFileModel javaClassFileModel = (JavaClassFileModel) reference.getClassFile(); javaClassFileModel.setSkipDecompilation(false); // try to decompile it FernflowerDecompilerOperation decompilerOperation = new FernflowerDecompilerOperation(); decompilerOperation.setFilesToDecompile(Collections.singletonList(javaClassFileModel)); decompilerOperation.perform(event, context); // Commit to ensure that we are using the latest data (otherwise data from other threads may not // be visible). event.getGraphContext().commit(); if (reference.getDecompiledSource() != null) { reference.getDecompiledSource().setGenerateSourceReport(true); } } if (originalSource != null) originalSource.setGenerateSourceReport(true); if (decompiledSource != null) decompiledSource.setGenerateSourceReport(true); }
@Override public void perform(final GraphRewrite event, final EvaluationContext context) { ExecutionStatistics.get().begin("ProcyonDecompilationOperation.perform"); int threads = WindupExecutors.getDefaultThreadCount(); LOG.info("Decompiling with " + threads + " threads"); WindupJavaConfigurationService configurationService = new WindupJavaConfigurationService(event.getGraphContext()); Iterable<JavaClassFileModel> allClasses = getFilesToDecompile(event.getGraphContext()); List<ClassDecompileRequest> classesToDecompile = new ArrayList<>(10000); // Just a guess as to the average size for (JavaClassFileModel classFileModel : allClasses) { if (configurationService.shouldScanPackage(classFileModel.getPackageName())) { File outputDir = DecompilerUtil.getOutputDirectoryForClass(event.getGraphContext(), classFileModel); classesToDecompile.add(new ClassDecompileRequest(outputDir.toPath(), classFileModel.asFile().toPath(), outputDir.toPath())); } } Collections.sort(classesToDecompile, (ClassDecompileRequest o1, ClassDecompileRequest o2) -> o1.getOutputDirectory().toAbsolutePath().toString().compareTo(o2.getOutputDirectory().toString())); ProgressEstimate progressEstimate = new ProgressEstimate(classesToDecompile.size()); AddDecompiledItemsToGraph addDecompiledItemsToGraph = new AddDecompiledItemsToGraph(progressEstimate, event); ProcyonDecompiler decompiler = new ProcyonDecompiler(new ProcyonConfiguration().setIncludeNested(false)); decompiler.setExecutorService(WindupExecutors.newFixedThreadPool(threads), threads); decompiler.decompileClassFiles(classesToDecompile, addDecompiledItemsToGraph); decompiler.close(); ExecutionStatistics.get().end("ProcyonDecompilationOperation.perform"); }
Iterable<JavaClassFileModel> filesToDecompile = getFilesToDecompile(event.getGraphContext()); for (JavaClassFileModel classFileModel : filesToDecompile) File outputDir = DecompilerUtil.getOutputDirectoryForClass(event.getGraphContext(), classFileModel); if (configurationService.shouldScanPackage(classFileModel.getPackageName())) AddDecompiledItemsToGraph addDecompiledItemsToGraph = new AddDecompiledItemsToGraph(classesToDecompile, progressEstimate, event); FernflowerDecompiler decompiler = new FernflowerDecompiler(); decompiler.setExecutorService(WindupExecutors.newFixedThreadPool(threads), threads);
@Override public Configuration getConfiguration(RuleLoaderContext ruleLoaderContext) { return ConfigurationBuilder.begin() .addRule() .when(SourceMode.isDisabled()) .perform(new DecompileCondition()) .addRule() .when(SourceMode.isDisabled()) .perform(new CleanFromMultipleSourceFiles()); } // @formatter:on
@Override public void perform(GraphRewrite event, EvaluationContext context, JavaClassFileModel fileModel) { ExecutionStatistics.get().begin("ClassFilePreDecompilationScan.perform()"); try { addClassFileMetadata(event, context, fileModel); if (fileModel.getParseError() != null) return; filterClassesToDecompile(event, context, fileModel); } finally { ExecutionStatistics.get().end("ClassFilePreDecompilationScan.perform()"); } }
@Override public void perform(GraphRewrite event, EvaluationContext context) { final GraphContext graphContext = event.getGraphContext(); List<Map<Object, Object>> javaSourceGroups = graphContext.getQuery(JavaSourceFileModel.class).getRawTraversal() .group() .by(v -> groupByProjectModelFunction(graphContext, (Vertex)v)) .toList(); final GraphService<JavaSourceFileModel> service = new GraphService<>(event.getGraphContext(), JavaSourceFileModel.class); for (Map<Object, Object> duplicateLists : javaSourceGroups) { for (Object duplicateListObject : duplicateLists.values()) { List<Vertex> duplicateList = (List<Vertex>)duplicateListObject; List<JavaSourceFileModel> toDelete = returnVerticesToDelete(service, duplicateList); toDelete.forEach(javaSourceFileModel -> javaSourceFileModel.remove()); } } }
@Override public Configuration getConfiguration(RuleLoaderContext ruleLoaderContext) { return ConfigurationBuilder.begin() .addRule() .when(Query.fromType(JavaClassFileModel.class) .withoutProperty(FileModel.PARSE_ERROR) ) .perform(new ClassFilePreDecompilationScan()); } // @formatter:on
@Override public void perform(GraphRewrite event, EvaluationContext context) { switch (getDecompilerType()) { case FERNFLOWER: new FernflowerDecompilerOperation().perform(event, context); break; case PROCYON: new ProcyonDecompilerOperation().perform(event, context); break; default: throw new WindupException("Failed to select decompiler due to unrecognized type: " + getDecompilerType()); } }
private void markAsReportReportable(GraphRewrite event, EvaluationContext context, JavaClassModel reference) { AbstractJavaSourceModel originalSource = reference.getOriginalSource(); JavaSourceFileModel decompiledSource = reference.getDecompiledSource(); if (originalSource == null && decompiledSource == null && reference.getClassFile() != null && reference.getClassFile() instanceof JavaClassFileModel) { JavaClassFileModel javaClassFileModel = (JavaClassFileModel) reference.getClassFile(); javaClassFileModel.setSkipDecompilation(false); // try to decompile it FernflowerDecompilerOperation decompilerOperation = new FernflowerDecompilerOperation(); decompilerOperation.setFilesToDecompile(Collections.singletonList(javaClassFileModel)); decompilerOperation.perform(event, context); // Commit to ensure that we are using the latest data (otherwise data from other threads may not // be visible). event.getGraphContext().commit(); if (reference.getDecompiledSource() != null) { reference.getDecompiledSource().setGenerateSourceReport(true); } } if (originalSource != null) originalSource.setGenerateSourceReport(true); if (decompiledSource != null) decompiledSource.setGenerateSourceReport(true); }
@Override public void perform(final GraphRewrite event, final EvaluationContext context) { ExecutionStatistics.get().begin("ProcyonDecompilationOperation.perform"); int threads = WindupExecutors.getDefaultThreadCount(); LOG.info("Decompiling with " + threads + " threads"); WindupJavaConfigurationService configurationService = new WindupJavaConfigurationService(event.getGraphContext()); Iterable<JavaClassFileModel> allClasses = getFilesToDecompile(event.getGraphContext()); List<ClassDecompileRequest> classesToDecompile = new ArrayList<>(10000); // Just a guess as to the average size for (JavaClassFileModel classFileModel : allClasses) { if (configurationService.shouldScanPackage(classFileModel.getPackageName())) { File outputDir = DecompilerUtil.getOutputDirectoryForClass(event.getGraphContext(), classFileModel); classesToDecompile.add(new ClassDecompileRequest(outputDir.toPath(), classFileModel.asFile().toPath(), outputDir.toPath())); } } Collections.sort(classesToDecompile, (ClassDecompileRequest o1, ClassDecompileRequest o2) -> o1.getOutputDirectory().toAbsolutePath().toString().compareTo(o2.getOutputDirectory().toString())); ProgressEstimate progressEstimate = new ProgressEstimate(classesToDecompile.size()); AddDecompiledItemsToGraph addDecompiledItemsToGraph = new AddDecompiledItemsToGraph(progressEstimate, event); ProcyonDecompiler decompiler = new ProcyonDecompiler(new ProcyonConfiguration().setIncludeNested(false)); decompiler.setExecutorService(WindupExecutors.newFixedThreadPool(threads), threads); decompiler.decompileClassFiles(classesToDecompile, addDecompiledItemsToGraph); decompiler.close(); ExecutionStatistics.get().end("ProcyonDecompilationOperation.perform"); }
Iterable<JavaClassFileModel> filesToDecompile = getFilesToDecompile(event.getGraphContext()); for (JavaClassFileModel classFileModel : filesToDecompile) File outputDir = DecompilerUtil.getOutputDirectoryForClass(event.getGraphContext(), classFileModel); if (configurationService.shouldScanPackage(classFileModel.getPackageName())) AddDecompiledItemsToGraph addDecompiledItemsToGraph = new AddDecompiledItemsToGraph(classesToDecompile, progressEstimate, event); FernflowerDecompiler decompiler = new FernflowerDecompiler(); decompiler.setExecutorService(WindupExecutors.newFixedThreadPool(threads), threads);
@Override public Configuration getConfiguration(RuleLoaderContext ruleLoaderContext) { return ConfigurationBuilder.begin() .addRule() .when(SourceMode.isDisabled()) .perform(new DecompileCondition()) .addRule() .when(SourceMode.isDisabled()) .perform(new CleanFromMultipleSourceFiles()); } // @formatter:on
@Override public void perform(GraphRewrite event, EvaluationContext context, JavaClassFileModel fileModel) { ExecutionStatistics.get().begin("ClassFilePreDecompilationScan.perform()"); try { addClassFileMetadata(event, context, fileModel); if (fileModel.getParseError() != null) return; filterClassesToDecompile(event, context, fileModel); } finally { ExecutionStatistics.get().end("ClassFilePreDecompilationScan.perform()"); } }
@Override public void perform(GraphRewrite event, EvaluationContext context) { final GraphContext graphContext = event.getGraphContext(); List<Map<Object, Object>> javaSourceGroups = graphContext.getQuery(JavaSourceFileModel.class).getRawTraversal() .group() .by(v -> groupByProjectModelFunction(graphContext, (Vertex)v)) .toList(); final GraphService<JavaSourceFileModel> service = new GraphService<>(event.getGraphContext(), JavaSourceFileModel.class); for (Map<Object, Object> duplicateLists : javaSourceGroups) { for (Object duplicateListObject : duplicateLists.values()) { List<Vertex> duplicateList = (List<Vertex>)duplicateListObject; List<JavaSourceFileModel> toDelete = returnVerticesToDelete(service, duplicateList); toDelete.forEach(javaSourceFileModel -> javaSourceFileModel.remove()); } } }
Iterable<JavaClassFileModel> getFilesToDecompile(GraphContext context) { if (this.filesToDecompile == null) { filesToDecompile = getDefaultFilesToDecompile(context); } return filesToDecompile; }
private DecompilerType getDecompilerType() { String decompilerProperty = System.getProperty(DECOMPILER_PROPERTY); if (StringUtils.isBlank(decompilerProperty)) return DecompilerType.FERNFLOWER; else { return DecompilerType.valueOf(decompilerProperty.toUpperCase()); } } }
@Override public Configuration getConfiguration(RuleLoaderContext ruleLoaderContext) { return ConfigurationBuilder.begin() .addRule() .when(Query.fromType(JavaClassFileModel.class) .withoutProperty(FileModel.PARSE_ERROR) ) .perform(new ClassFilePreDecompilationScan()); } // @formatter:on