本文整理匯總了Java中cuchaz.enigma.mapping.ClassNameReplacer類的典型用法代碼示例。如果您正苦於以下問題:Java ClassNameReplacer類的具體用法?Java ClassNameReplacer怎麽用?Java ClassNameReplacer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ClassNameReplacer類屬於cuchaz.enigma.mapping包,在下文中一共展示了ClassNameReplacer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: replaceArrayClasses
import cuchaz.enigma.mapping.ClassNameReplacer; //導入依賴的package包/類
@Test
public void replaceArrayClasses() {
{
final Signature oldSig = new Signature("([LFoo;)[[[LBar;");
final Signature sig = new Signature(oldSig, new ClassNameReplacer() {
@Override
public String replace(String val) {
if (val.equals("Foo")) {
return "Food";
} else if (val.equals("Bar")) {
return "Beer";
}
return null;
}
});
assertThat(sig.getArgumentTypes(), contains(
new Type("[LFood;")
));
assertThat(sig.getReturnType(), is(new Type("[[[LBeer;")));
}
}
示例2: replaceArrayClasses
import cuchaz.enigma.mapping.ClassNameReplacer; //導入依賴的package包/類
@Test
public void replaceArrayClasses()
{
{
final Signature oldSig = new Signature("([LFoo;)[[[LBar;");
final Signature sig = new Signature(oldSig, new ClassNameReplacer()
{
@Override
public String replace(String val)
{
if(val.equals("Foo"))
return "Food";
else if(val.equals("Bar"))
return "Beer";
return null;
}
});
assertThat(sig.getArgumentTypes(), contains(new Type("[LFood;")));
assertThat(sig.getReturnType(), is(new Type("[[[LBeer;")));
}
}
示例3: moveClasssesOutOfDefaultPackage
import cuchaz.enigma.mapping.ClassNameReplacer; //導入依賴的package包/類
private static Type moveClasssesOutOfDefaultPackage(Type type) {
return new Type(type, new ClassNameReplacer() {
@Override
public String replace(String className) {
ClassEntry entry = new ClassEntry(className);
if (entry.isInDefaultPackage()) {
return Constants.NonePackage + "/" + className;
}
return null;
}
});
}
示例4: translate
import cuchaz.enigma.mapping.ClassNameReplacer; //導入依賴的package包/類
private static Type translate(Type type, final BiMap<ClassEntry,ClassEntry> map) {
return new Type(type, new ClassNameReplacer() {
@Override
public String replace(String inClassName) {
ClassEntry outClassEntry = map.get(new ClassEntry(inClassName));
if (outClassEntry == null) {
return null;
}
return outClassEntry.getName();
}
});
}
示例5: renameClasses
import cuchaz.enigma.mapping.ClassNameReplacer; //導入依賴的package包/類
public static void renameClasses(CtClass c, final Translator translator) {
renameClasses(c, new ClassNameReplacer() {
@Override
public String replace(String className) {
ClassEntry entry = translator.translateEntry(new ClassEntry(className));
if (entry != null) {
return entry.getName();
}
return null;
}
});
}
示例6: moveAllClassesOutOfDefaultPackage
import cuchaz.enigma.mapping.ClassNameReplacer; //導入依賴的package包/類
public static void moveAllClassesOutOfDefaultPackage(CtClass c, final String newPackageName) {
renameClasses(c, new ClassNameReplacer() {
@Override
public String replace(String className) {
ClassEntry entry = new ClassEntry(className);
if (entry.isInDefaultPackage()) {
return newPackageName + "/" + entry.getName();
}
return null;
}
});
}
示例7: moveAllClassesIntoDefaultPackage
import cuchaz.enigma.mapping.ClassNameReplacer; //導入依賴的package包/類
public static void moveAllClassesIntoDefaultPackage(CtClass c, final String oldPackageName) {
renameClasses(c, new ClassNameReplacer() {
@Override
public String replace(String className) {
ClassEntry entry = new ClassEntry(className);
if (entry.getPackageName().equals(oldPackageName)) {
return entry.getSimpleName();
}
return null;
}
});
}
示例8: renameClasses
import cuchaz.enigma.mapping.ClassNameReplacer; //導入依賴的package包/類
public static void renameClasses(CtClass c, final Translator translator)
{
renameClasses(c, new ClassNameReplacer()
{
@Override
public String replace(String className)
{
ClassEntry entry =
translator.translateEntry(new ClassEntry(className));
if(entry != null)
return entry.getName();
return null;
}
});
}
示例9: moveAllClassesOutOfDefaultPackage
import cuchaz.enigma.mapping.ClassNameReplacer; //導入依賴的package包/類
public static void moveAllClassesOutOfDefaultPackage(CtClass c,
final String newPackageName)
{
renameClasses(c, new ClassNameReplacer()
{
@Override
public String replace(String className)
{
ClassEntry entry = new ClassEntry(className);
if(entry.isInDefaultPackage())
return newPackageName + "/" + entry.getName();
return null;
}
});
}
示例10: moveAllClassesIntoDefaultPackage
import cuchaz.enigma.mapping.ClassNameReplacer; //導入依賴的package包/類
public static void moveAllClassesIntoDefaultPackage(CtClass c,
final String oldPackageName)
{
renameClasses(c, new ClassNameReplacer()
{
@Override
public String replace(String className)
{
ClassEntry entry = new ClassEntry(className);
if(entry.getPackageName().equals(oldPackageName))
return entry.getSimpleName();
return null;
}
});
}
示例11: migrateClassMapping
import cuchaz.enigma.mapping.ClassNameReplacer; //導入依賴的package包/類
private static ClassMapping migrateClassMapping(ClassEntry newObfClass, ClassMapping oldClassMapping, final ClassMatches matches, boolean useSimpleName) {
ClassNameReplacer replacer = new ClassNameReplacer() {
@Override
public String replace(String className) {
ClassEntry newClassEntry = matches.getUniqueMatches().get(new ClassEntry(className));
if (newClassEntry != null) {
return newClassEntry.getName();
}
return null;
}
};
ClassMapping newClassMapping;
String deobfName = oldClassMapping.getDeobfName();
if (deobfName != null) {
if (useSimpleName) {
deobfName = new ClassEntry(deobfName).getSimpleName();
}
newClassMapping = new ClassMapping(newObfClass.getName(), deobfName);
} else {
newClassMapping = new ClassMapping(newObfClass.getName());
}
// migrate fields
for (FieldMapping oldFieldMapping : oldClassMapping.fields()) {
if (canMigrate(oldFieldMapping.getObfType(), matches)) {
newClassMapping.addFieldMapping(new FieldMapping(oldFieldMapping, replacer));
} else {
System.out.println(String.format("Can't map field, dropping: %s.%s %s",
oldClassMapping.getDeobfName(),
oldFieldMapping.getDeobfName(),
oldFieldMapping.getObfType()
));
}
}
// migrate methods
for (MethodMapping oldMethodMapping : oldClassMapping.methods()) {
if (canMigrate(oldMethodMapping.getObfSignature(), matches)) {
newClassMapping.addMethodMapping(new MethodMapping(oldMethodMapping, replacer));
} else {
System.out.println(String.format("Can't map method, dropping: %s.%s %s",
oldClassMapping.getDeobfName(),
oldMethodMapping.getDeobfName(),
oldMethodMapping.getObfSignature()
));
}
}
return newClassMapping;
}
示例12: ReplacerClassMap
import cuchaz.enigma.mapping.ClassNameReplacer; //導入依賴的package包/類
public ReplacerClassMap(ClassNameReplacer replacer) {
m_replacer = replacer;
}
示例13: ReplacerClassMap
import cuchaz.enigma.mapping.ClassNameReplacer; //導入依賴的package包/類
public ReplacerClassMap(ClassNameReplacer replacer) {
m_replacer = replacer;
}
示例14: renameClasses
import cuchaz.enigma.mapping.ClassNameReplacer; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public static void renameClasses(CtClass c, ClassNameReplacer replacer) {
// sadly, we can't use CtClass.renameClass() because SignatureAttribute.renameClass() is extremely buggy =(
ReplacerClassMap map = new ReplacerClassMap(replacer);
ClassFile classFile = c.getClassFile();
// rename the constant pool (covers ClassInfo, MethodTypeInfo, and NameAndTypeInfo)
ConstPool constPool = c.getClassFile().getConstPool();
constPool.renameClass(map);
// rename class attributes
renameAttributes(classFile.getAttributes(), map, SignatureType.Class);
// rename methods
for (MethodInfo methodInfo : (List<MethodInfo>) classFile.getMethods()) {
methodInfo.setDescriptor(Descriptor.rename(methodInfo.getDescriptor(), map));
renameAttributes(methodInfo.getAttributes(), map, SignatureType.Method);
}
// rename fields
for (FieldInfo fieldInfo : (List<FieldInfo>) classFile.getFields()) {
fieldInfo.setDescriptor(Descriptor.rename(fieldInfo.getDescriptor(), map));
renameAttributes(fieldInfo.getAttributes(), map, SignatureType.Field);
}
// rename the class name itself last
// NOTE: don't use the map here, because setName() calls the buggy SignatureAttribute.renameClass()
// we only want to replace exactly this class name
String newName = renameClassName(c.getName(), map);
if (newName != null) {
c.setName(newName);
}
// replace simple names in the InnerClasses attribute too
InnerClassesAttribute attr = (InnerClassesAttribute) c.getClassFile().getAttribute(InnerClassesAttribute.tag);
if (attr != null) {
for (int i = 0; i < attr.tableLength(); i++) {
// get the inner class full name (which has already been translated)
ClassEntry classEntry = new ClassEntry(Descriptor.toJvmName(attr.innerClass(i)));
if (attr.innerNameIndex(i) != 0) {
// update the inner name
attr.setInnerNameIndex(i, constPool.addUtf8Info(classEntry.getInnermostClassName()));
}
/* DEBUG
System.out.println(String.format("\tDEOBF: %s-> ATTR: %s,%s,%s", classEntry, attr.outerClass(i), attr.innerClass(i), attr.innerName(i)));
*/
}
}
}
示例15: ReplacerClassMap
import cuchaz.enigma.mapping.ClassNameReplacer; //導入依賴的package包/類
public ReplacerClassMap(ClassNameReplacer replacer)
{
m_replacer = replacer;
}