From a628fb9396d10cfbeb03c88cb1c2c119ae202a21 Mon Sep 17 00:00:00 2001 From: jeff Date: Thu, 18 Sep 2014 22:41:25 -0400 Subject: fixed crash with jar loading --- src/cuchaz/enigma/bytecode/ClassRenamer.java | 20 ++++++++++++++++++-- src/cuchaz/enigma/mapping/ClassEntry.java | 4 ++-- 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/cuchaz/enigma/bytecode/ClassRenamer.java b/src/cuchaz/enigma/bytecode/ClassRenamer.java index efe22a1..86a0433 100644 --- a/src/cuchaz/enigma/bytecode/ClassRenamer.java +++ b/src/cuchaz/enigma/bytecode/ClassRenamer.java @@ -74,7 +74,7 @@ public class ClassRenamer } } - public static Set getAllClassEntries( CtClass c ) + public static Set getAllClassEntries( final CtClass c ) { // get the classes that javassist knows about final Set entries = Sets.newHashSet(); @@ -85,7 +85,23 @@ public class ClassRenamer { if( obj instanceof String ) { - entries.add( new ClassEntry( (String)obj ) ); + String str = (String)obj; + + // javassist throws a lot of weird things at this map + // I either have to implement my on class scanner, or just try to filter out the weirdness + // I'm opting to filter out the weirdness for now + + // skip anything with generic arguments + if( str.indexOf( '<' ) >= 0 || str.indexOf( '>' ) >= 0 || str.indexOf( ';' ) >= 0 ) + { + return null; + } + + // convert path/to/class.inner to path/to/class$inner + str = str.replace( '.', '$' ); + + // remember everything else + entries.add( new ClassEntry( str ) ); } return null; } diff --git a/src/cuchaz/enigma/mapping/ClassEntry.java b/src/cuchaz/enigma/mapping/ClassEntry.java index f8477c9..c6faa50 100644 --- a/src/cuchaz/enigma/mapping/ClassEntry.java +++ b/src/cuchaz/enigma/mapping/ClassEntry.java @@ -27,14 +27,14 @@ public class ClassEntry implements Entry, Serializable } if( className.indexOf( '.' ) >= 0 ) { - throw new IllegalArgumentException( "Class name must be in JVM format. ie, path/to/package/class$inner" ); + throw new IllegalArgumentException( "Class name must be in JVM format. ie, path/to/package/class$inner : " + className ); } m_name = className; if( isInnerClass() && getInnerClassName().indexOf( '/' ) >= 0 ) { - throw new IllegalArgumentException( "Inner class must not have a package: " + getInnerClassName() ); + throw new IllegalArgumentException( "Inner class must not have a package: " + className ); } } -- cgit v1.2.3