Skip to content

Commit

Permalink
ecd-plugin#10 Updated Fernflower to community version 352
Browse files Browse the repository at this point in the history
  • Loading branch information
pbi-qfs committed Jun 15, 2018
1 parent a608de6 commit eeff544
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 15 deletions.
7 changes: 4 additions & 3 deletions AUDIT.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ _Primary Source: https://commons.apache.org/downloads/index.html_

### Fernflower
_Primary Source: https://github.com/JetBrains/intellij-community/tree/master/plugins/java-decompiler/engine_
* `./org.sf.feeling.decompiler/lib/fernflower.jar`
* SHA-256: 598321f62b394b01bfd0f2a14dc28ccca50704f64ac15a1cb18fb2613aec3763
* Version from http://central.maven.org/maven2/org/jboss/windup/decompiler/fernflower/fernflower/2.5.0.Final/fernflower-2.5.0.Final.jar
_Build Source: https://github.com/MinecraftForge/FernFlower with builds at http://files.minecraftforge.net/maven/net/minecraftforge/fernflower/_
* `./org.sf.feeling.decompiler/lib/fernflower-352.jar`
* SHA-256: 799e1e968613abdb74a61bebb08c49132cde5c6eb8d8e5c80a768bfb57a44785
* Version from http://files.minecraftforge.net/maven/net/minecraftforge/fernflower/352/fernflower-352.jar

### Minimal JSON
_Primary Source: https://github.com/ralfstx/minimal-json_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@

import java.io.File;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.jetbrains.java.decompiler.main.DecompilerContext;
import org.jetbrains.java.decompiler.main.collectors.CounterContainer;
import org.jetbrains.java.decompiler.struct.StructClass;
import org.jetbrains.java.decompiler.struct.lazy.LazyLoader;
import org.sf.feeling.decompiler.JavaDecompilerPlugin;
Expand Down Expand Up @@ -66,8 +63,6 @@ public void decompile( String root, String classPackage, String className )
{
if ( classPackage.length( ) == 0 )
{
DecompilerContext.initContext( new HashMap<String, Object>( ) );
DecompilerContext.setCounterContainer( new CounterContainer( ) );
StructClass structClass = new StructClass( FileUtil.getBytes( new File( root, className ) ),
true,
new LazyLoader( null ) );
Expand Down
2 changes: 1 addition & 1 deletion org.sf.feeling.decompiler/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib" path="lib/commons-codec-1.5.jar" sourcepath="C:/Users/Feeling/AppData/Local/Temp/decompiler/source/commons-codec-1.5-sources-1495079853335.jar"/>
<classpathentry exported="true" kind="lib" path="lib/fernflower.jar"/>
<classpathentry exported="true" kind="lib" path="lib/fernflower-352.jar"/>
<classpathentry exported="true" kind="lib" path="lib/json.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jsoup.jar" sourcepath="C:/Users/Feeling/AppData/Local/Temp/decompiler/source/jsoup-1.9.2-sources-1495082896849.jar"/>
<classpathentry kind="lib" path="lib/com.drgarbage.asm_5.0.3.jar"/>
Expand Down
2 changes: 1 addition & 1 deletion org.sf.feeling.decompiler/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: lib/commons-codec-1.5.jar,
lib/fernflower.jar,
lib/fernflower-352.jar,
lib/json.jar,
lib/jsoup.jar,
library.jar,
Expand Down
Binary file added org.sf.feeling.decompiler/lib/fernflower-352.jar
Binary file not shown.
Binary file removed org.sf.feeling.decompiler/lib/fernflower.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@

package org.sf.feeling.decompiler.fernflower;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FilenameFilter;
import java.io.PrintStream;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
Expand All @@ -18,6 +20,7 @@
import java.util.regex.Pattern;

import org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler;
import org.jetbrains.java.decompiler.main.decompiler.PrintStreamLogger;
import org.jetbrains.java.decompiler.main.extern.IFernflowerLogger;
import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences;
import org.sf.feeling.decompiler.JavaDecompilerPlugin;
Expand All @@ -34,6 +37,8 @@ public class FernFlowerDecompiler implements IDecompiler
private String source = ""; // $NON-NLS-1$ //$NON-NLS-1$
private long time, start;
private String log = ""; //$NON-NLS-1$

ByteArrayOutputStream loggerStream;

/**
* Performs a <code>Runtime.exec()</code> on jad executable with selected
Expand All @@ -50,9 +55,12 @@ public void decompile( String root, String packege, final String className )
start = System.currentTimeMillis( );
log = ""; //$NON-NLS-1$
source = ""; //$NON-NLS-1$

loggerStream = new ByteArrayOutputStream( );

File workingDir = new File( root + "/" + packege ); //$NON-NLS-1$

Map<String, Object> mapOptions = new HashMap<String, Object>( );
final Map<String, Object> mapOptions = new HashMap<String, Object>( );

mapOptions.put( IFernflowerPreferences.REMOVE_SYNTHETIC, "1" ); //$NON-NLS-1$
mapOptions.put( IFernflowerPreferences.DECOMPILE_GENERIC_SIGNATURES, "1" ); //$NON-NLS-1$
Expand All @@ -66,13 +74,25 @@ public void decompile( String root, String packege, final String className )
mapOptions.put( IFernflowerPreferences.BYTECODE_SOURCE_MAPPING, "1" ); //$NON-NLS-1$
}

File tmpDir = new File( System.getProperty( "java.io.tmpdir" ), //$NON-NLS-1$
final File tmpDir = new File( System.getProperty( "java.io.tmpdir" ), //$NON-NLS-1$
String.valueOf( System.currentTimeMillis( ) ) );

if ( !tmpDir.exists( ) )
tmpDir.mkdirs( );

ConsoleDecompiler decompiler = new ConsoleDecompiler( tmpDir, mapOptions );
// Work around protected constructor
class EmbeddedConsoleDecompiler extends ConsoleDecompiler {

protected EmbeddedConsoleDecompiler()
{
super( tmpDir,
mapOptions ,
new PrintStreamLogger(new PrintStream( loggerStream )));
}

}
ConsoleDecompiler decompiler = new EmbeddedConsoleDecompiler();

File[] files = workingDir.listFiles( new FilenameFilter( ) {

@Override
Expand All @@ -87,7 +107,7 @@ public boolean accept( File dir, String name )
{
for ( int j = 0; j < files.length; j++ )
{
decompiler.addSpace( files[j], true );
decompiler.addSource( files[j] );
}
}

Expand Down Expand Up @@ -172,6 +192,9 @@ public List getExceptions( )
@Override
public String getLog( )
{
if (loggerStream != null) {
return log + loggerStream.toString( );
}
return log;
}

Expand Down
2 changes: 1 addition & 1 deletion org.sf.feeling.decompiler/target/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Export-Package: com.eclipsesource.json,org.jetbrains.java.decompiler.m
ng.decompiler.util
Bundle-Name: Enhanced Class Decompiler
Bundle-Version: 3.0.0.201806130753
Bundle-ClassPath: lib/commons-codec-1.5.jar,lib/fernflower.jar,lib/jso
Bundle-ClassPath: lib/commons-codec-1.5.jar,lib/fernflower-352.jar,lib/jso
n.jar,lib/jsoup.jar,library.jar,lib/com.drgarbage.asm_5.0.3.jar,lib/c
om.drgarbage.asm.util_5.0.3.jar,.
Bundle-Localization: plugin
Expand Down

0 comments on commit eeff544

Please sign in to comment.