@ Override public DecompilationResult decompileClassFile ( Path rootDir , Path classFilePath , Path outputDir ) throws DecompilationException { Checks . checkDirectoryToBeRead ( rootDir . toFile ( ) , "Classes root dir" ) ; File classFile = classFilePath . toFile ( ) ; Checks . checkFileToBeRead ( classFile , "Class file" ) ; Checks . checkDirectoryToBeFilled ( outputDir . toFile ( ) , "Output directory" ) ; log . info ( "Decompiling .class '" + classFilePath + "' to '" + outputDir + "' from: '" + rootDir + "'" ) ; String name = classFilePath . normalize ( ) . toAbsolutePath ( ) . toString ( ) . substring ( rootDir . toAbsolutePath ( ) . toString ( ) . length ( ) + 1 ) ; final String typeName = StringUtils . removeEnd ( name , ".class" ) ; // .replace('/', '.'); DecompilationResult result = new DecompilationResult ( ) ; try { DecompilerSettings settings = getDefaultSettings ( outputDir . toFile ( ) ) ; this . procyonConf . setDecompilerSettings ( settings ) ; // TODO: This is horrible mess. final ITypeLoader typeLoader = new CompositeTypeLoader ( new WindupClasspathTypeLoader ( rootDir . toString ( ) ) , new ClasspathTypeLoader ( ) ) ; WindupMetadataSystem metadataSystem = new WindupMetadataSystem ( typeLoader ) ; File outputFile = this . decompileType ( settings , metadataSystem , typeName ) ; result . addDecompiled ( Collections . singletonList ( classFilePath . toString ( ) ) , outputFile . getAbsolutePath ( ) ) ; } catch ( Throwable e ) { DecompilationFailure failure = new DecompilationFailure ( "Error during decompilation of " + classFilePath . toString ( ) + ":\n " + e . getMessage ( ) , Collections . singletonList ( name ) , e ) ; log . severe ( failure . getMessage ( ) ) ; result . addFailure ( failure ) ; } return result ; }
Decompiles the given . class file and creates the specified output source file .