private static IIdentifierRenamer loadHelper(String className, IFernflowerLogger logger) { if (className != null) { try { Class<?> renamerClass = Fernflower.class.getClassLoader().loadClass(className); return (IIdentifierRenamer) renamerClass.getDeclaredConstructor().newInstance(); } catch (Exception e) { logger.writeMessage("Cannot load renamer '" + className + "'", IFernflowerLogger.Severity.WARN, e); } } return new ConverterHelper(); }
private static void doTest(Type elementType, String className, String element, String descriptor, boolean shallBeRenamed) { boolean result = new ConverterHelper().toBeRenamed(elementType, className, element, descriptor); String assertionMessage = shallBeRenamed ? "Identifier { %s, %s, %s, %s } shall be renamed" : "Identifier { %s, %s, %s, %s } shall not be renamed"; assertTrue(String.format(assertionMessage, elementType.toString(), className, element, descriptor), result == shallBeRenamed); } }
public void rename(StructContext context) { try { this.context = context; String user_class = (String)DecompilerContext.getProperty(IFernflowerPreferences.USER_RENAMER_CLASS); if (user_class != null) { try { helper = (IIdentifierRenamer)IdentifierConverter.class.getClassLoader().loadClass(user_class).newInstance(); } catch (Exception ignored) { } } if (helper == null) { helper = new ConverterHelper(); } interceptor = new PoolInterceptor(helper); buildInheritanceTree(); renameAllClasses(); renameInterfaces(); renameClasses(); DecompilerContext.setPoolInterceptor(interceptor); context.reloadContext(); } catch (IOException ex) { throw new RuntimeException("Renaming failed!"); } }