Source:
public static void main ( java.lang.String [ ] args ) throws java.lang.Exception { java.nio.file.Path dumpDirectory = java.nio.file.Files.createTempDirectory ( "lambdas" ) ; java.lang.System.setProperty ( LambdaClassMaker.LAMBDA_METAFACTORY_DUMPER_PROPERTY , dumpDirectory.toString ( ) ) ; if ( ( ( args.length ) == 1 ) && ( args [ 0 ] . startsWith ( "@" ) ) ) { args = java.nio.file.Files.readAllLines ( java.nio.file.Paths.get ( args [ 0 ] . substring ( 1 ) ) , java.nio.charset.StandardCharsets.ISO_8859_1 ) . toArray ( new java.lang.String [ 0 ] ) ; } com.google.devtools.common.options.OptionsParser optionsParser = com.google.devtools.common.options.OptionsParser.newOptionsParser ( com.google.devtools.build.android.desugar.Desugar.Options.class ) ; optionsParser.parseAndExitUponError ( args ) ; com.google.devtools.build.android.desugar.Desugar.Options options = optionsParser.getOptions ( com.google.devtools.build.android.desugar.Desugar.Options.class ) ; if ( options.verbose ) { java.lang.System.out.printf ( "Lambda classes will be written under %s%n" , dumpDirectory ) ; } boolean allowDefaultMethods = ( options.minSdkVersion ) >= 24 ; java.lang.ClassLoader parent ; if ( ( options.bootclasspath.isEmpty ( ) ) && ( ! ( options.allowEmptyBootclasspath ) ) ) { parent = java.lang.ClassLoader.getSystemClassLoader ( ) ; } else { parent = new com.google.devtools.build.android.desugar.Desugar.ThrowingClassLoader ( ) ; } java.lang.ClassLoader loader = com.google.devtools.build.android.desugar.Desugar.createClassLoader ( options.bootclasspath , options.inputJar , options.classpath , parent ) ; try ( java.util.zip.ZipFile in = new java.util.zip.ZipFile ( options.inputJar.toFile ( ) ) ; java.util.zip.ZipOutputStream out = new java.util.zip.ZipOutputStream ( new java.io.BufferedOutputStream ( java.nio.file.Files.newOutputStream ( options.outputJar ) ) ) ) { com.google.devtools.build.android.desugar.LambdaClassMaker lambdas = new com.google.devtools.build.android.desugar.LambdaClassMaker ( dumpDirectory ) ; com.google.devtools.build.android.desugar.ClassReaderFactory readerFactory = new com.google.devtools.build.android.desugar.ClassReaderFactory ( in ) ; com.google.common.collect.ImmutableSet.Builder < java.lang.String > interfaceLambdaMethodCollector = com.google.common.collect.ImmutableSet.builder ( ) ; for ( java.util.Enumeration < ? extends java.util.zip.ZipEntry > entries = in.entries ( ) ; entries.hasMoreElements ( ) ; ) { java.util.zip.ZipEntry entry = entries.nextElement ( ) ; try ( java.io.InputStream content = in.getInputStream ( entry ) ) { if ( entry.getName ( ) . endsWith ( ".class" ) ) { org.objectweb.asm.ClassReader reader = new org.objectweb.asm.ClassReader ( content ) ; org.objectweb.asm.ClassWriter writer = new org.objectweb.asm.ClassWriter ( org.objectweb.asm.ClassWriter.COMPUTE_MAXS ) ; org.objectweb.asm.ClassVisitor visitor = writer ; if ( ! allowDefaultMethods ) { visitor = new com.google.devtools.build.android.desugar.Java7Compatibility ( visitor , readerFactory ) ; } reader.accept ( new com.google.devtools.build.android.desugar.LambdaDesugaring ( visitor , loader , lambdas , interfaceLambdaMethodCollector , allowDefaultMethods ) , 0 ) ; com.google.devtools.build.android.desugar.Desugar.writeStoredEntry ( out , entry.getName ( ) , writer.toByteArray ( ) ) ; } else { java.util.zip.ZipEntry destEntry = new java.util.zip.ZipEntry ( entry ) ; destEntry.setCompressedSize ( ( - 1 ) ) ; out.putNextEntry ( destEntry ) ; com.google.common.io.ByteStreams.copy ( content , out ) ; out.closeEntry ( ) ; } } } com.google.common.collect.ImmutableSet < java.lang.String > interfaceLambdaMethods = interfaceLambdaMethodCollector.build ( ) ; if ( allowDefaultMethods ) { com.google.common.base.Preconditions.checkState ( interfaceLambdaMethods.isEmpty ( ) , "Desugaring with default methods enabled moved interface lambdas" ) ; } for ( java.util.Map.Entry < java.nio.file.Path , com.google.devtools.build.android.desugar.LambdaInfo > lambdaClass : lambdas.drain ( ) . entrySet ( ) ) { try ( java.io.InputStream bytecode = java.nio.file.Files.newInputStream ( dumpDirectory.resolve ( lambdaClass.getKey ( ) ) ) ) { org.objectweb.asm.ClassReader reader = new org.objectweb.asm.ClassReader ( bytecode ) ; org.objectweb.asm.ClassWriter writer = new org.objectweb.asm.ClassWriter ( org.objectweb.asm.ClassWriter.COMPUTE_MAXS ) ; org.objectweb.asm.ClassVisitor visitor = writer ; if ( ! allowDefaultMethods ) { visitor = new com.google.devtools.build.android.desugar.Java7Compatibility ( visitor , ( ( com.google.devtools.build.android.desugar.ClassReaderFactory ) ( null ) ) ) ; } com.google.devtools.build.android.desugar.LambdaClassFixer lambdaFixer = new com.google.devtools.build.android.desugar.LambdaClassFixer ( visitor , lambdaClass.getValue ( ) , readerFactory , interfaceLambdaMethods , allowDefaultMethods ) ; reader.accept ( new com.google.devtools.build.android.desugar.LambdaDesugaring ( lambdaFixer , loader , lambdas , null , allowDefaultMethods ) , 0 ) ; com.google.devtools.build.android.desugar.Desugar.writeStoredEntry ( out , ( ( lambdaFixer.getInternalName ( ) ) + ".class" ) , writer.toByteArray ( ) ) ; } } java.util.Map < java.nio.file.Path , com.google.devtools.build.android.desugar.LambdaInfo > leftBehind = lambdas.drain ( ) ; com.google.common.base.Preconditions.checkState ( leftBehind.isEmpty ( ) , "Didn't process %s" , leftBehind ) ; } }

Target:
public static void main ( java.lang.String [ ] args ) throws java.lang.Exception { java.nio.file.Path dumpDirectory = java.nio.file.Files.createTempDirectory ( "lambdas" ) ; java.lang.System.setProperty ( LambdaClassMaker.LAMBDA_METAFACTORY_DUMPER_PROPERTY , dumpDirectory.toString ( ) ) ; com.google.devtools.build.android.desugar.Desugar.deleteTreeOnExit ( dumpDirectory ) ; if ( ( ( args.length ) == 1 ) && ( args [ 0 ] . startsWith ( "@" ) ) ) { args = java.nio.file.Files.readAllLines ( java.nio.file.Paths.get ( args [ 0 ] . substring ( 1 ) ) , java.nio.charset.StandardCharsets.ISO_8859_1 ) . toArray ( new java.lang.String [ 0 ] ) ; } com.google.devtools.common.options.OptionsParser optionsParser = com.google.devtools.common.options.OptionsParser.newOptionsParser ( com.google.devtools.build.android.desugar.Desugar.Options.class ) ; optionsParser.parseAndExitUponError ( args ) ; com.google.devtools.build.android.desugar.Desugar.Options options = optionsParser.getOptions ( com.google.devtools.build.android.desugar.Desugar.Options.class ) ; if ( options.verbose ) { java.lang.System.out.printf ( "Lambda classes will be written under %s%n" , dumpDirectory ) ; } boolean allowDefaultMethods = ( options.minSdkVersion ) >= 24 ; java.lang.ClassLoader parent ; if ( ( options.bootclasspath.isEmpty ( ) ) && ( ! ( options.allowEmptyBootclasspath ) ) ) { parent = java.lang.ClassLoader.getSystemClassLoader ( ) ; } else { parent = new com.google.devtools.build.android.desugar.Desugar.ThrowingClassLoader ( ) ; } java.lang.String prefix = "" ; if ( options.coreLibrary ) { prefix = "__desugar__/" ; } com.google.devtools.build.android.desugar.CoreLibraryRewriter rewriter = new com.google.devtools.build.android.desugar.CoreLibraryRewriter ( prefix ) ; java.lang.ClassLoader loader = com.google.devtools.build.android.desugar.Desugar.createClassLoader ( rewriter , options.bootclasspath , options.inputJar , options.classpath , parent ) ; try ( java.util.zip.ZipFile in = new java.util.zip.ZipFile ( options.inputJar.toFile ( ) ) ; java.util.zip.ZipOutputStream out = new java.util.zip.ZipOutputStream ( new java.io.BufferedOutputStream ( java.nio.file.Files.newOutputStream ( options.outputJar ) ) ) ) { com.google.devtools.build.android.desugar.LambdaClassMaker lambdas = new com.google.devtools.build.android.desugar.LambdaClassMaker ( dumpDirectory ) ; com.google.devtools.build.android.desugar.ClassReaderFactory readerFactory = new com.google.devtools.build.android.desugar.ClassReaderFactory ( in , rewriter ) ; com.google.common.collect.ImmutableSet.Builder < java.lang.String > interfaceLambdaMethodCollector = com.google.common.collect.ImmutableSet.builder ( ) ; for ( java.util.Enumeration < ? extends java.util.zip.ZipEntry > entries = in.entries ( ) ; entries.hasMoreElements ( ) ; ) { java.util.zip.ZipEntry entry = entries.nextElement ( ) ; try ( java.io.InputStream content = in.getInputStream ( entry ) ) { if ( entry.getName ( ) . endsWith ( ".class" ) ) { org.objectweb.asm.ClassReader reader = rewriter.reader ( content ) ; com.google.devtools.build.android.desugar.CoreLibraryRewriter.Writer writer = rewriter.writer ( ClassWriter.COMPUTE_MAXS ) ; org.objectweb.asm.ClassVisitor visitor = writer ; if ( ! allowDefaultMethods ) { visitor = new com.google.devtools.build.android.desugar.Java7Compatibility ( visitor , readerFactory ) ; } visitor = new com.google.devtools.build.android.desugar.LambdaDesugaring ( visitor , loader , lambdas , interfaceLambdaMethodCollector , allowDefaultMethods ) ; reader.accept ( visitor , 0 ) ; java.lang.String name = entry.getName ( ) ; name = rewriter.unprefix ( name ) ; com.google.devtools.build.android.desugar.Desugar.writeStoredEntry ( out , name , writer.toByteArray ( ) ) ; } else { java.util.zip.ZipEntry destEntry = new java.util.zip.ZipEntry ( entry ) ; destEntry.setCompressedSize ( ( - 1 ) ) ; out.putNextEntry ( destEntry ) ; com.google.common.io.ByteStreams.copy ( content , out ) ; out.closeEntry ( ) ; } } } com.google.common.collect.ImmutableSet < java.lang.String > interfaceLambdaMethods = interfaceLambdaMethodCollector.build ( ) ; if ( allowDefaultMethods ) { com.google.common.base.Preconditions.checkState ( interfaceLambdaMethods.isEmpty ( ) , "Desugaring with default methods enabled moved interface lambdas" ) ; } for ( java.util.Map.Entry < java.nio.file.Path , com.google.devtools.build.android.desugar.LambdaInfo > lambdaClass : lambdas.drain ( ) . entrySet ( ) ) { try ( java.io.InputStream bytecode = java.nio.file.Files.newInputStream ( dumpDirectory.resolve ( lambdaClass.getKey ( ) ) ) ) { org.objectweb.asm.ClassReader reader = rewriter.reader ( bytecode ) ; com.google.devtools.build.android.desugar.CoreLibraryRewriter.Writer writer = rewriter.writer ( ClassWriter.COMPUTE_MAXS ) ; org.objectweb.asm.ClassVisitor visitor = writer ; if ( ! allowDefaultMethods ) { visitor = new com.google.devtools.build.android.desugar.Java7Compatibility ( visitor , null ) ; } com.google.devtools.build.android.desugar.LambdaClassFixer lambdaFixer = new com.google.devtools.build.android.desugar.LambdaClassFixer ( visitor , lambdaClass.getValue ( ) , readerFactory , interfaceLambdaMethods , allowDefaultMethods ) ; reader.accept ( new com.google.devtools.build.android.desugar.LambdaDesugaring ( lambdaFixer , loader , lambdas , null , allowDefaultMethods ) , 0 ) ; java.lang.String name = ( lambdaFixer.getInternalName ( ) ) + ".class" ; name = rewriter.unprefix ( name ) ; com.google.devtools.build.android.desugar.Desugar.writeStoredEntry ( out , name , writer.toByteArray ( ) ) ; } } java.util.Map < java.nio.file.Path , com.google.devtools.build.android.desugar.LambdaInfo > leftBehind = lambdas.drain ( ) ; com.google.common.base.Preconditions.checkState ( leftBehind.isEmpty ( ) , "Didn't process %s" , leftBehind ) ; } }