Tabnine Logo
org.jboss.windup.rules.apps.java.decompiler
Code IndexAdd Tabnine to your IDE (free)

How to use org.jboss.windup.rules.apps.java.decompiler

Best Java code snippets using org.jboss.windup.rules.apps.java.decompiler (Showing top 20 results out of 315)

origin: org.jboss.windup.rules.apps/windup-rules-java-api

Iterable<JavaClassFileModel> getFilesToDecompile(GraphContext context)
{
  if (this.filesToDecompile == null)
  {
    filesToDecompile = getDefaultFilesToDecompile(context);
  }
  return filesToDecompile;
}
origin: windup/windup

@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());
  }
}
origin: org.jboss.windup.rules.apps/windup-rules-java-api

  private DecompilerType getDecompilerType()
  {
    String decompilerProperty = System.getProperty(DECOMPILER_PROPERTY);
    if (StringUtils.isBlank(decompilerProperty))
      return DecompilerType.FERNFLOWER;
    else
    {
      return DecompilerType.valueOf(decompilerProperty.toUpperCase());
    }
  }
}
origin: org.jboss.windup.rules.apps/windup-rules-java-ee

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);
}
origin: org.jboss.windup.rules.apps/windup-rules-java-api

@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");
}
origin: org.jboss.windup.rules.apps/windup-rules-java-api

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);
origin: windup/windup

@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
origin: org.jboss.windup.rules.apps/windup-rules-java-api

@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()");
  }
}
origin: windup/windup

@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());
    }
  }
}
origin: org.jboss.windup.rules.apps/windup-rules-java-api

@Override
public Configuration getConfiguration(RuleLoaderContext ruleLoaderContext)
{
  return ConfigurationBuilder.begin()
  .addRule()
  .when(Query.fromType(JavaClassFileModel.class)
      .withoutProperty(FileModel.PARSE_ERROR)
  )
  .perform(new ClassFilePreDecompilationScan());
}
// @formatter:on
origin: org.jboss.windup.rules.apps/windup-rules-java-api

@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());
  }
}
origin: windup/windup

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);
}
origin: windup/windup

@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");
}
origin: windup/windup

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);
origin: org.jboss.windup.rules.apps/windup-rules-java-api

@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
origin: windup/windup

@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()");
  }
}
origin: org.jboss.windup.rules.apps/windup-rules-java-api

@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());
    }
  }
}
origin: windup/windup

Iterable<JavaClassFileModel> getFilesToDecompile(GraphContext context)
{
  if (this.filesToDecompile == null)
  {
    filesToDecompile = getDefaultFilesToDecompile(context);
  }
  return filesToDecompile;
}
origin: windup/windup

  private DecompilerType getDecompilerType()
  {
    String decompilerProperty = System.getProperty(DECOMPILER_PROPERTY);
    if (StringUtils.isBlank(decompilerProperty))
      return DecompilerType.FERNFLOWER;
    else
    {
      return DecompilerType.valueOf(decompilerProperty.toUpperCase());
    }
  }
}
origin: windup/windup

@Override
public Configuration getConfiguration(RuleLoaderContext ruleLoaderContext)
{
  return ConfigurationBuilder.begin()
  .addRule()
  .when(Query.fromType(JavaClassFileModel.class)
      .withoutProperty(FileModel.PARSE_ERROR)
  )
  .perform(new ClassFilePreDecompilationScan());
}
// @formatter:on
org.jboss.windup.rules.apps.java.decompiler

Most used classes

  • FernflowerDecompilerOperation
  • AbstractDecompilerOperation
    An abstract operation providing some default methods useful for the DecompilerOperations.
  • ClassFilePreDecompilationScan
    An operation doing a pre-scan of the .class file in order to check if it is possible to tell in adva
  • CleanFromMultipleSourceFiles
    Removes all the duplicates of .java file within a projectModel. There may be multiple especially in
  • DecompileClassesRuleProvider$DecompileCondition
  • DecompilerUtil,
  • FernflowerDecompilerOperation$AddDecompiledItemsToGraph$2,
  • FernflowerDecompilerOperation$AddDecompiledItemsToGraph,
  • ProcyonDecompilerOperation$AddDecompiledItemsToGraph$2,
  • ProcyonDecompilerOperation$AddDecompiledItemsToGraph,
  • ProcyonDecompilerOperation
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now