mirror of
https://github.com/Skid-Technology/OpenAllatori.git
synced 2026-11-06 15:56:01 +02:00
added files.
This commit is contained in:
commit
78e95549f0
629 files changed
+77256
No files matched your search
@@ -0,0 +1,75 @@
|
||||
package com.allatori;
|
||||
|
||||
import com.allatori.cli.ObfuscationCommandSupport;
|
||||
import com.allatori.config.Configuration;
|
||||
import com.allatori.engine.ObfuscationEngine;
|
||||
import com.allatori.engine.ObfuscationException;
|
||||
import com.allatori.model.ClassStorage;
|
||||
import com.allatori.naming.MappingXmlWriter;
|
||||
import com.allatori.util.Log;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Obfuscate extends ObfuscationCommandSupport {
|
||||
|
||||
public static void obfuscate(ClassStorage classStorage) {
|
||||
new ObfuscationEngine(classStorage).obfuscate();
|
||||
}
|
||||
|
||||
public static void runObfuscation()
|
||||
throws IOException, ObfuscationException, ClassNotFoundException {
|
||||
ClassStorage classStorage;
|
||||
obfuscate(classStorage = createClassStorage());
|
||||
if (Configuration.getWatermarkOptions().getText2() != null
|
||||
&& Configuration.getWatermarkOptions().getText() != null) {
|
||||
addWatermark(classStorage);
|
||||
}
|
||||
if (Configuration.getObfuscationOptions().isJava6Enabled()) {
|
||||
limitClassVersion(classStorage);
|
||||
}
|
||||
writeAllOutputs(classStorage);
|
||||
Log.info2("Obfuscation completed. Writing log file...");
|
||||
MappingXmlWriter.update();
|
||||
}
|
||||
|
||||
public static void main(String[] texts) {
|
||||
String[] texts2;
|
||||
if (texts.length > 1 && "-silent".equals(texts[1])) {
|
||||
Log.setSilent(true);
|
||||
texts2 = texts;
|
||||
} else {
|
||||
System.out.println(getBanner());
|
||||
texts2 = texts;
|
||||
}
|
||||
if (texts2.length != 1 && !Log.isSilent()) {
|
||||
printUsage();
|
||||
System.exit(0);
|
||||
}
|
||||
if (!loadConfigurationSafely(texts[0])) {
|
||||
System.exit(-1);
|
||||
}
|
||||
try {
|
||||
runObfuscation();
|
||||
} catch (Exception exception) {
|
||||
Log.error(exception.getMessage());
|
||||
System.out.println(
|
||||
"############### EXCEPTION (" + VersionInfo.getVersion() + ") ###############");
|
||||
exception.printStackTrace();
|
||||
System.out.println("#################################################");
|
||||
System.exit(-1);
|
||||
}
|
||||
Configuration.update();
|
||||
}
|
||||
|
||||
public static void printUsage() {
|
||||
System.out.println("" + VersionInfo.getProductName() + " " + VersionInfo.getVersion());
|
||||
System.out.println("Usage:");
|
||||
System.out.println("com.allatori.Obfuscate <config file>");
|
||||
}
|
||||
|
||||
public static void run(File file) throws Exception {
|
||||
loadConfiguration(file.getPath());
|
||||
runObfuscation();
|
||||
Configuration.update();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.allatori;
|
||||
|
||||
import com.allatori.cli.ObfuscationCommandSupport;
|
||||
import com.allatori.stacktrace.MappingXmlReader;
|
||||
import com.allatori.stacktrace.StackTraceMappings;
|
||||
import com.allatori.stacktrace.StackTraceRestorer;
|
||||
import com.allatori.util.Log;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
public class StackTrace {
|
||||
|
||||
public static void printUsage() {
|
||||
System.out.println("Restore Stack Trace Utility");
|
||||
System.out.println("Usage:");
|
||||
System.out.println("com.allatori.StackTrace <log file> <input file> <output file>");
|
||||
}
|
||||
|
||||
public static String restoreStackTrace(File file, String text)
|
||||
throws FileNotFoundException,
|
||||
UnsupportedEncodingException,
|
||||
IOException,
|
||||
ParserConfigurationException,
|
||||
SAXException {
|
||||
StackTraceMappings stackTraceMappings =
|
||||
MappingXmlReader.createStackTraceMappings(
|
||||
new InputStreamReader(new FileInputStream(file), "UTF-8"));
|
||||
BufferedReader bufferedReader = new BufferedReader(new StringReader(text));
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
PrintWriter printWriter = new PrintWriter(stringWriter);
|
||||
StackTraceRestorer.processPrintWriter(bufferedReader, stackTraceMappings, printWriter);
|
||||
bufferedReader.close();
|
||||
printWriter.close();
|
||||
return stringWriter.toString();
|
||||
}
|
||||
|
||||
public static void main(String[] texts) {
|
||||
BufferedReader bufferedReader;
|
||||
System.out.println(ObfuscationCommandSupport.getBanner());
|
||||
try {
|
||||
if (texts.length != 3) {
|
||||
printUsage();
|
||||
System.exit(0);
|
||||
}
|
||||
StackTraceMappings stackTraceMappings = null;
|
||||
String text = texts[0];
|
||||
String[] texts2;
|
||||
label39:
|
||||
{
|
||||
try {
|
||||
stackTraceMappings =
|
||||
MappingXmlReader.createStackTraceMappings(
|
||||
new InputStreamReader(new FileInputStream(text), "UTF-8"));
|
||||
} catch (FileNotFoundException fileNotFoundException) {
|
||||
Log.error("Log file not found: " + fileNotFoundException.getMessage());
|
||||
System.exit(0);
|
||||
texts2 = texts;
|
||||
break label39;
|
||||
} catch (Exception exception) {
|
||||
Log.error("Error reading log file: " + exception.getMessage());
|
||||
System.exit(0);
|
||||
texts2 = texts;
|
||||
break label39;
|
||||
}
|
||||
texts2 = texts;
|
||||
}
|
||||
String text2 = texts2[1];
|
||||
String text3 = texts[2];
|
||||
BufferedReader bufferedReader2 = null;
|
||||
try {
|
||||
bufferedReader2 = new BufferedReader(new FileReader(text2));
|
||||
} catch (FileNotFoundException fileNotFoundException2) {
|
||||
Log.error("Input file not found: " + fileNotFoundException2.getMessage());
|
||||
System.exit(0);
|
||||
}
|
||||
PrintWriter printWriter = null;
|
||||
label34:
|
||||
{
|
||||
try {
|
||||
printWriter = new PrintWriter(new BufferedWriter(new FileWriter(text3)));
|
||||
} catch (IOException oException) {
|
||||
Log.error("Error writing output file: " + oException.getMessage());
|
||||
System.exit(0);
|
||||
bufferedReader = bufferedReader2;
|
||||
break label34;
|
||||
}
|
||||
bufferedReader = bufferedReader2;
|
||||
}
|
||||
StackTraceRestorer.processPrintWriter(bufferedReader, stackTraceMappings, printWriter);
|
||||
bufferedReader2.close();
|
||||
printWriter.close();
|
||||
} catch (Exception exception2) {
|
||||
System.out.println("Error: " + exception2.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.allatori;
|
||||
|
||||
import com.allatori.cli.ObfuscationCommandSupport;
|
||||
import com.allatori.stacktrace.MappingXmlReader;
|
||||
import com.allatori.stacktrace.StackTraceMappings;
|
||||
import com.allatori.stacktrace.StackTraceRestorer;
|
||||
import com.allatori.util.Log;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
public class StackTrace2 {
|
||||
|
||||
public static String restoreStackTrace(File file, String text)
|
||||
throws FileNotFoundException,
|
||||
UnsupportedEncodingException,
|
||||
IOException,
|
||||
ParserConfigurationException,
|
||||
SAXException {
|
||||
StackTraceMappings stackTraceMappings =
|
||||
MappingXmlReader.createStackTraceMappings(
|
||||
new InputStreamReader(new FileInputStream(file), "UTF-8"));
|
||||
BufferedReader bufferedReader = new BufferedReader(new StringReader(text));
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
PrintWriter printWriter = new PrintWriter(stringWriter);
|
||||
StackTraceRestorer.processPrintWriter2(bufferedReader, stackTraceMappings, printWriter);
|
||||
bufferedReader.close();
|
||||
printWriter.close();
|
||||
return stringWriter.toString();
|
||||
}
|
||||
|
||||
public static void printUsage() {
|
||||
System.out.println("Restore Stack Trace Utility");
|
||||
System.out.println("Usage:");
|
||||
System.out.println("com.allatori.StackTrace2 <log file> <input file> <output file>");
|
||||
}
|
||||
|
||||
public static void main(String[] texts) {
|
||||
BufferedReader bufferedReader;
|
||||
System.out.println(ObfuscationCommandSupport.getBanner());
|
||||
try {
|
||||
if (texts.length != 3) {
|
||||
printUsage();
|
||||
System.exit(0);
|
||||
}
|
||||
StackTraceMappings stackTraceMappings = null;
|
||||
String text = texts[0];
|
||||
String[] texts2;
|
||||
label39:
|
||||
{
|
||||
try {
|
||||
stackTraceMappings =
|
||||
MappingXmlReader.createStackTraceMappings(
|
||||
new InputStreamReader(new FileInputStream(text), "UTF-8"));
|
||||
} catch (FileNotFoundException fileNotFoundException) {
|
||||
Log.error("Log file not found: " + fileNotFoundException.getMessage());
|
||||
System.exit(0);
|
||||
texts2 = texts;
|
||||
break label39;
|
||||
} catch (Exception exception) {
|
||||
Log.error("Error reading log file: " + exception.getMessage());
|
||||
System.exit(0);
|
||||
texts2 = texts;
|
||||
break label39;
|
||||
}
|
||||
texts2 = texts;
|
||||
}
|
||||
String text2 = texts2[1];
|
||||
String text3 = texts[2];
|
||||
BufferedReader bufferedReader2 = null;
|
||||
try {
|
||||
bufferedReader2 = new BufferedReader(new FileReader(text2));
|
||||
} catch (FileNotFoundException fileNotFoundException2) {
|
||||
Log.error("Input file not found: " + fileNotFoundException2.getMessage());
|
||||
System.exit(0);
|
||||
}
|
||||
PrintWriter printWriter = null;
|
||||
label34:
|
||||
{
|
||||
try {
|
||||
printWriter = new PrintWriter(new BufferedWriter(new FileWriter(text3)));
|
||||
} catch (IOException oException) {
|
||||
Log.error("Error writing output file: " + oException.getMessage());
|
||||
System.exit(0);
|
||||
bufferedReader = bufferedReader2;
|
||||
break label34;
|
||||
}
|
||||
bufferedReader = bufferedReader2;
|
||||
}
|
||||
StackTraceRestorer.processPrintWriter2(bufferedReader, stackTraceMappings, printWriter);
|
||||
bufferedReader2.close();
|
||||
printWriter.close();
|
||||
} catch (Exception exception2) {
|
||||
System.out.println("Error: " + exception2.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.allatori;
|
||||
|
||||
public class VersionInfo {
|
||||
|
||||
public static String getProductName() {
|
||||
return "OpenAllatori";
|
||||
}
|
||||
|
||||
public static String getVersion() {
|
||||
return "v9.9";
|
||||
}
|
||||
|
||||
public static String getWebsite() {
|
||||
return "https://github.com/Skid-Technology";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.allatori;
|
||||
|
||||
import com.allatori.cli.ObfuscationCommandSupport;
|
||||
import com.allatori.config.Configuration;
|
||||
import com.allatori.model.ClassStorage;
|
||||
import com.allatori.util.Log;
|
||||
|
||||
public class Watermark extends ObfuscationCommandSupport {
|
||||
|
||||
public static void main(String[] texts) {
|
||||
System.out.println(getBanner());
|
||||
if (texts.length != 2) {
|
||||
printUsage();
|
||||
System.exit(0);
|
||||
}
|
||||
byte value = 0;
|
||||
String[] texts2;
|
||||
if ("-add".equals(texts[0])) {
|
||||
value = 0;
|
||||
texts2 = texts;
|
||||
} else if ("-extract".equals(texts[0])) {
|
||||
value = 1;
|
||||
texts2 = texts;
|
||||
} else {
|
||||
printUsage();
|
||||
System.exit(0);
|
||||
texts2 = texts;
|
||||
}
|
||||
if (!loadConfigurationSafely(texts2[1], value != 0)) {
|
||||
System.exit(-1);
|
||||
}
|
||||
try {
|
||||
ClassStorage classStorage = Obfuscate.createClassStorage();
|
||||
if (Configuration.getWatermarkOptions().isEnabled()) {
|
||||
if (Configuration.getWatermarkOptions().getText2() == null) {
|
||||
Log.error("Configuration error. Watermark key is not set.");
|
||||
System.exit(0);
|
||||
}
|
||||
System.out.println("Extracted watermark: \"" + extractWatermark(classStorage) + "\"");
|
||||
} else {
|
||||
if (Configuration.getWatermarkOptions().getText2() == null) {
|
||||
Log.error("Configuration error. Watermark key is not set.");
|
||||
System.exit(0);
|
||||
}
|
||||
if (Configuration.getWatermarkOptions().getText() == null) {
|
||||
Log.error("Configuration error. Watermark value is not set.");
|
||||
System.exit(0);
|
||||
}
|
||||
addWatermark(classStorage);
|
||||
writeAllOutputs(classStorage);
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
Log.error(exception.getMessage());
|
||||
}
|
||||
Configuration.update();
|
||||
}
|
||||
|
||||
public static void printUsage() {
|
||||
System.out.println("" + VersionInfo.getProductName() + " " + VersionInfo.getVersion());
|
||||
System.out.println("Usage:");
|
||||
System.out.println("com.allatori.Watermark -add <config file>");
|
||||
System.out.println("or");
|
||||
System.out.println("com.allatori.Watermark -extract <config file>");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.allatori.ant;
|
||||
|
||||
import com.allatori.Obfuscate;
|
||||
import com.allatori.config.Configuration;
|
||||
import com.allatori.util.FileUtils;
|
||||
import java.io.File;
|
||||
import org.apache.tools.ant.BuildException;
|
||||
import org.apache.tools.ant.Task;
|
||||
|
||||
public class ObfuscatorTask extends Task {
|
||||
|
||||
public String config;
|
||||
|
||||
public void execute() {
|
||||
if (this.config == null) {
|
||||
throw new BuildException("Missing 'config' attribute.");
|
||||
}
|
||||
try {
|
||||
File file;
|
||||
if (!(file = new File(this.config)).canRead()) {
|
||||
throw new BuildException(("Cannot find configuration file: '" + this.config + "'"));
|
||||
}
|
||||
File file2 = new File(("" + this.config + ".resolved"));
|
||||
file2.deleteOnExit();
|
||||
String text = FileUtils.createText(file, "UTF-8");
|
||||
String text2 = this.getProject().replaceProperties(text);
|
||||
FileUtils.processText(file2, "UTF-8", text2);
|
||||
Configuration.processText(file2.getPath());
|
||||
Obfuscate.runObfuscation();
|
||||
Configuration.update();
|
||||
} catch (Exception exception) {
|
||||
throw new BuildException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public void setConfig(String config) {
|
||||
this.config = config;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,336 @@
|
||||
package com.allatori.bytecode;
|
||||
|
||||
import com.allatori.config.Configuration;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.lib.bcel.generic.MethodGen$2;
|
||||
import com.allatori.lib.bcel.generic.Type;
|
||||
import com.allatori.model.ClassStorage;
|
||||
import com.allatori.util.Log;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Collections;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.Vector;
|
||||
|
||||
public class ClassHierarchy {
|
||||
|
||||
public Hashtable entries;
|
||||
|
||||
public Hashtable entries2;
|
||||
|
||||
public Vector values;
|
||||
|
||||
public static final String TEXT = "-=404=-";
|
||||
|
||||
public static final Vector VALUES = new Vector();
|
||||
|
||||
public static final Set VALUES2 = new OrderedClassSet();
|
||||
|
||||
public ClassStorage classStorage;
|
||||
|
||||
public Set values2;
|
||||
|
||||
public Set createValues(Set values) {
|
||||
if (values.contains("-=404=-")) {
|
||||
return VALUES2;
|
||||
}
|
||||
TreeSet treeSet = new TreeSet();
|
||||
for (String text : ((Iterable<String>) ((Iterable<?>) values))) {
|
||||
if (this.classStorage.getClassGen(text) == null) {
|
||||
try {
|
||||
Method[] methods;
|
||||
for (int value =
|
||||
(methods =
|
||||
Class.forName(text, false, this.classStorage.getClassLoader())
|
||||
.getDeclaredMethods())
|
||||
.length
|
||||
- 1;
|
||||
value >= 0;
|
||||
value--) {
|
||||
Method method = methods[value];
|
||||
if (this.matchesMethod(method)) {
|
||||
treeSet.add(method.getName() + "&" + Type.getSignature(method));
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException classNotFoundException) {
|
||||
} catch (NoClassDefFoundError noClassDefFoundError) {
|
||||
String text2;
|
||||
if ((text2 = noClassDefFoundError.getMessage()).length() > 0) {
|
||||
String text3 = text2.replace('/', '.');
|
||||
if (!this.entries.containsKey(text3)) {
|
||||
this.entries.put(text3, "");
|
||||
Log.warn("Class '" + text3 + "' cannot be found.");
|
||||
}
|
||||
}
|
||||
} catch (VerifyError verifyError) {
|
||||
Log.warn(
|
||||
"Cannot read class. Possible JVM compile and runtime versions mismatch: "
|
||||
+ verifyError.getMessage());
|
||||
}
|
||||
} else {
|
||||
int value2;
|
||||
if (Configuration.getIgnoreClassesOptions()
|
||||
.matchesClassGen(this.classStorage, this.classStorage.getClassGen(text))) {
|
||||
com.allatori.lib.bcel.classfile.Method[] methods2;
|
||||
for (int value3 =
|
||||
value2 = (methods2 = this.classStorage.getClassGen(text).getMethods()).length - 1;
|
||||
value3 >= 0;
|
||||
value3 = --value2) {
|
||||
com.allatori.lib.bcel.classfile.Method method2;
|
||||
if (!(method2 = methods2[value2]).isEnabled9() && !method2.isEnabled11()) {
|
||||
treeSet.add("" + method2.getText() + "&" + method2.getText2());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return treeSet;
|
||||
}
|
||||
|
||||
public void processClassGen(ClassGen classGen) {
|
||||
this.values.remove(classGen);
|
||||
this.values.add(0, classGen);
|
||||
String superclassName = classGen.getSuperclassName();
|
||||
ClassGen classGen2 = this.classStorage.getClassGen(superclassName);
|
||||
if (classGen2 != null) {
|
||||
this.processClassGen(classGen2);
|
||||
}
|
||||
String[] texts;
|
||||
int value;
|
||||
for (int value2 = value = (texts = classGen.getInterfaceNames()).length - 1;
|
||||
value2 >= 0;
|
||||
value2 = --value) {
|
||||
ClassGen classGen3;
|
||||
if ((classGen3 = this.classStorage.getClassGen(texts[value])) != null) {
|
||||
this.processClassGen(classGen3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void update() {
|
||||
Hashtable hashtable = new Hashtable();
|
||||
int value;
|
||||
for (int value2 = value = 0; value2 < this.values.size(); value2 = ++value) {
|
||||
ClassGen classGen = (ClassGen) this.values.get(value);
|
||||
hashtable.put(classGen, "");
|
||||
Vector values2 = this.getValues(classGen.getClassName());
|
||||
int value3 = 0;
|
||||
for (int value4 = value3; value4 < values2.size(); value4 = ++value3) {
|
||||
ClassGen classGen2 = (ClassGen) values2.get(value3);
|
||||
if (hashtable.containsKey(classGen2)) {
|
||||
Log.error("Incorrect classes order");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean matchesText(String text, String text2, String text3) {
|
||||
return this.values2.contains("" + text + "&" + text2 + "&" + text3);
|
||||
}
|
||||
|
||||
public void processClassGen2(ClassGen classGen) {
|
||||
Set values = this.createValues(classGen);
|
||||
Set values3;
|
||||
Set values4 = this.createValues(values3 = this.createValues2(classGen));
|
||||
Iterator iterator2;
|
||||
Iterator iterator3 = iterator2 = this.createValues(values, values4).iterator();
|
||||
while (iterator3.hasNext()) {
|
||||
Set values5 = this.values2;
|
||||
StringBuilder stringBuilder =
|
||||
new StringBuilder().insert(0, classGen.getClassName()).append("&");
|
||||
iterator3 = iterator2;
|
||||
values5.add(stringBuilder.append(iterator2.next()).toString());
|
||||
}
|
||||
this.processValues(values3, values4);
|
||||
}
|
||||
|
||||
public void update2() {
|
||||
Vector vector = new Vector();
|
||||
Iterator iterator;
|
||||
Iterator iterator2 = iterator = this.classStorage.getClassesByName2();
|
||||
while (iterator2.hasNext()) {
|
||||
iterator2 = iterator;
|
||||
vector.add(iterator.next());
|
||||
}
|
||||
Collections.sort(vector, new ClassHierarchyComparator(this));
|
||||
this.values = new Vector();
|
||||
for (ClassGen classGen : ((Iterable<ClassGen>) ((Iterable<?>) vector))) {
|
||||
if (this.getValues(classGen.getClassName()).size() == 0) {
|
||||
this.processClassGen(classGen);
|
||||
}
|
||||
}
|
||||
Collections.sort(this.values, new MethodGen$2(this));
|
||||
this.update();
|
||||
}
|
||||
|
||||
public Set createValues(Set values, Set values2) {
|
||||
TreeSet treeSet = new TreeSet();
|
||||
Set values3 = values.size() < values2.size() ? values : values2;
|
||||
Set values4 = values.size() < values2.size() ? values2 : values;
|
||||
for (Object result : values3) {
|
||||
if (values4.contains(result)) {
|
||||
treeSet.add(result);
|
||||
}
|
||||
}
|
||||
return treeSet;
|
||||
}
|
||||
|
||||
public void processValues(Set values, Set values3) {
|
||||
Iterator iterator2 = values.iterator();
|
||||
label36:
|
||||
while (true) {
|
||||
for (Iterator iterator3 = iterator2; iterator3.hasNext(); iterator3 = iterator2) {
|
||||
String text = (String) iterator2.next();
|
||||
if (!"-=404=-".equals(text)) {
|
||||
ClassGen classGen;
|
||||
if ((classGen = this.classStorage.getClassGen(text)) != null && classGen.isEnabled5()) {
|
||||
Iterator iterator4;
|
||||
iterator3 =
|
||||
iterator4 = this.createValues(this.createValues(classGen), values3).iterator();
|
||||
while (iterator3.hasNext()) {
|
||||
Set values4 = this.values2;
|
||||
StringBuilder stringBuilder =
|
||||
new StringBuilder().insert(0, classGen.getClassName()).append("&");
|
||||
iterator3 = iterator4;
|
||||
values4.add(stringBuilder.append(iterator4.next()).toString());
|
||||
}
|
||||
}
|
||||
continue label36;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public void processClassGen3(ClassGen classGen) {
|
||||
this.processClassGen(classGen.getSuperclassName(), classGen);
|
||||
int value;
|
||||
String[] texts;
|
||||
for (int value2 = value = (texts = classGen.getInterfaceNames()).length - 1;
|
||||
value2 >= 0;
|
||||
value2 = value) {
|
||||
int value3 = value;
|
||||
String[] texts2 = texts;
|
||||
value--;
|
||||
this.processClassGen(texts2[value3], classGen);
|
||||
}
|
||||
}
|
||||
|
||||
public Set createValues(ClassGen classGen) {
|
||||
TreeSet treeSet = new TreeSet();
|
||||
com.allatori.lib.bcel.classfile.Method[] methods;
|
||||
int value;
|
||||
for (int value2 = value = (methods = classGen.getMethods()).length - 1;
|
||||
value2 >= 0;
|
||||
value2 = --value) {
|
||||
com.allatori.lib.bcel.classfile.Method method = methods[value];
|
||||
if (this.matchesMethod(method)) {
|
||||
treeSet.add(method.getText() + "&" + method.getText2());
|
||||
}
|
||||
}
|
||||
return treeSet;
|
||||
}
|
||||
|
||||
public ClassHierarchy(ClassStorage classStorage2) {
|
||||
super();
|
||||
this.entries2 = new Hashtable();
|
||||
this.values2 = new TreeSet();
|
||||
this.entries = new Hashtable();
|
||||
this.classStorage = classStorage2;
|
||||
}
|
||||
|
||||
public void processText(Set values, String text) {
|
||||
values.add(text);
|
||||
ClassGen classGen = this.classStorage.getClassGen(text);
|
||||
if (classGen != null) {
|
||||
this.processText(values, classGen.getSuperclassName());
|
||||
int value;
|
||||
String[] texts;
|
||||
for (int value2 = value = (texts = classGen.getInterfaceNames()).length - 1;
|
||||
value2 >= 0;
|
||||
value2 = value) {
|
||||
int value3 = value;
|
||||
String[] texts2 = texts;
|
||||
value--;
|
||||
this.processText(values, texts2[value3]);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
Class classValue;
|
||||
if ((classValue = Class.forName(text, false, this.classStorage.getClassLoader()))
|
||||
.getSuperclass()
|
||||
!= null) {
|
||||
this.processText(values, classValue.getSuperclass().getName());
|
||||
}
|
||||
Class[] classs;
|
||||
int value4 = (classs = classValue.getInterfaces()).length - 1;
|
||||
while (value4 >= 0) {
|
||||
int value5 = value4;
|
||||
Class[] classs2 = classs;
|
||||
value4--;
|
||||
this.processText(values, classs2[value5].getName());
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
values.add("-=404=-");
|
||||
if (!this.entries.containsKey(text)) {
|
||||
this.entries.put(text, "");
|
||||
Log.warn("Class '" + text + "' cannot be found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean matchesMethod(com.allatori.lib.bcel.classfile.Method method) {
|
||||
return !method.isEnabled9() && !method.isEnabled11();
|
||||
}
|
||||
|
||||
public Vector getValues(String text) {
|
||||
Vector vector;
|
||||
return (vector = (Vector) this.entries2.get(text)) != null ? vector : VALUES;
|
||||
}
|
||||
|
||||
public Set createValues2(ClassGen classGen) {
|
||||
TreeSet treeSet = new TreeSet();
|
||||
this.processText(treeSet, classGen.getClassName());
|
||||
return treeSet;
|
||||
}
|
||||
|
||||
public boolean matchesMethod(Method method) {
|
||||
return !Modifier.isPrivate(method.getModifiers()) && !Modifier.isStatic(method.getModifiers());
|
||||
}
|
||||
|
||||
public void update3() {
|
||||
Iterator iterator;
|
||||
Iterator iterator2 = iterator = this.classStorage.getClassesByName2();
|
||||
while (iterator2.hasNext()) {
|
||||
ClassGen classGen = (ClassGen) iterator.next();
|
||||
iterator2 = iterator;
|
||||
this.processClassGen3(classGen);
|
||||
this.processClassGen2(classGen);
|
||||
}
|
||||
if (this.entries.size() > 0) {
|
||||
Log.warn(
|
||||
"Some classes weren't found. It may result in weaker obfuscation. Add needed jars to the"
|
||||
+ " 'classpath' element of the configuration file.");
|
||||
}
|
||||
this.update2();
|
||||
}
|
||||
|
||||
public void processClassGen(String text, ClassGen classGen) {
|
||||
if (this.classStorage.getClassGen(text) != null) {
|
||||
Vector vector;
|
||||
if ((vector = (Vector) this.entries2.get(text)) == null) {
|
||||
vector = new Vector();
|
||||
}
|
||||
vector.add(classGen);
|
||||
this.entries2.put(text, vector);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.allatori.bytecode;
|
||||
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class ClassHierarchyComparator implements Comparator {
|
||||
|
||||
public final ClassHierarchy classHierarchy;
|
||||
|
||||
@Override
|
||||
public int compare(Object result, Object result2) {
|
||||
String className = ((ClassGen) result).getClassName();
|
||||
String className2 = ((ClassGen) result2).getClassName();
|
||||
return className.compareTo(className2);
|
||||
}
|
||||
|
||||
public ClassHierarchyComparator(ClassHierarchy classHierarchy2) {
|
||||
super();
|
||||
this.classHierarchy = classHierarchy2;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,15 @@
|
||||
package com.allatori.bytecode;
|
||||
|
||||
import com.allatori.lib.bcel.classfile.ConstantPool;
|
||||
import com.allatori.lib.bcel.classfile.Method;
|
||||
import com.allatori.lib.bcel.generic.ConstantPoolGen;
|
||||
import com.allatori.lib.bcel.generic.MethodGen;
|
||||
|
||||
public class MethodFactory {
|
||||
|
||||
public static MethodGen createMethodGen(
|
||||
Method method, String text, ConstantPoolGen constantPoolGen, ConstantPool constantPool) {
|
||||
method.setConstantPool(constantPool);
|
||||
return new MethodGen(method, text, constantPoolGen);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.allatori.bytecode;
|
||||
|
||||
import java.util.TreeSet;
|
||||
|
||||
public class OrderedClassSet extends TreeSet {
|
||||
|
||||
@Override
|
||||
public boolean contains(Object result) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
package com.allatori.cli;
|
||||
|
||||
import com.allatori.VersionInfo;
|
||||
import com.allatori.config.ClassPathEntry;
|
||||
import com.allatori.config.Configuration;
|
||||
import com.allatori.config.ConfigurationException;
|
||||
import com.allatori.config.InputEntry;
|
||||
import com.allatori.config.InputJar;
|
||||
import com.allatori.engine.ObfuscationException;
|
||||
import com.allatori.io.ClassStorageClassLoader;
|
||||
import com.allatori.io.DirectoryClassReader;
|
||||
import com.allatori.io.DirectoryWriter;
|
||||
import com.allatori.io.JarClassReader;
|
||||
import com.allatori.io.JarWriter;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.model.ClassStorage;
|
||||
import com.allatori.util.Log;
|
||||
import com.allatori.watermark.WatermarkProcessor;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
public class ObfuscationCommandSupport {
|
||||
|
||||
public static void limitClassVersion(ClassStorage classStorage) {
|
||||
Iterator classesByName2 = classStorage.getClassesByName2();
|
||||
while (classesByName2.hasNext()) {
|
||||
ClassGen classGen;
|
||||
if ((classGen = (ClassGen) classesByName2.next()).getMajor() > 50) {
|
||||
classGen.setMajor(50);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeOutputs(ClassStorage classStorage)
|
||||
throws IOException, FileNotFoundException {
|
||||
JarWriter jarWriter = new JarWriter();
|
||||
Iterator iterator2;
|
||||
Iterator iterator3 = iterator2 = Configuration.getInputOptions().getValues().iterator();
|
||||
while (iterator3.hasNext()) {
|
||||
InputJar inputJar = (InputJar) iterator2.next();
|
||||
iterator3 = iterator2;
|
||||
jarWriter.processClassStorage(inputJar.text2, inputJar.text, classStorage);
|
||||
}
|
||||
Iterator iterator4;
|
||||
iterator3 = iterator4 = Configuration.getInputOptions().getValues3().iterator();
|
||||
while (iterator3.hasNext()) {
|
||||
InputEntry inputEntry = (InputEntry) iterator4.next();
|
||||
iterator3 = iterator4;
|
||||
jarWriter.processClassStorage(inputEntry.text2, inputEntry.text, classStorage);
|
||||
}
|
||||
if (Configuration.getInputOptions().getText() != null) {
|
||||
Vector vector;
|
||||
String[] texts = new String[(vector = Configuration.getInputOptions().getValues3()).size()];
|
||||
int value;
|
||||
for (int value2 = value = 0; value2 < vector.size(); value2 = value) {
|
||||
String text3 = ((InputEntry) vector.get(value)).text;
|
||||
int value3 = value;
|
||||
value++;
|
||||
texts[value3] = text3;
|
||||
}
|
||||
jarWriter.processText(texts, Configuration.getInputOptions().getText());
|
||||
}
|
||||
jarWriter.update();
|
||||
}
|
||||
|
||||
public static void loadConfiguration(String text) throws Exception {
|
||||
try {
|
||||
Configuration.processText(text);
|
||||
} catch (ConfigurationException configurationException) {
|
||||
if (configurationException.getCause() == null) {
|
||||
throw new Exception(("Configuration error. " + configurationException.getMessage()));
|
||||
} else {
|
||||
throw new Exception(
|
||||
("Error reading configuration. " + configurationException.getCause().getMessage()),
|
||||
configurationException.getCause());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void addWatermark(ClassStorage classStorage) throws ObfuscationException {
|
||||
new WatermarkProcessor(classStorage, Configuration.getWatermarkOptions().getText2())
|
||||
.processText(Configuration.getWatermarkOptions().getText());
|
||||
}
|
||||
|
||||
public static String extractWatermark(ClassStorage classStorage) throws ObfuscationException {
|
||||
return new WatermarkProcessor(classStorage, Configuration.getWatermarkOptions().getText2())
|
||||
.createText();
|
||||
}
|
||||
|
||||
public static void writeAllOutputs(ClassStorage classStorage)
|
||||
throws IOException, FileNotFoundException, ClassNotFoundException {
|
||||
writeOutputs(classStorage);
|
||||
writeDirectoryOutputs(classStorage);
|
||||
}
|
||||
|
||||
public static StringBuffer getStringBuffer(StringBuffer stringBuffer, char value, int value2) {
|
||||
int value3;
|
||||
for (int value4 = value3 = 0; value4 < value2; value4 = value3) {
|
||||
value3++;
|
||||
stringBuffer.append(value);
|
||||
}
|
||||
return stringBuffer;
|
||||
}
|
||||
|
||||
public static boolean loadConfigurationSafely(String text) {
|
||||
return loadConfigurationSafely(text, false);
|
||||
}
|
||||
|
||||
public static String getBanner() {
|
||||
String text = " ## # # ## ### ### ## ###";
|
||||
String text2 = "Java bytecode obfuscator";
|
||||
String text3 = "" + VersionInfo.getProductName() + " " + VersionInfo.getVersion();
|
||||
String website = VersionInfo.getWebsite();
|
||||
int value =
|
||||
Math.max(
|
||||
text.length(), Math.max(text3.length(), Math.max(website.length(), text2.length())));
|
||||
value += 4;
|
||||
StringBuffer stringBuffer;
|
||||
getStringBuffer(stringBuffer = new StringBuffer("\n"), '#', value).append("\n#");
|
||||
getStringBuffer(stringBuffer, ' ', value - 2).append("#\n#");
|
||||
int value2 = (value - text.length() - 2) / 2;
|
||||
int value3 = value - value2 - text.length() - 2;
|
||||
if (value2 > value3) {
|
||||
value3++;
|
||||
value2--;
|
||||
}
|
||||
getStringBuffer(stringBuffer, ' ', value2).append(text);
|
||||
getStringBuffer(stringBuffer, ' ', value3).append("#\n#");
|
||||
getStringBuffer(stringBuffer, ' ', value2).append((String) "# # # # # # # # # # # # ");
|
||||
getStringBuffer(stringBuffer, ' ', value3).append("#\n#");
|
||||
getStringBuffer(stringBuffer, ' ', value2).append((String) "### # # ### # # # ## # ");
|
||||
getStringBuffer(stringBuffer, ' ', value3).append("#\n#");
|
||||
getStringBuffer(stringBuffer, ' ', value2).append((String) "# # ### ### # # # ### # # ###");
|
||||
getStringBuffer(stringBuffer, ' ', value3).append("#\n#");
|
||||
int value4 = (value - text2.length() - 2) / 2;
|
||||
int value5 = value - value4 - text2.length() - 2;
|
||||
if (value4 > value5) {
|
||||
value5++;
|
||||
value4--;
|
||||
}
|
||||
getStringBuffer(stringBuffer, ' ', value - 2).append("#\n#");
|
||||
getStringBuffer(stringBuffer, ' ', value4).append(text2);
|
||||
getStringBuffer(stringBuffer, ' ', value5).append("#\n#");
|
||||
getStringBuffer(stringBuffer, ' ', value - 2).append("#\n#");
|
||||
int value6 = (value - text3.length() - 2) / 2;
|
||||
int value7 = value - value6 - text3.length() - 2;
|
||||
if (value6 > value7) {
|
||||
value7++;
|
||||
value6--;
|
||||
}
|
||||
getStringBuffer(stringBuffer, ' ', value6).append(text3);
|
||||
getStringBuffer(stringBuffer, ' ', value7).append("#\n#");
|
||||
getStringBuffer(stringBuffer, ' ', value - 2).append("#\n#");
|
||||
int value8 = (value - website.length() - 2) / 2;
|
||||
int value9 = value - value8 - website.length() - 2;
|
||||
if (value8 > value9) {
|
||||
value9++;
|
||||
value8--;
|
||||
}
|
||||
getStringBuffer(stringBuffer, ' ', value8).append(website);
|
||||
getStringBuffer(stringBuffer, ' ', value9).append("#\n#");
|
||||
getStringBuffer(stringBuffer, ' ', value - 2).append("#\n");
|
||||
getStringBuffer(stringBuffer, '#', value).append("\n");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public static boolean loadConfigurationSafely(String text, boolean matches) {
|
||||
try {
|
||||
Configuration.processEnabled(text, matches);
|
||||
return true;
|
||||
} catch (ConfigurationException configurationException) {
|
||||
if (configurationException.getCause() == null) {
|
||||
Log.error("Configuration error. " + configurationException.getMessage());
|
||||
} else {
|
||||
Log.error("Error reading configuration. " + configurationException.getCause().getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static ClassStorage createClassStorage() throws IOException {
|
||||
ClassStorage classStorage = new ClassStorage(createClassLoader());
|
||||
Iterator iterator2;
|
||||
Iterator iterator3 = iterator2 = Configuration.getInputOptions().getValues().iterator();
|
||||
while (iterator3.hasNext()) {
|
||||
InputJar inputJar = (InputJar) iterator2.next();
|
||||
iterator3 = iterator2;
|
||||
JarClassReader.processClassStorage(inputJar.text2, classStorage);
|
||||
}
|
||||
Iterator iterator4;
|
||||
iterator3 = iterator4 = Configuration.getInputOptions().getValues3().iterator();
|
||||
while (iterator3.hasNext()) {
|
||||
InputEntry inputEntry = (InputEntry) iterator4.next();
|
||||
iterator3 = iterator4;
|
||||
JarClassReader.processClassStorage(inputEntry.text2, classStorage);
|
||||
}
|
||||
Iterator iterator5;
|
||||
iterator3 = iterator5 = Configuration.getInputOptions().getValues2().iterator();
|
||||
while (iterator3.hasNext()) {
|
||||
ClassPathEntry classPathEntry = (ClassPathEntry) iterator5.next();
|
||||
iterator3 = iterator5;
|
||||
DirectoryClassReader.processText(classPathEntry.text, classStorage, classPathEntry.text);
|
||||
}
|
||||
return classStorage;
|
||||
}
|
||||
|
||||
public static ClassStorageClassLoader createClassLoader() {
|
||||
Vector values = Configuration.getClassPathOptions().getValues();
|
||||
int value;
|
||||
for (int value2 = value = 0; value2 < values.size(); value2 = ++value) {
|
||||
try {
|
||||
values.set(value, new File((String) values.get(value)).toURL());
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
URL[] uRLs = (URL[]) values.toArray(new URL[0]);
|
||||
return new ClassStorageClassLoader(uRLs);
|
||||
}
|
||||
|
||||
public static void writeDirectoryOutputs(ClassStorage classStorage)
|
||||
throws FileNotFoundException, IOException, ClassNotFoundException {
|
||||
DirectoryWriter directoryWriter = new DirectoryWriter();
|
||||
Iterator iterator2;
|
||||
Iterator iterator3 = iterator2 = Configuration.getInputOptions().getValues2().iterator();
|
||||
while (iterator3.hasNext()) {
|
||||
ClassPathEntry classPathEntry = (ClassPathEntry) iterator2.next();
|
||||
iterator3 = iterator2;
|
||||
directoryWriter.processClassStorage(classPathEntry.text, classPathEntry.text2, classStorage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.allatori.config;
|
||||
|
||||
public class ClassPathEntry {
|
||||
|
||||
public String text;
|
||||
|
||||
public String text2;
|
||||
|
||||
public ClassPathEntry(String text, String text2) {
|
||||
super();
|
||||
this.text = text;
|
||||
this.text2 = text2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
public class ClassPathOptions {
|
||||
|
||||
public final Configuration configuration;
|
||||
|
||||
public Vector values;
|
||||
|
||||
public void processText(String text) {
|
||||
this.values.add(text);
|
||||
}
|
||||
|
||||
public Vector getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public ClassPathOptions(Configuration configuration2) {
|
||||
super();
|
||||
this.configuration = configuration2;
|
||||
this.values = new Vector();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import com.allatori.util.random.RandomUtils;
|
||||
|
||||
public class Configuration {
|
||||
|
||||
public ObfuscationOptions obfuscationOptions;
|
||||
|
||||
public OutputOptions outputOptions = new OutputOptions(this);
|
||||
|
||||
public LogOptions logOptions;
|
||||
|
||||
public MethodRemovalOptions methodRemovalOptions;
|
||||
|
||||
public MemberOrderOptions memberOrderOptions;
|
||||
|
||||
public WatermarkOptions watermarkOptions;
|
||||
|
||||
public static Configuration configuration = null;
|
||||
|
||||
public RenamingOptions renamingOptions;
|
||||
|
||||
public DebugInfoOptions debugInfoOptions;
|
||||
|
||||
public SyntheticOptions syntheticOptions;
|
||||
|
||||
public IgnoreClassesOptions ignoreClassesOptions;
|
||||
|
||||
public OptimizationOptions optimizationOptions;
|
||||
|
||||
public FieldRemovalOptions fieldRemovalOptions;
|
||||
|
||||
public MethodCallRemovalOptions methodCallRemovalOptions;
|
||||
|
||||
public ClassPathOptions classPathOptions;
|
||||
|
||||
public PackageRenamingOptions packageRenamingOptions;
|
||||
|
||||
public InputOptions inputOptions = new InputOptions(this);
|
||||
|
||||
public MappingOptions mappingOptions;
|
||||
|
||||
public ExtensiveFlowOptions extensiveFlowOptions;
|
||||
|
||||
public static MemberOrderOptions getMemberOrderOptions() {
|
||||
return configuration.memberOrderOptions;
|
||||
}
|
||||
|
||||
public static void processText(String text) throws ConfigurationException {
|
||||
processEnabled(text, false);
|
||||
}
|
||||
|
||||
public static InputOptions getInputOptions() {
|
||||
return configuration.inputOptions;
|
||||
}
|
||||
|
||||
public static IgnoreClassesOptions getIgnoreClassesOptions() {
|
||||
return configuration.ignoreClassesOptions;
|
||||
}
|
||||
|
||||
public static RenamingOptions getRenamingOptions() {
|
||||
return configuration.renamingOptions;
|
||||
}
|
||||
|
||||
public static MethodCallRemovalOptions getMethodCallRemovalOptions() {
|
||||
return configuration.methodCallRemovalOptions;
|
||||
}
|
||||
|
||||
public static ExtensiveFlowOptions getExtensiveFlowOptions() {
|
||||
return configuration.extensiveFlowOptions;
|
||||
}
|
||||
|
||||
public static void processEnabled(String text, boolean matches) throws ConfigurationException {
|
||||
configuration = new Configuration();
|
||||
configuration.watermarkOptions.setEnabled(matches);
|
||||
new XmlParsingContext(text).parse();
|
||||
RandomUtils.update();
|
||||
if (getObfuscationOptions().getCharacter() == '\uffff') {
|
||||
getObfuscationOptions().setCharacter((char) (RandomUtils.calculateCount(125) + 1));
|
||||
}
|
||||
}
|
||||
|
||||
public static MethodRemovalOptions getMethodRemovalOptions() {
|
||||
return configuration.methodRemovalOptions;
|
||||
}
|
||||
|
||||
public static SyntheticOptions getSyntheticOptions() {
|
||||
return configuration.syntheticOptions;
|
||||
}
|
||||
|
||||
public static ClassPathOptions getClassPathOptions() {
|
||||
return configuration.classPathOptions;
|
||||
}
|
||||
|
||||
public static FieldRemovalOptions getFieldRemovalOptions() {
|
||||
return configuration.fieldRemovalOptions;
|
||||
}
|
||||
|
||||
public Configuration() {
|
||||
this.classPathOptions = new ClassPathOptions(this);
|
||||
this.renamingOptions = new RenamingOptions(this);
|
||||
this.watermarkOptions = new WatermarkOptions(this);
|
||||
this.obfuscationOptions = new ObfuscationOptions(this);
|
||||
this.debugInfoOptions = new DebugInfoOptions(this);
|
||||
this.extensiveFlowOptions = new ExtensiveFlowOptions(this);
|
||||
this.syntheticOptions = new SyntheticOptions(this);
|
||||
this.memberOrderOptions = new MemberOrderOptions(this);
|
||||
this.methodCallRemovalOptions = new MethodCallRemovalOptions(this);
|
||||
this.optimizationOptions = new OptimizationOptions(this);
|
||||
this.fieldRemovalOptions = new FieldRemovalOptions(this);
|
||||
this.packageRenamingOptions = new PackageRenamingOptions(this);
|
||||
this.ignoreClassesOptions = new IgnoreClassesOptions(this);
|
||||
this.logOptions = new LogOptions(this);
|
||||
this.methodRemovalOptions = new MethodRemovalOptions(this);
|
||||
this.mappingOptions = new MappingOptions(this);
|
||||
}
|
||||
|
||||
public static OptimizationOptions getOptimizationOptions() {
|
||||
return configuration.optimizationOptions;
|
||||
}
|
||||
|
||||
public static void update() {
|
||||
configuration = null;
|
||||
}
|
||||
|
||||
public static WatermarkOptions getWatermarkOptions() {
|
||||
return configuration.watermarkOptions;
|
||||
}
|
||||
|
||||
public static LogOptions getLogOptions() {
|
||||
return configuration.logOptions;
|
||||
}
|
||||
|
||||
public static DebugInfoOptions getDebugInfoOptions() {
|
||||
return configuration.debugInfoOptions;
|
||||
}
|
||||
|
||||
public static MappingOptions getMappingOptions() {
|
||||
return configuration.mappingOptions;
|
||||
}
|
||||
|
||||
public static PackageRenamingOptions getPackageRenamingOptions() {
|
||||
return configuration.packageRenamingOptions;
|
||||
}
|
||||
|
||||
public static ObfuscationOptions getObfuscationOptions() {
|
||||
return configuration.obfuscationOptions;
|
||||
}
|
||||
|
||||
public static OutputOptions getOutputOptions() {
|
||||
return configuration.outputOptions;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.allatori.config;
|
||||
|
||||
public class ConfigurationConstructorToken {}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.allatori.config;
|
||||
|
||||
public class ConfigurationException extends Exception {
|
||||
|
||||
public ConfigurationException(Throwable throwable) {
|
||||
super(throwable);
|
||||
}
|
||||
|
||||
public ConfigurationException(String text) {
|
||||
super(text);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,33 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import org.xml.sax.Locator;
|
||||
|
||||
public class ConfigurationLocator implements Locator {
|
||||
|
||||
public final ConfigurationHandler configurationHandler;
|
||||
|
||||
@Override
|
||||
public int getLineNumber() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPublicId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnNumber() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public ConfigurationLocator(ConfigurationHandler configurationHandler2) {
|
||||
super();
|
||||
this.configurationHandler = configurationHandler2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSystemId() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
public class ConfigurationSaxException extends SAXException {
|
||||
|
||||
public final XmlParsingContext xmlParsingContext;
|
||||
|
||||
public ConfigurationSaxException(XmlParsingContext xmlParsingContext2, String text) {
|
||||
super(text);
|
||||
this.xmlParsingContext = xmlParsingContext2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.allatori.config;
|
||||
|
||||
public interface ConfigurationSource {
|
||||
|
||||
void parse() throws ConfigurationException;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import com.allatori.config.rule.RuleEntry;
|
||||
import com.allatori.config.rule.RuleSet;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.lib.bcel.generic.MethodGen;
|
||||
import com.allatori.model.ClassStorage;
|
||||
|
||||
public class DebugInfoOptions {
|
||||
|
||||
public String text;
|
||||
|
||||
public boolean enabled;
|
||||
|
||||
public final Configuration configuration;
|
||||
|
||||
public String text2;
|
||||
|
||||
public RuleSet ruleSet;
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public String getText2() {
|
||||
return this.text2;
|
||||
}
|
||||
|
||||
public DebugInfoOptions(Configuration configuration2) {
|
||||
super();
|
||||
this.configuration = configuration2;
|
||||
this.ruleSet = new RuleSet(0);
|
||||
}
|
||||
|
||||
public boolean matchesMethodGen(
|
||||
ClassStorage classStorage, ClassGen classGen, MethodGen methodGen) {
|
||||
return this.ruleSet.calculateCount(classStorage, classGen, methodGen) == 1;
|
||||
}
|
||||
|
||||
public boolean matchesClassGen(ClassStorage classStorage, ClassGen classGen) {
|
||||
return this.ruleSet.calculateCount(classStorage, classGen) == 1;
|
||||
}
|
||||
|
||||
public void setText2(String text2) {
|
||||
this.text2 = text2;
|
||||
}
|
||||
|
||||
public void processRuleEntry(RuleEntry ruleEntry) {
|
||||
this.ruleSet.processRuleEntry(ruleEntry);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import com.allatori.config.rule.RuleEntry;
|
||||
import com.allatori.config.rule.RuleSet;
|
||||
import com.allatori.lib.bcel.generic.AnnotationEntryGen;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.lib.bcel.generic.ElementValuePairGen;
|
||||
import com.allatori.lib.bcel.generic.MethodGen;
|
||||
import com.allatori.model.ClassStorage;
|
||||
import java.util.List;
|
||||
|
||||
public class ExtensiveFlowOptions {
|
||||
|
||||
public static final int COUNT = 0;
|
||||
|
||||
public static final int COUNT2 = 2;
|
||||
|
||||
public static final int COUNT3 = 1;
|
||||
|
||||
public final Configuration configuration;
|
||||
|
||||
public RuleSet ruleSet;
|
||||
|
||||
public ExtensiveFlowOptions(Configuration configuration2) {
|
||||
super();
|
||||
this.configuration = configuration2;
|
||||
this.ruleSet = new RuleSet(1);
|
||||
}
|
||||
|
||||
public int calculateCount(ClassStorage classStorage, ClassGen classGen, MethodGen methodGen) {
|
||||
if (!Configuration.getObfuscationOptions().isEnabled()
|
||||
&& methodGen.getName().startsWith("Allatori")) {
|
||||
return 1;
|
||||
}
|
||||
byte value = 1;
|
||||
AnnotationEntryGen[] annotationEntryGens = methodGen.getAnnotationEntryGens();
|
||||
while (true) {
|
||||
AnnotationEntryGen[] annotationEntryGens2 = annotationEntryGens;
|
||||
int value2 = annotationEntryGens2.length;
|
||||
int value3;
|
||||
for (int value4 = value3 = 0; value4 < value2; value4 = ++value3) {
|
||||
AnnotationEntryGen annotationEntryGen = annotationEntryGens2[value3];
|
||||
if ("Lcom/allatori/annotations/DisableExtensiveFlowObfuscation;"
|
||||
.equals(annotationEntryGen.getText2())) {
|
||||
return 0;
|
||||
}
|
||||
if ("Lcom/allatori/annotations/NormalExtensiveFlowObfuscation;"
|
||||
.equals(annotationEntryGen.getText2())) {
|
||||
return 1;
|
||||
}
|
||||
if ("Lcom/allatori/annotations/MaximumExtensiveFlowObfuscation;"
|
||||
.equals(annotationEntryGen.getText2())) {
|
||||
return 2;
|
||||
}
|
||||
List values;
|
||||
if ("Lcom/allatori/annotations/ExtensiveFlowObfuscation;"
|
||||
.equals(annotationEntryGen.getText2())
|
||||
&& (values = annotationEntryGen.getValues()) != null
|
||||
&& values.size() > 0
|
||||
&& ((ElementValuePairGen) values.get(0)).getValue() != null) {
|
||||
if ("maximum".equals(((ElementValuePairGen) values.get(0)).getValue().stringifyValue())) {
|
||||
return 2;
|
||||
}
|
||||
if ("normal".equals(((ElementValuePairGen) values.get(0)).getValue().stringifyValue())) {
|
||||
return 1;
|
||||
}
|
||||
if ("disable".equals(((ElementValuePairGen) values.get(0)).getValue().stringifyValue())) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (value == 0) {
|
||||
if (Configuration.getObfuscationOptions().isEnabled3()
|
||||
&& Configuration.getObfuscationOptions().isMethodsNamingEnabled()) {
|
||||
return 0;
|
||||
}
|
||||
return this.ruleSet.calculateCount(classStorage, classGen, methodGen);
|
||||
}
|
||||
value = 0;
|
||||
annotationEntryGens = classGen.getAnnotationEntries();
|
||||
}
|
||||
}
|
||||
|
||||
public void processRuleEntry(RuleEntry ruleEntry) {
|
||||
this.ruleSet.processRuleEntry(ruleEntry);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import com.allatori.config.rule.RuleEntry;
|
||||
import com.allatori.config.rule.RuleSet;
|
||||
import com.allatori.lib.bcel.classfile.Field;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.model.ClassStorage;
|
||||
import java.util.Vector;
|
||||
|
||||
public class FieldRemovalOptions {
|
||||
|
||||
public Vector values;
|
||||
|
||||
public final Configuration configuration;
|
||||
|
||||
public RuleSet ruleSet;
|
||||
|
||||
public boolean isValues() {
|
||||
return this.values.size() > 0;
|
||||
}
|
||||
|
||||
public FieldRemovalOptions(Configuration configuration2) {
|
||||
super();
|
||||
this.configuration = configuration2;
|
||||
this.ruleSet = new RuleSet(0);
|
||||
this.values = new Vector();
|
||||
}
|
||||
|
||||
public void processText(String text) {
|
||||
this.values.add(text);
|
||||
}
|
||||
|
||||
public boolean matchesText(String text) {
|
||||
return this.values.contains(text);
|
||||
}
|
||||
|
||||
public boolean matchesField(ClassStorage classStorage, ClassGen classGen, Field field) {
|
||||
if (classStorage == null) {
|
||||
return false;
|
||||
} else {
|
||||
return this.ruleSet.getValues() == 0
|
||||
? false
|
||||
: this.ruleSet.calculateCount(classStorage, classGen, field) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void processRuleEntry(RuleEntry ruleEntry) {
|
||||
this.ruleSet.processRuleEntry(ruleEntry);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import com.allatori.config.rule.ClassRule;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.model.ClassStorage;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
public class IgnoreClassesOptions {
|
||||
|
||||
public final Configuration configuration;
|
||||
|
||||
public boolean enabled;
|
||||
|
||||
public Vector values;
|
||||
|
||||
public boolean matchesClassGen(ClassStorage classStorage, ClassGen classGen) {
|
||||
if (!this.enabled) {
|
||||
return false;
|
||||
}
|
||||
Iterator iterator2 = this.values.iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
ClassRule classRule;
|
||||
if ((classRule = (ClassRule) iterator2.next()).matches(classStorage, classGen)) {
|
||||
if (!classRule.matches()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void processClassRule(ClassRule classRule) {
|
||||
this.values.add(classRule);
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
public IgnoreClassesOptions(Configuration configuration2) {
|
||||
super();
|
||||
this.configuration = configuration2;
|
||||
this.values = new Vector();
|
||||
this.enabled = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.allatori.config;
|
||||
|
||||
public class InputEntry {
|
||||
|
||||
public String text;
|
||||
|
||||
public String text2;
|
||||
|
||||
public InputEntry(String text2, String text) {
|
||||
super();
|
||||
this.text2 = text2;
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.allatori.config;
|
||||
|
||||
public class InputJar extends InputEntry {
|
||||
|
||||
public String text;
|
||||
|
||||
public String text2;
|
||||
|
||||
public InputJar(String text3, String text4, String text, String text2) {
|
||||
super(text3, text4);
|
||||
this.text = text;
|
||||
this.text2 = text2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
public class InputOptions {
|
||||
|
||||
public final Configuration configuration;
|
||||
|
||||
public Vector values;
|
||||
|
||||
public Vector values2;
|
||||
|
||||
public Vector values3;
|
||||
|
||||
public String text;
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public void processInputJar(InputJar inputJar) {
|
||||
this.values.add(inputJar);
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public Vector getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
public Vector getValues3() {
|
||||
return this.values3;
|
||||
}
|
||||
|
||||
public InputOptions(Configuration configuration2) {
|
||||
super();
|
||||
this.configuration = configuration2;
|
||||
this.values3 = new Vector();
|
||||
this.values = new Vector();
|
||||
this.values2 = new Vector();
|
||||
this.text = null;
|
||||
}
|
||||
|
||||
public void processInputEntry(InputEntry inputEntry) {
|
||||
this.values3.add(inputEntry);
|
||||
}
|
||||
|
||||
public void processClassPathEntry(ClassPathEntry classPathEntry) {
|
||||
this.values2.add(classPathEntry);
|
||||
}
|
||||
|
||||
public Vector getValues2() {
|
||||
return this.values2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import com.allatori.config.rule.ClassRule;
|
||||
import com.allatori.config.rule.FieldRule;
|
||||
import com.allatori.config.rule.MethodRule;
|
||||
import com.allatori.lib.bcel.classfile.AnnotationEntry;
|
||||
import com.allatori.lib.bcel.classfile.Field;
|
||||
import com.allatori.lib.bcel.classfile.Method;
|
||||
import com.allatori.lib.bcel.generic.AnnotationEntryGen;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.model.ClassStorage;
|
||||
import java.util.Vector;
|
||||
|
||||
public class KeepNamesOptions {
|
||||
|
||||
public final RenamingOptions renamingOptions;
|
||||
|
||||
public Vector values;
|
||||
|
||||
public ClassRule classRule;
|
||||
|
||||
public boolean matchesMethod(ClassStorage classStorage, ClassGen classGen, Method method) {
|
||||
if (this.matchesMethod2(classStorage, classGen, method)) {
|
||||
return true;
|
||||
}
|
||||
if (RenamingOptions.matchesRenamingOptions(this.renamingOptions)) {
|
||||
return false;
|
||||
}
|
||||
AnnotationEntry[] annotationEntries = method.getAnnotationEntries();
|
||||
int value;
|
||||
for (int value2 = value = 0; value2 < annotationEntries.length; value2 = ++value) {
|
||||
AnnotationEntry annotationEntry = annotationEntries[value];
|
||||
if ("Lcom/allatori/annotations/Rename;".equals(annotationEntry.getText())) {
|
||||
return true;
|
||||
}
|
||||
if ("Lcom/allatori/annotations/DoNotRename;".equals(annotationEntry.getText())) {
|
||||
return false;
|
||||
}
|
||||
if ("Lcom/allatori/annotations/KeepName;".equals(annotationEntry.getText())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int value3;
|
||||
for (int value4 = value3 = 0; value4 < this.values.size(); value4 = ++value3) {
|
||||
ClassRule classRule2;
|
||||
if ((classRule2 = (ClassRule) this.values.get(value3)).matches5()
|
||||
&& classRule2.matches(classStorage, classGen)
|
||||
&& classRule2.matches(method)) {
|
||||
return false;
|
||||
}
|
||||
if (classRule2.matches() && classRule2.matches(classStorage, classGen)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return !this.classRule.matches5() || !this.classRule.matches(method);
|
||||
}
|
||||
|
||||
public boolean matchesMethod2(ClassStorage classStorage, ClassGen classGen, Method method) {
|
||||
return method.getText().startsWith("Allatori") || this.matchesClassGen2(classStorage, classGen);
|
||||
}
|
||||
|
||||
public void processFieldRule(FieldRule fieldRule) {
|
||||
this.classRule.processFieldRule(fieldRule);
|
||||
}
|
||||
|
||||
public KeepNamesOptions(
|
||||
RenamingOptions renamingOptions,
|
||||
NamingOptionsConstructorToken namingOptionsConstructorToken) {
|
||||
this(renamingOptions);
|
||||
}
|
||||
|
||||
public boolean matchesField(ClassStorage classStorage, ClassGen classGen, Field field) {
|
||||
if (this.matchesField2(classStorage, classGen, field)) {
|
||||
return true;
|
||||
}
|
||||
if (RenamingOptions.matchesRenamingOptions(this.renamingOptions)) {
|
||||
return false;
|
||||
}
|
||||
AnnotationEntry[] annotationEntries = field.getAnnotationEntries();
|
||||
int value;
|
||||
for (int value2 = value = 0; value2 < annotationEntries.length; value2 = ++value) {
|
||||
AnnotationEntry annotationEntry = annotationEntries[value];
|
||||
if ("Lcom/allatori/annotations/Rename;".equals(annotationEntry.getText())) {
|
||||
return true;
|
||||
}
|
||||
if ("Lcom/allatori/annotations/DoNotRename;".equals(annotationEntry.getText())) {
|
||||
return false;
|
||||
}
|
||||
if ("Lcom/allatori/annotations/KeepName;".equals(annotationEntry.getText())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int value3;
|
||||
for (int value4 = value3 = 0; value4 < this.values.size(); value4 = ++value3) {
|
||||
ClassRule classRule2;
|
||||
if ((classRule2 = (ClassRule) this.values.get(value3)).matches4()
|
||||
&& classRule2.matches(classStorage, classGen)
|
||||
&& classRule2.matches(classStorage, field)) {
|
||||
return false;
|
||||
}
|
||||
if (classRule2.matches() && classRule2.matches(classStorage, classGen)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return !this.classRule.matches4() || !this.classRule.matches(classStorage, field);
|
||||
}
|
||||
|
||||
public boolean matchesField2(ClassStorage classStorage, ClassGen classGen, Field field) {
|
||||
return this.matchesClassGen2(classStorage, classGen);
|
||||
}
|
||||
|
||||
public boolean matchesClassGen(ClassStorage classStorage, ClassGen classGen) {
|
||||
if (this.matchesClassGen2(classStorage, classGen)) {
|
||||
return true;
|
||||
}
|
||||
if (RenamingOptions.matchesRenamingOptions(this.renamingOptions)) {
|
||||
return false;
|
||||
}
|
||||
AnnotationEntryGen[] annotationEntries = classGen.getAnnotationEntries();
|
||||
int value;
|
||||
for (int value2 = value = 0; value2 < annotationEntries.length; value2 = ++value) {
|
||||
AnnotationEntryGen annotationEntryGen = annotationEntries[value];
|
||||
if ("Lcom/allatori/annotations/Rename;".equals(annotationEntryGen.getText2())) {
|
||||
return true;
|
||||
}
|
||||
if ("Lcom/allatori/annotations/DoNotRename;".equals(annotationEntryGen.getText2())) {
|
||||
return false;
|
||||
}
|
||||
if ("Lcom/allatori/annotations/KeepName;".equals(annotationEntryGen.getText2())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int value3;
|
||||
for (int value4 = value3 = 0; value4 < this.values.size(); value4 = ++value3) {
|
||||
ClassRule classRule;
|
||||
if ((!(classRule = (ClassRule) this.values.get(value3)).matches2() || classRule.matches())
|
||||
&& classRule.matches(classStorage, classGen)) {
|
||||
if (classRule.matches()) {
|
||||
return true;
|
||||
}
|
||||
if (!classRule.matches3()) {
|
||||
return false;
|
||||
}
|
||||
int value5;
|
||||
Field[] fields;
|
||||
for (int value6 = value5 = (fields = classGen.getFields()).length - 1;
|
||||
value6 >= 0;
|
||||
value6 = --value5) {
|
||||
Field field = fields[value5];
|
||||
if (!Configuration.getRenamingOptions()
|
||||
.getKeepNamesOptions()
|
||||
.matchesField(classStorage, classGen, field)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int value7;
|
||||
Method[] methods;
|
||||
for (int value8 = value7 = (methods = classGen.getMethods()).length - 1;
|
||||
value8 >= 0;
|
||||
value8 = --value7) {
|
||||
Method method = methods[value7];
|
||||
if (!Configuration.getRenamingOptions()
|
||||
.getKeepNamesOptions()
|
||||
.matchesMethod(classStorage, classGen, method)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void processClassRule(ClassRule classRule) {
|
||||
this.values.add(classRule);
|
||||
}
|
||||
|
||||
public KeepNamesOptions(RenamingOptions renamingOptions2) {
|
||||
super();
|
||||
this.renamingOptions = renamingOptions2;
|
||||
this.values = new Vector();
|
||||
try {
|
||||
this.classRule = new ClassRule("class *", true, false);
|
||||
ClassRule classRule2 = new ClassRule("class * extends java.lang.Enum", true, false);
|
||||
classRule2.processMethodRule(new MethodRule("values(**)", false, false));
|
||||
classRule2.processMethodRule(new MethodRule("valueOf(**)", false, false));
|
||||
this.processClassRule(classRule2);
|
||||
this.processClassRule(new ClassRule("interface *.package-info", false, false));
|
||||
} catch (ConfigurationException configurationException) {
|
||||
configurationException.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void processMethodRule(MethodRule methodRule) {
|
||||
this.classRule.processMethodRule(methodRule);
|
||||
}
|
||||
|
||||
public boolean matchesClassGen2(ClassStorage classStorage, ClassGen classGen) {
|
||||
return classStorage.getInputClasses().contains(classGen);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.allatori.config;
|
||||
|
||||
public class LineNumberOptions {
|
||||
|
||||
public static final int COUNT = 3;
|
||||
|
||||
public final RenamingOptions renamingOptions;
|
||||
|
||||
public int lineNumbersMode;
|
||||
|
||||
public static final int COUNT2 = 2;
|
||||
|
||||
public static final int COUNT3 = 1;
|
||||
|
||||
public void setLineNumbersMode(int lineNumbersMode) {
|
||||
this.lineNumbersMode = lineNumbersMode;
|
||||
}
|
||||
|
||||
public int getLineNumbersMode() {
|
||||
return this.lineNumbersMode;
|
||||
}
|
||||
|
||||
public LineNumberOptions(RenamingOptions renamingOptions2) {
|
||||
super();
|
||||
this.renamingOptions = renamingOptions2;
|
||||
this.lineNumbersMode = 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import com.allatori.config.rule.RuleEntry;
|
||||
import com.allatori.config.rule.RuleSet;
|
||||
import com.allatori.lib.bcel.classfile.Method;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.lib.bcel.generic.MethodGen;
|
||||
import com.allatori.model.ClassStorage;
|
||||
|
||||
public class LocalVariableOptions {
|
||||
|
||||
public RuleSet ruleSet;
|
||||
|
||||
public static final int COUNT = 4;
|
||||
|
||||
public static final int COUNT2 = 5;
|
||||
|
||||
public final RenamingOptions renamingOptions;
|
||||
|
||||
public static final int COUNT3 = 3;
|
||||
|
||||
public static final int COUNT4 = 1;
|
||||
|
||||
public static final int COUNT5 = 6;
|
||||
|
||||
public String localVariablesNaming;
|
||||
|
||||
public static final int COUNT6 = 2;
|
||||
|
||||
public int localVariablesNamingMode;
|
||||
|
||||
public void setLocalVariablesNaming(String localVariablesNaming) {
|
||||
this.localVariablesNaming = localVariablesNaming;
|
||||
}
|
||||
|
||||
public void processRuleEntry(RuleEntry ruleEntry) {
|
||||
this.ruleSet.processRuleEntry(ruleEntry);
|
||||
}
|
||||
|
||||
public int calculateCount(ClassStorage classStorage, ClassGen classGen, MethodGen methodGen) {
|
||||
return Configuration.getObfuscationOptions().isEnabled3()
|
||||
&& Configuration.getObfuscationOptions().isMethodsNamingEnabled()
|
||||
? 4
|
||||
: this.ruleSet.calculateCount(classStorage, classGen, methodGen);
|
||||
}
|
||||
|
||||
public void setLocalVariablesNamingMode(int localVariablesNamingMode) {
|
||||
this.localVariablesNamingMode = localVariablesNamingMode;
|
||||
}
|
||||
|
||||
public int calculateCount(ClassStorage classStorage, ClassGen classGen, Method method) {
|
||||
return Configuration.getObfuscationOptions().isEnabled3()
|
||||
&& Configuration.getObfuscationOptions().isMethodsNamingEnabled()
|
||||
? 4
|
||||
: this.ruleSet.calculateCount(classStorage, classGen, method);
|
||||
}
|
||||
|
||||
public LocalVariableOptions(RenamingOptions renamingOptions2) {
|
||||
super();
|
||||
this.renamingOptions = renamingOptions2;
|
||||
this.localVariablesNamingMode = 6;
|
||||
this.ruleSet = new RuleSet(6);
|
||||
this.localVariablesNaming = "a";
|
||||
}
|
||||
|
||||
public String getLocalVariablesNaming() {
|
||||
return this.localVariablesNaming;
|
||||
}
|
||||
|
||||
public int calculateCount() {
|
||||
return Configuration.getObfuscationOptions().isEnabled3()
|
||||
&& Configuration.getObfuscationOptions().isMethodsNamingEnabled()
|
||||
? 4
|
||||
: this.localVariablesNamingMode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.allatori.config;
|
||||
|
||||
public class LogOptions {
|
||||
|
||||
public String comLicense4jSupport;
|
||||
|
||||
public final Configuration configuration;
|
||||
|
||||
public void setComLicense4jSupport(String comLicense4jSupport) {
|
||||
this.comLicense4jSupport = comLicense4jSupport;
|
||||
}
|
||||
|
||||
public boolean isText() {
|
||||
return this.comLicense4jSupport != null;
|
||||
}
|
||||
|
||||
public LogOptions(Configuration configuration2) {
|
||||
super();
|
||||
this.configuration = configuration2;
|
||||
this.comLicense4jSupport = null;
|
||||
}
|
||||
|
||||
public String getComLicense4jSupport() {
|
||||
return this.comLicense4jSupport;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import com.allatori.naming.RenamingLog;
|
||||
import com.allatori.util.LookupTable;
|
||||
|
||||
public class MappingOptions {
|
||||
|
||||
public LookupTable lookupTable;
|
||||
|
||||
public RenamingLog renamingLog;
|
||||
|
||||
public final Configuration configuration;
|
||||
|
||||
public LookupTable lookupTable2;
|
||||
|
||||
public MappingOptions(Configuration configuration2) {
|
||||
super();
|
||||
this.configuration = configuration2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import com.allatori.config.rule.RuleEntry;
|
||||
import com.allatori.config.rule.RuleSet;
|
||||
import com.allatori.lib.bcel.classfile.Field;
|
||||
import com.allatori.lib.bcel.classfile.Method;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.model.ClassStorage;
|
||||
|
||||
public class MemberOrderOptions {
|
||||
|
||||
public final Configuration configuration;
|
||||
|
||||
public RuleSet ruleSet;
|
||||
|
||||
public RuleSet ruleSet2;
|
||||
|
||||
public void processRuleEntry(RuleEntry ruleEntry) {
|
||||
this.ruleSet2.processRuleEntry(ruleEntry);
|
||||
}
|
||||
|
||||
public boolean matchesMethod(ClassStorage classStorage, ClassGen classGen, Method method) {
|
||||
return classStorage == null || this.ruleSet.getValues() == 0
|
||||
? false
|
||||
: this.ruleSet.calculateCount(classStorage, classGen, method) > 0;
|
||||
}
|
||||
|
||||
public boolean matchesField(ClassStorage classStorage, ClassGen classGen, Field field) {
|
||||
return classStorage == null || this.ruleSet2.getValues() == 0
|
||||
? false
|
||||
: this.ruleSet2.calculateCount(classStorage, classGen, field) > 0;
|
||||
}
|
||||
|
||||
public void processRuleEntry2(RuleEntry ruleEntry) {
|
||||
this.ruleSet.processRuleEntry(ruleEntry);
|
||||
}
|
||||
|
||||
public MemberOrderOptions(Configuration configuration2) {
|
||||
super();
|
||||
this.configuration = configuration2;
|
||||
this.ruleSet2 = new RuleSet(0);
|
||||
this.ruleSet = new RuleSet(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import com.allatori.config.rule.RuleEntry;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.lib.bcel.generic.MethodGen;
|
||||
import com.allatori.model.ClassStorage;
|
||||
import com.allatori.transform.DistributedStringEncryptionTransformer;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
public class MethodCallRemovalOptions {
|
||||
|
||||
public Vector values;
|
||||
|
||||
public boolean enabled;
|
||||
|
||||
public final Configuration configuration;
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public MethodCallRemovalOptions(Configuration configuration2) {
|
||||
super();
|
||||
this.configuration = configuration2;
|
||||
this.enabled = false;
|
||||
this.values = new Vector();
|
||||
}
|
||||
|
||||
public boolean matchesText(
|
||||
ClassStorage classStorage,
|
||||
ClassGen classGen,
|
||||
MethodGen methodGen,
|
||||
String text3,
|
||||
String text5,
|
||||
String text6) {
|
||||
if (classStorage != null && text3 != null && text5 != null) {
|
||||
if (text5.startsWith(DistributedStringEncryptionTransformer.text4)) {
|
||||
return false;
|
||||
}
|
||||
if ("<init>".equals(text5)) {
|
||||
return false;
|
||||
}
|
||||
if ("<clinit>".equals(text5)) {
|
||||
return false;
|
||||
}
|
||||
if (this.values.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
Iterator iterator2 = this.values.iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
MethodCallRemovalRule methodCallRemovalRule;
|
||||
if ((methodCallRemovalRule = (MethodCallRemovalRule) iterator2.next())
|
||||
.ruleEntry.classRule.matches(classStorage, classGen)
|
||||
&& methodCallRemovalRule.ruleEntry.classRule.matches(methodGen)
|
||||
&& text3.matches(methodCallRemovalRule.text)
|
||||
&& text5.matches(methodCallRemovalRule.text2)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return Configuration.getOptimizationOptions().matchesText("" + text3 + "." + text5 + text6);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void processText(RuleEntry ruleEntry, String text, String text2) {
|
||||
this.enabled = true;
|
||||
String text3 = text.replaceAll("\\.", "\\\\.").replaceAll("\\*", ".*");
|
||||
String text4 = text2.replaceAll("\\.", "\\\\.").replaceAll("\\*", ".*");
|
||||
this.values.add(new MethodCallRemovalRule(this, ruleEntry, text3, text4));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import com.allatori.config.rule.RuleEntry;
|
||||
|
||||
public class MethodCallRemovalRule {
|
||||
|
||||
public String text;
|
||||
|
||||
public RuleEntry ruleEntry;
|
||||
|
||||
public final MethodCallRemovalOptions methodCallRemovalOptions;
|
||||
|
||||
public String text2;
|
||||
|
||||
public MethodCallRemovalRule(
|
||||
MethodCallRemovalOptions methodCallRemovalOptions2,
|
||||
RuleEntry ruleEntry2,
|
||||
String text,
|
||||
String text2) {
|
||||
super();
|
||||
this.methodCallRemovalOptions = methodCallRemovalOptions2;
|
||||
this.ruleEntry = ruleEntry2;
|
||||
this.text = text;
|
||||
this.text2 = text2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import com.allatori.config.rule.RuleEntry;
|
||||
import com.allatori.config.rule.RuleSet;
|
||||
import com.allatori.lib.bcel.classfile.Method;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.model.ClassStorage;
|
||||
|
||||
public class MethodRemovalOptions {
|
||||
|
||||
public String testString;
|
||||
|
||||
public RuleSet ruleSet;
|
||||
|
||||
public final Configuration configuration;
|
||||
|
||||
public void setTestString(String testString) {
|
||||
this.testString = testString;
|
||||
}
|
||||
|
||||
public void processRuleEntry(RuleEntry ruleEntry) {
|
||||
this.ruleSet.processRuleEntry(ruleEntry);
|
||||
}
|
||||
|
||||
public MethodRemovalOptions(Configuration configuration2) {
|
||||
super();
|
||||
this.configuration = configuration2;
|
||||
this.ruleSet = new RuleSet(0);
|
||||
this.testString = null;
|
||||
}
|
||||
|
||||
public String getTestString() {
|
||||
return this.testString;
|
||||
}
|
||||
|
||||
public boolean matchesMethod(ClassStorage classStorage, ClassGen classGen, Method method) {
|
||||
if (classStorage == null) {
|
||||
return false;
|
||||
} else {
|
||||
return this.ruleSet.getValues() == 0
|
||||
? false
|
||||
: this.ruleSet.calculateCount(classStorage, classGen, method) > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,346 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import com.allatori.naming.generator.AsciiNameGenerator;
|
||||
import com.allatori.naming.generator.JavaKeywordNameGenerator;
|
||||
import com.allatori.naming.generator.LengthBoundNameGenerator;
|
||||
import com.allatori.naming.generator.LowercaseConfusableNameGenerator;
|
||||
import com.allatori.naming.generator.LowercaseNameGenerator;
|
||||
import com.allatori.naming.generator.MainNameGenerator;
|
||||
import com.allatori.naming.generator.MethodNameGenerator;
|
||||
import com.allatori.naming.generator.MixedConfusableNameGenerator;
|
||||
import com.allatori.naming.generator.NameGenerator;
|
||||
import com.allatori.naming.generator.NumericNameGenerator;
|
||||
import com.allatori.naming.generator.PackageNameGenerator;
|
||||
import com.allatori.naming.generator.PrefixedNameGenerator;
|
||||
import com.allatori.naming.generator.RandomizedNameGenerator;
|
||||
import com.allatori.naming.generator.TypeNameGenerator;
|
||||
import com.allatori.naming.generator.UppercaseNameGenerator;
|
||||
import com.allatori.naming.generator.WindowsDeviceNameGenerator;
|
||||
import java.util.Locale;
|
||||
|
||||
public class NameGenerationOptions {
|
||||
|
||||
public String[] texts;
|
||||
|
||||
public static final int COUNT = 3;
|
||||
|
||||
public static final int COUNT2 = 1;
|
||||
|
||||
public static final int COUNT3 = 9;
|
||||
|
||||
public String[] texts2;
|
||||
|
||||
public static final int COUNT4 = 4;
|
||||
|
||||
public String methodsNamingPrefix;
|
||||
|
||||
public static final int COUNT5 = 8;
|
||||
|
||||
public String text2;
|
||||
|
||||
public String[] texts3;
|
||||
|
||||
public int classesNamingMode;
|
||||
|
||||
public final RenamingOptions renamingOptions;
|
||||
|
||||
public static final int COUNT6 = 2;
|
||||
|
||||
public String classesNamingPrefix;
|
||||
|
||||
public String[] texts4;
|
||||
|
||||
public static final int COUNT7 = 6;
|
||||
|
||||
public String fieldsNamingPrefix;
|
||||
|
||||
public int packagesNamingMode;
|
||||
|
||||
public int methodsNamingMode;
|
||||
|
||||
public int fieldsNamingMode;
|
||||
|
||||
public boolean fieldsNamingEnabled;
|
||||
|
||||
public boolean classesNamingEnabled;
|
||||
|
||||
public static final int COUNT8 = 5;
|
||||
|
||||
public boolean methodsNamingEnabled;
|
||||
|
||||
public static final int COUNT9 = 7;
|
||||
|
||||
public void setTexts3(String[] texts) {
|
||||
this.texts3 = texts;
|
||||
}
|
||||
|
||||
public void setMethodsNamingPrefix(String methodsNamingPrefix) {
|
||||
this.methodsNamingPrefix = methodsNamingPrefix;
|
||||
}
|
||||
|
||||
public NameGenerator createNameGenerator() {
|
||||
return new LengthBoundNameGenerator(new LowercaseNameGenerator());
|
||||
}
|
||||
|
||||
public void setEnabled(boolean fieldsNamingEnabled) {
|
||||
this.fieldsNamingEnabled = fieldsNamingEnabled;
|
||||
}
|
||||
|
||||
public void setTexts(String[] texts2) {
|
||||
this.texts = texts2;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
if (this.methodsNamingMode == 5) {
|
||||
return MixedConfusableNameGenerator.nextName2();
|
||||
} else {
|
||||
return this.methodsNamingMode == 9
|
||||
? LowercaseConfusableNameGenerator.nextName2()
|
||||
: RenamingOptions.getLocalVariableOptions(this.renamingOptions).getLocalVariablesNaming();
|
||||
}
|
||||
}
|
||||
|
||||
public NameGenerator createNameGenerator2() {
|
||||
NameGenerator nameGenerator;
|
||||
NameGenerationOptions nameGenerationOptions;
|
||||
if (this.methodsNamingMode == 1) {
|
||||
nameGenerator = new LowercaseNameGenerator();
|
||||
nameGenerationOptions = this;
|
||||
} else if (this.methodsNamingMode == 8) {
|
||||
nameGenerator = new UppercaseNameGenerator();
|
||||
nameGenerationOptions = this;
|
||||
} else if (this.methodsNamingMode == 3) {
|
||||
nameGenerator = new JavaKeywordNameGenerator();
|
||||
nameGenerationOptions = this;
|
||||
} else if (this.methodsNamingMode == 5) {
|
||||
nameGenerator = new MixedConfusableNameGenerator();
|
||||
nameGenerationOptions = this;
|
||||
} else if (this.methodsNamingMode == 9) {
|
||||
nameGenerator = new LowercaseConfusableNameGenerator();
|
||||
nameGenerationOptions = this;
|
||||
} else if (this.methodsNamingMode == 6) {
|
||||
nameGenerator = new NumericNameGenerator();
|
||||
nameGenerationOptions = this;
|
||||
} else if (this.methodsNamingMode == 7) {
|
||||
nameGenerator = new PackageNameGenerator(this.texts);
|
||||
nameGenerationOptions = this;
|
||||
} else {
|
||||
nameGenerator = new AsciiNameGenerator();
|
||||
nameGenerationOptions = this;
|
||||
}
|
||||
if (nameGenerationOptions.methodsNamingEnabled) {
|
||||
nameGenerator = new MainNameGenerator(nameGenerator, false, true);
|
||||
}
|
||||
NameGenerator nameGenerator2 = new LengthBoundNameGenerator(nameGenerator);
|
||||
if (this.text2 != null) {
|
||||
nameGenerator2 = new MethodNameGenerator(this.text2, nameGenerator2);
|
||||
}
|
||||
if (this.methodsNamingPrefix != null) {
|
||||
nameGenerator2 = new TypeNameGenerator(this.methodsNamingPrefix, nameGenerator2);
|
||||
}
|
||||
return nameGenerator2;
|
||||
}
|
||||
|
||||
public NameGenerator createNameGenerator3() {
|
||||
if (RenamingOptions.getLocalVariableOptions(this.renamingOptions).calculateCount() == 2) {
|
||||
return new LowercaseNameGenerator();
|
||||
} else {
|
||||
return RenamingOptions.getLocalVariableOptions(this.renamingOptions).calculateCount() == 1
|
||||
? new PrefixedNameGenerator(
|
||||
RenamingOptions.getLocalVariableOptions(this.renamingOptions)
|
||||
.getLocalVariablesNaming())
|
||||
: new LowercaseNameGenerator();
|
||||
}
|
||||
}
|
||||
|
||||
public NameGenerator createNameGenerator4() {
|
||||
NameGenerator nameGenerator;
|
||||
if (this.packagesNamingMode == 6) {
|
||||
nameGenerator = new NumericNameGenerator();
|
||||
} else if (this.packagesNamingMode == 7) {
|
||||
nameGenerator = new PackageNameGenerator(this.texts4);
|
||||
} else if (this.packagesNamingMode == 8) {
|
||||
nameGenerator = new UppercaseNameGenerator();
|
||||
} else {
|
||||
nameGenerator = new LowercaseNameGenerator();
|
||||
}
|
||||
return new LengthBoundNameGenerator(nameGenerator);
|
||||
}
|
||||
|
||||
public NameGenerationOptions(RenamingOptions renamingOptions2) {
|
||||
super();
|
||||
this.renamingOptions = renamingOptions2;
|
||||
this.packagesNamingMode = 1;
|
||||
this.classesNamingMode = 2;
|
||||
this.classesNamingEnabled = false;
|
||||
this.fieldsNamingMode = 2;
|
||||
this.methodsNamingMode = 2;
|
||||
this.fieldsNamingEnabled = false;
|
||||
this.methodsNamingEnabled = false;
|
||||
this.text2 = null;
|
||||
this.fieldsNamingPrefix = null;
|
||||
this.methodsNamingPrefix = null;
|
||||
this.classesNamingPrefix = null;
|
||||
this.texts2 = null;
|
||||
this.texts = null;
|
||||
this.texts3 = null;
|
||||
this.texts4 = null;
|
||||
}
|
||||
|
||||
public boolean isClassesNamingEnabled() {
|
||||
return this.classesNamingEnabled;
|
||||
}
|
||||
|
||||
public void setMethodsNamingMode(int methodsNamingMode) {
|
||||
this.methodsNamingMode = methodsNamingMode;
|
||||
}
|
||||
|
||||
public void setFieldsNamingMode(int fieldsNamingMode) {
|
||||
this.fieldsNamingMode = fieldsNamingMode;
|
||||
}
|
||||
|
||||
public boolean isFieldsNamingEnabled() {
|
||||
return this.fieldsNamingEnabled;
|
||||
}
|
||||
|
||||
public void setClassesNamingPrefix(String classesNamingPrefix) {
|
||||
this.classesNamingPrefix = classesNamingPrefix;
|
||||
}
|
||||
|
||||
public NameGenerator createNameGenerator5() {
|
||||
NameGenerator nameGenerator;
|
||||
NameGenerationOptions nameGenerationOptions;
|
||||
if (this.fieldsNamingMode == 1) {
|
||||
nameGenerator = new LowercaseNameGenerator();
|
||||
nameGenerationOptions = this;
|
||||
} else if (this.fieldsNamingMode == 8) {
|
||||
nameGenerator = new UppercaseNameGenerator();
|
||||
nameGenerationOptions = this;
|
||||
} else if (this.fieldsNamingMode == 3) {
|
||||
nameGenerator = new JavaKeywordNameGenerator();
|
||||
nameGenerationOptions = this;
|
||||
} else if (this.fieldsNamingMode == 5) {
|
||||
nameGenerator = new MixedConfusableNameGenerator();
|
||||
nameGenerationOptions = this;
|
||||
} else if (this.fieldsNamingMode == 9) {
|
||||
nameGenerator = new LowercaseConfusableNameGenerator();
|
||||
nameGenerationOptions = this;
|
||||
} else if (this.fieldsNamingMode == 6) {
|
||||
nameGenerator = new NumericNameGenerator();
|
||||
nameGenerationOptions = this;
|
||||
} else if (this.fieldsNamingMode == 7) {
|
||||
nameGenerator = new PackageNameGenerator(this.texts2);
|
||||
nameGenerationOptions = this;
|
||||
} else {
|
||||
nameGenerator = new AsciiNameGenerator();
|
||||
nameGenerationOptions = this;
|
||||
}
|
||||
if (nameGenerationOptions.fieldsNamingEnabled) {
|
||||
nameGenerator = new MainNameGenerator(nameGenerator, true, false);
|
||||
}
|
||||
NameGenerator nameGenerator2 = new LengthBoundNameGenerator(nameGenerator);
|
||||
if (this.text2 != null) {
|
||||
nameGenerator2 = new MethodNameGenerator(this.text2, nameGenerator2);
|
||||
}
|
||||
if (this.fieldsNamingPrefix != null) {
|
||||
nameGenerator2 = new TypeNameGenerator(this.fieldsNamingPrefix, nameGenerator2);
|
||||
}
|
||||
return nameGenerator2;
|
||||
}
|
||||
|
||||
public void setTexts4(String[] texts) {
|
||||
this.texts4 = texts;
|
||||
}
|
||||
|
||||
public void setEnabled3(boolean methodsNamingEnabled) {
|
||||
this.methodsNamingEnabled = methodsNamingEnabled;
|
||||
}
|
||||
|
||||
public NameGenerator createNameGenerator6() {
|
||||
NameGenerator nameGenerator;
|
||||
NameGenerationOptions nameGenerationOptions;
|
||||
if (this.classesNamingMode == 1) {
|
||||
nameGenerator = new LowercaseNameGenerator();
|
||||
nameGenerationOptions = this;
|
||||
} else if (this.classesNamingMode == 8) {
|
||||
nameGenerator = new UppercaseNameGenerator();
|
||||
nameGenerationOptions = this;
|
||||
} else if (this.classesNamingMode == 4) {
|
||||
nameGenerator = new WindowsDeviceNameGenerator();
|
||||
nameGenerationOptions = this;
|
||||
} else if (this.classesNamingMode == 5) {
|
||||
nameGenerator = new MixedConfusableNameGenerator();
|
||||
nameGenerationOptions = this;
|
||||
} else if (this.classesNamingMode == 9) {
|
||||
nameGenerator = new LowercaseConfusableNameGenerator();
|
||||
nameGenerationOptions = this;
|
||||
} else if (this.classesNamingMode == 6) {
|
||||
nameGenerator = new NumericNameGenerator();
|
||||
nameGenerationOptions = this;
|
||||
} else if (this.classesNamingMode == 7) {
|
||||
nameGenerator = new PackageNameGenerator(this.texts3);
|
||||
nameGenerationOptions = this;
|
||||
} else {
|
||||
nameGenerator = new AsciiNameGenerator();
|
||||
nameGenerationOptions = this;
|
||||
}
|
||||
String text;
|
||||
if (nameGenerationOptions.classesNamingMode != 1
|
||||
&& this.classesNamingMode != 8
|
||||
&& this.classesNamingMode != 6
|
||||
&& this.classesNamingMode != 9
|
||||
&& this.classesNamingMode != 7
|
||||
&& Configuration.getInputOptions().getValues2().size() > 0
|
||||
&& ((text = System.getProperty("os.name").toLowerCase(Locale.ENGLISH)) == null
|
||||
|| text.indexOf("win") >= 0
|
||||
|| text.indexOf("mac") >= 0)) {
|
||||
nameGenerator = new LowercaseNameGenerator();
|
||||
}
|
||||
if (Configuration.getObfuscationOptions().isEnabled3()) {
|
||||
nameGenerator = new RandomizedNameGenerator(nameGenerator);
|
||||
}
|
||||
NameGenerator nameGenerator2 = new LengthBoundNameGenerator(nameGenerator);
|
||||
if (this.classesNamingPrefix != null) {
|
||||
nameGenerator2 = new TypeNameGenerator(this.classesNamingPrefix, nameGenerator2);
|
||||
}
|
||||
return nameGenerator2;
|
||||
}
|
||||
|
||||
public void setEnabled2(boolean classesNamingEnabled) {
|
||||
this.classesNamingEnabled = classesNamingEnabled;
|
||||
}
|
||||
|
||||
public NameGenerationOptions(
|
||||
RenamingOptions renamingOptions,
|
||||
NamingOptionsConstructorToken namingOptionsConstructorToken) {
|
||||
this(renamingOptions);
|
||||
}
|
||||
|
||||
public void setTexts2(String[] texts) {
|
||||
this.texts2 = texts;
|
||||
}
|
||||
|
||||
public void processText(String text2) {
|
||||
if (this.text2 == null) {
|
||||
this.text2 = text2;
|
||||
} else {
|
||||
this.text2 = "" + this.text2 + this.text2.substring(8, 9) + text2;
|
||||
}
|
||||
}
|
||||
|
||||
public void setFieldsNamingPrefix(String fieldsNamingPrefix) {
|
||||
this.fieldsNamingPrefix = fieldsNamingPrefix;
|
||||
}
|
||||
|
||||
public void setClassesNamingMode(int classesNamingMode) {
|
||||
this.classesNamingMode = classesNamingMode;
|
||||
}
|
||||
|
||||
public boolean isMethodsNamingEnabled() {
|
||||
return this.methodsNamingEnabled;
|
||||
}
|
||||
|
||||
public void setPackagesNamingMode(int packagesNamingMode) {
|
||||
this.packagesNamingMode = packagesNamingMode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.allatori.config;
|
||||
|
||||
public class NamingOptionsConstructorToken {}
|
||||
@@ -0,0 +1,426 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import com.allatori.config.rule.RuleEntry;
|
||||
import com.allatori.config.rule.RuleSet;
|
||||
import com.allatori.lib.bcel.classfile.Method;
|
||||
import com.allatori.lib.bcel.generic.AnnotationEntryGen;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.lib.bcel.generic.ElementValuePairGen;
|
||||
import com.allatori.lib.bcel.generic.MethodGen;
|
||||
import com.allatori.model.ClassStorage;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
||||
public class ObfuscationOptions {
|
||||
|
||||
public RuleSet ruleSet;
|
||||
|
||||
public static final int COUNT = 1;
|
||||
|
||||
public char stringEncryptionSeed;
|
||||
|
||||
public boolean enabled;
|
||||
|
||||
public static final int COUNT2 = 2;
|
||||
|
||||
public static final int COUNT3 = 1;
|
||||
|
||||
public RuleSet ruleSet2;
|
||||
|
||||
public boolean outputJarCommentEnabled;
|
||||
|
||||
public String decryptorExcludePattern;
|
||||
|
||||
public boolean enabled3;
|
||||
|
||||
public static final int COUNT4 = 0;
|
||||
|
||||
public RuleSet ruleSet3;
|
||||
|
||||
public static final int COUNT5 = 100;
|
||||
|
||||
public static final int COUNT6 = 0;
|
||||
|
||||
public boolean java6Enabled;
|
||||
|
||||
public String stringEncryptionIgnoredStrings;
|
||||
|
||||
public boolean packageStringEncryptionEnabled;
|
||||
|
||||
public Hashtable entries;
|
||||
|
||||
public String decryptorIncludePattern;
|
||||
|
||||
public static final int COUNT7 = 0;
|
||||
|
||||
public RuleSet ruleSet4;
|
||||
|
||||
public String randomSeed;
|
||||
|
||||
public String outputJarComment;
|
||||
|
||||
public boolean methodsNamingEnabled;
|
||||
|
||||
public boolean globalStringEncryptionEnabled;
|
||||
|
||||
public String text6;
|
||||
|
||||
public int stringEncryptionVersion;
|
||||
|
||||
public static final int COUNT8 = 1000;
|
||||
|
||||
public static final int COUNT9 = 3;
|
||||
|
||||
public final Configuration configuration;
|
||||
|
||||
public static final int COUNT10 = 1;
|
||||
|
||||
public RuleSet ruleSet5;
|
||||
|
||||
public static final int COUNT11 = 0;
|
||||
|
||||
public static final int COUNT12 = 101;
|
||||
|
||||
public static final int COUNT13 = 1;
|
||||
|
||||
public RuleSet ruleSet6;
|
||||
|
||||
public boolean finalizeEnabled;
|
||||
|
||||
public RuleSet ruleSet7;
|
||||
|
||||
public void setDecryptorExcludePattern(String decryptorExcludePattern) {
|
||||
this.decryptorExcludePattern = decryptorExcludePattern;
|
||||
}
|
||||
|
||||
public void setEnabled7(boolean globalStringEncryptionEnabled) {
|
||||
this.globalStringEncryptionEnabled = globalStringEncryptionEnabled;
|
||||
}
|
||||
|
||||
public void setCharacter(char stringEncryptionSeed) {
|
||||
this.stringEncryptionSeed = stringEncryptionSeed;
|
||||
}
|
||||
|
||||
public boolean isOutputJarCommentEnabled() {
|
||||
return this.outputJarCommentEnabled;
|
||||
}
|
||||
|
||||
public String getRandomSeed() {
|
||||
return this.randomSeed;
|
||||
}
|
||||
|
||||
public void setEnabled3(boolean enabled3) {
|
||||
this.enabled3 = enabled3;
|
||||
}
|
||||
|
||||
public ObfuscationOptions(Configuration configuration2) {
|
||||
super();
|
||||
this.configuration = configuration2;
|
||||
this.entries = new Hashtable();
|
||||
this.ruleSet6 = new RuleSet(1);
|
||||
this.ruleSet5 = new RuleSet(0);
|
||||
this.ruleSet3 = new RuleSet(1);
|
||||
this.ruleSet = new RuleSet(1);
|
||||
this.ruleSet7 = new RuleSet(0);
|
||||
this.ruleSet2 = new RuleSet(0);
|
||||
this.ruleSet4 = new RuleSet(0);
|
||||
this.randomSeed = null;
|
||||
this.finalizeEnabled = false;
|
||||
this.enabled = false;
|
||||
this.enabled3 = false;
|
||||
this.methodsNamingEnabled = true;
|
||||
this.outputJarCommentEnabled = true;
|
||||
this.outputJarComment = null;
|
||||
this.stringEncryptionSeed = '\uffff';
|
||||
this.stringEncryptionVersion = 1;
|
||||
this.globalStringEncryptionEnabled = false;
|
||||
this.packageStringEncryptionEnabled = false;
|
||||
this.decryptorIncludePattern = "";
|
||||
this.decryptorExcludePattern = "";
|
||||
this.java6Enabled = false;
|
||||
this.text6 = "org.springframework.boot.";
|
||||
}
|
||||
|
||||
public boolean matchesMethod(ClassStorage classStorage, ClassGen classGen, Method method) {
|
||||
return classStorage == null
|
||||
? false
|
||||
: this.ruleSet4.calculateCount(classStorage, classGen, method) > 0;
|
||||
}
|
||||
|
||||
public void setEnabled8(boolean finalizeEnabled) {
|
||||
this.finalizeEnabled = finalizeEnabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public int calculateCount(ClassStorage classStorage, ClassGen classGen) {
|
||||
if (!this.packageStringEncryptionEnabled && classGen.getClassName().startsWith(this.text6)) {
|
||||
return 0;
|
||||
}
|
||||
AnnotationEntryGen[] annotationEntryGens;
|
||||
int value = (annotationEntryGens = classGen.getAnnotationEntries()).length;
|
||||
int value2;
|
||||
for (int value3 = value2 = 0; value3 < value; value3 = ++value2) {
|
||||
AnnotationEntryGen annotationEntryGen = annotationEntryGens[value2];
|
||||
if ("Lcom/allatori/annotations/DisableStringEncryption;"
|
||||
.equals(annotationEntryGen.getText2())) {
|
||||
return 0;
|
||||
}
|
||||
if ("Lcom/allatori/annotations/EnableStringEncryption;"
|
||||
.equals(annotationEntryGen.getText2())) {
|
||||
return 1;
|
||||
}
|
||||
if ("Lcom/allatori/annotations/MaximumStringEncryption;"
|
||||
.equals(annotationEntryGen.getText2())) {
|
||||
return 3;
|
||||
}
|
||||
List values;
|
||||
if ("Lcom/allatori/annotations/StringEncryption;".equals(annotationEntryGen.getText2())
|
||||
&& (values = annotationEntryGen.getValues()) != null
|
||||
&& values.size() > 0
|
||||
&& ((ElementValuePairGen) values.get(0)).getValue() != null) {
|
||||
if ("enable".equals(((ElementValuePairGen) values.get(0)).getValue().stringifyValue())) {
|
||||
return 1;
|
||||
}
|
||||
if ("disable".equals(((ElementValuePairGen) values.get(0)).getValue().stringifyValue())) {
|
||||
return 0;
|
||||
}
|
||||
if ("maximum".equals(((ElementValuePairGen) values.get(0)).getValue().stringifyValue())) {
|
||||
return 2;
|
||||
}
|
||||
if ("maximum-with-warnings"
|
||||
.equals(((ElementValuePairGen) values.get(0)).getValue().stringifyValue())) {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.ruleSet6.calculateCount(classStorage, classGen);
|
||||
}
|
||||
|
||||
public boolean isGlobalStringEncryptionEnabled() {
|
||||
return this.globalStringEncryptionEnabled;
|
||||
}
|
||||
|
||||
public void setEnabled5(boolean packageStringEncryptionEnabled) {
|
||||
this.packageStringEncryptionEnabled = packageStringEncryptionEnabled;
|
||||
}
|
||||
|
||||
public boolean isMethodsNamingEnabled() {
|
||||
return this.methodsNamingEnabled;
|
||||
}
|
||||
|
||||
public void setRandomSeed(String randomSeed) {
|
||||
this.randomSeed = randomSeed;
|
||||
}
|
||||
|
||||
public String getDecryptorIncludePattern() {
|
||||
return this.decryptorIncludePattern;
|
||||
}
|
||||
|
||||
public String getDecryptorExcludePattern() {
|
||||
return this.decryptorExcludePattern;
|
||||
}
|
||||
|
||||
public int calculateCount2(ClassStorage classStorage, ClassGen classGen) {
|
||||
return this.ruleSet3.calculateCount(classStorage, classGen);
|
||||
}
|
||||
|
||||
public Hashtable getEntries() {
|
||||
return this.entries;
|
||||
}
|
||||
|
||||
public String getStringEncryptionIgnoredStrings() {
|
||||
return this.stringEncryptionIgnoredStrings;
|
||||
}
|
||||
|
||||
public void setStringEncryptionVersion(int stringEncryptionVersion) {
|
||||
this.stringEncryptionVersion = stringEncryptionVersion;
|
||||
}
|
||||
|
||||
public void processRuleEntry(RuleEntry ruleEntry) {
|
||||
this.ruleSet7.processRuleEntry(ruleEntry);
|
||||
}
|
||||
|
||||
public int calculateCount(ClassStorage classStorage, ClassGen classGen, MethodGen methodGen) {
|
||||
if (this.enabled) {
|
||||
return 0;
|
||||
}
|
||||
AnnotationEntryGen[] annotationEntryGens;
|
||||
int value = (annotationEntryGens = classGen.getAnnotationEntries()).length;
|
||||
int value2;
|
||||
for (int value3 = value2 = 0; value3 < value; value3 = ++value2) {
|
||||
AnnotationEntryGen annotationEntryGen = annotationEntryGens[value2];
|
||||
if ("Lcom/allatori/annotations/StrongStringEncryptionType;"
|
||||
.equals(annotationEntryGen.getText2())) {
|
||||
return 1;
|
||||
}
|
||||
if ("Lcom/allatori/annotations/FastStringEncryptionType;"
|
||||
.equals(annotationEntryGen.getText2())) {
|
||||
return 0;
|
||||
}
|
||||
List values;
|
||||
if ("Lcom/allatori/annotations/StringEncryptionType;".equals(annotationEntryGen.getText2())
|
||||
&& (values = annotationEntryGen.getValues()) != null
|
||||
&& values.size() > 0
|
||||
&& ((ElementValuePairGen) values.get(0)).getValue() != null) {
|
||||
if ("fast".equals(((ElementValuePairGen) values.get(0)).getValue().stringifyValue())) {
|
||||
return 0;
|
||||
}
|
||||
if ("strong".equals(((ElementValuePairGen) values.get(0)).getValue().stringifyValue())) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.ruleSet5.calculateCount(classStorage, classGen, methodGen);
|
||||
}
|
||||
|
||||
public void setEnabled2(boolean outputJarCommentEnabled) {
|
||||
this.outputJarCommentEnabled = outputJarCommentEnabled;
|
||||
}
|
||||
|
||||
public void processRuleEntry2(RuleEntry ruleEntry) {
|
||||
this.ruleSet4.processRuleEntry(ruleEntry);
|
||||
}
|
||||
|
||||
public boolean isPackageStringEncryptionEnabled() {
|
||||
return this.packageStringEncryptionEnabled;
|
||||
}
|
||||
|
||||
public void processRuleEntry3(RuleEntry ruleEntry) {
|
||||
this.ruleSet.processRuleEntry(ruleEntry);
|
||||
}
|
||||
|
||||
public void setStringEncryptionIgnoredStrings(String stringEncryptionIgnoredStrings) {
|
||||
this.stringEncryptionIgnoredStrings = stringEncryptionIgnoredStrings;
|
||||
}
|
||||
|
||||
public void processRuleEntry4(RuleEntry ruleEntry) {
|
||||
this.ruleSet6.processRuleEntry(ruleEntry);
|
||||
}
|
||||
|
||||
public boolean matchesClassGen(ClassStorage classStorage, ClassGen classGen) {
|
||||
return classStorage == null ? false : this.ruleSet7.calculateCount(classStorage, classGen) > 0;
|
||||
}
|
||||
|
||||
public void setEnabled6(boolean methodsNamingEnabled) {
|
||||
this.methodsNamingEnabled = methodsNamingEnabled;
|
||||
}
|
||||
|
||||
public char getCharacter() {
|
||||
return this.stringEncryptionSeed;
|
||||
}
|
||||
|
||||
public int getStringEncryptionVersion() {
|
||||
return this.stringEncryptionVersion;
|
||||
}
|
||||
|
||||
public boolean isJava6Enabled() {
|
||||
return this.java6Enabled;
|
||||
}
|
||||
|
||||
public void processRuleEntry5(RuleEntry ruleEntry) {
|
||||
this.ruleSet5.processRuleEntry(ruleEntry);
|
||||
}
|
||||
|
||||
public void setDecryptorIncludePattern(String decryptorIncludePattern) {
|
||||
this.decryptorIncludePattern = decryptorIncludePattern;
|
||||
}
|
||||
|
||||
public boolean isFinalizeEnabled() {
|
||||
return this.finalizeEnabled;
|
||||
}
|
||||
|
||||
public String getOutputJarComment() {
|
||||
return this.outputJarComment;
|
||||
}
|
||||
|
||||
public void processRuleEntry6(RuleEntry ruleEntry) {
|
||||
this.ruleSet3.processRuleEntry(ruleEntry);
|
||||
}
|
||||
|
||||
public void setOutputJarComment(String outputJarComment) {
|
||||
this.outputJarComment = outputJarComment;
|
||||
}
|
||||
|
||||
public boolean isEnabled3() {
|
||||
return this.enabled3;
|
||||
}
|
||||
|
||||
public void setEnabled4(boolean java6Enabled) {
|
||||
this.java6Enabled = java6Enabled;
|
||||
}
|
||||
|
||||
public boolean matchesMethodGen(
|
||||
ClassStorage classStorage, ClassGen classGen, MethodGen methodGen) {
|
||||
if (methodGen.getName().startsWith("Allatori")) {
|
||||
return !Configuration.getObfuscationOptions().isEnabled();
|
||||
}
|
||||
AnnotationEntryGen[] annotationEntryGens;
|
||||
int value = (annotationEntryGens = methodGen.getAnnotationEntryGens()).length;
|
||||
int value2;
|
||||
for (int value3 = value2 = 0; value3 < value; value3 = ++value2) {
|
||||
AnnotationEntryGen annotationEntryGen = annotationEntryGens[value2];
|
||||
if ("Lcom/allatori/annotations/DisableControlFlowObfuscation;"
|
||||
.equals(annotationEntryGen.getText2())) {
|
||||
return false;
|
||||
}
|
||||
if ("Lcom/allatori/annotations/EnableControlFlowObfuscation;"
|
||||
.equals(annotationEntryGen.getText2())) {
|
||||
return true;
|
||||
}
|
||||
List values;
|
||||
if ("Lcom/allatori/annotations/ControlFlowObfuscation;".equals(annotationEntryGen.getText2())
|
||||
&& (values = annotationEntryGen.getValues()) != null
|
||||
&& values.size() > 0
|
||||
&& ((ElementValuePairGen) values.get(0)).getValue() != null) {
|
||||
if ("enable".equals(((ElementValuePairGen) values.get(0)).getValue().stringifyValue())) {
|
||||
return true;
|
||||
}
|
||||
if ("disable".equals(((ElementValuePairGen) values.get(0)).getValue().stringifyValue())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
AnnotationEntryGen[] annotationEntryGens2;
|
||||
int value4 = (annotationEntryGens2 = classGen.getAnnotationEntries()).length;
|
||||
int value5;
|
||||
for (int value6 = value5 = 0; value6 < value4; value6 = ++value5) {
|
||||
AnnotationEntryGen annotationEntryGen2 = annotationEntryGens2[value5];
|
||||
if ("Lcom/allatori/annotations/DisableControlFlowObfuscation;"
|
||||
.equals(annotationEntryGen2.getText2())) {
|
||||
return false;
|
||||
}
|
||||
if ("Lcom/allatori/annotations/EnableControlFlowObfuscation;"
|
||||
.equals(annotationEntryGen2.getText2())) {
|
||||
return true;
|
||||
}
|
||||
List values2;
|
||||
if ("Lcom/allatori/annotations/ControlFlowObfuscation;".equals(annotationEntryGen2.getText2())
|
||||
&& (values2 = annotationEntryGen2.getValues()) != null
|
||||
&& values2.size() > 0
|
||||
&& ((ElementValuePairGen) values2.get(0)).getValue() != null) {
|
||||
if ("enable".equals(((ElementValuePairGen) values2.get(0)).getValue().stringifyValue())) {
|
||||
return true;
|
||||
}
|
||||
if ("disable".equals(((ElementValuePairGen) values2.get(0)).getValue().stringifyValue())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.ruleSet.calculateCount(classStorage, classGen, methodGen) > 0;
|
||||
}
|
||||
|
||||
public boolean matchesClassGen2(ClassStorage classStorage, ClassGen classGen) {
|
||||
return classStorage == null ? false : this.ruleSet2.calculateCount(classStorage, classGen) > 0;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public void processRuleEntry7(RuleEntry ruleEntry) {
|
||||
this.ruleSet2.processRuleEntry(ruleEntry);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import com.allatori.config.rule.RuleEntry;
|
||||
import com.allatori.config.rule.RuleSet;
|
||||
import com.allatori.lib.bcel.classfile.Method;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.model.ClassStorage;
|
||||
import java.util.Vector;
|
||||
|
||||
public class OptimizationOptions {
|
||||
|
||||
public RuleSet ruleSet;
|
||||
|
||||
public Vector values;
|
||||
|
||||
public RuleSet ruleSet2;
|
||||
|
||||
public final Configuration configuration;
|
||||
|
||||
public boolean matchesClassGen(ClassStorage classStorage, ClassGen classGen) {
|
||||
if (classStorage == null) {
|
||||
return false;
|
||||
} else {
|
||||
return this.ruleSet.getValues() == 0
|
||||
? false
|
||||
: this.ruleSet.calculateCount(classStorage, classGen) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void processRuleEntry(RuleEntry ruleEntry) {
|
||||
this.ruleSet.processRuleEntry(ruleEntry);
|
||||
}
|
||||
|
||||
public void processRuleEntry2(RuleEntry ruleEntry) {
|
||||
this.ruleSet2.processRuleEntry(ruleEntry);
|
||||
}
|
||||
|
||||
public boolean matchesText(String text) {
|
||||
return this.values.contains(text);
|
||||
}
|
||||
|
||||
public OptimizationOptions(Configuration configuration2) {
|
||||
super();
|
||||
this.configuration = configuration2;
|
||||
this.ruleSet = new RuleSet(0);
|
||||
this.ruleSet2 = new RuleSet(0);
|
||||
this.values = new Vector();
|
||||
}
|
||||
|
||||
public boolean matchesMethod(ClassStorage classStorage, ClassGen classGen, Method method) {
|
||||
if (classStorage == null) {
|
||||
return false;
|
||||
} else {
|
||||
return this.ruleSet2.getValues() == 0
|
||||
? false
|
||||
: this.ruleSet2.calculateCount(classStorage, classGen, method) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void processText(String text) {
|
||||
this.values.add(text);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.allatori.config;
|
||||
|
||||
public class OutputOptions {
|
||||
|
||||
public int compressionLevel;
|
||||
|
||||
public String logFile;
|
||||
|
||||
public final Configuration configuration;
|
||||
|
||||
public boolean keepDuplicateEntries;
|
||||
|
||||
public void setEnabled(boolean keepDuplicateEntries) {
|
||||
this.keepDuplicateEntries = keepDuplicateEntries;
|
||||
}
|
||||
|
||||
public OutputOptions(Configuration configuration2) {
|
||||
super();
|
||||
this.configuration = configuration2;
|
||||
this.compressionLevel = -1;
|
||||
this.keepDuplicateEntries = false;
|
||||
}
|
||||
|
||||
public void setCompressionLevel(int compressionLevel) {
|
||||
this.compressionLevel = compressionLevel;
|
||||
}
|
||||
|
||||
public boolean isKeepDuplicateEntries() {
|
||||
return this.keepDuplicateEntries;
|
||||
}
|
||||
|
||||
public void setLogFile(String logFile) {
|
||||
this.logFile = logFile;
|
||||
}
|
||||
|
||||
public String getLogFile() {
|
||||
return this.logFile;
|
||||
}
|
||||
|
||||
public int getCompressionLevel() {
|
||||
return this.compressionLevel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import com.allatori.config.rule.RuleEntry;
|
||||
|
||||
public class PackageNameRule {
|
||||
|
||||
public RuleEntry ruleEntry;
|
||||
|
||||
public final PackageRenamingOptions packageRenamingOptions;
|
||||
|
||||
public String text;
|
||||
|
||||
public PackageNameRule(
|
||||
PackageRenamingOptions packageRenamingOptions2, RuleEntry ruleEntry2, String text) {
|
||||
super();
|
||||
this.packageRenamingOptions = packageRenamingOptions2;
|
||||
this.ruleEntry = ruleEntry2;
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import com.allatori.config.rule.RuleEntry;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.model.ClassStorage;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
public class PackageRenamingOptions {
|
||||
|
||||
public Vector values;
|
||||
|
||||
public boolean enabled;
|
||||
|
||||
public final Configuration configuration;
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public boolean matchesText(ClassStorage classStorage, ClassGen classGen, String text2) {
|
||||
if (classStorage != null && classGen != null && text2 != null) {
|
||||
if (this.values.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
Iterator iterator2 = this.values.iterator();
|
||||
while (iterator2.hasNext()) {
|
||||
PackageNameRule packageNameRule;
|
||||
if ((packageNameRule = (PackageNameRule) iterator2.next())
|
||||
.ruleEntry.classRule.matches(classStorage, classGen)
|
||||
&& text2.matches(packageNameRule.text)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void processText(RuleEntry ruleEntry, String text) {
|
||||
this.enabled = true;
|
||||
String text2 = text.replaceAll("\\.", "\\\\.").replaceAll("\\*", ".*");
|
||||
this.values.add(new PackageNameRule(this, ruleEntry, text2));
|
||||
}
|
||||
|
||||
public PackageRenamingOptions(Configuration configuration2) {
|
||||
super();
|
||||
this.configuration = configuration2;
|
||||
this.enabled = false;
|
||||
this.values = new Vector();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import com.allatori.config.rule.RuleEntry;
|
||||
import com.allatori.config.rule.RuleSet;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.model.ClassStorage;
|
||||
|
||||
public class RenamingOptions {
|
||||
|
||||
public String defaultPackage;
|
||||
|
||||
public boolean enabled;
|
||||
|
||||
public NameGenerationOptions nameGenerationOptions;
|
||||
|
||||
public boolean compatibleRenamingEnabled;
|
||||
|
||||
public KeepNamesOptions keepNamesOptions;
|
||||
|
||||
public boolean randomizeNamesEnabled;
|
||||
|
||||
public LocalVariableOptions localVariableOptions;
|
||||
|
||||
public String incrementalObfuscation;
|
||||
|
||||
public boolean classesNamingEnabled;
|
||||
|
||||
public boolean skipRenamingEnabled;
|
||||
|
||||
public RuleSet ruleSet;
|
||||
|
||||
public boolean fieldsNamingEnabled;
|
||||
|
||||
public final Configuration configuration;
|
||||
|
||||
public LineNumberOptions lineNumberOptions;
|
||||
|
||||
public ResourceRenamingOptions resourceRenamingOptions;
|
||||
|
||||
public boolean forceDefaultPackageEnabled;
|
||||
|
||||
public boolean enabled8;
|
||||
|
||||
public boolean isSkipRenamingEnabled() {
|
||||
return this.skipRenamingEnabled;
|
||||
}
|
||||
|
||||
public void setIncrementalObfuscation(String incrementalObfuscation) {
|
||||
this.incrementalObfuscation = incrementalObfuscation;
|
||||
}
|
||||
|
||||
public void setEnabled2(boolean compatibleRenamingEnabled) {
|
||||
this.compatibleRenamingEnabled = compatibleRenamingEnabled;
|
||||
}
|
||||
|
||||
public boolean isForceDefaultPackageEnabled() {
|
||||
return this.forceDefaultPackageEnabled;
|
||||
}
|
||||
|
||||
public RenamingOptions(Configuration configuration2) {
|
||||
super();
|
||||
this.configuration = configuration2;
|
||||
this.skipRenamingEnabled = false;
|
||||
this.forceDefaultPackageEnabled = false;
|
||||
this.enabled8 = false;
|
||||
this.fieldsNamingEnabled = false;
|
||||
this.randomizeNamesEnabled = true;
|
||||
this.enabled = false;
|
||||
this.compatibleRenamingEnabled = false;
|
||||
this.classesNamingEnabled = false;
|
||||
this.ruleSet = new RuleSet(0);
|
||||
this.keepNamesOptions = new KeepNamesOptions(this, null);
|
||||
this.lineNumberOptions = new LineNumberOptions(this);
|
||||
this.nameGenerationOptions = new NameGenerationOptions(this, null);
|
||||
this.localVariableOptions = new LocalVariableOptions(this);
|
||||
this.resourceRenamingOptions = new ResourceRenamingOptions(this);
|
||||
}
|
||||
|
||||
public KeepNamesOptions getKeepNamesOptions() {
|
||||
return this.keepNamesOptions;
|
||||
}
|
||||
|
||||
public NameGenerationOptions getNameGenerationOptions() {
|
||||
return this.nameGenerationOptions;
|
||||
}
|
||||
|
||||
public LocalVariableOptions getLocalVariableOptions() {
|
||||
return this.localVariableOptions;
|
||||
}
|
||||
|
||||
public boolean matchesClassGen(ClassStorage classStorage, ClassGen classGen) {
|
||||
return this.ruleSet.calculateCount(classStorage, classGen) == 1;
|
||||
}
|
||||
|
||||
public LineNumberOptions getLineNumberOptions() {
|
||||
return this.lineNumberOptions;
|
||||
}
|
||||
|
||||
public void setEnabled3(boolean randomizeNamesEnabled) {
|
||||
this.randomizeNamesEnabled = randomizeNamesEnabled;
|
||||
}
|
||||
|
||||
public boolean isClassesNamingEnabled() {
|
||||
return this.classesNamingEnabled;
|
||||
}
|
||||
|
||||
public static boolean matchesRenamingOptions(RenamingOptions renamingOptions) {
|
||||
return renamingOptions.skipRenamingEnabled;
|
||||
}
|
||||
|
||||
public ResourceRenamingOptions getResourceRenamingOptions() {
|
||||
return this.resourceRenamingOptions;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public void setEnabled4(boolean classesNamingEnabled) {
|
||||
this.classesNamingEnabled = classesNamingEnabled;
|
||||
}
|
||||
|
||||
public void processRuleEntry(RuleEntry ruleEntry) {
|
||||
this.ruleSet.processRuleEntry(ruleEntry);
|
||||
}
|
||||
|
||||
public boolean isText2() {
|
||||
return this.incrementalObfuscation != null;
|
||||
}
|
||||
|
||||
public void setEnabled8(boolean enabled8) {
|
||||
this.enabled8 = enabled8;
|
||||
}
|
||||
|
||||
public void setEnabled7(boolean forceDefaultPackageEnabled) {
|
||||
this.forceDefaultPackageEnabled = forceDefaultPackageEnabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public void setDefaultPackage(String defaultPackage) {
|
||||
this.defaultPackage = defaultPackage;
|
||||
}
|
||||
|
||||
public boolean isFieldsNamingEnabled() {
|
||||
return this.fieldsNamingEnabled;
|
||||
}
|
||||
|
||||
public static LocalVariableOptions getLocalVariableOptions(RenamingOptions renamingOptions) {
|
||||
return renamingOptions.localVariableOptions;
|
||||
}
|
||||
|
||||
public void setEnabled6(boolean fieldsNamingEnabled) {
|
||||
this.fieldsNamingEnabled = fieldsNamingEnabled;
|
||||
}
|
||||
|
||||
public boolean isEnabled8() {
|
||||
return this.enabled8;
|
||||
}
|
||||
|
||||
public String getDefaultPackage() {
|
||||
return this.defaultPackage;
|
||||
}
|
||||
|
||||
public boolean isCompatibleRenamingEnabled() {
|
||||
return this.compatibleRenamingEnabled;
|
||||
}
|
||||
|
||||
public boolean isRandomizeNamesEnabled() {
|
||||
return this.randomizeNamesEnabled;
|
||||
}
|
||||
|
||||
public String getIncrementalObfuscation() {
|
||||
return this.incrementalObfuscation;
|
||||
}
|
||||
|
||||
public boolean isText() {
|
||||
return this.defaultPackage != null;
|
||||
}
|
||||
|
||||
public void setEnabled5(boolean skipRenamingEnabled) {
|
||||
this.skipRenamingEnabled = skipRenamingEnabled;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.allatori.config;
|
||||
|
||||
public class ResourceNameRule {
|
||||
|
||||
public final ResourceRenamingOptions resourceRenamingOptions;
|
||||
|
||||
public boolean enabled;
|
||||
|
||||
public String text;
|
||||
|
||||
public String text2;
|
||||
|
||||
public static boolean matchesResourceNameRule(ResourceNameRule resourceNameRule) {
|
||||
return resourceNameRule.enabled;
|
||||
}
|
||||
|
||||
public static String getText(ResourceNameRule resourceNameRule) {
|
||||
return resourceNameRule.text;
|
||||
}
|
||||
|
||||
public static String getText2(ResourceNameRule resourceNameRule) {
|
||||
return resourceNameRule.text2;
|
||||
}
|
||||
|
||||
public ResourceNameRule(
|
||||
ResourceRenamingOptions resourceRenamingOptions2,
|
||||
String text,
|
||||
boolean enabled,
|
||||
String text2) {
|
||||
super();
|
||||
this.resourceRenamingOptions = resourceRenamingOptions2;
|
||||
this.text = text;
|
||||
this.enabled = enabled;
|
||||
this.text2 = text2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Vector;
|
||||
|
||||
public class ResourceRenamingOptions {
|
||||
|
||||
public boolean updateResourceNamesEnabled;
|
||||
|
||||
public Vector values;
|
||||
|
||||
public final RenamingOptions renamingOptions;
|
||||
|
||||
public void processText(String text, boolean matches, String text2) {
|
||||
String text3 = text.replaceAll("\\.", "\\\\.").replaceAll("\\*", ".*");
|
||||
this.values.add(new ResourceNameRule(this, text3, matches, text2));
|
||||
}
|
||||
|
||||
public boolean matchesText(String text) {
|
||||
String text2;
|
||||
if (!(text2 = text.toLowerCase(Locale.ENGLISH)).endsWith(".jar")
|
||||
&& !text2.endsWith(".class")
|
||||
&& !text2.endsWith(".jks")
|
||||
&& !text2.endsWith(".ttf")
|
||||
&& !text2.endsWith(".png")
|
||||
&& !text2.endsWith(".jpg")
|
||||
&& !text2.endsWith(".jpeg")
|
||||
&& !text2.endsWith(".gif")
|
||||
&& !text2.endsWith(".bmp")
|
||||
&& !text2.endsWith(".svg")
|
||||
&& !text2.endsWith(".ico")) {
|
||||
for (ResourceNameRule resourceNameRule :
|
||||
((Iterable<ResourceNameRule>) ((Iterable<?>) this.values))) {
|
||||
if (text.matches(ResourceNameRule.getText(resourceNameRule))) {
|
||||
return ResourceNameRule.matchesResourceNameRule(resourceNameRule);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public String getText(String text) {
|
||||
text.toLowerCase(Locale.ENGLISH);
|
||||
for (ResourceNameRule resourceNameRule :
|
||||
((Iterable<ResourceNameRule>) ((Iterable<?>) this.values))) {
|
||||
if (text.matches(ResourceNameRule.getText(resourceNameRule))) {
|
||||
return ResourceNameRule.getText2(resourceNameRule);
|
||||
}
|
||||
}
|
||||
return "UTF-8";
|
||||
}
|
||||
|
||||
public void setEnabled(boolean updateResourceNamesEnabled) {
|
||||
this.updateResourceNamesEnabled = updateResourceNamesEnabled;
|
||||
}
|
||||
|
||||
public ResourceRenamingOptions(RenamingOptions renamingOptions2) {
|
||||
super();
|
||||
this.renamingOptions = renamingOptions2;
|
||||
this.updateResourceNamesEnabled = false;
|
||||
this.values = new Vector();
|
||||
}
|
||||
|
||||
public boolean isUpdateResourceNamesEnabled() {
|
||||
return this.updateResourceNamesEnabled;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import com.allatori.config.rule.RuleEntry;
|
||||
import com.allatori.config.rule.RuleSet;
|
||||
import com.allatori.lib.bcel.classfile.AnnotationEntry;
|
||||
import com.allatori.lib.bcel.classfile.Field;
|
||||
import com.allatori.lib.bcel.classfile.Method;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.model.ClassStorage;
|
||||
|
||||
public class SyntheticOptions {
|
||||
|
||||
public RuleSet ruleSet;
|
||||
|
||||
public RuleSet ruleSet2;
|
||||
|
||||
public final Configuration configuration;
|
||||
|
||||
public boolean matchesMethod(ClassStorage classStorage, ClassGen classGen, Method method) {
|
||||
if (classStorage == null) {
|
||||
return false;
|
||||
}
|
||||
AnnotationEntry[] annotationEntries = method.getAnnotationEntries();
|
||||
int value;
|
||||
for (int value2 = value = 0; value2 < annotationEntries.length; value2 = ++value) {
|
||||
AnnotationEntry annotationEntry = annotationEntries[value];
|
||||
if ("Lcom/allatori/annotations/Synthetize;".equals(annotationEntry.getText())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return this.ruleSet2.getValues() == 0
|
||||
? method.isEnabled9()
|
||||
: this.ruleSet2.calculateCount(classStorage, classGen, method) > 0;
|
||||
}
|
||||
|
||||
public void processRuleEntry(RuleEntry ruleEntry) {
|
||||
this.ruleSet.processRuleEntry(ruleEntry);
|
||||
}
|
||||
|
||||
public SyntheticOptions(Configuration configuration2) {
|
||||
super();
|
||||
this.configuration = configuration2;
|
||||
this.ruleSet = new RuleSet(0);
|
||||
this.ruleSet2 = new RuleSet(0);
|
||||
}
|
||||
|
||||
public void processRuleEntry2(RuleEntry ruleEntry) {
|
||||
this.ruleSet2.processRuleEntry(ruleEntry);
|
||||
}
|
||||
|
||||
public boolean matchesField(ClassStorage classStorage, ClassGen classGen, Field field) {
|
||||
if (classStorage == null) {
|
||||
return false;
|
||||
}
|
||||
AnnotationEntry[] annotationEntries = field.getAnnotationEntries();
|
||||
int value;
|
||||
for (int value2 = value = 0; value2 < annotationEntries.length; value2 = ++value) {
|
||||
AnnotationEntry annotationEntry = annotationEntries[value];
|
||||
if ("Lcom/allatori/annotations/Synthetize;".equals(annotationEntry.getText())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return this.ruleSet.getValues() == 0
|
||||
? false
|
||||
: this.ruleSet.calculateCount(classStorage, classGen, field) > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.allatori.config;
|
||||
|
||||
public class WatermarkOptions {
|
||||
|
||||
public boolean enabled;
|
||||
|
||||
public String text;
|
||||
|
||||
public final Configuration configuration;
|
||||
|
||||
public String text2;
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public WatermarkOptions(Configuration configuration2) {
|
||||
super();
|
||||
this.configuration = configuration2;
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public void setText2(String text2) {
|
||||
this.text2 = text2;
|
||||
}
|
||||
|
||||
public String getText2() {
|
||||
return this.text2;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.text;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.allatori.config;
|
||||
|
||||
import java.io.FileReader;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.XMLReader;
|
||||
|
||||
public class XmlParsingContext implements ConfigurationSource {
|
||||
|
||||
public String text;
|
||||
|
||||
@Override
|
||||
public void parse() throws ConfigurationException {
|
||||
try {
|
||||
FileReader fileReader = new FileReader(this.text);
|
||||
XMLReader xMLReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
|
||||
xMLReader.setContentHandler(new ConfigurationHandler(this, null));
|
||||
xMLReader.parse(new InputSource(fileReader));
|
||||
} catch (ConfigurationSaxException configurationSaxException) {
|
||||
throw new ConfigurationException(configurationSaxException.getMessage());
|
||||
} catch (Exception exception) {
|
||||
throw new ConfigurationException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public XmlParsingContext(String text) {
|
||||
super();
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public static String getText(XmlParsingContext xmlParsingContext) {
|
||||
return xmlParsingContext.text;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.allatori.config.property;
|
||||
|
||||
public abstract class PropertyHandler {
|
||||
|
||||
public abstract void apply(String text, String text2);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.allatori.config.property;
|
||||
|
||||
import com.allatori.config.ConfigurationException;
|
||||
|
||||
public class PropertyRegistry {
|
||||
|
||||
public static Object[][] values =
|
||||
new Object[][] {{"string-encryption", StringEncryptionProperty.class}, {"", ""}, {"", ""}};
|
||||
|
||||
public static String text3 = "enable";
|
||||
|
||||
public static String text = "disable";
|
||||
|
||||
public static String text2 = "maximum";
|
||||
|
||||
public static PropertyHandler createPropertyHandler(String text) throws ConfigurationException {
|
||||
int value;
|
||||
for (int value2 = value = values.length - 1; value2 >= 0; value2 = --value) {
|
||||
if (text.equals(values[value][0])) {
|
||||
Class classValue = (Class) values[value][1];
|
||||
try {
|
||||
return (PropertyHandler) classValue.newInstance();
|
||||
} catch (Exception exception) {
|
||||
throw new ConfigurationException("Cannot instantiate property class");
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new ConfigurationException("Unknown property");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.allatori.config.property;
|
||||
|
||||
public class StringEncryptionProperty extends PropertyHandler {
|
||||
|
||||
@Override
|
||||
public void apply(String text, String text2) {}
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
package com.allatori.config.rule;
|
||||
|
||||
import com.allatori.config.ConfigurationException;
|
||||
import com.allatori.lib.bcel.classfile.Field;
|
||||
import com.allatori.lib.bcel.classfile.Method;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.lib.bcel.generic.MethodGen;
|
||||
import com.allatori.model.ClassStorage;
|
||||
import java.util.Vector;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ClassRule {
|
||||
|
||||
public Vector values;
|
||||
|
||||
public String[] texts;
|
||||
|
||||
public int count;
|
||||
|
||||
public boolean enabled;
|
||||
|
||||
public boolean enabled2;
|
||||
|
||||
public String text;
|
||||
|
||||
public boolean enabled3;
|
||||
|
||||
public String text2;
|
||||
|
||||
public String text3;
|
||||
|
||||
public String text4;
|
||||
|
||||
public Vector values2;
|
||||
|
||||
public boolean enabled4 = false;
|
||||
|
||||
public ClassRule(
|
||||
String text, boolean matches, boolean matches2, boolean enabled4, boolean enabled3)
|
||||
throws ConfigurationException {
|
||||
this(text, matches, matches2);
|
||||
this.enabled4 = enabled4;
|
||||
this.enabled3 = enabled3;
|
||||
}
|
||||
|
||||
public boolean matches(MethodGen methodGen) {
|
||||
int value;
|
||||
for (int value2 = value = 0; value2 < this.values.size(); value2 = ++value) {
|
||||
MethodRule methodRule;
|
||||
if ((methodRule = (MethodRule) this.values.get(value)).matches(methodGen)) {
|
||||
if (!methodRule.matches()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean matches() {
|
||||
return this.enabled2;
|
||||
}
|
||||
|
||||
public ClassRule(String text, boolean enabled, boolean enabled2) throws ConfigurationException {
|
||||
super();
|
||||
this.enabled4 = false;
|
||||
this.enabled3 = false;
|
||||
this.values2 = new Vector();
|
||||
this.values = new Vector();
|
||||
this.enabled = enabled;
|
||||
this.enabled2 = enabled2;
|
||||
this.processText(text);
|
||||
}
|
||||
|
||||
public void processText(String text5) throws ConfigurationException {
|
||||
Matcher matcher2;
|
||||
if ((matcher2 =
|
||||
Pattern.compile(
|
||||
"(.*?(?:class|interface))\\s+(.+?)(?:\\s+extends\\s+(.+?))?(?:\\s+implements\\s+(.+?))?(?:\\s+instanceof\\s+(.+?))?")
|
||||
.matcher(text5))
|
||||
.matches()) {
|
||||
String text6 = matcher2.group(1);
|
||||
this.count = TemplateUtils.calculateCount(text6);
|
||||
Matcher matcher3;
|
||||
if (TemplateUtils.matches2(text6)) {
|
||||
int value;
|
||||
if ((value = text6.indexOf(32)) == -1) {
|
||||
value = text6.length();
|
||||
}
|
||||
this.text = TemplateUtils.getText2(text6.substring(1, value));
|
||||
this.text = 'L' + this.text.replaceAll("\\\\\\.", "/") + ';';
|
||||
matcher3 = matcher2;
|
||||
} else {
|
||||
this.text = null;
|
||||
matcher3 = matcher2;
|
||||
}
|
||||
String text7 = matcher3.group(2);
|
||||
this.text2 = TemplateUtils.getText2(text7);
|
||||
this.text3 = TemplateUtils.getText2(matcher2.group(3));
|
||||
this.texts = TemplateUtils.getTexts(matcher2.group(4));
|
||||
this.text4 = TemplateUtils.getText2(matcher2.group(5));
|
||||
} else {
|
||||
throw new ConfigurationException("Invalid template.");
|
||||
}
|
||||
}
|
||||
|
||||
public ClassRule() {
|
||||
this.enabled3 = false;
|
||||
this.values2 = new Vector();
|
||||
this.values = new Vector();
|
||||
}
|
||||
|
||||
public boolean matches(ClassStorage classStorage, ClassGen classGen) {
|
||||
if (!TemplateUtils.matches(classGen, this.count)) {
|
||||
return this.enabled3;
|
||||
} else if (!classGen.getClassName().matches(this.text2)) {
|
||||
return this.enabled3;
|
||||
} else if (!classGen.getSuperclassName().matches(this.text3)) {
|
||||
return this.enabled3;
|
||||
} else if (!TemplateUtils.matches(classGen.getInterfaceNames(), this.texts)) {
|
||||
return this.enabled3;
|
||||
} else if (!TemplateUtils.matches(classStorage, classGen.getClassName(), this.text4)) {
|
||||
return this.enabled3;
|
||||
} else {
|
||||
return this.text != null && !TemplateUtils.matches(classGen.getAnnotationEntries(), this.text)
|
||||
? this.enabled3
|
||||
: !this.enabled3;
|
||||
}
|
||||
}
|
||||
|
||||
public void processMethodRule(MethodRule methodRule) {
|
||||
this.values.add(methodRule);
|
||||
}
|
||||
|
||||
public boolean matches2() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public void processFieldRule(FieldRule fieldRule) {
|
||||
this.values2.add(fieldRule);
|
||||
}
|
||||
|
||||
public boolean matches(ClassStorage classStorage, Field field) {
|
||||
int value;
|
||||
for (int value2 = value = 0; value2 < this.values2.size(); value2 = ++value) {
|
||||
FieldRule fieldRule;
|
||||
if ((fieldRule = (FieldRule) this.values2.get(value)).matches(classStorage, field)) {
|
||||
if (!fieldRule.matches()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean matches(Method method) {
|
||||
int value;
|
||||
for (int value2 = value = 0; value2 < this.values.size(); value2 = ++value) {
|
||||
MethodRule methodRule;
|
||||
if ((methodRule = (MethodRule) this.values.get(value)).matches(method)) {
|
||||
if (!methodRule.matches()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean matches3() {
|
||||
return this.enabled4;
|
||||
}
|
||||
|
||||
public ClassRule createClassRule() {
|
||||
ClassRule classRule = new ClassRule();
|
||||
classRule.enabled = this.enabled;
|
||||
classRule.enabled2 = this.enabled2;
|
||||
classRule.enabled4 = this.enabled4;
|
||||
classRule.count = this.count;
|
||||
classRule.text2 = this.text2;
|
||||
classRule.text3 = this.text3;
|
||||
classRule.text4 = this.text4;
|
||||
classRule.texts = this.texts;
|
||||
classRule.text = this.text;
|
||||
return classRule;
|
||||
}
|
||||
|
||||
public boolean matches4() {
|
||||
return this.values2.size() > 0;
|
||||
}
|
||||
|
||||
public boolean matches5() {
|
||||
return this.values.size() > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.allatori.config.rule;
|
||||
|
||||
import com.allatori.config.ConfigurationException;
|
||||
import com.allatori.lib.bcel.classfile.Field;
|
||||
import com.allatori.model.ClassStorage;
|
||||
|
||||
public class FieldRule {
|
||||
|
||||
public String text;
|
||||
|
||||
public boolean enabled;
|
||||
|
||||
public String text2;
|
||||
|
||||
public String text3;
|
||||
|
||||
public String text4;
|
||||
|
||||
public boolean enabled2;
|
||||
|
||||
public int count;
|
||||
|
||||
public boolean matches(ClassStorage classStorage, Field field) {
|
||||
if (!TemplateUtils.matches(field, this.count)) {
|
||||
return this.enabled;
|
||||
}
|
||||
if (!field.getText().matches(this.text4)) {
|
||||
return this.enabled;
|
||||
}
|
||||
if (!field.getType().toString().matches(this.text3)) {
|
||||
return this.enabled;
|
||||
}
|
||||
if (this.text != null && !TemplateUtils.matches(field.getAnnotationEntries(), this.text)) {
|
||||
return this.enabled;
|
||||
}
|
||||
if (this.text2 != null) {
|
||||
String text5;
|
||||
if ((text5 = field.getText2()).charAt(0) != 'L' || text5.charAt(text5.length() - 1) != ';') {
|
||||
return this.enabled;
|
||||
}
|
||||
String text6 = text5.substring(1, text5.length() - 1).replace('/', '.');
|
||||
if (!TemplateUtils.matches(classStorage, text6, this.text2)) {
|
||||
return this.enabled;
|
||||
}
|
||||
}
|
||||
return !this.enabled;
|
||||
}
|
||||
|
||||
public void processText(String text5) throws ConfigurationException {
|
||||
String[] texts;
|
||||
if ((texts = text5.split("\\s+")) != null && texts.length != 0) {
|
||||
int value;
|
||||
FieldRule fieldRule;
|
||||
if ((value = texts.length) >= 3 && "instanceof".equals(texts[value - 2])) {
|
||||
int value2 = value - 1;
|
||||
String[] texts2 = texts;
|
||||
value -= 2;
|
||||
fieldRule = this;
|
||||
this.text2 = TemplateUtils.getText2(texts2[value2]);
|
||||
} else {
|
||||
fieldRule = this;
|
||||
this.text2 = null;
|
||||
}
|
||||
fieldRule.text4 = TemplateUtils.getText(texts[value - 1]);
|
||||
if (value > 1
|
||||
&& !TemplateUtils.matches3(texts[value - 2])
|
||||
&& !TemplateUtils.matches2(texts[value - 2])) {
|
||||
fieldRule = this;
|
||||
this.text3 = TemplateUtils.getText2(texts[value - 2]);
|
||||
} else {
|
||||
fieldRule = this;
|
||||
this.text3 = ".*";
|
||||
}
|
||||
fieldRule.count = TemplateUtils.calculateCount(text5);
|
||||
if (TemplateUtils.matches2(texts[0])) {
|
||||
this.text = TemplateUtils.getText2(texts[0].substring(1));
|
||||
this.text = 'L' + this.text.replaceAll("\\\\\\.", "/") + ';';
|
||||
} else {
|
||||
this.text = null;
|
||||
}
|
||||
} else {
|
||||
throw new ConfigurationException("Invalid template.");
|
||||
}
|
||||
}
|
||||
|
||||
public FieldRule(String text, boolean enabled2, boolean enabled) throws ConfigurationException {
|
||||
super();
|
||||
this.processText(text);
|
||||
this.enabled2 = enabled2;
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public boolean matches() {
|
||||
return this.enabled2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.allatori.config.rule;
|
||||
|
||||
import com.allatori.config.ConfigurationException;
|
||||
import com.allatori.lib.bcel.classfile.Method;
|
||||
import com.allatori.lib.bcel.generic.MethodGen;
|
||||
|
||||
public class MethodRule {
|
||||
|
||||
public String text;
|
||||
|
||||
public String text2;
|
||||
|
||||
public String text3;
|
||||
|
||||
public String text4;
|
||||
|
||||
public boolean enabled;
|
||||
|
||||
public boolean enabled2;
|
||||
|
||||
public int count;
|
||||
|
||||
public boolean matches(MethodGen methodGen) {
|
||||
if (!TemplateUtils.matches(methodGen, this.count)) {
|
||||
return this.enabled2;
|
||||
} else if (!methodGen.getName().matches(this.text3)) {
|
||||
return this.enabled2;
|
||||
} else if (!methodGen.getReturnType().toString().matches(this.text)) {
|
||||
return this.enabled2;
|
||||
} else if (!TemplateUtils.matches(methodGen.getArgumentTypes(), this.text2)) {
|
||||
return this.enabled2;
|
||||
} else {
|
||||
return this.text4 != null
|
||||
&& !TemplateUtils.matches(methodGen.getAnnotationEntryGens(), this.text4)
|
||||
? this.enabled2
|
||||
: !this.enabled2;
|
||||
}
|
||||
}
|
||||
|
||||
public void processText(String text5) throws ConfigurationException {
|
||||
String[] texts;
|
||||
String[] texts2;
|
||||
if ((texts = text5.split("\\(|\\)")).length != 2) {
|
||||
if (texts.length == 1 && text5.endsWith("()")) {
|
||||
texts2 = texts;
|
||||
} else {
|
||||
if (texts.length <= 2 || !text5.contains("regex:")) {
|
||||
throw new ConfigurationException("Invalid template.");
|
||||
}
|
||||
String text6 = text5.substring(0, text5.lastIndexOf(40));
|
||||
String text7 = text5.substring(text5.lastIndexOf(40) + 1, text5.lastIndexOf(41));
|
||||
texts2 = texts = new String[] {text6, text7};
|
||||
}
|
||||
} else {
|
||||
texts2 = texts;
|
||||
}
|
||||
if (texts2.length == 1) {
|
||||
texts2 = texts;
|
||||
this.text2 = "";
|
||||
} else {
|
||||
texts2 = texts;
|
||||
String text8 = texts[1];
|
||||
this.text2 = TemplateUtils.getText4(text8);
|
||||
}
|
||||
String[] texts3;
|
||||
String text9;
|
||||
if ((texts3 = (text9 = texts2[0]).split("\\s+")) != null && texts3.length != 0) {
|
||||
this.text3 = TemplateUtils.getText(texts3[texts3.length - 1]);
|
||||
MethodRule methodRule;
|
||||
if (texts3.length > 1
|
||||
&& !TemplateUtils.matches3(texts3[texts3.length - 2])
|
||||
&& !TemplateUtils.matches2(texts3[texts3.length - 2])) {
|
||||
this.text = TemplateUtils.getText2(texts3[texts3.length - 2]);
|
||||
methodRule = this;
|
||||
} else {
|
||||
methodRule = this;
|
||||
this.text = ".*";
|
||||
}
|
||||
methodRule.count = TemplateUtils.calculateCount(text9);
|
||||
if (TemplateUtils.matches2(texts3[0])) {
|
||||
this.text4 = TemplateUtils.getText2(texts3[0].substring(1));
|
||||
this.text4 = 'L' + this.text4.replaceAll("\\\\\\.", "/") + ';';
|
||||
} else {
|
||||
this.text4 = null;
|
||||
}
|
||||
} else {
|
||||
throw new ConfigurationException("Invalid template.");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean matches() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public MethodRule(String text, boolean enabled, boolean enabled2) throws ConfigurationException {
|
||||
super();
|
||||
this.processText(text);
|
||||
this.enabled = enabled;
|
||||
this.enabled2 = enabled2;
|
||||
}
|
||||
|
||||
public boolean matches(Method method) {
|
||||
if (!TemplateUtils.matches(method, this.count)) {
|
||||
return this.enabled2;
|
||||
} else if (!method.getText().matches(this.text3)) {
|
||||
return this.enabled2;
|
||||
} else if (!method.getReturnType().toString().matches(this.text)) {
|
||||
return this.enabled2;
|
||||
} else if (!TemplateUtils.matches(method.getArgumentTypes(), this.text2)) {
|
||||
return this.enabled2;
|
||||
} else {
|
||||
return this.text4 != null && !TemplateUtils.matches(method.getAnnotationEntries(), this.text4)
|
||||
? this.enabled2
|
||||
: !this.enabled2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.allatori.config.rule;
|
||||
|
||||
public class RuleEntry {
|
||||
|
||||
public int count;
|
||||
|
||||
public ClassRule classRule;
|
||||
|
||||
public RuleEntry(int count, ClassRule classRule2) {
|
||||
super();
|
||||
this.count = count;
|
||||
this.classRule = classRule2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.allatori.config.rule;
|
||||
|
||||
import com.allatori.lib.bcel.classfile.Field;
|
||||
import com.allatori.lib.bcel.classfile.Method;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.lib.bcel.generic.MethodGen;
|
||||
import com.allatori.model.ClassStorage;
|
||||
import java.util.Vector;
|
||||
|
||||
public class RuleSet {
|
||||
|
||||
public Vector values;
|
||||
|
||||
public int count;
|
||||
|
||||
public int getValues() {
|
||||
return this.values.size();
|
||||
}
|
||||
|
||||
public int calculateCount(ClassStorage classStorage, ClassGen classGen, Field field) {
|
||||
int value;
|
||||
for (int value2 = value = 0; value2 < this.values.size(); value2 = ++value) {
|
||||
RuleEntry ruleEntry;
|
||||
if ((ruleEntry = (RuleEntry) this.values.get(value))
|
||||
.classRule.matches(classStorage, classGen)) {
|
||||
if (field == null) {
|
||||
return ruleEntry.count;
|
||||
}
|
||||
if (ruleEntry.classRule.matches(classStorage, field)) {
|
||||
return ruleEntry.count;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.count;
|
||||
}
|
||||
|
||||
public int calculateCount(ClassStorage classStorage, ClassGen classGen, Method method) {
|
||||
int value;
|
||||
for (int value2 = value = 0; value2 < this.values.size(); value2 = ++value) {
|
||||
RuleEntry ruleEntry;
|
||||
if ((ruleEntry = (RuleEntry) this.values.get(value))
|
||||
.classRule.matches(classStorage, classGen)) {
|
||||
if (method == null) {
|
||||
return ruleEntry.count;
|
||||
}
|
||||
if (ruleEntry.classRule.matches(method)) {
|
||||
return ruleEntry.count;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.count;
|
||||
}
|
||||
|
||||
public RuleSet(int count) {
|
||||
super();
|
||||
this.values = new Vector();
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public void processRuleEntry(RuleEntry ruleEntry) {
|
||||
this.values.add(ruleEntry);
|
||||
}
|
||||
|
||||
public int calculateCount(ClassStorage classStorage, ClassGen classGen, MethodGen methodGen) {
|
||||
int value;
|
||||
for (int value2 = value = 0; value2 < this.values.size(); value2 = ++value) {
|
||||
RuleEntry ruleEntry;
|
||||
if ((ruleEntry = (RuleEntry) this.values.get(value))
|
||||
.classRule.matches(classStorage, classGen)) {
|
||||
if (methodGen == null) {
|
||||
return ruleEntry.count;
|
||||
}
|
||||
if (ruleEntry.classRule.matches(methodGen)) {
|
||||
return ruleEntry.count;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.count;
|
||||
}
|
||||
|
||||
public int calculateCount(ClassStorage classStorage, ClassGen classGen) {
|
||||
return this.calculateCount(classStorage, classGen, (MethodGen) null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,352 @@
|
||||
package com.allatori.config.rule;
|
||||
|
||||
import com.allatori.lib.bcel.classfile.AccessFlags;
|
||||
import com.allatori.lib.bcel.classfile.AnnotationEntry;
|
||||
import com.allatori.lib.bcel.generic.AnnotationEntryGen;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.lib.bcel.generic.Type;
|
||||
import com.allatori.model.ClassStorage;
|
||||
import com.allatori.util.Log;
|
||||
|
||||
public class TemplateUtils {
|
||||
|
||||
public static final int COUNT = 2048;
|
||||
|
||||
public static final int COUNT2 = 512;
|
||||
|
||||
public static final int COUNT3 = 32;
|
||||
|
||||
public static final int COUNT4 = 8192;
|
||||
|
||||
public static final int COUNT5 = 128;
|
||||
|
||||
public static final int COUNT6 = 4;
|
||||
|
||||
public static final int COUNT7 = 256;
|
||||
|
||||
public static final int COUNT8 = 1;
|
||||
|
||||
public static final int COUNT9 = 2;
|
||||
|
||||
public static final int COUNT10 = 8;
|
||||
|
||||
public static final int COUNT11 = 1024;
|
||||
|
||||
public static final int COUNT12 = 16;
|
||||
|
||||
public static final int COUNT13 = 4096;
|
||||
|
||||
public static final int COUNT14 = 64;
|
||||
|
||||
public static boolean matches(String text) {
|
||||
if (text.equals("public")) {
|
||||
return true;
|
||||
} else if (text.equals("protected")) {
|
||||
return true;
|
||||
} else if (text.equals("package")) {
|
||||
return true;
|
||||
} else if (text.equals("private")) {
|
||||
return true;
|
||||
} else if (text.equals("protected+")) {
|
||||
return true;
|
||||
} else {
|
||||
return text.equals("package+") ? true : text.equals("private+");
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean matches(String[] texts, String[] texts2) {
|
||||
int value;
|
||||
int value2;
|
||||
for (int value3 = value2 = texts2.length - 1; value3 >= 0; value3 = --value2) {
|
||||
byte value4 = 0;
|
||||
int value5;
|
||||
value3 = value5 = texts.length - 1;
|
||||
while (true) {
|
||||
if (value3 < 0) {
|
||||
value = value4;
|
||||
break;
|
||||
}
|
||||
if (texts[value5].matches(texts2[value2])) {
|
||||
value = 1;
|
||||
break;
|
||||
}
|
||||
value3 = --value5;
|
||||
}
|
||||
if (value == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String getText(String text) {
|
||||
return getText2(text);
|
||||
}
|
||||
|
||||
public static String getText2(String text) {
|
||||
return text == null ? ".*" : getText3(text.trim().replaceAll("\\$", "\\\\\\$"));
|
||||
}
|
||||
|
||||
public static String getText3(String text) {
|
||||
return text.startsWith("regex:")
|
||||
? text.substring(6)
|
||||
: text.replaceAll("\\.", "\\\\.").replaceAll("\\*", ".*");
|
||||
}
|
||||
|
||||
public static boolean matches(AnnotationEntry[] annotationEntrys, String text) {
|
||||
if (text == null) {
|
||||
return true;
|
||||
}
|
||||
int value;
|
||||
for (int value2 = value = annotationEntrys.length - 1; value2 >= 0; value2 = --value) {
|
||||
if (annotationEntrys[value].getText().matches(text)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String[] getTexts(String text) {
|
||||
if (text == null) {
|
||||
return new String[0];
|
||||
}
|
||||
String[] texts;
|
||||
if ((texts = text.split("\\s*,\\s*")) == null) {
|
||||
return new String[0];
|
||||
}
|
||||
int value;
|
||||
for (int value2 = value = texts.length - 1; value2 >= 0; value2 = value) {
|
||||
texts[value] = texts[value].replaceAll("\\$", "\\\\\\$");
|
||||
String text3 = getText3(texts[value]);
|
||||
int value3 = value;
|
||||
String[] texts2 = texts;
|
||||
value--;
|
||||
texts2[value3] = text3;
|
||||
}
|
||||
return texts;
|
||||
}
|
||||
|
||||
public static int calculateCount(String text) {
|
||||
String text2 = text.trim();
|
||||
short value = 0;
|
||||
if (text2.indexOf("public") >= 0) {
|
||||
value = 1;
|
||||
}
|
||||
if (text2.indexOf("protected") >= 0) {
|
||||
value |= 2;
|
||||
}
|
||||
if (text2.indexOf("package") >= 0) {
|
||||
value |= 4;
|
||||
}
|
||||
if (text2.indexOf("private") >= 0) {
|
||||
value |= 8;
|
||||
}
|
||||
if (text2.indexOf("protected+") >= 0) {
|
||||
value |= 3;
|
||||
}
|
||||
if (text2.indexOf("package+") >= 0) {
|
||||
value |= 7;
|
||||
}
|
||||
if (text2.indexOf("private+") >= 0) {
|
||||
value |= 15;
|
||||
}
|
||||
if (value == 0) {
|
||||
value = 15;
|
||||
}
|
||||
if (text2.indexOf("static") >= 0) {
|
||||
value |= 16;
|
||||
}
|
||||
if (text2.indexOf("final") >= 0) {
|
||||
value |= 32;
|
||||
}
|
||||
if (text2.indexOf("synchronized") >= 0) {
|
||||
value |= 64;
|
||||
}
|
||||
if (text2.indexOf("volatile") >= 0) {
|
||||
value |= 128;
|
||||
}
|
||||
if (text2.indexOf("transient") >= 0) {
|
||||
value |= 256;
|
||||
}
|
||||
if (text2.indexOf("native") >= 0) {
|
||||
value |= 512;
|
||||
}
|
||||
if (text2.indexOf("interface") >= 0) {
|
||||
value |= 1024;
|
||||
}
|
||||
if (text2.indexOf("abstract") >= 0) {
|
||||
value |= 2048;
|
||||
}
|
||||
if (text2.indexOf("strictfp") >= 0) {
|
||||
value |= 4096;
|
||||
}
|
||||
if (text2.indexOf("enum") >= 0) {
|
||||
value |= 8192;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static boolean matches2(String text) {
|
||||
return text.charAt(0) == '@';
|
||||
}
|
||||
|
||||
public static boolean matches3(String text) {
|
||||
if (text.indexOf("public") >= 0) {
|
||||
return true;
|
||||
} else if (text.indexOf("protected") >= 0) {
|
||||
return true;
|
||||
} else if (text.indexOf("package") >= 0) {
|
||||
return true;
|
||||
} else if (text.indexOf("private") >= 0) {
|
||||
return true;
|
||||
} else if (text.indexOf("static") >= 0) {
|
||||
return true;
|
||||
} else if (text.indexOf("final") >= 0) {
|
||||
return true;
|
||||
} else if (text.indexOf("synchronized") >= 0) {
|
||||
return true;
|
||||
} else if (text.indexOf("volatile") >= 0) {
|
||||
return true;
|
||||
} else if (text.indexOf("transient") >= 0) {
|
||||
return true;
|
||||
} else if (text.indexOf("native") >= 0) {
|
||||
return true;
|
||||
} else if (text.indexOf("interface") >= 0) {
|
||||
return true;
|
||||
} else if (text.indexOf("abstract") >= 0) {
|
||||
return true;
|
||||
} else {
|
||||
return text.indexOf("strictfp") >= 0 ? true : text.indexOf("enum") >= 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean matches(AnnotationEntryGen[] annotationEntryGens, String text) {
|
||||
if (text == null) {
|
||||
return true;
|
||||
}
|
||||
int value;
|
||||
for (int value2 = value = annotationEntryGens.length - 1; value2 >= 0; value2 = --value) {
|
||||
try {
|
||||
if (annotationEntryGens[value].getText2().matches(text)) {
|
||||
return true;
|
||||
}
|
||||
} catch (ClassCastException classCastException) {
|
||||
throw classCastException;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean matches(ClassStorage classStorage, String text, String text2) {
|
||||
if (text == null) {
|
||||
return false;
|
||||
}
|
||||
if (text.matches(text2)) {
|
||||
return true;
|
||||
}
|
||||
ClassGen classGen;
|
||||
if ((classGen = classStorage.getClassGen(text)) != null) {
|
||||
int value;
|
||||
String[] texts;
|
||||
for (int value2 = value = (texts = classGen.getInterfaceNames()).length - 1;
|
||||
value2 >= 0;
|
||||
value2 = --value) {
|
||||
if (matches(classStorage, texts[value], text2)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return matches(classStorage, classGen.getSuperclassName(), text2);
|
||||
} else {
|
||||
try {
|
||||
int value3;
|
||||
Class classValue;
|
||||
Class[] classs;
|
||||
for (int value4 =
|
||||
value3 =
|
||||
(classs =
|
||||
(classValue =
|
||||
Class.forName(text, false, classStorage.getClassLoader()))
|
||||
.getInterfaces())
|
||||
.length
|
||||
- 1;
|
||||
value4 >= 0;
|
||||
value4 = --value3) {
|
||||
if (matches(classStorage, classs[value3].getName(), text2)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return classValue.getSuperclass() != null
|
||||
? matches(classStorage, classValue.getSuperclass().getName(), text2)
|
||||
: false;
|
||||
} catch (ClassNotFoundException classNotFoundException) {
|
||||
return true;
|
||||
} catch (SecurityException securityException) {
|
||||
Log.error("Cannot read class: " + text);
|
||||
throw securityException;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean matches(Type[] types, String text) {
|
||||
StringBuffer stringBuffer = new StringBuffer("");
|
||||
int value;
|
||||
for (int value2 = value = types.length - 1; value2 >= 0; value2 = value) {
|
||||
StringBuilder stringBuilder = new StringBuilder().append(types[value].toString());
|
||||
value--;
|
||||
stringBuffer.insert((byte) 0, stringBuilder.append((String) ",").toString());
|
||||
}
|
||||
if (stringBuffer.length() > 0) {
|
||||
stringBuffer.deleteCharAt(stringBuffer.length() - 1);
|
||||
}
|
||||
return stringBuffer.toString().matches(text);
|
||||
}
|
||||
|
||||
public static String getText4(String text) {
|
||||
return text.replaceAll("\\s+", "")
|
||||
.replaceAll("\\[", "\\\\[")
|
||||
.replaceAll("]", "\\\\]")
|
||||
.replaceAll("\\.", "\\\\.")
|
||||
.replaceAll("\\*\\*", "%@#")
|
||||
.replaceAll("\\*", "[^,]*")
|
||||
.replaceAll("\\%\\@\\#", ".*");
|
||||
}
|
||||
|
||||
public static boolean matches(AccessFlags accessFlags, int value) {
|
||||
if (accessFlags.isEnabled6()) {
|
||||
if ((value & 1) == 0) {
|
||||
return false;
|
||||
}
|
||||
} else if (accessFlags.isEnabled13()) {
|
||||
if ((value & 2) == 0) {
|
||||
return false;
|
||||
}
|
||||
} else if (accessFlags.isEnabled9()) {
|
||||
if ((value & 8) == 0) {
|
||||
return false;
|
||||
}
|
||||
} else if ((value & 4) == 0) {
|
||||
return false;
|
||||
}
|
||||
if ((value & 16) > 0 && !accessFlags.isEnabled11()) {
|
||||
return false;
|
||||
} else if ((value & 32) > 0 && !accessFlags.isEnabled3()) {
|
||||
return false;
|
||||
} else if ((value & 64) > 0 && !accessFlags.isEnabled12()) {
|
||||
return false;
|
||||
} else if ((value & 128) > 0 && !accessFlags.isEnabled()) {
|
||||
return false;
|
||||
} else if ((value & 256) > 0 && !accessFlags.isEnabled4()) {
|
||||
return false;
|
||||
} else if ((value & 512) > 0 && !accessFlags.isEnabled14()) {
|
||||
return false;
|
||||
} else if ((value & 1024) > 0 && !accessFlags.isEnabled5()) {
|
||||
return false;
|
||||
} else if ((value & 2048) > 0 && !accessFlags.isEnabled15()) {
|
||||
return false;
|
||||
} else {
|
||||
return (value & 4096) > 0 && !accessFlags.isEnabled7()
|
||||
? false
|
||||
: (value & 8192) <= 0 || accessFlags.isEnabled10();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.allatori.crypto;
|
||||
|
||||
import com.allatori.config.Configuration;
|
||||
import com.allatori.lib.bcel.generic.InstructionFactory;
|
||||
import com.allatori.lib.bcel.generic.InvokeInstruction;
|
||||
import com.allatori.lib.bcel.generic.Type;
|
||||
import com.allatori.util.Log;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
public class CustomStringEncryption {
|
||||
|
||||
public static String text = "allatori-custom-12321-32123:";
|
||||
|
||||
public static String createText(
|
||||
String text, ClassLoader classLoader, String text2, String text3) {
|
||||
String text4 = text;
|
||||
String[] texts = null;
|
||||
try {
|
||||
int value = Integer.parseInt(text4.substring(text4.indexOf(91) + 1, text4.indexOf(93)));
|
||||
text4 = text4.substring(text4.indexOf(93) + 1);
|
||||
String text5;
|
||||
if ((text5 =
|
||||
(String)
|
||||
Class.forName(
|
||||
(texts =
|
||||
(String[])
|
||||
Configuration.getObfuscationOptions().getEntries().get(value))
|
||||
[0],
|
||||
true,
|
||||
classLoader)
|
||||
.getDeclaredMethod(texts[1], String.class, String.class, String.class)
|
||||
.invoke(null, text4, text2, text3))
|
||||
== null) {
|
||||
Log.error(
|
||||
"Custom string encryption error: null value is returned by "
|
||||
+ texts[0]
|
||||
+ "."
|
||||
+ texts[1]
|
||||
+ "()");
|
||||
throw new NullPointerException();
|
||||
} else {
|
||||
return text5;
|
||||
}
|
||||
} catch (ClassNotFoundException classNotFoundException) {
|
||||
Log.error("Cannot load custom string encryption class (class not found): " + texts[0]);
|
||||
return text4;
|
||||
} catch (NoSuchMethodException noSuchMethodException) {
|
||||
Log.error("Cannot find custom string encryption method: " + texts[0] + "." + texts[1] + "()");
|
||||
return text4;
|
||||
} catch (Exception exception) {
|
||||
Log.error("Custom string encryption error: " + exception.getMessage());
|
||||
return text4;
|
||||
}
|
||||
}
|
||||
|
||||
public static InvokeInstruction getInvokeInstruction(
|
||||
InstructionFactory instructionFactory, int value) {
|
||||
String[] texts = (String[]) Configuration.getObfuscationOptions().getEntries().get(value);
|
||||
return instructionFactory.createInvoke(
|
||||
texts[2], texts[3], Type.STRING, new Type[] {Type.STRING}, (short) 184);
|
||||
}
|
||||
|
||||
public static String createText(String text2, int value, ClassLoader classLoader) {
|
||||
String[] texts = (String[]) Configuration.getObfuscationOptions().getEntries().get(value);
|
||||
try {
|
||||
Class classValue = Class.forName(texts[0], true, classLoader);
|
||||
try {
|
||||
Method method;
|
||||
if (!Modifier.isStatic(
|
||||
(method = classValue.getDeclaredMethod(texts[1], String.class)).getModifiers())
|
||||
|| !Modifier.isPublic(method.getModifiers())) {
|
||||
Log.error(
|
||||
"Custom string encryption method is not static and public: "
|
||||
+ texts[0]
|
||||
+ "."
|
||||
+ texts[1]
|
||||
+ "()");
|
||||
}
|
||||
String text3;
|
||||
if ((text3 = (String) method.invoke(null, text2)) == null) {
|
||||
Log.error(
|
||||
"Custom string encryption error: null value is returned by "
|
||||
+ texts[0]
|
||||
+ "."
|
||||
+ texts[1]
|
||||
+ "()");
|
||||
throw new NullPointerException();
|
||||
} else {
|
||||
return text3;
|
||||
}
|
||||
} catch (NoSuchMethodException noSuchMethodException) {
|
||||
Method method2;
|
||||
if (!Modifier.isStatic(
|
||||
(method2 =
|
||||
classValue.getDeclaredMethod(
|
||||
texts[1], String.class, String.class, String.class))
|
||||
.getModifiers())
|
||||
|| !Modifier.isPublic(method2.getModifiers())) {
|
||||
Log.error(
|
||||
"Custom string encryption method is not static and public: "
|
||||
+ texts[0]
|
||||
+ "."
|
||||
+ texts[1]
|
||||
+ "()");
|
||||
}
|
||||
return "" + text + '[' + value + ']' + text2;
|
||||
}
|
||||
} catch (ClassNotFoundException classNotFoundException) {
|
||||
Log.error("Cannot load custom string encryption class (class not found): " + texts[0]);
|
||||
return text2;
|
||||
} catch (NoSuchMethodException noSuchMethodException2) {
|
||||
Log.error("Cannot find custom string encryption method: " + texts[0] + "." + texts[1] + "()");
|
||||
return text2;
|
||||
} catch (Exception exception) {
|
||||
Log.error("Custom string encryption error: " + exception.getMessage());
|
||||
return text2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,738 @@
|
||||
package com.allatori.crypto;
|
||||
|
||||
import com.allatori.bytecode.MethodFactory;
|
||||
import com.allatori.config.Configuration;
|
||||
import com.allatori.lib.bcel.classfile.Attribute;
|
||||
import com.allatori.lib.bcel.classfile.Constant;
|
||||
import com.allatori.lib.bcel.classfile.ConstantPool;
|
||||
import com.allatori.lib.bcel.classfile.ConstantString;
|
||||
import com.allatori.lib.bcel.classfile.ConstantUtf8;
|
||||
import com.allatori.lib.bcel.classfile.ConstantValue;
|
||||
import com.allatori.lib.bcel.classfile.Field;
|
||||
import com.allatori.lib.bcel.classfile.Method;
|
||||
import com.allatori.lib.bcel.classfile.SourceFile;
|
||||
import com.allatori.lib.bcel.classfile.StackMap;
|
||||
import com.allatori.lib.bcel.classfile.StackMapEntry;
|
||||
import com.allatori.lib.bcel.classfile.StackMapType;
|
||||
import com.allatori.lib.bcel.generic.ArrayType;
|
||||
import com.allatori.lib.bcel.generic.BranchInstruction;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.lib.bcel.generic.ConstantPoolGen;
|
||||
import com.allatori.lib.bcel.generic.FieldGen;
|
||||
import com.allatori.lib.bcel.generic.FieldInstruction;
|
||||
import com.allatori.lib.bcel.generic.GETFIELD;
|
||||
import com.allatori.lib.bcel.generic.GETSTATIC;
|
||||
import com.allatori.lib.bcel.generic.IF_ACMPEQ;
|
||||
import com.allatori.lib.bcel.generic.IF_ACMPNE;
|
||||
import com.allatori.lib.bcel.generic.IINC;
|
||||
import com.allatori.lib.bcel.generic.Instruction;
|
||||
import com.allatori.lib.bcel.generic.InstructionConstants;
|
||||
import com.allatori.lib.bcel.generic.InstructionFactory;
|
||||
import com.allatori.lib.bcel.generic.InstructionHandle;
|
||||
import com.allatori.lib.bcel.generic.InstructionList;
|
||||
import com.allatori.lib.bcel.generic.InstructionTargeter;
|
||||
import com.allatori.lib.bcel.generic.LDC;
|
||||
import com.allatori.lib.bcel.generic.LineNumberGen;
|
||||
import com.allatori.lib.bcel.generic.MethodGen;
|
||||
import com.allatori.lib.bcel.generic.PUSH;
|
||||
import com.allatori.lib.bcel.generic.PUTFIELD;
|
||||
import com.allatori.lib.bcel.generic.PUTSTATIC;
|
||||
import com.allatori.lib.bcel.generic.Type;
|
||||
import com.allatori.util.Log;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.util.Collection;
|
||||
import java.util.Vector;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class StringEncryptionUtils {
|
||||
|
||||
public static Vector values = new Vector();
|
||||
|
||||
public static boolean matchesText(Vector vector, String text) {
|
||||
if ("000".equals(text)) {
|
||||
return false;
|
||||
}
|
||||
if ("001".equals(text)) {
|
||||
vector.add(InstructionConstants.ICONST_1);
|
||||
} else if ("010".equals(text)) {
|
||||
vector.add(InstructionConstants.ICONST_2);
|
||||
} else if ("011".equals(text)) {
|
||||
vector.add(InstructionConstants.ICONST_3);
|
||||
} else if ("100".equals(text)) {
|
||||
vector.add(InstructionConstants.ICONST_4);
|
||||
} else if ("101".equals(text)) {
|
||||
vector.add(InstructionConstants.ICONST_5);
|
||||
} else if ("110".equals(text)) {
|
||||
vector.add(InstructionConstants.ICONST_3);
|
||||
vector.add(InstructionConstants.ICONST_5);
|
||||
vector.add(InstructionConstants.IXOR);
|
||||
} else if ("111".equals(text)) {
|
||||
vector.add(InstructionConstants.ICONST_2);
|
||||
vector.add(InstructionConstants.ICONST_5);
|
||||
vector.add(InstructionConstants.IXOR);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void processCollection(ClassGen classGen, Collection values) {
|
||||
InstructionHandle instructionHandle;
|
||||
int value;
|
||||
Field[] fields;
|
||||
for (int value2 = value = (fields = classGen.getFields()).length - 1;
|
||||
value2 >= 0;
|
||||
value2 = --value) {
|
||||
Constant constant;
|
||||
ConstantValue constantValue;
|
||||
if ((constantValue = fields[value].getConstantValue()) != null
|
||||
&& (constant =
|
||||
classGen.getConstantPool().getConstant(constantValue.getConstantValueIndex()))
|
||||
instanceof ConstantString) {
|
||||
String bytes =
|
||||
((ConstantUtf8)
|
||||
classGen
|
||||
.getConstantPool()
|
||||
.getConstant(((ConstantString) constant).getStringIndex()))
|
||||
.getBytes();
|
||||
values.add(bytes);
|
||||
}
|
||||
}
|
||||
Method[] methods;
|
||||
int value3;
|
||||
for (int value4 = value3 = (methods = classGen.getMethods()).length - 1;
|
||||
value4 >= 0;
|
||||
value4 = --value3) {
|
||||
Method method;
|
||||
if ((method = methods[value3]).getCode() != null) {
|
||||
InstructionList instructionList;
|
||||
InstructionHandle instructionHandle2;
|
||||
InstructionHandle instructionHandle3 =
|
||||
instructionHandle2 =
|
||||
(instructionList =
|
||||
MethodFactory.createMethodGen(
|
||||
method,
|
||||
classGen.getClassName(),
|
||||
classGen.getConstantPool(),
|
||||
classGen.getConstantPool().getConstantPool())
|
||||
.getInstructionList())
|
||||
.getStart();
|
||||
while (instructionHandle3 != null) {
|
||||
label119:
|
||||
{
|
||||
if (instructionHandle2.getInstruction() instanceof PUTSTATIC
|
||||
|| instructionHandle2.getInstruction() instanceof PUTFIELD) {
|
||||
if (instructionHandle2.getInstructionHandle() == null) {
|
||||
instructionHandle = instructionHandle2;
|
||||
break label119;
|
||||
}
|
||||
InstructionHandle instructionHandle4;
|
||||
if ((instructionHandle4 = instructionHandle2.getInstructionHandle()).getInstruction()
|
||||
instanceof LDC) {
|
||||
LDC lDC = (LDC) instructionHandle4.getInstruction();
|
||||
Constant constant2;
|
||||
if ((constant2 = classGen.getConstantPool().getConstant(lDC.getIndex()))
|
||||
instanceof ConstantString) {
|
||||
String bytes2 =
|
||||
((ConstantUtf8)
|
||||
classGen
|
||||
.getConstantPool()
|
||||
.getConstant(((ConstantString) constant2).getStringIndex()))
|
||||
.getBytes();
|
||||
values.add(bytes2);
|
||||
}
|
||||
}
|
||||
}
|
||||
instructionHandle = instructionHandle2;
|
||||
}
|
||||
instructionHandle3 = instructionHandle2 = instructionHandle.getInstructionHandle2();
|
||||
}
|
||||
InstructionHandle instructionHandle5;
|
||||
InstructionHandle instructionHandle6 = instructionHandle5 = instructionList.getStart();
|
||||
while (instructionHandle6 != null) {
|
||||
InstructionHandle instructionHandle7;
|
||||
if (!(instructionHandle5.getInstruction() instanceof LDC)) {
|
||||
instructionHandle7 = instructionHandle5;
|
||||
} else {
|
||||
LDC lDC2 = (LDC) instructionHandle5.getInstruction();
|
||||
Constant constant3;
|
||||
if (!((constant3 = classGen.getConstantPool().getConstant(lDC2.getIndex()))
|
||||
instanceof ConstantString)) {
|
||||
instructionHandle7 = instructionHandle5;
|
||||
} else {
|
||||
ConstantPoolGen constantPool = classGen.getConstantPool();
|
||||
int value5 = lDC2.produceStack(constantPool);
|
||||
InstructionHandle instructionHandle22 = instructionHandle5.getInstructionHandle2();
|
||||
int value6 = 0;
|
||||
while (true) {
|
||||
if (instructionHandle22 != null) {
|
||||
int value7 = instructionHandle22.getInstruction().produceStack(constantPool);
|
||||
int value8 = instructionHandle22.getInstruction().consumeStack(constantPool);
|
||||
if (value7 != -2) {
|
||||
if (value8 == -2) {
|
||||
instructionHandle7 = instructionHandle5;
|
||||
break;
|
||||
}
|
||||
int value9;
|
||||
if ((value9 = value5 - value8) > 0) {
|
||||
value5 = value9 + value7;
|
||||
instructionHandle22 = instructionHandle22.getInstructionHandle2();
|
||||
int value10 = value6++;
|
||||
if (value10 > (byte) 33) {
|
||||
instructionHandle7 = instructionHandle5;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
Instruction instruction;
|
||||
if ((instruction = instructionHandle22.getInstruction()) instanceof IF_ACMPEQ
|
||||
|| instruction instanceof IF_ACMPNE) {
|
||||
String bytes3 =
|
||||
((ConstantUtf8)
|
||||
classGen
|
||||
.getConstantPool()
|
||||
.getConstant(((ConstantString) constant3).getStringIndex()))
|
||||
.getBytes();
|
||||
instructionHandle7 = instructionHandle5;
|
||||
values.add(bytes3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
instructionHandle7 = instructionHandle5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
instructionHandle6 = instructionHandle5 = instructionHandle7.getInstructionHandle2();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void update() {
|
||||
values = new Vector();
|
||||
if (Configuration.getObfuscationOptions().getStringEncryptionIgnoredStrings() != null) {
|
||||
BufferedReader bufferedReader;
|
||||
try {
|
||||
for (String text =
|
||||
(bufferedReader =
|
||||
new BufferedReader(
|
||||
new FileReader(
|
||||
Configuration.getObfuscationOptions()
|
||||
.getStringEncryptionIgnoredStrings())))
|
||||
.readLine();
|
||||
text != null;
|
||||
text = bufferedReader.readLine()) {
|
||||
if (text.length() > 0) {
|
||||
String text2;
|
||||
if (text.startsWith("regex:")) {
|
||||
text2 = text.substring(6);
|
||||
} else {
|
||||
text2 = text.replaceAll("\\.", "\\\\.").replaceAll("\\*", ".*");
|
||||
}
|
||||
values.add(Pattern.compile(text2, 32));
|
||||
}
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void processCharacter(ClassGen classGen, String text, char value) {
|
||||
InstructionFactory instructionFactory = new InstructionFactory(classGen);
|
||||
ConstantPoolGen constantPool = classGen.getConstantPool();
|
||||
InstructionList instructionList = new InstructionList();
|
||||
MethodGen methodGen =
|
||||
new MethodGen(
|
||||
9,
|
||||
Type.STRING,
|
||||
new Type[] {Type.STRING},
|
||||
new String[] {"s"},
|
||||
text,
|
||||
classGen.getClassName(),
|
||||
instructionList,
|
||||
constantPool);
|
||||
int value2 = constantPool.addClass("java.lang.String");
|
||||
int value3 = constantPool.addClass("[C");
|
||||
int value4 = constantPool.addUtf8("StackMap");
|
||||
ConstantPool constantPool2 = constantPool.getConstantPool();
|
||||
StackMapType[] stackMapTypes = new StackMapType[4];
|
||||
stackMapTypes[0] = new StackMapType((byte) 7, value2, constantPool2);
|
||||
stackMapTypes[1] = new StackMapType((byte) 7, value3, constantPool2);
|
||||
stackMapTypes[2] = new StackMapType((byte) 1, 0, constantPool2);
|
||||
stackMapTypes[3] = new StackMapType((byte) 1, 0, constantPool2);
|
||||
StackMapEntry stackMapEntry =
|
||||
new StackMapEntry(27, 4, stackMapTypes, 0, new StackMapType[0], constantPool2);
|
||||
StackMapEntry stackMapEntry2 =
|
||||
new StackMapEntry(
|
||||
58,
|
||||
4,
|
||||
new StackMapType[] {
|
||||
new StackMapType((byte) 7, value2, constantPool2),
|
||||
new StackMapType((byte) 7, value3, constantPool2),
|
||||
new StackMapType((byte) 1, 0, constantPool2),
|
||||
new StackMapType((byte) 1, 0, constantPool2)
|
||||
},
|
||||
0,
|
||||
new StackMapType[0],
|
||||
constantPool2);
|
||||
StackMap stackMap =
|
||||
new StackMap(
|
||||
value4, 30, new StackMapEntry[] {stackMapEntry, stackMapEntry2}, constantPool2);
|
||||
methodGen.addCodeAttribute(stackMap);
|
||||
instructionList.getInstructionHandle(
|
||||
InstructionFactory.createLocalVariableInstruction2(Type.OBJECT, 0));
|
||||
instructionList.getInstructionHandle(
|
||||
instructionFactory.createInvoke(
|
||||
"java.lang.String", "length", Type.INT, Type.NO_ARGS, (short) 182));
|
||||
instructionList.getInstructionHandle(instructionFactory.createNewArray(Type.CHAR, (short) 1));
|
||||
instructionList.getInstructionHandle(new PUSH(constantPool, 1));
|
||||
instructionList.getInstructionHandle(InstructionConstants.DUP);
|
||||
instructionList.getInstructionHandle(InstructionConstants.POP2);
|
||||
instructionList.getInstructionHandle(
|
||||
InstructionFactory.createLocalVariableInstruction(Type.OBJECT, 1));
|
||||
instructionList.getInstructionHandle(new PUSH(constantPool, value));
|
||||
instructionList.getInstructionHandle(new PUSH(constantPool, 1));
|
||||
instructionList.getInstructionHandle(InstructionConstants.DUP);
|
||||
instructionList.getInstructionHandle(InstructionConstants.POP2);
|
||||
instructionList.getInstructionHandle(
|
||||
InstructionFactory.createLocalVariableInstruction(Type.INT, 2));
|
||||
instructionList.getInstructionHandle(
|
||||
InstructionFactory.createLocalVariableInstruction2(Type.OBJECT, 1));
|
||||
instructionList.getInstructionHandle(InstructionConstants.ARRAYLENGTH);
|
||||
instructionList.getInstructionHandle(new PUSH(constantPool, 1));
|
||||
instructionList.getInstructionHandle(new PUSH(constantPool, 1));
|
||||
instructionList.getInstructionHandle(InstructionConstants.DUP);
|
||||
instructionList.getInstructionHandle(InstructionConstants.POP2);
|
||||
instructionList.getInstructionHandle(InstructionConstants.ISUB);
|
||||
instructionList.getInstructionHandle(
|
||||
InstructionFactory.createLocalVariableInstruction(Type.INT, 3));
|
||||
BranchInstruction branchInstruction =
|
||||
InstructionFactory.createBranchInstruction((short) 167, null);
|
||||
instructionList.getBranchHandle(branchInstruction);
|
||||
InstructionHandle instructionHandle =
|
||||
instructionList.getInstructionHandle(
|
||||
InstructionFactory.createLocalVariableInstruction2(Type.OBJECT, 1));
|
||||
instructionList.getInstructionHandle(
|
||||
InstructionFactory.createLocalVariableInstruction2(Type.INT, 3));
|
||||
instructionList.getInstructionHandle(
|
||||
InstructionFactory.createLocalVariableInstruction2(Type.OBJECT, 0));
|
||||
instructionList.getInstructionHandle(
|
||||
InstructionFactory.createLocalVariableInstruction2(Type.INT, 3));
|
||||
instructionList.getInstructionHandle(
|
||||
instructionFactory.createInvoke(
|
||||
"java.lang.String", "charAt", Type.CHAR, new Type[] {Type.INT}, (short) 182));
|
||||
instructionList.getInstructionHandle(
|
||||
InstructionFactory.createLocalVariableInstruction2(Type.INT, 2));
|
||||
instructionList.getInstructionHandle(InstructionConstants.IXOR);
|
||||
instructionList.getInstructionHandle(InstructionConstants.I2C);
|
||||
instructionList.getInstructionHandle(new PUSH(constantPool, 1));
|
||||
instructionList.getInstructionHandle(InstructionConstants.DUP);
|
||||
instructionList.getInstructionHandle(InstructionConstants.POP2);
|
||||
instructionList.getInstructionHandle(InstructionConstants.CASTORE);
|
||||
instructionList.getInstructionHandle(
|
||||
InstructionFactory.createLocalVariableInstruction2(Type.INT, 2));
|
||||
instructionList.getInstructionHandle(
|
||||
InstructionFactory.createLocalVariableInstruction2(Type.INT, 3));
|
||||
instructionList.getInstructionHandle(InstructionConstants.IXOR);
|
||||
instructionList.getInstructionHandle(InstructionConstants.I2C);
|
||||
instructionList.getInstructionHandle(
|
||||
InstructionFactory.createLocalVariableInstruction(Type.INT, 2));
|
||||
instructionList.getInstructionHandle(
|
||||
InstructionFactory.createLocalVariableInstruction2(Type.INT, 2));
|
||||
instructionList.getInstructionHandle(new PUSH(constantPool, 63));
|
||||
instructionList.getInstructionHandle(new PUSH(constantPool, 1));
|
||||
instructionList.getInstructionHandle(InstructionConstants.DUP);
|
||||
instructionList.getInstructionHandle(InstructionConstants.POP2);
|
||||
instructionList.getInstructionHandle(InstructionConstants.IAND);
|
||||
instructionList.getInstructionHandle(InstructionConstants.I2C);
|
||||
instructionList.getInstructionHandle(
|
||||
InstructionFactory.createLocalVariableInstruction(Type.INT, 2));
|
||||
instructionList.getInstructionHandle(new IINC(3, -1));
|
||||
InstructionHandle instructionHandle2 =
|
||||
instructionList.getInstructionHandle(
|
||||
InstructionFactory.createLocalVariableInstruction2(Type.INT, 3));
|
||||
instructionList.getBranchHandle(
|
||||
InstructionFactory.createBranchInstruction((short) 156, instructionHandle));
|
||||
instructionList.getInstructionHandle(instructionFactory.createNew("java.lang.String"));
|
||||
instructionList.getInstructionHandle(InstructionConstants.DUP);
|
||||
instructionList.getInstructionHandle(
|
||||
InstructionFactory.createLocalVariableInstruction2(Type.OBJECT, 1));
|
||||
instructionList.getInstructionHandle(
|
||||
instructionFactory.createInvoke(
|
||||
"java.lang.String",
|
||||
"<init>",
|
||||
Type.VOID,
|
||||
new Type[] {new ArrayType(Type.CHAR, 1)},
|
||||
(short) 183));
|
||||
instructionList.getInstructionHandle(InstructionFactory.createReturn(Type.OBJECT));
|
||||
branchInstruction.setTarget(instructionHandle2);
|
||||
methodGen.update5();
|
||||
methodGen.update4();
|
||||
classGen.processMethod2(methodGen.getMethod());
|
||||
instructionList.update3();
|
||||
}
|
||||
|
||||
public static boolean matchesText(String text) {
|
||||
int value;
|
||||
for (int value2 = value = values.size() - 1; value2 >= 0; value2 = --value) {
|
||||
if (((Pattern) values.get(value)).matcher(text).matches()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean matchesText2(Vector vector, String text) {
|
||||
if ("00".equals(text)) {
|
||||
return false;
|
||||
}
|
||||
if ("01".equals(text)) {
|
||||
vector.add(InstructionConstants.ICONST_1);
|
||||
} else if ("10".equals(text)) {
|
||||
vector.add(InstructionConstants.ICONST_2);
|
||||
} else if ("11".equals(text)) {
|
||||
vector.add(InstructionConstants.ICONST_3);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Vector createValues(int value) {
|
||||
Vector vector = new Vector();
|
||||
String text;
|
||||
String text2 = text = Integer.toBinaryString(value);
|
||||
while (text2.length() < 7) {
|
||||
text2 = text = "0" + text;
|
||||
}
|
||||
if (text.startsWith("0")) {
|
||||
boolean matches;
|
||||
if (matches = matchesText(vector, text.substring(1, 4))) {
|
||||
vector.add(InstructionConstants.ICONST_3);
|
||||
vector.add(InstructionConstants.ISHL);
|
||||
}
|
||||
if (matchesText(vector, text.substring(4, 7)) && matches) {
|
||||
vector.add(InstructionConstants.IXOR);
|
||||
}
|
||||
return vector;
|
||||
} else if (text.endsWith("0")) {
|
||||
boolean matches2;
|
||||
if (matches2 = matchesText(vector, text.substring(0, 3))) {
|
||||
vector.add(InstructionConstants.ICONST_4);
|
||||
vector.add(InstructionConstants.ISHL);
|
||||
}
|
||||
if (matchesText(vector, text.substring(3, 6)) && matches2) {
|
||||
vector.add(InstructionConstants.ICONST_1);
|
||||
vector.add(InstructionConstants.ISHL);
|
||||
vector.add(InstructionConstants.IXOR);
|
||||
}
|
||||
return vector;
|
||||
} else if (text.charAt(3) == '0') {
|
||||
boolean matches3;
|
||||
if (matches3 = matchesText(vector, text.substring(0, 3))) {
|
||||
vector.add(InstructionConstants.ICONST_4);
|
||||
vector.add(InstructionConstants.ISHL);
|
||||
}
|
||||
if (matchesText(vector, text.substring(4, 7)) && matches3) {
|
||||
vector.add(InstructionConstants.IXOR);
|
||||
}
|
||||
return vector;
|
||||
} else {
|
||||
matchesText(vector, text.substring(0, 3));
|
||||
vector.add(InstructionConstants.ICONST_4);
|
||||
vector.add(InstructionConstants.ISHL);
|
||||
boolean matches4 = matchesText2(vector, text.substring(3, 5));
|
||||
if (matches4) {
|
||||
vector.add(InstructionConstants.ICONST_2);
|
||||
vector.add(InstructionConstants.ISHL);
|
||||
}
|
||||
if (matchesText2(vector, text.substring(5, 7))) {
|
||||
vector.add(InstructionConstants.IXOR);
|
||||
}
|
||||
if (matches4) {
|
||||
vector.add(InstructionConstants.IXOR);
|
||||
}
|
||||
return vector;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getText(ClassGen classGen) {
|
||||
Attribute[] attributes;
|
||||
if ((attributes = classGen.getAttributes()) == null) {
|
||||
return "Unknown Source";
|
||||
}
|
||||
int value;
|
||||
for (int value2 = value = attributes.length - 1; value2 >= 0; value2 = --value) {
|
||||
if (attributes[value] instanceof SourceFile) {
|
||||
return ((SourceFile) attributes[value]).getText();
|
||||
}
|
||||
}
|
||||
return "Unknown Source";
|
||||
}
|
||||
|
||||
public static void processClassGen(ClassGen classGen) {
|
||||
Method[] methods;
|
||||
int value;
|
||||
for (int value2 = value = (methods = classGen.getMethods()).length - 1;
|
||||
value2 >= 0;
|
||||
value2 = --value) {
|
||||
Method method;
|
||||
if ((method = methods[value]).getCode() != null) {
|
||||
InstructionHandle instructionHandle;
|
||||
InstructionList instructionList;
|
||||
InstructionHandle instructionHandle2 =
|
||||
instructionHandle =
|
||||
(instructionList =
|
||||
MethodFactory.createMethodGen(
|
||||
method,
|
||||
classGen.getClassName(),
|
||||
classGen.getConstantPool(),
|
||||
classGen.getConstantPool().getConstantPool())
|
||||
.getInstructionList())
|
||||
.getStart();
|
||||
while (instructionHandle2 != null) {
|
||||
InstructionHandle instructionHandle3;
|
||||
if (!(instructionHandle.getInstruction() instanceof LDC)) {
|
||||
instructionHandle3 = instructionHandle;
|
||||
} else {
|
||||
LDC lDC = (LDC) instructionHandle.getInstruction();
|
||||
if (!(classGen.getConstantPool().getConstant(lDC.getIndex())
|
||||
instanceof ConstantString)) {
|
||||
instructionHandle3 = instructionHandle;
|
||||
} else {
|
||||
label145:
|
||||
{
|
||||
ConstantPoolGen constantPool = classGen.getConstantPool();
|
||||
int value3 = lDC.produceStack(constantPool);
|
||||
InstructionHandle instructionHandle22 = instructionHandle.getInstructionHandle2();
|
||||
int value4 = 0;
|
||||
while (instructionHandle22 != null) {
|
||||
int value5 = instructionHandle22.getInstruction().produceStack(constantPool);
|
||||
int value6 = instructionHandle22.getInstruction().consumeStack(constantPool);
|
||||
if (value5 == -2) {
|
||||
break;
|
||||
}
|
||||
if (value6 == -2) {
|
||||
instructionHandle3 = instructionHandle;
|
||||
break label145;
|
||||
}
|
||||
int value7;
|
||||
if ((value7 = value3 - value6) <= 0) {
|
||||
Instruction instruction;
|
||||
if (!((instruction = instructionHandle22.getInstruction()) instanceof IF_ACMPEQ)
|
||||
&& !(instruction instanceof IF_ACMPNE)) {
|
||||
break;
|
||||
}
|
||||
int value8;
|
||||
do {
|
||||
value8 = calculateCount(instructionHandle22);
|
||||
} while ((instructionHandle22 = instructionHandle22.getInstructionHandle())
|
||||
!= null
|
||||
&& value8 == -1);
|
||||
String text =
|
||||
""
|
||||
+ classGen.getClassName()
|
||||
+ "."
|
||||
+ method.getText()
|
||||
+ "("
|
||||
+ getText(classGen);
|
||||
if (value8 != -1) {
|
||||
text = "" + text + ":" + value8;
|
||||
}
|
||||
String text2 = "" + text + ")";
|
||||
Log.warn("Comparing strings using '==' operator at " + text2);
|
||||
instructionHandle3 = instructionHandle;
|
||||
break label145;
|
||||
}
|
||||
value3 = value7 + value5;
|
||||
instructionHandle22 = instructionHandle22.getInstructionHandle2();
|
||||
int value9 = value4++;
|
||||
if (value9 > (byte) 33) {
|
||||
instructionHandle3 = instructionHandle;
|
||||
break label145;
|
||||
}
|
||||
}
|
||||
instructionHandle3 = instructionHandle;
|
||||
}
|
||||
}
|
||||
}
|
||||
instructionHandle2 = instructionHandle = instructionHandle3.getInstructionHandle2();
|
||||
}
|
||||
InstructionHandle instructionHandle4;
|
||||
InstructionHandle instructionHandle5 = instructionHandle4 = instructionList.getStart();
|
||||
while (instructionHandle5 != null) {
|
||||
InstructionHandle instructionHandle6;
|
||||
if (!(instructionHandle4.getInstruction() instanceof GETSTATIC)
|
||||
&& !(instructionHandle4.getInstruction() instanceof GETFIELD)) {
|
||||
instructionHandle6 = instructionHandle4;
|
||||
} else {
|
||||
FieldInstruction fieldInstruction =
|
||||
(FieldInstruction) instructionHandle4.getInstruction();
|
||||
ConstantPoolGen constantPool2 = classGen.getConstantPool();
|
||||
if (!((String) "Ljava/lang/String;").equals(fieldInstruction.getText3(constantPool2))) {
|
||||
instructionHandle6 = instructionHandle4;
|
||||
} else {
|
||||
label142:
|
||||
{
|
||||
int value10 = fieldInstruction.produceStack(constantPool2);
|
||||
InstructionHandle instructionHandle23 = instructionHandle4.getInstructionHandle2();
|
||||
int value11 = 0;
|
||||
while (instructionHandle23 != null) {
|
||||
int value12 = instructionHandle23.getInstruction().produceStack(constantPool2);
|
||||
int value13 = instructionHandle23.getInstruction().consumeStack(constantPool2);
|
||||
if (value12 == -2) {
|
||||
break;
|
||||
}
|
||||
if (value13 == -2) {
|
||||
instructionHandle6 = instructionHandle4;
|
||||
break label142;
|
||||
}
|
||||
int value14;
|
||||
if ((value14 = value10 - value13) <= 0) {
|
||||
Instruction instruction2;
|
||||
if (!((instruction2 = instructionHandle23.getInstruction())
|
||||
instanceof IF_ACMPEQ)
|
||||
&& !(instruction2 instanceof IF_ACMPNE)) {
|
||||
break;
|
||||
}
|
||||
int value15;
|
||||
do {
|
||||
value15 = calculateCount(instructionHandle23);
|
||||
} while ((instructionHandle23 = instructionHandle23.getInstructionHandle())
|
||||
!= null
|
||||
&& value15 == -1);
|
||||
String text3 =
|
||||
""
|
||||
+ classGen.getClassName()
|
||||
+ "."
|
||||
+ method.getText()
|
||||
+ "("
|
||||
+ getText(classGen);
|
||||
if (value15 != -1) {
|
||||
text3 = "" + text3 + ":" + value15;
|
||||
}
|
||||
String text4 = "" + text3 + ")";
|
||||
Log.warn("Comparing strings using '==' operator at " + text4);
|
||||
instructionHandle6 = instructionHandle4;
|
||||
break label142;
|
||||
}
|
||||
value10 = value14 + value12;
|
||||
instructionHandle23 = instructionHandle23.getInstructionHandle2();
|
||||
int value16 = value11++;
|
||||
if (value16 > (byte) 33) {
|
||||
instructionHandle6 = instructionHandle4;
|
||||
break label142;
|
||||
}
|
||||
}
|
||||
instructionHandle6 = instructionHandle4;
|
||||
}
|
||||
}
|
||||
}
|
||||
instructionHandle5 = instructionHandle4 = instructionHandle6.getInstructionHandle2();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int calculateCount(InstructionHandle instructionHandle) {
|
||||
InstructionTargeter[] instructionTargeters;
|
||||
if ((instructionTargeters = instructionHandle.getTargeters()) == null) {
|
||||
return -1;
|
||||
}
|
||||
int value;
|
||||
for (int value2 = value = instructionTargeters.length - 1; value2 >= 0; value2 = --value) {
|
||||
if (instructionTargeters[value] instanceof LineNumberGen) {
|
||||
return ((LineNumberGen) instructionTargeters[value]).getSourceLine();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static void processClassGen2(ClassGen classGen) {
|
||||
int value;
|
||||
Field[] fields;
|
||||
for (int value2 = value = (fields = classGen.getFields()).length - 1;
|
||||
value2 >= 0;
|
||||
value2 = --value) {
|
||||
Field field;
|
||||
ConstantValue constantValue;
|
||||
Constant constant;
|
||||
if ((constantValue = (field = fields[value]).getConstantValue()) != null
|
||||
&& (constant =
|
||||
classGen.getConstantPool().getConstant(constantValue.getConstantValueIndex()))
|
||||
instanceof ConstantString
|
||||
&& field.isEnabled3()) {
|
||||
if (!field.isEnabled11()) {
|
||||
FieldGen fieldGen = new FieldGen(field, classGen.getConstantPool());
|
||||
fieldGen.cancelInitValue();
|
||||
classGen.replaceField(field, fieldGen.getField());
|
||||
} else {
|
||||
Method method = null;
|
||||
int value3;
|
||||
Method[] methods;
|
||||
for (int value4 = value3 = (methods = classGen.getMethods()).length - 1;
|
||||
value4 >= 0;
|
||||
value4 = --value3) {
|
||||
Method method2 = methods[value3];
|
||||
if ("<clinit>".equals(method2.getText())) {
|
||||
method = method2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
InstructionList instructionList = new InstructionList();
|
||||
instructionList.getInstructionHandle4(InstructionFactory.createReturn(Type.VOID));
|
||||
MethodGen methodGen;
|
||||
ClassGen classGen2;
|
||||
if (method != null) {
|
||||
instructionList =
|
||||
(methodGen =
|
||||
MethodFactory.createMethodGen(
|
||||
method,
|
||||
classGen.getClassName(),
|
||||
classGen.getConstantPool(),
|
||||
classGen.getConstantPool().getConstantPool()))
|
||||
.getInstructionList();
|
||||
classGen2 = classGen;
|
||||
} else {
|
||||
methodGen =
|
||||
new MethodGen(
|
||||
8,
|
||||
Type.VOID,
|
||||
Type.NO_ARGS,
|
||||
new String[0],
|
||||
"<clinit>",
|
||||
classGen.getClassName(),
|
||||
instructionList,
|
||||
classGen.getConstantPool());
|
||||
classGen2 = classGen;
|
||||
}
|
||||
String bytes =
|
||||
((ConstantUtf8)
|
||||
classGen2
|
||||
.getConstantPool()
|
||||
.getConstant(((ConstantString) constant).getStringIndex()))
|
||||
.getBytes();
|
||||
InstructionFactory instructionFactory = new InstructionFactory(classGen);
|
||||
instructionList.getInstructionHandle4(
|
||||
instructionFactory.createFieldAccess(
|
||||
classGen.getClassName(), field.getText(), Type.STRING, (short) 179));
|
||||
instructionList.getInstructionHandle2(new PUSH(classGen.getConstantPool(), bytes));
|
||||
methodGen.update5();
|
||||
methodGen.update4();
|
||||
InstructionList instructionList2;
|
||||
if (method != null) {
|
||||
classGen.replaceMethod(method, methodGen.getMethod());
|
||||
instructionList2 = instructionList;
|
||||
} else {
|
||||
classGen.processMethod2(methodGen.getMethod());
|
||||
instructionList2 = instructionList;
|
||||
}
|
||||
instructionList2.update3();
|
||||
FieldGen fieldGen2 = new FieldGen(field, classGen.getConstantPool());
|
||||
fieldGen2.cancelInitValue();
|
||||
classGen.replaceField(field, fieldGen2.getField());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package com.allatori.eclipse;
|
||||
|
||||
import com.allatori.Obfuscate;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.util.Map;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.jdt.core.IClasspathEntry;
|
||||
import org.eclipse.jdt.core.IJavaProject;
|
||||
import org.eclipse.jdt.core.JavaCore;
|
||||
|
||||
public class AllatoriBuilder extends IncrementalProjectBuilder {
|
||||
|
||||
public static final String TEXT = "com.allatori.eclipse";
|
||||
|
||||
public IProject[] build(int value, Map entries, IProgressMonitor progressMonitor)
|
||||
throws CoreException {
|
||||
this.getProject();
|
||||
switch (value) {
|
||||
case 6:
|
||||
this.processIProgressMonitor(progressMonitor);
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void processIProgressMonitor(IProgressMonitor progressMonitor) throws CoreException {
|
||||
try {
|
||||
String text = this.getProject().getLocation().toString();
|
||||
File file;
|
||||
File file2;
|
||||
if (!(file = new File(text + "/allatori.xml")).exists()) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
StringBuilder stringBuilder2 = new StringBuilder();
|
||||
IClasspathEntry[] classpathEntrys;
|
||||
IJavaProject javaProject;
|
||||
int value =
|
||||
(classpathEntrys =
|
||||
(javaProject = JavaCore.create(this.getProject())).getResolvedClasspath(true))
|
||||
.length;
|
||||
int value2;
|
||||
for (int value3 = value2 = 0; value3 < value; value3 = ++value2) {
|
||||
IClasspathEntry classpathEntry;
|
||||
if ((classpathEntry = classpathEntrys[value2]).getEntryKind() == 3) {
|
||||
if (classpathEntry.getOutputLocation() != null) {
|
||||
String text2 = classpathEntry.getOutputLocation().removeFirstSegments(1).toString();
|
||||
stringBuilder.append(" <dir in=\"" + text2 + "\" out=\"" + text2 + "\"/>\n");
|
||||
}
|
||||
} else if (classpathEntry.getEntryKind() == 1) {
|
||||
stringBuilder2.append(
|
||||
" <jar name=\"" + classpathEntry.getPath().toString() + "\"/>\n");
|
||||
}
|
||||
}
|
||||
if (javaProject.getOutputLocation() != null) {
|
||||
String text3 = javaProject.getOutputLocation().removeFirstSegments(1).toString();
|
||||
stringBuilder.append(" <dir in=\"" + text3 + "\" out=\"" + text3 + "\"/>\n");
|
||||
}
|
||||
String text4 =
|
||||
"<config>\n <input>\n"
|
||||
+ stringBuilder
|
||||
+ " </input>\n\n"
|
||||
+ " <classpath>\n"
|
||||
+ stringBuilder2
|
||||
+ " </classpath>\n\n"
|
||||
+ " <keep-names>\n"
|
||||
+ " <class access=\"protected+\">\n"
|
||||
+ " <field access=\"protected+\"/>\n"
|
||||
+ " <method access=\"protected+\"/>\n"
|
||||
+ " </class>\n"
|
||||
+ " </keep-names>\n\n"
|
||||
+ " <property name=\"log-file\" value=\"allatori-log.xml\"/>\n"
|
||||
+ "</config>\n";
|
||||
BufferedWriter bufferedWriter =
|
||||
new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
|
||||
file2 = file;
|
||||
bufferedWriter.write(text4);
|
||||
bufferedWriter.close();
|
||||
} else {
|
||||
StringBuffer stringBuffer = new StringBuffer((int) file.length());
|
||||
int value4;
|
||||
BufferedReader bufferedReader;
|
||||
for (BufferedReader bufferedReader2 =
|
||||
bufferedReader =
|
||||
new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
|
||||
(value4 = bufferedReader2.read()) != -1;
|
||||
bufferedReader2 = bufferedReader) {
|
||||
stringBuffer.append((char) value4);
|
||||
}
|
||||
bufferedReader.close();
|
||||
String text5;
|
||||
if ((text5 = stringBuffer.toString()).contains("${eclipse-")) {
|
||||
StringBuilder stringBuilder3 = new StringBuilder();
|
||||
StringBuilder stringBuilder4 = new StringBuilder();
|
||||
IJavaProject javaProject2;
|
||||
IClasspathEntry[] classpathEntrys2;
|
||||
int value5 =
|
||||
(classpathEntrys2 =
|
||||
(javaProject2 = JavaCore.create(this.getProject()))
|
||||
.getResolvedClasspath(true))
|
||||
.length;
|
||||
int value6;
|
||||
for (int value7 = value6 = 0; value7 < value5; value7 = ++value6) {
|
||||
IClasspathEntry classpathEntry2;
|
||||
if ((classpathEntry2 = classpathEntrys2[value6]).getEntryKind() == 3) {
|
||||
if (classpathEntry2.getOutputLocation() != null) {
|
||||
String text6 =
|
||||
classpathEntry2.getOutputLocation().removeFirstSegments(1).toString();
|
||||
stringBuilder3.append(
|
||||
" <dir in=\"" + text6 + "\" out=\"" + text6 + "\"/>\n");
|
||||
}
|
||||
} else if (classpathEntry2.getEntryKind() == 1) {
|
||||
stringBuilder4.append(
|
||||
" <jar name=\"" + classpathEntry2.getPath().toString() + "\"/>\n");
|
||||
}
|
||||
}
|
||||
if (javaProject2.getOutputLocation() != null) {
|
||||
String text7 = javaProject2.getOutputLocation().removeFirstSegments(1).toString();
|
||||
stringBuilder3.append(" <dir in=\"" + text7 + "\" out=\"" + text7 + "\"/>\n");
|
||||
}
|
||||
String text8 =
|
||||
text5
|
||||
.replace("${eclipse-input}", stringBuilder3)
|
||||
.replace("${eclipse-classpath}", stringBuilder4);
|
||||
file = new File(text + "/allatori-resolved.xml");
|
||||
BufferedWriter bufferedWriter2 =
|
||||
new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
|
||||
bufferedWriter2.write(text8);
|
||||
bufferedWriter2.close();
|
||||
}
|
||||
file2 = file;
|
||||
}
|
||||
Obfuscate.run(file2);
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
throw new CoreException(
|
||||
new Status(4, "com.allatori.eclipse", 0, exception.getMessage(), exception));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.allatori.eclipse;
|
||||
|
||||
import org.eclipse.core.expressions.PropertyTester;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
public class AllatoriPropertyTester extends PropertyTester {
|
||||
|
||||
public static final String TEXT = "isEnabled";
|
||||
|
||||
public boolean test(Object result, String text, Object[] results, Object result2) {
|
||||
IProject project;
|
||||
return "isEnabled".equals(text)
|
||||
&& (project =
|
||||
(IProject) Platform.getAdapterManager().getAdapter(result, IProject.class))
|
||||
!= null
|
||||
? MenuAddBuilder.matchesIProject(project)
|
||||
: false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.allatori.eclipse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.IHandler;
|
||||
import org.eclipse.core.resources.ICommand;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.ui.handlers.HandlerUtil;
|
||||
|
||||
public class MenuAddBuilder extends AbstractHandler implements IHandler {
|
||||
|
||||
public static final boolean matchesIProject(IProject project) {
|
||||
try {
|
||||
ICommand[] commands;
|
||||
int value = (commands = project.getDescription().getBuildSpec()).length;
|
||||
int value2;
|
||||
for (int value3 = value2 = 0; value3 < value; value3 = ++value2) {
|
||||
ICommand command = commands[value2];
|
||||
if ("com.allatori.eclipse".equals(command.getBuilderName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (CoreException coreException) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static IProject getIProject(ExecutionEvent executionEvent) {
|
||||
ISelection selection;
|
||||
if ((selection = HandlerUtil.getCurrentSelection(executionEvent))
|
||||
instanceof IStructuredSelection) {
|
||||
Object firstElement = ((IStructuredSelection) selection).getFirstElement();
|
||||
return (IProject) Platform.getAdapterManager().getAdapter(firstElement, IProject.class);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object execute(ExecutionEvent executionEvent) {
|
||||
IProject project;
|
||||
if ((project = getIProject(executionEvent)) != null) {
|
||||
try {
|
||||
if (matchesIProject(project)) {
|
||||
return null;
|
||||
}
|
||||
ICommand command;
|
||||
IProjectDescription projectDescription;
|
||||
(command = (projectDescription = project.getDescription()).newCommand())
|
||||
.setBuilderName("com.allatori.eclipse");
|
||||
ArrayList values;
|
||||
(values = new ArrayList()).addAll(Arrays.asList(projectDescription.getBuildSpec()));
|
||||
int value = 0;
|
||||
Iterator iterator2 = values.iterator();
|
||||
ArrayList values2;
|
||||
label29:
|
||||
{
|
||||
for (Iterator iterator3 = iterator2; iterator3.hasNext(); iterator3 = iterator2) {
|
||||
value++;
|
||||
ICommand command2 = (ICommand) iterator2.next();
|
||||
if ("org.eclipse.jdt.core.javabuilder".equals(command2.getBuilderName())) {
|
||||
values2 = values;
|
||||
break label29;
|
||||
}
|
||||
}
|
||||
values2 = values;
|
||||
}
|
||||
values2.add(value, command);
|
||||
projectDescription.setBuildSpec((ICommand[]) values.toArray(new ICommand[values.size()]));
|
||||
project.setDescription(projectDescription, null);
|
||||
} catch (CoreException coreException) {
|
||||
coreException.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.allatori.eclipse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.IHandler;
|
||||
import org.eclipse.core.resources.ICommand;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public class MenuRemoveBuilder extends AbstractHandler implements IHandler {
|
||||
|
||||
public Object execute(ExecutionEvent executionEvent) {
|
||||
IProject project;
|
||||
if ((project = MenuAddBuilder.getIProject(executionEvent)) != null) {
|
||||
try {
|
||||
IProjectDescription description = project.getDescription();
|
||||
ArrayList values;
|
||||
(values = new ArrayList()).addAll(Arrays.asList(description.getBuildSpec()));
|
||||
ICommand[] commands;
|
||||
int value = (commands = description.getBuildSpec()).length;
|
||||
int value2;
|
||||
for (int value3 = value2 = 0; value3 < value; value3 = ++value2) {
|
||||
ICommand command = commands[value2];
|
||||
if ("com.allatori.eclipse".equals(command.getBuilderName())) {
|
||||
values.remove(command);
|
||||
}
|
||||
}
|
||||
description.setBuildSpec((ICommand[]) values.toArray(new ICommand[values.size()]));
|
||||
project.setDescription(description, null);
|
||||
} catch (CoreException coreException) {
|
||||
coreException.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.allatori.engine;
|
||||
|
||||
public class ObfuscationAbortException extends Exception {}
|
||||
@@ -0,0 +1,177 @@
|
||||
package com.allatori.engine;
|
||||
|
||||
import com.allatori.bytecode.ConstantPoolEditor;
|
||||
import com.allatori.config.Configuration;
|
||||
import com.allatori.lib.bcel.classfile.Method;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.lib.bcel.util.comparator.MethodComparator;
|
||||
import com.allatori.model.ClassStorage;
|
||||
import com.allatori.naming.NameRenamer;
|
||||
import com.allatori.naming.generator.LowercaseConfusableNameGenerator;
|
||||
import com.allatori.naming.generator.MixedConfusableNameGenerator;
|
||||
import com.allatori.transform.ClassConstantPoolTransformer;
|
||||
import com.allatori.transform.ClassTransformer;
|
||||
import com.allatori.transform.ControlFlowTransformer;
|
||||
import com.allatori.transform.DistributedStringEncryptionTransformer;
|
||||
import com.allatori.transform.FieldAccessTransformer;
|
||||
import com.allatori.transform.GlobalStringEncryptionTransformer;
|
||||
import com.allatori.transform.HardwareIdTransformer;
|
||||
import com.allatori.transform.MemberConstantPoolTransformer;
|
||||
import com.allatori.transform.MemberReorderTransformer;
|
||||
import com.allatori.transform.MemberVisibilityTransformer;
|
||||
import com.allatori.transform.MethodAccessTransformer;
|
||||
import com.allatori.transform.OptimizerTransformer;
|
||||
import com.allatori.transform.RemoveFieldsTransformer;
|
||||
import com.allatori.transform.RemoveMethodsTransformer;
|
||||
import com.allatori.transform.StripAttributesTransformer;
|
||||
import com.allatori.util.Log;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
public class ObfuscationEngine {
|
||||
|
||||
public ClassStorage classStorage;
|
||||
|
||||
public boolean enabled;
|
||||
|
||||
public void update() {
|
||||
if (Configuration.getLogOptions().isText()) {
|
||||
new HardwareIdTransformer(this.classStorage).transform(null);
|
||||
}
|
||||
Vector vector = new Vector();
|
||||
vector.add(new MemberVisibilityTransformer(this.classStorage));
|
||||
vector.add(new RemoveMethodsTransformer(this.classStorage));
|
||||
vector.add(new RemoveFieldsTransformer(this.classStorage));
|
||||
if (Configuration.getDebugInfoOptions().getText2() != null
|
||||
&& Configuration.getDebugInfoOptions().getText() != null) {
|
||||
vector.add(new FieldAccessTransformer(this.classStorage));
|
||||
}
|
||||
int stringEncryptionVersion =
|
||||
Configuration.getObfuscationOptions().getStringEncryptionVersion();
|
||||
Configuration.getObfuscationOptions();
|
||||
if (stringEncryptionVersion == 1) {
|
||||
DistributedStringEncryptionTransformer distributedStringEncryptionTransformer;
|
||||
if ((distributedStringEncryptionTransformer =
|
||||
new DistributedStringEncryptionTransformer(this.classStorage))
|
||||
.isEnabled()) {
|
||||
vector.add(distributedStringEncryptionTransformer);
|
||||
this.enabled = true;
|
||||
} else {
|
||||
vector.add(new GlobalStringEncryptionTransformer(this.classStorage));
|
||||
}
|
||||
} else {
|
||||
vector.add(new GlobalStringEncryptionTransformer(this.classStorage));
|
||||
}
|
||||
vector.add(new MethodAccessTransformer(this.classStorage));
|
||||
vector.add(new ControlFlowTransformer(this.classStorage));
|
||||
vector.add(new OptimizerTransformer(this.classStorage));
|
||||
Iterator classesByName2 = this.classStorage.getClassesByName2();
|
||||
while (classesByName2.hasNext()) {
|
||||
ClassGen classGen = (ClassGen) classesByName2.next();
|
||||
Iterator iterator2;
|
||||
if (!Configuration.getIgnoreClassesOptions().matchesClassGen(this.classStorage, classGen)) {
|
||||
for (Iterator iterator3 = iterator2 = vector.iterator();
|
||||
iterator3.hasNext();
|
||||
iterator3 = iterator2) {
|
||||
((ClassTransformer) iterator2.next()).transform(classGen);
|
||||
}
|
||||
}
|
||||
}
|
||||
Iterator iterator4;
|
||||
Iterator iterator5 = iterator4 = vector.iterator();
|
||||
while (iterator5.hasNext()) {
|
||||
ClassTransformer classTransformer = (ClassTransformer) iterator4.next();
|
||||
iterator5 = iterator4;
|
||||
classTransformer.finish();
|
||||
}
|
||||
}
|
||||
|
||||
public ObfuscationEngine(ClassStorage classStorage2) {
|
||||
super();
|
||||
this.enabled = false;
|
||||
this.classStorage = classStorage2;
|
||||
Method.setComparator(MethodComparator.getMethodComparator());
|
||||
MixedConfusableNameGenerator.processCount(
|
||||
Integer.toBinaryString(classStorage2.getClassesByName()).length());
|
||||
LowercaseConfusableNameGenerator.processCount(
|
||||
Integer.toBinaryString(classStorage2.getClassesByName()).length() + 1);
|
||||
}
|
||||
|
||||
public void update2() {
|
||||
ConstantPoolEditor constantPoolEditor = new ConstantPoolEditor(this.classStorage);
|
||||
Iterator classesByName2 = this.classStorage.getClassesByName2();
|
||||
while (classesByName2.hasNext()) {
|
||||
ClassGen classGen = (ClassGen) classesByName2.next();
|
||||
if (!Configuration.getIgnoreClassesOptions().matchesClassGen(this.classStorage, classGen)) {
|
||||
constantPoolEditor.processClassGen(classGen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void obfuscate() {
|
||||
Iterator classesByName2 = this.classStorage.getClassesByName2();
|
||||
ObfuscationEngine obfuscationEngine;
|
||||
while (true) {
|
||||
if (classesByName2.hasNext()) {
|
||||
ClassGen classGen;
|
||||
if ((classGen = (ClassGen) classesByName2.next())
|
||||
.getSuperclassName()
|
||||
.startsWith("javax.microedition.")) {
|
||||
Configuration.getObfuscationOptions().setEnabled(true);
|
||||
obfuscationEngine = this;
|
||||
break;
|
||||
}
|
||||
if (!classGen.getSuperclassName().startsWith("android.")) {
|
||||
continue;
|
||||
}
|
||||
Configuration.getObfuscationOptions().setEnabled3(true);
|
||||
obfuscationEngine = this;
|
||||
break;
|
||||
}
|
||||
obfuscationEngine = this;
|
||||
break;
|
||||
}
|
||||
obfuscationEngine.update();
|
||||
MemberReorderTransformer memberReorderTransformer =
|
||||
new MemberReorderTransformer(this.classStorage);
|
||||
Iterator classesByName22 = this.classStorage.getClassesByName2();
|
||||
while (classesByName22.hasNext()) {
|
||||
ClassGen classGen2 = (ClassGen) classesByName22.next();
|
||||
if (!Configuration.getIgnoreClassesOptions().matchesClassGen(this.classStorage, classGen2)) {
|
||||
memberReorderTransformer.transform(classGen2);
|
||||
}
|
||||
}
|
||||
this.renameMembers();
|
||||
memberReorderTransformer.finish();
|
||||
ClassTransformer classTransformer;
|
||||
if (this.enabled) {
|
||||
classTransformer = new ClassConstantPoolTransformer(this.classStorage);
|
||||
obfuscationEngine = this;
|
||||
} else {
|
||||
classTransformer = new MemberConstantPoolTransformer(this.classStorage);
|
||||
obfuscationEngine = this;
|
||||
}
|
||||
Iterator classesByName23 = obfuscationEngine.classStorage.getClassesByName2();
|
||||
while (classesByName23.hasNext()) {
|
||||
ClassGen classGen3 = (ClassGen) classesByName23.next();
|
||||
if (!Configuration.getIgnoreClassesOptions().matchesClassGen(this.classStorage, classGen3)) {
|
||||
classTransformer.transform(classGen3);
|
||||
}
|
||||
}
|
||||
classTransformer.finish();
|
||||
this.update2();
|
||||
new StripAttributesTransformer(this.classStorage).transform(null);
|
||||
}
|
||||
|
||||
public void renameMembers() {
|
||||
try {
|
||||
new NameRenamer(this.classStorage).rename();
|
||||
} catch (ObfuscationAbortException obfuscationAbortException) {
|
||||
try {
|
||||
Log.warn("Rerunning obfuscation due to un-renamed packages.");
|
||||
new NameRenamer(this.classStorage).rename();
|
||||
} catch (ObfuscationAbortException obfuscationAbortException2) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.allatori.engine;
|
||||
|
||||
public class ObfuscationException extends Exception {
|
||||
|
||||
public ObfuscationException(String text) {
|
||||
super(text);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.allatori.internal;
|
||||
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
|
||||
public interface BytecodeSupport {
|
||||
|
||||
void processClassGen(ClassGen classGen);
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.allatori.internal;
|
||||
|
||||
import com.allatori.lib.bcel.Constants;
|
||||
import com.allatori.lib.bcel.ExceptionConstants;
|
||||
import com.allatori.lib.bcel.classfile.Constant;
|
||||
import com.allatori.lib.bcel.classfile.ConstantInvokeDynamic;
|
||||
import com.allatori.lib.bcel.classfile.ConstantNameAndType;
|
||||
import com.allatori.lib.bcel.classfile.ConstantPool;
|
||||
import com.allatori.lib.bcel.generic.ConstantPoolGen;
|
||||
import com.allatori.lib.bcel.generic.ExceptionThrower;
|
||||
import com.allatori.lib.bcel.generic.NameSignatureInstruction;
|
||||
import com.allatori.lib.bcel.generic.StackConsumer;
|
||||
import com.allatori.lib.bcel.generic.StackProducer;
|
||||
import com.allatori.lib.bcel.generic.Type;
|
||||
import com.allatori.lib.bcel.generic.Visitor;
|
||||
import com.allatori.lib.bcel.util.ByteSequence;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
public class NameSignatureInstructionSupport extends NameSignatureInstruction
|
||||
implements ExceptionThrower, StackConsumer, StackProducer {
|
||||
|
||||
public ConstantInvokeDynamic getConstantInvokeDynamic(ConstantPoolGen constantPoolGen) {
|
||||
return (ConstantInvokeDynamic) constantPoolGen.getConstantPool().getConstant(this.index);
|
||||
}
|
||||
|
||||
public Type[] getTypes(ConstantPoolGen constantPoolGen) {
|
||||
return Type.getArgumentTypes(this.getText(constantPoolGen));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(Visitor visitor) {
|
||||
visitor.visitExceptionThrower(this);
|
||||
visitor.visitTypedInstruction(this);
|
||||
visitor.visitStackConsumer(this);
|
||||
visitor.visitStackProducer(this);
|
||||
visitor.visitCPInstruction(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int produceStack(ConstantPoolGen constantPoolGen) {
|
||||
return Type.calculateCount(this.getText(constantPoolGen));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initFromFile(ByteSequence byteSequence, boolean matches) throws IOException {
|
||||
super.initFromFile(byteSequence, matches);
|
||||
this.length = 5;
|
||||
byteSequence.readUnsignedShort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class[] getExceptions() {
|
||||
Class[] classs = new Class[4 + ExceptionConstants.TYPES4.length];
|
||||
System.arraycopy(ExceptionConstants.TYPES4, 0, classs, 0, ExceptionConstants.TYPES4.length);
|
||||
classs[ExceptionConstants.TYPES4.length + 3] = ExceptionConstants.TYPE9;
|
||||
classs[ExceptionConstants.TYPES4.length + 2] = ExceptionConstants.TYPE7;
|
||||
classs[ExceptionConstants.TYPES4.length + 1] = ExceptionConstants.TYPE14;
|
||||
classs[ExceptionConstants.TYPES4.length] = ExceptionConstants.TYPE6;
|
||||
return classs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ConstantPool constantPool) {
|
||||
Constant constant = constantPool.getConstant(this.index);
|
||||
StringTokenizer stringTokenizer = new StringTokenizer(constantPool.constantToString(constant));
|
||||
return ""
|
||||
+ Constants.TEXTS8[this.opcode]
|
||||
+ " "
|
||||
+ stringTokenizer.nextToken().replace('.', '/')
|
||||
+ stringTokenizer.nextToken();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int consumeStack(ConstantPoolGen constantPoolGen) {
|
||||
return Type.calculateCount2(this.getText(constantPoolGen));
|
||||
}
|
||||
|
||||
public Type getType2(ConstantPoolGen constantPoolGen) {
|
||||
return Type.getReturnType(this.getText(constantPoolGen));
|
||||
}
|
||||
|
||||
public NameSignatureInstructionSupport() {}
|
||||
|
||||
@Override
|
||||
public Type getType(ConstantPoolGen constantPoolGen) {
|
||||
return this.getType2(constantPoolGen);
|
||||
}
|
||||
|
||||
public String getText3(ConstantPoolGen constantPoolGen) {
|
||||
return this.getText2(constantPoolGen);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(DataOutputStream dataOutputStream) throws IOException {
|
||||
dataOutputStream.writeByte(this.opcode);
|
||||
dataOutputStream.writeShort(this.index);
|
||||
dataOutputStream.writeByte(0);
|
||||
dataOutputStream.writeByte(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantNameAndType getNameAndType(ConstantPoolGen constantPoolGen) {
|
||||
ConstantPool constantPool = constantPoolGen.getConstantPool();
|
||||
ConstantInvokeDynamic constantInvokeDynamic = this.getConstantInvokeDynamic(constantPoolGen);
|
||||
return (ConstantNameAndType)
|
||||
constantPool.getConstant(constantInvokeDynamic.getBootstrapMethodAttrIndex2());
|
||||
}
|
||||
|
||||
public NameSignatureInstructionSupport(short value, int value2) {
|
||||
super(value, value2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.allatori.internal;
|
||||
|
||||
import com.allatori.lib.bcel.verifier.exc.VerifierConstraintViolatedException;
|
||||
|
||||
public class VerifierConstraintViolatedExceptionSupport
|
||||
extends VerifierConstraintViolatedException {
|
||||
|
||||
public VerifierConstraintViolatedExceptionSupport(String text) {
|
||||
super(text);
|
||||
}
|
||||
|
||||
public VerifierConstraintViolatedExceptionSupport() {}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.allatori.io;
|
||||
|
||||
import com.allatori.config.Configuration;
|
||||
import com.allatori.config.InputEntry;
|
||||
import com.allatori.model.ClassStorage;
|
||||
import com.allatori.util.Log;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.Vector;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
public class ClassStorageClassLoader extends URLClassLoader {
|
||||
|
||||
public ClassStorage classStorage;
|
||||
|
||||
public byte[] createValues(JarFile jarFile, ZipEntry zipEntry) throws IOException {
|
||||
byte[] values = new byte[(int) zipEntry.getSize()];
|
||||
DataInputStream dataInputStream;
|
||||
(dataInputStream = new DataInputStream(jarFile.getInputStream(zipEntry)))
|
||||
.readFully(values, 0, values.length);
|
||||
dataInputStream.close();
|
||||
return values;
|
||||
}
|
||||
|
||||
public ClassStorageClassLoader(URL[] uRLs) {
|
||||
super(uRLs, ClassStorageClassLoader.class.getClassLoader());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class findClass(String name) throws ClassNotFoundException, ClassNotFoundException {
|
||||
try {
|
||||
try {
|
||||
if (classStorage.getClassGen(name) != null) return createType(name);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return super.findClass(name);
|
||||
} catch (ClassNotFoundException failure) {
|
||||
try {
|
||||
return createType(name);
|
||||
} catch (Exception ignored) {
|
||||
throw failure;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Class createType(String text) throws Exception {
|
||||
try {
|
||||
String text3 = text.replace('.', '/').concat(".class");
|
||||
Vector values3 = Configuration.getInputOptions().getValues3();
|
||||
int value;
|
||||
for (int value2 = value = 0; value2 < values3.size(); value2 = ++value) {
|
||||
InputEntry inputEntry = (InputEntry) values3.get(value);
|
||||
JarFile jarFile = new JarFile(inputEntry.text2);
|
||||
try {
|
||||
ZipEntry zipEntry;
|
||||
if ((zipEntry = jarFile.getEntry(text3)) != null) {
|
||||
byte[] values = this.createValues(jarFile, zipEntry);
|
||||
try {
|
||||
return this.defineClass(text, values, 0, values.length);
|
||||
} catch (IncompatibleClassChangeError incompatibleClassChangeError) {
|
||||
Log.error("IncompatibleClassChangeError for class " + text);
|
||||
throw incompatibleClassChangeError;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
jarFile.close();
|
||||
}
|
||||
}
|
||||
throw new Exception();
|
||||
} catch (Exception exception) {
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
public void setClassStorage(ClassStorage classStorage2) {
|
||||
this.classStorage = classStorage2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.allatori.io;
|
||||
|
||||
import com.allatori.lib.bcel.classfile.ClassParser;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.model.ClassStorage;
|
||||
import com.allatori.util.Log;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class DirectoryClassReader {
|
||||
|
||||
public static ClassGen createClassGen(InputStream inputStream, String text) throws IOException {
|
||||
ClassGen classGen = new ClassGen(new ClassParser(inputStream, text).parse());
|
||||
inputStream.close();
|
||||
return classGen;
|
||||
}
|
||||
|
||||
public static void processText(String text, ClassStorage classStorage, String text2) {
|
||||
File[] files = new File(text).listFiles();
|
||||
int value;
|
||||
for (int value2 = value = 0; value2 < files.length; value2 = ++value) {
|
||||
File file;
|
||||
if ((file = files[value]).isDirectory()) {
|
||||
processText(file.getPath(), classStorage, text2);
|
||||
}
|
||||
if (file.getName().endsWith(".class")) {
|
||||
try {
|
||||
classStorage.processText(
|
||||
createClassGen(new BufferedInputStream(new FileInputStream(file)), file.getName()),
|
||||
text2);
|
||||
} catch (Exception exception) {
|
||||
if (!file.getName().endsWith("module-info.class")) {
|
||||
Log.error("Cannot parse class " + file.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.allatori.io;
|
||||
|
||||
import com.allatori.lib.asm.ClassWriter;
|
||||
import com.allatori.util.Log;
|
||||
|
||||
public class DirectoryClassWriter extends ClassWriter {
|
||||
|
||||
public final ClassLoader classLoader;
|
||||
|
||||
public final DirectoryWriter directoryWriter;
|
||||
|
||||
public DirectoryClassWriter(
|
||||
DirectoryWriter directoryWriter2, int value, ClassLoader classLoader2) {
|
||||
super(value);
|
||||
this.directoryWriter = directoryWriter2;
|
||||
this.classLoader = classLoader2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommonSuperClass(String text, String text2) {
|
||||
Class classValue;
|
||||
Class classValue2;
|
||||
try {
|
||||
classValue2 = Class.forName(text.replace('/', '.'), false, this.classLoader);
|
||||
classValue = Class.forName(text2.replace('/', '.'), false, this.classLoader);
|
||||
} catch (ClassNotFoundException classNotFoundException) {
|
||||
if (!DirectoryWriter.getValues(this.directoryWriter)
|
||||
.contains(classNotFoundException.getMessage())) {
|
||||
DirectoryWriter.getValues(this.directoryWriter).add(classNotFoundException.getMessage());
|
||||
Log.error("CLASS NOT FOUND: " + classNotFoundException.getMessage());
|
||||
Log.error(" ADD NEEDED JAR TO THE 'classpath' ELEMENT OF THE CONFIGURATION FILE.");
|
||||
}
|
||||
return "java/lang/Object";
|
||||
} catch (NoClassDefFoundError noClassDefFoundError) {
|
||||
if (!DirectoryWriter.getValues(this.directoryWriter)
|
||||
.contains(noClassDefFoundError.getMessage())) {
|
||||
DirectoryWriter.getValues(this.directoryWriter).add(noClassDefFoundError.getMessage());
|
||||
Log.error("CLASS NOT FOUND: " + noClassDefFoundError.getMessage());
|
||||
Log.error(" ADD NEEDED JAR TO THE 'classpath' ELEMENT OF THE CONFIGURATION FILE.");
|
||||
}
|
||||
return "java/lang/Object";
|
||||
} catch (Exception exception) {
|
||||
throw new RuntimeException(exception.toString());
|
||||
} catch (UnsupportedClassVersionError unsupportedClassVersionError) {
|
||||
if (!DirectoryWriter.matchesDirectoryWriter(this.directoryWriter)) {
|
||||
DirectoryWriter.matchesEnabled(this.directoryWriter, true);
|
||||
Log.error(
|
||||
"SOME CLASS(ES) CANNOT BE READ DUE TO JVM VERSION INCOMPATIBILITY: "
|
||||
+ unsupportedClassVersionError.toString());
|
||||
Log.error(" USE NEWER JVM VERSION TO RUN ALLATORI.");
|
||||
}
|
||||
return "java/lang/Object";
|
||||
} catch (Error error2) {
|
||||
return "java/lang/Object";
|
||||
}
|
||||
if (classValue2.isAssignableFrom(classValue)) {
|
||||
return text;
|
||||
}
|
||||
if (classValue.isAssignableFrom(classValue2)) {
|
||||
return text2;
|
||||
}
|
||||
if (!classValue2.isInterface() && !classValue.isInterface()) {
|
||||
while (!(classValue2 = classValue2.getSuperclass()).isAssignableFrom(classValue)) {}
|
||||
return classValue2.getName().replace('.', '/');
|
||||
} else {
|
||||
return "java/lang/Object";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
package com.allatori.io;
|
||||
|
||||
import com.allatori.config.Configuration;
|
||||
import com.allatori.lib.asm.ClassReader;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.model.ClassStorage;
|
||||
import com.allatori.util.FileUtils;
|
||||
import com.allatori.util.Log;
|
||||
import com.allatori.util.StreamUtils;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Vector;
|
||||
|
||||
public class DirectoryWriter {
|
||||
|
||||
public String text;
|
||||
|
||||
public ClassStorage classStorage;
|
||||
|
||||
public boolean enabled;
|
||||
|
||||
public HashSet values = new HashSet();
|
||||
|
||||
public DirectoryWriter() {
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
public void processFile(ClassGen classGen, File file)
|
||||
throws FileNotFoundException, ClassNotFoundException, IOException {
|
||||
file.getParentFile().mkdirs();
|
||||
BufferedOutputStream bufferedOutputStream =
|
||||
new BufferedOutputStream(new FileOutputStream(file));
|
||||
BufferedOutputStream bufferedOutputStream2;
|
||||
if (classGen.getMajor() > 50) {
|
||||
ResolvingClassLoader resolvingClassLoader =
|
||||
new ResolvingClassLoader(
|
||||
this.classStorage, Configuration.getMappingOptions().lookupTable);
|
||||
ClassReader classReader = new ClassReader(classGen.getJavaClass().getBytes());
|
||||
DirectoryClassWriter directoryClassWriter =
|
||||
new DirectoryClassWriter(this, 2, resolvingClassLoader);
|
||||
bufferedOutputStream2 = bufferedOutputStream;
|
||||
classReader.accept(directoryClassWriter, 4);
|
||||
bufferedOutputStream.write(directoryClassWriter.toByteArray());
|
||||
} else {
|
||||
bufferedOutputStream2 = bufferedOutputStream;
|
||||
bufferedOutputStream.write(classGen.getJavaClass().getBytes());
|
||||
}
|
||||
bufferedOutputStream2.close();
|
||||
}
|
||||
|
||||
public void processText(File file, File file2, ClassStorage classStorage, String text2)
|
||||
throws FileNotFoundException, IOException, ClassNotFoundException {
|
||||
File[] files = file.listFiles();
|
||||
int value;
|
||||
for (int value2 = value = 0; value2 < files.length; value2 = ++value) {
|
||||
File file3;
|
||||
if ((file3 = files[value]).isDirectory()) {
|
||||
String text3;
|
||||
if ((text3 = "" + text2 + "." + file3.getName()).startsWith(".")) {
|
||||
text3 = text3.substring(1);
|
||||
}
|
||||
this.processText(
|
||||
file3, new File(("" + file2.getPath() + "/" + file3.getName())), classStorage, text3);
|
||||
} else if (file3.getName().endsWith(".class")) {
|
||||
String name = file3.getName();
|
||||
String text4 = name.substring(0, name.length() - 6);
|
||||
if (text2.length() > 0) {
|
||||
text4 = "" + text2 + "." + text4;
|
||||
}
|
||||
ClassGen classGen;
|
||||
if ((classGen = classStorage.getClassGen(text4)) != null
|
||||
&& !Configuration.getIgnoreClassesOptions().matchesClassGen(classStorage, classGen)) {
|
||||
String className = classGen.getClassName();
|
||||
String text5 = "" + className.replace('.', '/') + ".class";
|
||||
this.processFile(classGen, new File(("" + this.text + "/" + text5)));
|
||||
} else {
|
||||
if (classGen == null) {
|
||||
Log.warn(
|
||||
"File "
|
||||
+ file3.getPath()
|
||||
+ " is copied with no modifications, as it is not in its package.");
|
||||
}
|
||||
new File(file2.getPath()).mkdirs();
|
||||
FileUtils.processFile(file3, new File(("" + file2.getPath() + "/" + file3.getName())));
|
||||
}
|
||||
} else {
|
||||
String text6 = "" + file2.getPath() + "/" + file3.getName();
|
||||
if (Configuration.getRenamingOptions()
|
||||
.getResourceRenamingOptions()
|
||||
.isUpdateResourceNamesEnabled()) {
|
||||
if ((text6 =
|
||||
""
|
||||
+ this.text
|
||||
+ "/"
|
||||
+ StreamUtils.createText(
|
||||
"",
|
||||
new StringBuilder()
|
||||
.insert(0, text2.replace('.', '/'))
|
||||
.append('/')
|
||||
.append(file3.getName())
|
||||
.toString()))
|
||||
.contains("/")) {
|
||||
new File(text6.substring(0, text6.lastIndexOf(47))).mkdirs();
|
||||
}
|
||||
} else {
|
||||
new File(file2.getPath()).mkdirs();
|
||||
}
|
||||
if (Configuration.getRenamingOptions()
|
||||
.getResourceRenamingOptions()
|
||||
.matchesText(file3.getName())) {
|
||||
FileInputStream fileInputStream = new FileInputStream(file3);
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(new File(text6));
|
||||
StreamUtils.processText(
|
||||
fileInputStream,
|
||||
fileOutputStream,
|
||||
Configuration.getRenamingOptions()
|
||||
.getResourceRenamingOptions()
|
||||
.getText(file3.getName()));
|
||||
fileInputStream.close();
|
||||
fileOutputStream.close();
|
||||
} else {
|
||||
FileUtils.processFile(file3, new File(text6));
|
||||
}
|
||||
}
|
||||
}
|
||||
Vector inputClasses = classStorage.getInputClasses();
|
||||
int value3;
|
||||
for (int value4 = value3 = 0; value4 < inputClasses.size(); value4 = value3) {
|
||||
ClassGen classGen2;
|
||||
String className2 = (classGen2 = (ClassGen) inputClasses.get(value3)).getClassName();
|
||||
String text7 = "" + className2.replace('.', '/') + ".class";
|
||||
StringBuilder stringBuilder =
|
||||
new StringBuilder().insert(0, this.text).append("/").append(text7);
|
||||
value3++;
|
||||
this.processFile(classGen2, new File(stringBuilder.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public void processClassStorage(String text2, String text, ClassStorage classStorage2)
|
||||
throws FileNotFoundException, IOException, ClassNotFoundException {
|
||||
this.classStorage = classStorage2;
|
||||
this.text = text;
|
||||
if (text2.equals(text)) {
|
||||
this.processText(new File(text2), classStorage2, "");
|
||||
} else {
|
||||
this.processText(new File(text2), new File(text), classStorage2, "");
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean matchesDirectoryWriter(DirectoryWriter directoryWriter) {
|
||||
return directoryWriter.enabled;
|
||||
}
|
||||
|
||||
public void processText(File file, ClassStorage classStorage, String text2)
|
||||
throws FileNotFoundException, ClassNotFoundException, IOException {
|
||||
File[] files = file.listFiles();
|
||||
int value;
|
||||
for (int value2 = value = 0; value2 < files.length; value2 = ++value) {
|
||||
File file2;
|
||||
if ((file2 = files[value]).isDirectory()) {
|
||||
String text3;
|
||||
if ((text3 = "" + text2 + "." + file2.getName()).startsWith(".")) {
|
||||
text3 = text3.substring(1);
|
||||
}
|
||||
this.processText(file2, classStorage, text3);
|
||||
} else if (file2.getName().endsWith(".class")) {
|
||||
String name = file2.getName();
|
||||
String text4 = name.substring(0, name.length() - 6);
|
||||
if (text2.length() > 0) {
|
||||
text4 = "" + text2 + "." + text4;
|
||||
}
|
||||
ClassGen classGen;
|
||||
if ((classGen = classStorage.getClassGen(text4)) != null
|
||||
&& !Configuration.getIgnoreClassesOptions().matchesClassGen(classStorage, classGen)) {
|
||||
file2.delete();
|
||||
String className = classGen.getClassName();
|
||||
String text5 = "" + className.replace('.', '/') + ".class";
|
||||
this.processFile(classGen, new File(("" + this.text + "/" + text5)));
|
||||
}
|
||||
}
|
||||
}
|
||||
Vector inputClasses = classStorage.getInputClasses();
|
||||
int value3;
|
||||
for (int value4 = value3 = 0; value4 < inputClasses.size(); value4 = value3) {
|
||||
ClassGen classGen2;
|
||||
String className2 = (classGen2 = (ClassGen) inputClasses.get(value3)).getClassName();
|
||||
String text6 = "" + className2.replace('.', '/') + ".class";
|
||||
StringBuilder stringBuilder =
|
||||
new StringBuilder().insert(0, this.text).append("/").append(text6);
|
||||
value3++;
|
||||
this.processFile(classGen2, new File(stringBuilder.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public static HashSet getValues(DirectoryWriter directoryWriter) {
|
||||
return directoryWriter.values;
|
||||
}
|
||||
|
||||
public static boolean matchesEnabled(DirectoryWriter directoryWriter, boolean matches) {
|
||||
return directoryWriter.enabled = matches;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.allatori.io;
|
||||
|
||||
import com.allatori.lib.bcel.classfile.ClassParser;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.model.ClassStorage;
|
||||
import com.allatori.util.Log;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Enumeration;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
public class JarClassReader {
|
||||
|
||||
public static ClassGen createClassGen(InputStream inputStream, String text) throws IOException {
|
||||
ClassGen classGen = new ClassGen(new ClassParser(inputStream, text).parse());
|
||||
inputStream.close();
|
||||
return classGen;
|
||||
}
|
||||
|
||||
public static void processClassStorage(String text, ClassStorage classStorage)
|
||||
throws IOException {
|
||||
JarFile jarFile;
|
||||
Enumeration enumeration = (jarFile = new JarFile(text)).entries();
|
||||
while (enumeration.hasMoreElements()) {
|
||||
JarEntry jarEntry;
|
||||
if (!(jarEntry = (JarEntry) enumeration.nextElement()).isDirectory()
|
||||
&& jarEntry.getName().endsWith(".class")) {
|
||||
try {
|
||||
classStorage.processText(
|
||||
createClassGen(jarFile.getInputStream(jarEntry), jarEntry.getName()),
|
||||
text,
|
||||
jarEntry.getName());
|
||||
} catch (Exception exception) {
|
||||
if (!jarEntry.getName().endsWith("module-info.class")) {
|
||||
Log.error("Cannot parse class " + jarEntry.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
jarFile.close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.allatori.io;
|
||||
|
||||
import com.allatori.lib.asm.ClassWriter;
|
||||
import com.allatori.util.Log;
|
||||
|
||||
public class JarClassWriter extends ClassWriter {
|
||||
|
||||
public final JarWriter jarWriter;
|
||||
|
||||
public final ClassLoader classLoader;
|
||||
|
||||
@Override
|
||||
public String getCommonSuperClass(String text, String text2) {
|
||||
Class classValue;
|
||||
Class classValue2;
|
||||
try {
|
||||
classValue = Class.forName(text.replace('/', '.'), false, this.classLoader);
|
||||
classValue2 = Class.forName(text2.replace('/', '.'), false, this.classLoader);
|
||||
} catch (ClassNotFoundException classNotFoundException) {
|
||||
if (!JarWriter.getValues(this.jarWriter).contains(classNotFoundException.getMessage())) {
|
||||
JarWriter.getValues(this.jarWriter).add(classNotFoundException.getMessage());
|
||||
Log.error("CLASS NOT FOUND: " + classNotFoundException.getMessage());
|
||||
Log.error(" ADD NEEDED JAR TO THE 'classpath' ELEMENT OF THE CONFIGURATION FILE.");
|
||||
}
|
||||
return "java/lang/Object";
|
||||
} catch (NoClassDefFoundError noClassDefFoundError) {
|
||||
if (!JarWriter.getValues(this.jarWriter).contains(noClassDefFoundError.getMessage())) {
|
||||
JarWriter.getValues(this.jarWriter).add(noClassDefFoundError.getMessage());
|
||||
Log.error("CLASS NOT FOUND: " + noClassDefFoundError.getMessage());
|
||||
Log.error(" ADD NEEDED JAR TO THE 'classpath' ELEMENT OF THE CONFIGURATION FILE.");
|
||||
}
|
||||
return "java/lang/Object";
|
||||
} catch (Exception exception) {
|
||||
throw new RuntimeException(exception.toString());
|
||||
} catch (UnsupportedClassVersionError unsupportedClassVersionError) {
|
||||
if (!JarWriter.matchesJarWriter(this.jarWriter)) {
|
||||
JarWriter.matchesEnabled(this.jarWriter, true);
|
||||
Log.error(
|
||||
"SOME CLASS(ES) CANNOT BE READ DUE TO JVM VERSION INCOMPATIBILITY: "
|
||||
+ unsupportedClassVersionError.toString());
|
||||
Log.error(" USE NEWER JVM VERSION TO RUN ALLATORI.");
|
||||
}
|
||||
return "java/lang/Object";
|
||||
} catch (Error error2) {
|
||||
return "java/lang/Object";
|
||||
}
|
||||
if (classValue.isAssignableFrom(classValue2)) {
|
||||
return text;
|
||||
}
|
||||
if (classValue2.isAssignableFrom(classValue)) {
|
||||
return text2;
|
||||
}
|
||||
if (!classValue.isInterface() && !classValue2.isInterface()) {
|
||||
while (!(classValue = classValue.getSuperclass()).isAssignableFrom(classValue2)) {}
|
||||
return classValue.getName().replace('.', '/');
|
||||
} else {
|
||||
return "java/lang/Object";
|
||||
}
|
||||
}
|
||||
|
||||
public JarClassWriter(JarWriter jarWriter2, int value, ClassLoader classLoader2) {
|
||||
super(value);
|
||||
this.jarWriter = jarWriter2;
|
||||
this.classLoader = classLoader2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,425 @@
|
||||
package com.allatori.io;
|
||||
|
||||
import com.allatori.config.Configuration;
|
||||
import com.allatori.config.InputJar;
|
||||
import com.allatori.lib.asm.ClassReader;
|
||||
import com.allatori.lib.bcel.classfile.ClassParser;
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.model.ClassStorage;
|
||||
import com.allatori.util.Log;
|
||||
import com.allatori.util.StreamUtils;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.zip.CRC32;
|
||||
import java.util.zip.ZipException;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
public class JarWriter {
|
||||
|
||||
public final String text;
|
||||
|
||||
public Hashtable entries;
|
||||
|
||||
public boolean enabled;
|
||||
|
||||
public ClassStorage classStorage;
|
||||
|
||||
public Vector values;
|
||||
|
||||
public HashSet values2;
|
||||
|
||||
public JarWriter() {
|
||||
super();
|
||||
this.text = ".tmp";
|
||||
this.values = new Vector();
|
||||
this.values2 = new HashSet();
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
public String createText(JarFile jarFile, JarEntry jarEntry) {
|
||||
try {
|
||||
InputStream inputStream = jarFile.getInputStream(jarEntry);
|
||||
ClassGen classGen = new ClassGen(new ClassParser(inputStream, jarEntry.getName()).parse());
|
||||
inputStream.close();
|
||||
return jarEntry
|
||||
.getName()
|
||||
.substring(0, jarEntry.getName().length() - classGen.getClassName().length() - 6);
|
||||
} catch (Exception exception) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public void processText(String[] texts, String text) throws FileNotFoundException, IOException {
|
||||
byte[] values = new byte[262144];
|
||||
JarOutputStream jarOutputStream =
|
||||
new JarOutputStream(new FileOutputStream(("" + text + ".tmp")));
|
||||
if (Configuration.getOutputOptions().getCompressionLevel() != -1) {
|
||||
jarOutputStream.setLevel(Configuration.getOutputOptions().getCompressionLevel());
|
||||
}
|
||||
Hashtable hashtable = new Hashtable();
|
||||
int value;
|
||||
for (int value2 = value = 0; value2 < texts.length; value2 = value) {
|
||||
JarFile jarFile;
|
||||
Enumeration enumeration;
|
||||
Enumeration enumeration2 = enumeration = (jarFile = new JarFile(texts[value])).entries();
|
||||
while (enumeration2.hasMoreElements()) {
|
||||
JarEntry jarEntry = (JarEntry) enumeration.nextElement();
|
||||
if (hashtable.containsKey(jarEntry.getName())) {
|
||||
enumeration2 = enumeration;
|
||||
} else {
|
||||
hashtable.put(jarEntry.getName(), "");
|
||||
InputStream inputStream = jarFile.getInputStream(jarEntry);
|
||||
JarEntry jarEntry2 = new JarEntry(jarEntry.getName());
|
||||
jarOutputStream.putNextEntry(jarEntry2);
|
||||
InputStream inputStream2 = inputStream;
|
||||
int value3;
|
||||
while ((value3 = inputStream2.read(values)) > 0) {
|
||||
inputStream2 = inputStream;
|
||||
jarOutputStream.write(values, 0, value3);
|
||||
}
|
||||
jarOutputStream.closeEntry();
|
||||
enumeration2 = enumeration;
|
||||
}
|
||||
}
|
||||
JarFile jarFile2 = jarFile;
|
||||
value++;
|
||||
jarFile2.close();
|
||||
}
|
||||
if (Configuration.getObfuscationOptions().isOutputJarCommentEnabled()
|
||||
&& !Configuration.getObfuscationOptions().isEnabled()) {
|
||||
this.processJarOutputStream(jarOutputStream);
|
||||
}
|
||||
jarOutputStream.finish();
|
||||
jarOutputStream.close();
|
||||
this.processText(text + ".tmp", text);
|
||||
}
|
||||
|
||||
public static HashSet getValues(JarWriter jarWriter) {
|
||||
return jarWriter.values2;
|
||||
}
|
||||
|
||||
public void processJarOutputStream(String text, JarOutputStream jarOutputStream)
|
||||
throws IOException {
|
||||
String text2 = "";
|
||||
label17:
|
||||
while (true) {
|
||||
String text3 = text;
|
||||
while (text3.indexOf(47) > 0) {
|
||||
text2 = "" + text2 + text.substring(0, text.indexOf(47) + 1);
|
||||
text = text.substring(text.indexOf(47) + 1);
|
||||
if (this.entries.containsKey(text2)) {
|
||||
continue label17;
|
||||
}
|
||||
text3 = text;
|
||||
this.entries.put(text2, ".tmp");
|
||||
jarOutputStream.putNextEntry(new JarEntry(text2));
|
||||
jarOutputStream.closeEntry();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void processText(
|
||||
Vector vector, JarOutputStream jarOutputStream, ClassStorage classStorage, String text)
|
||||
throws IOException {
|
||||
int value;
|
||||
for (int value2 = value = vector.size() - 1; value2 >= 0; value2 = value) {
|
||||
ClassGen classGen = (ClassGen) vector.get(value);
|
||||
value--;
|
||||
this.processText(classGen, jarOutputStream, classStorage, text);
|
||||
}
|
||||
}
|
||||
|
||||
public void processJarOutputStream(JarOutputStream jarOutputStream) {
|
||||
if (Configuration.getObfuscationOptions().getOutputJarComment() != null) {
|
||||
jarOutputStream.setComment(Configuration.getObfuscationOptions().getOutputJarComment());
|
||||
}
|
||||
}
|
||||
|
||||
public void processClassStorage(String text3, String text4, ClassStorage classStorage2)
|
||||
throws IOException, FileNotFoundException, ZipException {
|
||||
byte value;
|
||||
this.classStorage = classStorage2;
|
||||
this.entries = new Hashtable();
|
||||
byte[] values2 = new byte[262144];
|
||||
String text5 = "";
|
||||
JarFile jarFile = new JarFile(text3);
|
||||
JarOutputStream jarOutputStream =
|
||||
new JarOutputStream(new FileOutputStream(("" + text4 + ".tmp")));
|
||||
HashSet values3 = new HashSet();
|
||||
if (Configuration.getOutputOptions().isKeepDuplicateEntries()) {
|
||||
try {
|
||||
Field field;
|
||||
if ((field = ZipOutputStream.class.getDeclaredField("names")) != null) {
|
||||
field.setAccessible(true);
|
||||
values3 = (HashSet) field.get(jarOutputStream);
|
||||
}
|
||||
} catch (RuntimeException runtimeException) {
|
||||
if (runtimeException.getClass().getName().endsWith("InaccessibleObjectException")) {
|
||||
Log.warn(
|
||||
"Use '--add-opens java.base/java.util.zip=ALL-UNNAMED' Java launcher option to keep"
|
||||
+ " output jar duplicate entries");
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
}
|
||||
if (Configuration.getOutputOptions().getCompressionLevel() != -1) {
|
||||
jarOutputStream.setLevel(Configuration.getOutputOptions().getCompressionLevel());
|
||||
}
|
||||
Vector vector = new Vector();
|
||||
Enumeration enumeration = jarFile.entries();
|
||||
while (true) {
|
||||
Enumeration enumeration2 = enumeration;
|
||||
JarEntry jarEntry;
|
||||
InputStream inputStream;
|
||||
JarEntry jarEntry2;
|
||||
while (true) {
|
||||
if (!enumeration2.hasMoreElements()) {
|
||||
this.processText(vector, jarOutputStream, classStorage2, text3);
|
||||
this.processText(classStorage2.getInputClasses(), jarOutputStream, classStorage2, text3);
|
||||
jarFile.close();
|
||||
if (Configuration.getObfuscationOptions().isOutputJarCommentEnabled()
|
||||
&& !Configuration.getObfuscationOptions().isEnabled()) {
|
||||
this.processJarOutputStream(jarOutputStream);
|
||||
}
|
||||
jarOutputStream.finish();
|
||||
jarOutputStream.close();
|
||||
this.processText("" + text4 + ".tmp", text4);
|
||||
return;
|
||||
}
|
||||
if ((jarEntry = (JarEntry) enumeration.nextElement()).isDirectory()) {
|
||||
enumeration2 = enumeration;
|
||||
} else {
|
||||
String text6;
|
||||
if (jarEntry.getName().endsWith(".class")
|
||||
&& (text6 = classStorage2.getText("" + text3 + '#' + jarEntry.getName())) != null) {
|
||||
text5 = classStorage2.getText2("" + text3 + '#' + text6);
|
||||
ClassGen classGen;
|
||||
if ((classGen = classStorage2.getClassGen(text6)) != null
|
||||
&& !Configuration.getIgnoreClassesOptions()
|
||||
.matchesClassGen(classStorage2, classGen)) {
|
||||
enumeration2 = enumeration;
|
||||
vector.add(classGen);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (jarEntry.getName().equals("META-INF/INDEX.LIST")) {
|
||||
enumeration2 = enumeration;
|
||||
this.values.add(text4);
|
||||
} else {
|
||||
inputStream = jarFile.getInputStream(jarEntry);
|
||||
String name = jarEntry.getName();
|
||||
if (Configuration.getRenamingOptions()
|
||||
.getResourceRenamingOptions()
|
||||
.isUpdateResourceNamesEnabled()) {
|
||||
if (text5 == null && text3.endsWith(".war")) {
|
||||
text5 = "WEB-INF/classes/";
|
||||
}
|
||||
if (jarEntry.getName().startsWith("BOOT-INF/classes/")) {
|
||||
text5 = "BOOT-INF/classes/";
|
||||
}
|
||||
if (jarEntry.getName().startsWith("WEB-INF/classes/")) {
|
||||
text5 = "WEB-INF/classes/";
|
||||
}
|
||||
name = StreamUtils.createText(text5, jarEntry.getName());
|
||||
}
|
||||
ClassGen classGen2;
|
||||
if (Configuration.getLogOptions().isText()
|
||||
&& "com/license4j/resources/d.bfi".equals(jarEntry.getName())
|
||||
&& (classGen2 = classStorage2.getClassGen("com.license4j.HardwareID")) != null) {
|
||||
String text7;
|
||||
if ((text7 = classGen2.getClassName()).indexOf(46) > 0) {
|
||||
String text8 = text7.substring(0, text7.lastIndexOf(46) + 1).replace('.', '/');
|
||||
name = "" + text8 + Configuration.getLogOptions().getComLicense4jSupport();
|
||||
} else {
|
||||
name = Configuration.getLogOptions().getComLicense4jSupport();
|
||||
}
|
||||
}
|
||||
jarEntry2 = new JarEntry(name);
|
||||
if (!name.endsWith(".jar")) {
|
||||
break;
|
||||
}
|
||||
byte value2 = 0;
|
||||
Iterator iterator2 = Configuration.getInputOptions().getValues().iterator();
|
||||
while (true) {
|
||||
if (!iterator2.hasNext()) {
|
||||
value = value2;
|
||||
break;
|
||||
}
|
||||
InputJar inputJar;
|
||||
if ((inputJar = (InputJar) iterator2.next()).text.equals(text3)
|
||||
&& inputJar.text2.equals(jarEntry.getName())) {
|
||||
if (jarEntry.getMethod() == 0) {
|
||||
jarEntry2.setMethod(0);
|
||||
}
|
||||
File file = new File(inputJar.text);
|
||||
jarEntry2.setSize(file.length());
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
CRC32 cRC32 = new CRC32();
|
||||
FileInputStream fileInputStream2 = fileInputStream;
|
||||
int value3;
|
||||
while ((value3 = fileInputStream2.read(values2)) > 0) {
|
||||
fileInputStream2 = fileInputStream;
|
||||
cRC32.update(values2, 0, value3);
|
||||
}
|
||||
jarEntry2.setCrc(cRC32.getValue());
|
||||
fileInputStream.close();
|
||||
FileInputStream fileInputStream3 = new FileInputStream(file);
|
||||
this.processJarOutputStream(jarEntry2.getName(), jarOutputStream);
|
||||
try {
|
||||
jarOutputStream.putNextEntry(jarEntry2);
|
||||
if (Configuration.getOutputOptions().isKeepDuplicateEntries()) {
|
||||
values3.clear();
|
||||
}
|
||||
FileInputStream fileInputStream4 = fileInputStream3;
|
||||
int value4;
|
||||
while ((value4 = fileInputStream4.read(values2)) > 0) {
|
||||
fileInputStream4 = fileInputStream3;
|
||||
jarOutputStream.write(values2, 0, value4);
|
||||
}
|
||||
fileInputStream3.close();
|
||||
jarOutputStream.closeEntry();
|
||||
} catch (ZipException zipException) {
|
||||
if (!zipException.getMessage().contains("duplicate")) {
|
||||
throw zipException;
|
||||
}
|
||||
}
|
||||
value = value2 = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (value == 0 && jarEntry.getMethod() == 0) {
|
||||
jarEntry2.setMethod(0);
|
||||
jarEntry2.setSize(jarEntry.getSize());
|
||||
jarEntry2.setCrc(jarEntry.getCrc());
|
||||
}
|
||||
if (value2 == 0) {
|
||||
break;
|
||||
}
|
||||
enumeration2 = enumeration;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.processJarOutputStream(jarEntry2.getName(), jarOutputStream);
|
||||
try {
|
||||
jarOutputStream.putNextEntry(jarEntry2);
|
||||
if (Configuration.getOutputOptions().isKeepDuplicateEntries()) {
|
||||
values3.clear();
|
||||
}
|
||||
boolean matches =
|
||||
Configuration.getRenamingOptions()
|
||||
.getResourceRenamingOptions()
|
||||
.matchesText(jarEntry.getName());
|
||||
InputStream inputStream2 = inputStream;
|
||||
JarOutputStream jarOutputStream2;
|
||||
if (matches) {
|
||||
StreamUtils.processText(
|
||||
inputStream,
|
||||
jarOutputStream,
|
||||
Configuration.getRenamingOptions()
|
||||
.getResourceRenamingOptions()
|
||||
.getText(jarEntry.getName()));
|
||||
jarOutputStream2 = jarOutputStream;
|
||||
} else {
|
||||
int value5;
|
||||
while ((value5 = inputStream2.read(values2)) > 0) {
|
||||
inputStream2 = inputStream;
|
||||
jarOutputStream.write(values2, 0, value5);
|
||||
}
|
||||
jarOutputStream2 = jarOutputStream;
|
||||
}
|
||||
jarOutputStream2.closeEntry();
|
||||
} catch (ZipException zipException2) {
|
||||
if (!zipException2.getMessage().contains("duplicate")) {
|
||||
throw zipException2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean matchesEnabled(JarWriter jarWriter, boolean matches) {
|
||||
return jarWriter.enabled = matches;
|
||||
}
|
||||
|
||||
public static boolean matchesJarWriter(JarWriter jarWriter) {
|
||||
return jarWriter.enabled;
|
||||
}
|
||||
|
||||
public void processText(String text, String text2) {
|
||||
File file = new File(text);
|
||||
File file2;
|
||||
if ((file2 = new File(text2)).exists() && !file2.delete()) {
|
||||
Log.warn("Cannot delete '" + file2.getPath() + "'");
|
||||
}
|
||||
if (!file.renameTo(file2)) {
|
||||
Log.warn("Cannot rename '" + file.getPath() + "' to '" + file2.getPath() + "'");
|
||||
Log.warn("Resulting file is '" + file.getPath() + "'");
|
||||
}
|
||||
}
|
||||
|
||||
public void update() {
|
||||
int value;
|
||||
for (int value2 = value = 0; value2 < this.values.size(); value2 = value) {
|
||||
String text = (String) this.values.get(value);
|
||||
value++;
|
||||
this.processText(text);
|
||||
}
|
||||
}
|
||||
|
||||
public void processText(String text) {
|
||||
try {
|
||||
File file = new File(text);
|
||||
Runtime.getRuntime().exec("jar -i " + file.getName(), null, file.getParentFile());
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
}
|
||||
|
||||
public void processText(
|
||||
ClassGen classGen, JarOutputStream jarOutputStream, ClassStorage classStorage, String text)
|
||||
throws IOException {
|
||||
String text2;
|
||||
String text3 = text2 = classGen.getClassName();
|
||||
if (Configuration.getMappingOptions().lookupTable != null) {
|
||||
text3 = Configuration.getMappingOptions().lookupTable.getText(text2);
|
||||
}
|
||||
String text4;
|
||||
if ((text4 = classStorage.getText2("" + text + '#' + text3)) == null) {
|
||||
text4 = "";
|
||||
}
|
||||
String text5 = "" + text4 + text2.replace('.', '/') + ".class";
|
||||
JarEntry jarEntry = new JarEntry(text5);
|
||||
this.processJarOutputStream(text5, jarOutputStream);
|
||||
try {
|
||||
jarOutputStream.putNextEntry(jarEntry);
|
||||
JarOutputStream jarOutputStream2;
|
||||
if (classGen.getMajor() > 50) {
|
||||
ResolvingClassLoader resolvingClassLoader =
|
||||
new ResolvingClassLoader(classStorage, Configuration.getMappingOptions().lookupTable);
|
||||
ClassReader classReader = new ClassReader(classGen.getJavaClass().getBytes());
|
||||
JarClassWriter jarClassWriter = new JarClassWriter(this, 2, resolvingClassLoader);
|
||||
jarOutputStream2 = jarOutputStream;
|
||||
classReader.accept(jarClassWriter, 4);
|
||||
jarOutputStream.write(jarClassWriter.toByteArray());
|
||||
} else {
|
||||
jarOutputStream2 = jarOutputStream;
|
||||
jarOutputStream.write(classGen.getJavaClass().getBytes());
|
||||
}
|
||||
jarOutputStream2.closeEntry();
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.allatori.io;
|
||||
|
||||
import com.allatori.lib.bcel.generic.ClassGen;
|
||||
import com.allatori.model.ClassStorage;
|
||||
import com.allatori.util.LookupTable;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
public class ResolvingClassLoader extends URLClassLoader {
|
||||
|
||||
public ClassStorage classStorage;
|
||||
|
||||
public LookupTable lookupTable;
|
||||
|
||||
public ResolvingClassLoader(ClassStorage classStorage2, LookupTable lookupTable2) {
|
||||
super(new URL[0], classStorage2.getClassLoader());
|
||||
this.classStorage = classStorage2;
|
||||
this.lookupTable = lookupTable2;
|
||||
}
|
||||
|
||||
public Class getType(String text) {
|
||||
ClassGen classGen = this.classStorage.getClassGen(text);
|
||||
byte[] bytes = classGen.getJavaClass().getBytes();
|
||||
return this.defineClass(classGen.getClassName(), bytes, 0, bytes.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class findClass(String text) throws ClassNotFoundException {
|
||||
String text2 = text;
|
||||
try {
|
||||
if (this.lookupTable.matchesText(text2)) {
|
||||
text2 = this.lookupTable.getText(text2);
|
||||
}
|
||||
if (this.classStorage.getClassGen(text2) != null) {
|
||||
return this.getType(text2);
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
return super.findClass(text2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.allatori.lib.asm;
|
||||
|
||||
public abstract class AnnotationVisitor {
|
||||
|
||||
public final int api;
|
||||
|
||||
public AnnotationVisitor av;
|
||||
|
||||
public void visitEnum(String text, String text2, String text3) {
|
||||
if (this.av != null) {
|
||||
this.av.visitEnum(text, text2, text3);
|
||||
}
|
||||
}
|
||||
|
||||
public AnnotationVisitor(int api, AnnotationVisitor annotationVisitor) {
|
||||
super();
|
||||
if (api != 589824
|
||||
&& api != 524288
|
||||
&& api != 458752
|
||||
&& api != 393216
|
||||
&& api != 327680
|
||||
&& api != 262144
|
||||
&& api != 17432576) {
|
||||
throw new IllegalArgumentException(stringConcat$0(api));
|
||||
}
|
||||
if (api == 17432576) {
|
||||
Constants.checkAsmExperimental(this);
|
||||
}
|
||||
this.api = api;
|
||||
this.av = annotationVisitor;
|
||||
}
|
||||
|
||||
public static String stringConcat$0(int value) {
|
||||
return "Unsupported api " + value;
|
||||
}
|
||||
|
||||
public AnnotationVisitor visitAnnotation(String text, String text2) {
|
||||
return this.av != null ? this.av.visitAnnotation(text, text2) : null;
|
||||
}
|
||||
|
||||
public AnnotationVisitor(int value) {
|
||||
this(value, null);
|
||||
}
|
||||
|
||||
public AnnotationVisitor visitArray(String text) {
|
||||
return this.av != null ? this.av.visitArray(text) : null;
|
||||
}
|
||||
|
||||
public void visitEnd() {
|
||||
if (this.av != null) {
|
||||
this.av.visitEnd();
|
||||
}
|
||||
}
|
||||
|
||||
public AnnotationVisitor getDelegate() {
|
||||
return this.av;
|
||||
}
|
||||
|
||||
public void visit(String text, Object result) {
|
||||
if (this.av != null) {
|
||||
this.av.visit(text, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,361 @@
|
||||
package com.allatori.lib.asm;
|
||||
|
||||
public final class AnnotationWriter extends AnnotationVisitor {
|
||||
|
||||
public int count;
|
||||
|
||||
public AnnotationWriter nextAnnotation;
|
||||
|
||||
public final AnnotationWriter previousAnnotation;
|
||||
|
||||
public final int numElementValuePairsOffset;
|
||||
|
||||
public final boolean useNamedValues;
|
||||
|
||||
public final SymbolTable symbolTable;
|
||||
|
||||
public final ByteVector annotation;
|
||||
|
||||
@Override
|
||||
public AnnotationVisitor visitAnnotation(String text, String text2) {
|
||||
this.count++;
|
||||
if (this.useNamedValues) {
|
||||
this.annotation.putShort(this.symbolTable.addConstantUtf8(text));
|
||||
}
|
||||
this.annotation.put12(64, this.symbolTable.addConstantUtf8(text2)).putShort(0);
|
||||
return new AnnotationWriter(this.symbolTable, true, this.annotation, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(String text, Object result) {
|
||||
this.count++;
|
||||
if (this.useNamedValues) {
|
||||
this.annotation.putShort(this.symbolTable.addConstantUtf8(text));
|
||||
}
|
||||
if (result instanceof String) {
|
||||
this.annotation.put12(115, this.symbolTable.addConstantUtf8((String) result));
|
||||
} else if (result instanceof Byte) {
|
||||
this.annotation.put12(66, this.symbolTable.getSymbol((Byte) result).index);
|
||||
} else if (result instanceof Boolean) {
|
||||
int value = (Boolean) result ? 1 : 0;
|
||||
this.annotation.put12(90, this.symbolTable.getSymbol(value).index);
|
||||
} else if (result instanceof Character) {
|
||||
this.annotation.put12(67, this.symbolTable.getSymbol((Character) result).index);
|
||||
} else if (result instanceof Short) {
|
||||
this.annotation.put12(83, this.symbolTable.getSymbol((Short) result).index);
|
||||
} else if (result instanceof Type) {
|
||||
this.annotation.put12(99, this.symbolTable.addConstantUtf8(((Type) result).getDescriptor()));
|
||||
} else {
|
||||
if (result instanceof byte[]) {
|
||||
byte[] values = (byte[]) result;
|
||||
this.annotation.put12(91, values.length);
|
||||
int value2 = values.length;
|
||||
int value3;
|
||||
for (int value4 = value3 = 0; value4 < value2; value4 = value3) {
|
||||
byte value5 = values[value3];
|
||||
SymbolTable symbolTable2 = this.symbolTable;
|
||||
ByteVector byteVector = this.annotation;
|
||||
value3++;
|
||||
byteVector.put12((byte) 66, symbolTable2.getSymbol(value5).index);
|
||||
}
|
||||
} else if (result instanceof boolean[]) {
|
||||
boolean[] matchess = (boolean[]) result;
|
||||
this.annotation.put12(91, matchess.length);
|
||||
int value6 = matchess.length;
|
||||
int value7;
|
||||
for (int value8 = value7 = 0; value8 < value6; value8 = value7) {
|
||||
boolean matches = matchess[value7];
|
||||
ByteVector byteVector2 = this.annotation;
|
||||
Symbol symbol = this.symbolTable.getSymbol(matches ? 1 : 0);
|
||||
value7++;
|
||||
byteVector2.put12((byte) 90, symbol.index);
|
||||
}
|
||||
} else if (result instanceof short[]) {
|
||||
short[] values2 = (short[]) result;
|
||||
this.annotation.put12(91, values2.length);
|
||||
int value9 = values2.length;
|
||||
int value10;
|
||||
for (int value11 = value10 = 0; value11 < value9; value11 = value10) {
|
||||
short value12 = values2[value10];
|
||||
SymbolTable symbolTable3 = this.symbolTable;
|
||||
ByteVector byteVector3 = this.annotation;
|
||||
value10++;
|
||||
byteVector3.put12((byte) 83, symbolTable3.getSymbol(value12).index);
|
||||
}
|
||||
} else if (result instanceof char[]) {
|
||||
char[] values3 = (char[]) result;
|
||||
this.annotation.put12(91, values3.length);
|
||||
int value13 = values3.length;
|
||||
int value14;
|
||||
for (int value15 = value14 = 0; value15 < value13; value15 = value14) {
|
||||
char value16 = values3[value14];
|
||||
SymbolTable symbolTable4 = this.symbolTable;
|
||||
ByteVector byteVector4 = this.annotation;
|
||||
value14++;
|
||||
byteVector4.put12((byte) 67, symbolTable4.getSymbol(value16).index);
|
||||
}
|
||||
} else if (result instanceof int[]) {
|
||||
int[] values4 = (int[]) result;
|
||||
this.annotation.put12(91, values4.length);
|
||||
int value17 = values4.length;
|
||||
int value18;
|
||||
for (int value19 = value18 = 0; value19 < value17; value19 = value18) {
|
||||
int value20 = values4[value18];
|
||||
SymbolTable symbolTable5 = this.symbolTable;
|
||||
ByteVector byteVector5 = this.annotation;
|
||||
value18++;
|
||||
byteVector5.put12((byte) 73, symbolTable5.getSymbol(value20).index);
|
||||
}
|
||||
} else if (result instanceof long[]) {
|
||||
long[] values5 = (long[]) result;
|
||||
this.annotation.put12(91, values5.length);
|
||||
int value21 = values5.length;
|
||||
int value22;
|
||||
for (int value23 = value22 = 0; value23 < value21; value23 = value22) {
|
||||
long value24 = values5[value22];
|
||||
SymbolTable symbolTable6 = this.symbolTable;
|
||||
ByteVector byteVector6 = this.annotation;
|
||||
value22++;
|
||||
byteVector6.put12((byte) 74, symbolTable6.addConstantLong(value24).index);
|
||||
}
|
||||
} else if (result instanceof float[]) {
|
||||
float[] values6 = (float[]) result;
|
||||
this.annotation.put12(91, values6.length);
|
||||
int value25 = values6.length;
|
||||
int value26;
|
||||
for (int value27 = value26 = 0; value27 < value25; value27 = value26) {
|
||||
float value28 = values6[value26];
|
||||
SymbolTable symbolTable7 = this.symbolTable;
|
||||
ByteVector byteVector7 = this.annotation;
|
||||
value26++;
|
||||
byteVector7.put12((byte) 70, symbolTable7.addConstantFloat(value28).index);
|
||||
}
|
||||
} else if (result instanceof double[]) {
|
||||
double[] values7 = (double[]) result;
|
||||
this.annotation.put12(91, values7.length);
|
||||
int value29 = values7.length;
|
||||
int value30;
|
||||
for (int value31 = value30 = 0; value31 < value29; value31 = value30) {
|
||||
double value32 = values7[value30];
|
||||
SymbolTable symbolTable8 = this.symbolTable;
|
||||
ByteVector byteVector8 = this.annotation;
|
||||
value30++;
|
||||
byteVector8.put12((byte) 68, symbolTable8.addConstantDouble(value32).index);
|
||||
}
|
||||
} else {
|
||||
Symbol symbol2 = this.symbolTable.addConstant(result);
|
||||
this.annotation.put12(".s.IFJDCS".charAt(symbol2.tag), symbol2.index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void putParameterAnnotations(
|
||||
int value, AnnotationWriter[] annotationWriters, int value2, ByteVector byteVector) {
|
||||
int value3 = 1 + 2 * value2;
|
||||
int value4;
|
||||
for (int value5 = value4 = 0; value5 < value2; value5 = value4) {
|
||||
AnnotationWriter annotationWriter = annotationWriters[value4];
|
||||
int value6 =
|
||||
value3
|
||||
+ (annotationWriter == null ? 0 : annotationWriter.computeAnnotationsSize(null) - 8);
|
||||
value4++;
|
||||
value3 = value6;
|
||||
}
|
||||
byteVector.putShort(value);
|
||||
byteVector.putInt(value3);
|
||||
byteVector.putByte(value2);
|
||||
int value7 = 0;
|
||||
for (int value8 = value7; value8 < value2; value8 = ++value7) {
|
||||
AnnotationWriter annotationWriter2 = annotationWriters[value7];
|
||||
AnnotationWriter annotationWriter3 = null;
|
||||
int value9 = 0;
|
||||
AnnotationWriter annotationWriter4 = annotationWriter2;
|
||||
while (annotationWriter4 != null) {
|
||||
AnnotationWriter annotationWriter5 = annotationWriter2;
|
||||
value9++;
|
||||
annotationWriter5.visitEnd();
|
||||
annotationWriter3 = annotationWriter5;
|
||||
annotationWriter4 = annotationWriter2 = annotationWriter5.previousAnnotation;
|
||||
}
|
||||
byteVector.putShort(value9);
|
||||
AnnotationWriter annotationWriter6 = annotationWriter3;
|
||||
for (AnnotationWriter annotationWriter7 = annotationWriter6;
|
||||
annotationWriter7 != null;
|
||||
annotationWriter7 = annotationWriter6) {
|
||||
byteVector.putByteArray(
|
||||
annotationWriter6.annotation.data, 0, annotationWriter6.annotation.length);
|
||||
annotationWriter6 = annotationWriter6.nextAnnotation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void putAnnotations(
|
||||
SymbolTable symbolTable,
|
||||
AnnotationWriter annotationWriter,
|
||||
AnnotationWriter annotationWriter2,
|
||||
AnnotationWriter annotationWriter3,
|
||||
AnnotationWriter annotationWriter4,
|
||||
ByteVector byteVector) {
|
||||
if (annotationWriter != null) {
|
||||
annotationWriter.putAnnotations(
|
||||
symbolTable.addConstantUtf8("RuntimeVisibleAnnotations"), byteVector);
|
||||
}
|
||||
if (annotationWriter2 != null) {
|
||||
annotationWriter2.putAnnotations(
|
||||
symbolTable.addConstantUtf8("RuntimeInvisibleAnnotations"), byteVector);
|
||||
}
|
||||
if (annotationWriter3 != null) {
|
||||
annotationWriter3.putAnnotations(
|
||||
symbolTable.addConstantUtf8("RuntimeVisibleTypeAnnotations"), byteVector);
|
||||
}
|
||||
if (annotationWriter4 != null) {
|
||||
annotationWriter4.putAnnotations(
|
||||
symbolTable.addConstantUtf8("RuntimeInvisibleTypeAnnotations"), byteVector);
|
||||
}
|
||||
}
|
||||
|
||||
public static AnnotationWriter create(
|
||||
SymbolTable symbolTable, String text, AnnotationWriter annotationWriter) {
|
||||
ByteVector byteVector;
|
||||
(byteVector = new ByteVector()).putShort(symbolTable.addConstantUtf8(text)).putShort(0);
|
||||
return new AnnotationWriter(symbolTable, true, byteVector, annotationWriter);
|
||||
}
|
||||
|
||||
public int computeAnnotationsSize(String text) {
|
||||
if (text != null) {
|
||||
this.symbolTable.addConstantUtf8(text);
|
||||
}
|
||||
int value = 8;
|
||||
AnnotationWriter annotationWriter;
|
||||
for (AnnotationWriter annotationWriter2 = annotationWriter = this;
|
||||
annotationWriter2 != null;
|
||||
annotationWriter2 = annotationWriter = annotationWriter.previousAnnotation) {
|
||||
value += annotationWriter.annotation.length;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static AnnotationWriter create(
|
||||
SymbolTable symbolTable,
|
||||
int value,
|
||||
TypePath typePath,
|
||||
String text,
|
||||
AnnotationWriter annotationWriter) {
|
||||
ByteVector byteVector = new ByteVector();
|
||||
TypeReference.putTarget(value, byteVector);
|
||||
TypePath.put(typePath, byteVector);
|
||||
byteVector.putShort(symbolTable.addConstantUtf8(text)).putShort(0);
|
||||
return new AnnotationWriter(symbolTable, true, byteVector, annotationWriter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitEnum(String text, String text2, String text3) {
|
||||
this.count++;
|
||||
if (this.useNamedValues) {
|
||||
this.annotation.putShort(this.symbolTable.addConstantUtf8(text));
|
||||
}
|
||||
this.annotation
|
||||
.put12(101, this.symbolTable.addConstantUtf8(text2))
|
||||
.putShort(this.symbolTable.addConstantUtf8(text3));
|
||||
}
|
||||
|
||||
public static int computeParameterAnnotationsSize(
|
||||
String text, AnnotationWriter[] annotationWriters, int value) {
|
||||
int value2 = 7 + 2 * value;
|
||||
int value3;
|
||||
for (int value4 = value3 = 0; value4 < value; value4 = value3) {
|
||||
AnnotationWriter annotationWriter = annotationWriters[value3];
|
||||
int value5 =
|
||||
value2
|
||||
+ (annotationWriter == null ? 0 : annotationWriter.computeAnnotationsSize(text) - 8);
|
||||
value3++;
|
||||
value2 = value5;
|
||||
}
|
||||
return value2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotationVisitor visitArray(String text) {
|
||||
this.count++;
|
||||
if (this.useNamedValues) {
|
||||
this.annotation.putShort(this.symbolTable.addConstantUtf8(text));
|
||||
}
|
||||
this.annotation.put12(91, 0);
|
||||
return new AnnotationWriter(this.symbolTable, false, this.annotation, null);
|
||||
}
|
||||
|
||||
public static int computeAnnotationsSize(
|
||||
AnnotationWriter annotationWriter,
|
||||
AnnotationWriter annotationWriter2,
|
||||
AnnotationWriter annotationWriter3,
|
||||
AnnotationWriter annotationWriter4) {
|
||||
int value = 0;
|
||||
if (annotationWriter != null) {
|
||||
value += annotationWriter.computeAnnotationsSize("RuntimeVisibleAnnotations");
|
||||
}
|
||||
if (annotationWriter2 != null) {
|
||||
value += annotationWriter2.computeAnnotationsSize("RuntimeInvisibleAnnotations");
|
||||
}
|
||||
if (annotationWriter3 != null) {
|
||||
value += annotationWriter3.computeAnnotationsSize("RuntimeVisibleTypeAnnotations");
|
||||
}
|
||||
if (annotationWriter4 != null) {
|
||||
value += annotationWriter4.computeAnnotationsSize("RuntimeInvisibleTypeAnnotations");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public AnnotationWriter(
|
||||
SymbolTable symbolTable2,
|
||||
boolean useNamedValues,
|
||||
ByteVector byteVector,
|
||||
AnnotationWriter annotationWriter) {
|
||||
super(589824);
|
||||
this.symbolTable = symbolTable2;
|
||||
this.useNamedValues = useNamedValues;
|
||||
this.annotation = byteVector;
|
||||
this.numElementValuePairsOffset = byteVector.length == 0 ? -1 : byteVector.length - 2;
|
||||
if ((this.previousAnnotation = annotationWriter) != null) {
|
||||
annotationWriter.nextAnnotation = this;
|
||||
}
|
||||
}
|
||||
|
||||
public void putAnnotations(int value, ByteVector byteVector) {
|
||||
int value2 = 2;
|
||||
int value3 = 0;
|
||||
AnnotationWriter annotationWriter = this;
|
||||
AnnotationWriter annotationWriter2 = null;
|
||||
AnnotationWriter annotationWriter3 = this;
|
||||
while (annotationWriter3 != null) {
|
||||
annotationWriter.visitEnd();
|
||||
ByteVector byteVector2 = annotationWriter.annotation;
|
||||
int value4 = value2;
|
||||
AnnotationWriter annotationWriter4 = annotationWriter;
|
||||
AnnotationWriter annotationWriter5 = annotationWriter;
|
||||
value3++;
|
||||
value2 = value4 + byteVector2.length;
|
||||
annotationWriter2 = annotationWriter4;
|
||||
annotationWriter3 = annotationWriter = annotationWriter5.previousAnnotation;
|
||||
}
|
||||
byteVector.putShort(value);
|
||||
byteVector.putInt(value2);
|
||||
byteVector.putShort(value3);
|
||||
AnnotationWriter annotationWriter6 = annotationWriter2;
|
||||
for (AnnotationWriter annotationWriter7 = annotationWriter6;
|
||||
annotationWriter7 != null;
|
||||
annotationWriter7 = annotationWriter6) {
|
||||
byteVector.putByteArray(
|
||||
annotationWriter6.annotation.data, 0, annotationWriter6.annotation.length);
|
||||
annotationWriter6 = annotationWriter6.nextAnnotation;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitEnd() {
|
||||
if (this.numElementValuePairsOffset != -1) {
|
||||
byte[] values = this.annotation.data;
|
||||
values[this.numElementValuePairsOffset] = (byte) (this.count >>> 8);
|
||||
values[this.numElementValuePairsOffset + 1] = (byte) this.count;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.allatori.lib.asm;
|
||||
|
||||
public final class Attribute$Set {
|
||||
|
||||
public static final int SIZE_INCREMENT = 6;
|
||||
|
||||
public int size;
|
||||
|
||||
public Attribute[] data = new Attribute[6];
|
||||
|
||||
public void addAttributes(Attribute attribute) {
|
||||
Attribute attribute2;
|
||||
for (Attribute attribute3 = attribute2 = attribute;
|
||||
attribute3 != null;
|
||||
attribute3 = attribute2 = attribute2.nextAttribute) {
|
||||
if (!this.contains(attribute2)) {
|
||||
this.add(attribute2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Attribute[] toArray() {
|
||||
Attribute[] attributes = new Attribute[this.size];
|
||||
System.arraycopy(this.data, 0, attributes, 0, this.size);
|
||||
return attributes;
|
||||
}
|
||||
|
||||
public void add(Attribute attribute) {
|
||||
if (this.size >= this.data.length) {
|
||||
Attribute[] attributes;
|
||||
Attribute[] attributes2 = attributes = new Attribute[this.data.length + 6];
|
||||
System.arraycopy(this.data, 0, attributes, 0, this.size);
|
||||
this.data = attributes2;
|
||||
}
|
||||
this.data[this.size++] = attribute;
|
||||
}
|
||||
|
||||
public boolean contains(Attribute attribute) {
|
||||
int value;
|
||||
for (int value2 = value = 0; value2 < this.size; value2 = ++value) {
|
||||
if (this.data[value].type.equals(attribute.type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
package com.allatori.lib.asm;
|
||||
|
||||
public class Attribute {
|
||||
|
||||
public Attribute nextAttribute;
|
||||
|
||||
public final String type;
|
||||
|
||||
public ByteVector cachedContent;
|
||||
|
||||
public static Attribute read(
|
||||
Attribute attribute,
|
||||
ClassReader classReader,
|
||||
int value,
|
||||
int value2,
|
||||
char[] values,
|
||||
int value3,
|
||||
Label[] labels) {
|
||||
return attribute.read(classReader, value, value2, values, value3, labels);
|
||||
}
|
||||
|
||||
public final int computeAttributesSize(SymbolTable symbolTable) {
|
||||
return this.computeAttributesSize(symbolTable, (byte[]) (Object) null, 0, -1, -1);
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Label[] getLabels() {
|
||||
return new Label[0];
|
||||
}
|
||||
|
||||
public final void putAttributes(SymbolTable symbolTable, ByteVector byteVector) {
|
||||
this.putAttributes(symbolTable, (byte[]) (Object) null, 0, -1, -1, byteVector);
|
||||
}
|
||||
|
||||
public static int computeAttributesSize(SymbolTable symbolTable, int value, int value2) {
|
||||
int value3 = 0;
|
||||
if ((value & 4096) != 0 && symbolTable.getCount() < 49) {
|
||||
value3 += 6;
|
||||
symbolTable.addConstantUtf8("Synthetic");
|
||||
}
|
||||
if (value2 != 0) {
|
||||
value3 += 8;
|
||||
symbolTable.addConstantUtf8("Signature");
|
||||
}
|
||||
if ((value & 131072) != 0) {
|
||||
value3 += 6;
|
||||
symbolTable.addConstantUtf8("Deprecated");
|
||||
}
|
||||
return value3;
|
||||
}
|
||||
|
||||
public Attribute read(
|
||||
ClassReader classReader, int value, int value2, char[] values, int value3, Label[] labels) {
|
||||
Attribute attribute = new Attribute(this.type);
|
||||
attribute.cachedContent = new ByteVector(classReader.readBytes(value, value2));
|
||||
return attribute;
|
||||
}
|
||||
|
||||
public final int getAttributeCount() {
|
||||
int value = 0;
|
||||
Attribute attribute;
|
||||
Attribute attribute2 = attribute = this;
|
||||
while (attribute2 != null) {
|
||||
Attribute attribute3 = attribute.nextAttribute;
|
||||
Attribute attribute4 = attribute.nextAttribute;
|
||||
value++;
|
||||
attribute2 = attribute4;
|
||||
attribute = attribute3;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public ByteVector getByteVector(
|
||||
ClassWriter classWriter, byte[] values, int value, int value2, int value3) {
|
||||
if (this.cachedContent == null) {
|
||||
this.cachedContent = this.getByteVector2(classWriter, values, value, value2, value3);
|
||||
}
|
||||
return this.cachedContent;
|
||||
}
|
||||
|
||||
public boolean isEnabled2() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public final int computeAttributesSize(
|
||||
SymbolTable symbolTable, byte[] values, int value, int value2, int value3) {
|
||||
ClassWriter classWriter2 = symbolTable.classWriter;
|
||||
int value4 = 0;
|
||||
Attribute attribute;
|
||||
for (Attribute attribute2 = attribute = this; attribute2 != null; attribute2 = attribute) {
|
||||
symbolTable.addConstantUtf8(attribute.type);
|
||||
value4 += 6 + attribute.getByteVector(classWriter2, values, value, value2, value3).length;
|
||||
attribute = attribute.nextAttribute;
|
||||
}
|
||||
return value4;
|
||||
}
|
||||
|
||||
public ByteVector getByteVector2(
|
||||
ClassWriter classWriter, byte[] values, int value, int value2, int value3) {
|
||||
return this.cachedContent;
|
||||
}
|
||||
|
||||
public static byte[] write(
|
||||
Attribute attribute,
|
||||
ClassWriter classWriter,
|
||||
byte[] values,
|
||||
int value,
|
||||
int value2,
|
||||
int value3) {
|
||||
ByteVector byteVector;
|
||||
ByteVector byteVector2 =
|
||||
byteVector = attribute.getByteVector(classWriter, values, value, value2, value3);
|
||||
byte[] values2 = new byte[byteVector2.length];
|
||||
System.arraycopy(byteVector2.data, 0, values2, 0, byteVector.length);
|
||||
return values2;
|
||||
}
|
||||
|
||||
public static void putAttributes(
|
||||
SymbolTable symbolTable, int value, int value2, ByteVector byteVector) {
|
||||
if ((value & 4096) != 0 && symbolTable.getCount() < 49) {
|
||||
byteVector.putShort(symbolTable.addConstantUtf8("Synthetic")).putInt(0);
|
||||
}
|
||||
if (value2 != 0) {
|
||||
byteVector.putShort(symbolTable.addConstantUtf8("Signature")).putInt(2).putShort(value2);
|
||||
}
|
||||
if ((value & 131072) != 0) {
|
||||
byteVector.putShort(symbolTable.addConstantUtf8("Deprecated")).putInt(0);
|
||||
}
|
||||
}
|
||||
|
||||
public static Label readLabel(ClassReader classReader, int value, Label[] labels) {
|
||||
return classReader.createLabel(value, labels);
|
||||
}
|
||||
|
||||
public Attribute(String type) {
|
||||
super();
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public final void putAttributes(
|
||||
SymbolTable symbolTable,
|
||||
byte[] values,
|
||||
int value,
|
||||
int value2,
|
||||
int value3,
|
||||
ByteVector byteVector) {
|
||||
ClassWriter classWriter2 = symbolTable.classWriter;
|
||||
Attribute attribute;
|
||||
for (Attribute attribute2 = attribute = this; attribute2 != null; attribute2 = attribute) {
|
||||
ByteVector byteVector2 = attribute.getByteVector(classWriter2, values, value, value2, value3);
|
||||
byteVector.putShort(symbolTable.addConstantUtf8(attribute.type)).putInt(byteVector2.length);
|
||||
byteVector.putByteArray(byteVector2.data, 0, byteVector2.length);
|
||||
attribute = attribute.nextAttribute;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,364 @@
|
||||
package com.allatori.lib.asm;
|
||||
|
||||
public class ByteVector {
|
||||
|
||||
public int length;
|
||||
|
||||
public byte[] data = new byte[64];
|
||||
|
||||
public final ByteVector encodeUtf8(String text, int value, int value2) {
|
||||
int size = text.length();
|
||||
int value3 = value;
|
||||
int value4;
|
||||
for (int value5 = value4 = value; value5 < size; value5 = ++value4) {
|
||||
char value6;
|
||||
if ((value6 = text.charAt(value4)) >= 1 && value6 <= 127) {
|
||||
value3++;
|
||||
} else if (value6 <= 2047) {
|
||||
value3 += 2;
|
||||
} else {
|
||||
value3 += 3;
|
||||
}
|
||||
}
|
||||
if (value3 > value2) {
|
||||
throw new IllegalArgumentException("UTF8 string too large");
|
||||
}
|
||||
int value7;
|
||||
if ((value7 = this.length - value - 2) >= 0) {
|
||||
this.data[value7] = (byte) (value3 >>> 8);
|
||||
this.data[value7 + 1] = (byte) value3;
|
||||
}
|
||||
if (this.length + value3 - value > this.data.length) {
|
||||
this.enlarge(value3 - value);
|
||||
}
|
||||
int value8 = this.length;
|
||||
int value9;
|
||||
for (int value10 = value9 = value; value10 < size; value10 = ++value9) {
|
||||
char value11;
|
||||
if ((value11 = text.charAt(value9)) >= 1 && value11 <= 127) {
|
||||
byte value12 = (byte) value11;
|
||||
int value13 = value8;
|
||||
byte[] values = this.data;
|
||||
value8++;
|
||||
values[value13] = value12;
|
||||
} else if (value11 <= 2047) {
|
||||
char value14 = value11;
|
||||
int value15 = value8;
|
||||
byte[] values2 = this.data;
|
||||
value8++;
|
||||
values2[value15] = (byte) ((short) 192 | value14 >> (byte) 6 & 31);
|
||||
char value16 = value11;
|
||||
int value17 = value8;
|
||||
byte[] values3 = this.data;
|
||||
value8++;
|
||||
values3[value17] = (byte) ((short) 128 | value16 & (byte) 63);
|
||||
} else {
|
||||
char value18 = value11;
|
||||
int value19 = value8;
|
||||
byte[] values4 = this.data;
|
||||
value8++;
|
||||
values4[value19] = (byte) ((short) 224 | value18 >> (byte) 12 & 15);
|
||||
char value20 = value11;
|
||||
int value21 = value8;
|
||||
byte[] values5 = this.data;
|
||||
value8++;
|
||||
values5[value21] = (byte) ((short) 128 | value20 >> (byte) 6 & 63);
|
||||
char value22 = value11;
|
||||
int value23 = value8;
|
||||
byte[] values6 = this.data;
|
||||
value8++;
|
||||
values6[value23] = (byte) ((short) 128 | value22 & (byte) 63);
|
||||
}
|
||||
}
|
||||
this.length = value8;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return this.length;
|
||||
}
|
||||
|
||||
public ByteVector putInt(int value) {
|
||||
int value2 = this.length;
|
||||
if (this.length + 4 > this.data.length) {
|
||||
this.enlarge(4);
|
||||
}
|
||||
int value3 = value >>> 24;
|
||||
int value4 = value2;
|
||||
byte[] values = this.data;
|
||||
byte[] values2 = this.data;
|
||||
byte[] values3 = this.data;
|
||||
byte[] values4 = this.data;
|
||||
value2++;
|
||||
values[value4] = (byte) value3;
|
||||
int value5 = value >>> 16;
|
||||
int value6 = value2;
|
||||
value2++;
|
||||
values2[value6] = (byte) value5;
|
||||
int value7 = value >>> 8;
|
||||
int value8 = value2;
|
||||
value2++;
|
||||
values3[value8] = (byte) value7;
|
||||
byte value9 = (byte) value;
|
||||
int value10 = value2;
|
||||
value2++;
|
||||
values4[value10] = value9;
|
||||
this.length = value2;
|
||||
return this;
|
||||
}
|
||||
|
||||
public final ByteVector put112(int value, int value2, int value3) {
|
||||
int value4 = this.length;
|
||||
if (this.length + 4 > this.data.length) {
|
||||
this.enlarge(4);
|
||||
}
|
||||
byte value5 = (byte) value;
|
||||
int value6 = value4;
|
||||
byte[] values = this.data;
|
||||
byte[] values2 = this.data;
|
||||
byte[] values3 = this.data;
|
||||
byte[] values4 = this.data;
|
||||
value4++;
|
||||
values[value6] = value5;
|
||||
byte value7 = (byte) value2;
|
||||
int value8 = value4;
|
||||
value4++;
|
||||
values2[value8] = value7;
|
||||
int value9 = value3 >>> 8;
|
||||
int value10 = value4;
|
||||
value4++;
|
||||
values3[value10] = (byte) value9;
|
||||
byte value11 = (byte) value3;
|
||||
int value12 = value4;
|
||||
value4++;
|
||||
values4[value12] = value11;
|
||||
this.length = value4;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ByteVector putByteArray(byte[] values, int value, int length) {
|
||||
if (this.length + length > this.data.length) {
|
||||
this.enlarge(length);
|
||||
}
|
||||
if (values != null) {
|
||||
System.arraycopy(values, value, this.data, this.length, length);
|
||||
}
|
||||
this.length += length;
|
||||
return this;
|
||||
}
|
||||
|
||||
public final ByteVector put12(int value, int value2) {
|
||||
int value3 = this.length;
|
||||
if (this.length + 3 > this.data.length) {
|
||||
this.enlarge(3);
|
||||
}
|
||||
byte value4 = (byte) value;
|
||||
int value5 = value3;
|
||||
byte[] values = this.data;
|
||||
byte[] values2 = this.data;
|
||||
byte[] values3 = this.data;
|
||||
value3++;
|
||||
values[value5] = value4;
|
||||
int value6 = value2 >>> 8;
|
||||
int value7 = value3;
|
||||
value3++;
|
||||
values2[value7] = (byte) value6;
|
||||
byte value8 = (byte) value2;
|
||||
int value9 = value3;
|
||||
value3++;
|
||||
values3[value9] = value8;
|
||||
this.length = value3;
|
||||
return this;
|
||||
}
|
||||
|
||||
public final ByteVector put11(int value, int value2) {
|
||||
int value3 = this.length;
|
||||
if (this.length + 2 > this.data.length) {
|
||||
this.enlarge(2);
|
||||
}
|
||||
byte value4 = (byte) value;
|
||||
int value5 = value3;
|
||||
byte[] values = this.data;
|
||||
byte[] values2 = this.data;
|
||||
value3++;
|
||||
values[value5] = value4;
|
||||
byte value6 = (byte) value2;
|
||||
int value7 = value3;
|
||||
value3++;
|
||||
values2[value7] = value6;
|
||||
this.length = value3;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void enlarge(int value) {
|
||||
if (this.length > this.data.length) {
|
||||
throw new AssertionError("Internal error");
|
||||
}
|
||||
int value2 = 2 * this.data.length;
|
||||
int value3 = this.length + value;
|
||||
byte[] values;
|
||||
byte[] values2 = values = new byte[value2 > value3 ? value2 : value3];
|
||||
System.arraycopy(this.data, 0, values, 0, this.length);
|
||||
this.data = values2;
|
||||
}
|
||||
|
||||
public ByteVector() {}
|
||||
|
||||
public final ByteVector put122(int value, int value2, int value3) {
|
||||
int value4 = this.length;
|
||||
if (this.length + 5 > this.data.length) {
|
||||
this.enlarge(5);
|
||||
}
|
||||
byte value5 = (byte) value;
|
||||
int value6 = value4;
|
||||
byte[] values = this.data;
|
||||
byte[] values2 = this.data;
|
||||
byte[] values3 = this.data;
|
||||
byte[] values4 = this.data;
|
||||
byte[] values5 = this.data;
|
||||
value4++;
|
||||
values[value6] = value5;
|
||||
int value7 = value2 >>> 8;
|
||||
int value8 = value4;
|
||||
value4++;
|
||||
values2[value8] = (byte) value7;
|
||||
byte value9 = (byte) value2;
|
||||
int value10 = value4;
|
||||
value4++;
|
||||
values3[value10] = value9;
|
||||
int value11 = value3 >>> 8;
|
||||
int value12 = value4;
|
||||
value4++;
|
||||
values4[value12] = (byte) value11;
|
||||
byte value13 = (byte) value3;
|
||||
int value14 = value4;
|
||||
value4++;
|
||||
values5[value14] = value13;
|
||||
this.length = value4;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ByteVector(byte[] data) {
|
||||
super();
|
||||
this.data = data;
|
||||
this.length = data.length;
|
||||
}
|
||||
|
||||
public ByteVector putShort(int value) {
|
||||
int value2 = this.length;
|
||||
if (this.length + 2 > this.data.length) {
|
||||
this.enlarge(2);
|
||||
}
|
||||
int value3 = value >>> 8;
|
||||
int value4 = value2;
|
||||
byte[] values = this.data;
|
||||
byte[] values2 = this.data;
|
||||
value2++;
|
||||
values[value4] = (byte) value3;
|
||||
byte value5 = (byte) value;
|
||||
int value6 = value2;
|
||||
value2++;
|
||||
values2[value6] = value5;
|
||||
this.length = value2;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ByteVector putLong(long value) {
|
||||
int value2 = this.length;
|
||||
if (this.length + 8 > this.data.length) {
|
||||
this.enlarge(8);
|
||||
}
|
||||
byte[] values = this.data;
|
||||
int value3 = (int) (value >>> 32);
|
||||
int value4 = value3 >>> 24;
|
||||
int value5 = value2;
|
||||
value2++;
|
||||
values[value5] = (byte) value4;
|
||||
int value6 = value3 >>> 16;
|
||||
int value7 = value2;
|
||||
value2++;
|
||||
values[value7] = (byte) value6;
|
||||
int value8 = value3 >>> 8;
|
||||
int value9 = value2;
|
||||
value2++;
|
||||
values[value9] = (byte) value8;
|
||||
byte value10 = (byte) value3;
|
||||
int value11 = value2;
|
||||
value2++;
|
||||
values[value11] = value10;
|
||||
int value12 = (int) value;
|
||||
int value13 = value12 >>> 24;
|
||||
int value14 = value2;
|
||||
value2++;
|
||||
values[value14] = (byte) value13;
|
||||
int value15 = value12 >>> 16;
|
||||
int value16 = value2;
|
||||
value2++;
|
||||
values[value16] = (byte) value15;
|
||||
int value17 = value12 >>> 8;
|
||||
int value18 = value2;
|
||||
value2++;
|
||||
values[value18] = (byte) value17;
|
||||
byte value19 = (byte) value12;
|
||||
int value20 = value2;
|
||||
value2++;
|
||||
values[value20] = value19;
|
||||
this.length = value2;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ByteVector putByte(int value) {
|
||||
int value2 = this.length;
|
||||
if (this.length + 1 > this.data.length) {
|
||||
this.enlarge(1);
|
||||
}
|
||||
byte value3 = (byte) value;
|
||||
int value4 = value2;
|
||||
byte[] values = this.data;
|
||||
value2++;
|
||||
values[value4] = value3;
|
||||
this.length = value2;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ByteVector(int value) {
|
||||
super();
|
||||
this.data = new byte[value];
|
||||
}
|
||||
|
||||
public ByteVector putUTF8(String text) {
|
||||
int value;
|
||||
if ((value = text.length()) > 65535) {
|
||||
throw new IllegalArgumentException("UTF8 string too large");
|
||||
}
|
||||
int value2 = this.length;
|
||||
if (this.length + 2 + value > this.data.length) {
|
||||
this.enlarge(2 + value);
|
||||
}
|
||||
byte[] values = this.data;
|
||||
int value3 = value >>> 8;
|
||||
int value4 = value2;
|
||||
byte[] values2 = this.data;
|
||||
byte[] values3 = this.data;
|
||||
value2++;
|
||||
values2[value4] = (byte) value3;
|
||||
byte value5 = (byte) value;
|
||||
int value6 = value2;
|
||||
value2++;
|
||||
values3[value6] = value5;
|
||||
int value7;
|
||||
for (int value8 = value7 = 0; value8 < value; value8 = ++value7) {
|
||||
char value9;
|
||||
if ((value9 = text.charAt(value7)) < 1 || value9 > 127) {
|
||||
this.length = value2;
|
||||
return this.encodeUtf8(text, value7, 65535);
|
||||
}
|
||||
byte value10 = (byte) value9;
|
||||
int value11 = value2;
|
||||
value2++;
|
||||
values[value11] = value10;
|
||||
}
|
||||
this.length = value2;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,28 @@
|
||||
package com.allatori.lib.asm;
|
||||
|
||||
public final class ClassTooLargeException extends IndexOutOfBoundsException {
|
||||
|
||||
public final int constantPoolCount;
|
||||
|
||||
public final String className;
|
||||
|
||||
public static final long serialVersionUID = 160715609518896765L;
|
||||
|
||||
public int getConstantPoolCount() {
|
||||
return this.constantPoolCount;
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return this.className;
|
||||
}
|
||||
|
||||
public ClassTooLargeException(String className, int constantPoolCount) {
|
||||
super(stringConcat$0(className));
|
||||
this.className = className;
|
||||
this.constantPoolCount = constantPoolCount;
|
||||
}
|
||||
|
||||
public static String stringConcat$0(String text) {
|
||||
return "Class too large: " + text;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package com.allatori.lib.asm;
|
||||
|
||||
public abstract class ClassVisitor {
|
||||
|
||||
public final int api;
|
||||
|
||||
public ClassVisitor cv;
|
||||
|
||||
public AnnotationVisitor visitAnnotation(String text, boolean matches) {
|
||||
return this.cv != null ? this.cv.visitAnnotation(text, matches) : null;
|
||||
}
|
||||
|
||||
public void visitSource(String text, String text2) {
|
||||
if (this.cv != null) {
|
||||
this.cv.visitSource(text, text2);
|
||||
}
|
||||
}
|
||||
|
||||
public void visitPermittedSubclass(String text) {
|
||||
if (this.api < 589824) {
|
||||
throw new UnsupportedOperationException("PermittedSubclasses requires ASM9");
|
||||
}
|
||||
if (this.cv != null) {
|
||||
this.cv.visitPermittedSubclass(text);
|
||||
}
|
||||
}
|
||||
|
||||
public ClassVisitor(int value) {
|
||||
this(value, null);
|
||||
}
|
||||
|
||||
public void visitOuterClass(String text, String text2, String text3) {
|
||||
if (this.cv != null) {
|
||||
this.cv.visitOuterClass(text, text2, text3);
|
||||
}
|
||||
}
|
||||
|
||||
public void visit(
|
||||
int value, int value2, String text, String text2, String text3, String[] texts) {
|
||||
if (this.api < 524288 && (value2 & 65536) != 0) {
|
||||
throw new UnsupportedOperationException("Records requires ASM8");
|
||||
}
|
||||
if (this.cv != null) {
|
||||
this.cv.visit(value, value2, text, text2, text3, texts);
|
||||
}
|
||||
}
|
||||
|
||||
public ClassVisitor getDelegate() {
|
||||
return this.cv;
|
||||
}
|
||||
|
||||
public FieldVisitor visitField(
|
||||
int value, String text, String text2, String text3, Object result) {
|
||||
return this.cv != null ? this.cv.visitField(value, text, text2, text3, result) : null;
|
||||
}
|
||||
|
||||
public ModuleVisitor visitModule(String text, int value, String text2) {
|
||||
if (this.api < 393216) {
|
||||
throw new UnsupportedOperationException("Module requires ASM6");
|
||||
} else {
|
||||
return this.cv != null ? this.cv.visitModule(text, value, text2) : null;
|
||||
}
|
||||
}
|
||||
|
||||
public AnnotationVisitor visitTypeAnnotation(
|
||||
int value, TypePath typePath, String text, boolean matches) {
|
||||
if (this.api < 327680) {
|
||||
throw new UnsupportedOperationException("TypeAnnotation requires ASM5");
|
||||
} else {
|
||||
return this.cv != null ? this.cv.visitTypeAnnotation(value, typePath, text, matches) : null;
|
||||
}
|
||||
}
|
||||
|
||||
public void visitInnerClass(String text, String text2, String text3, int value) {
|
||||
if (this.cv != null) {
|
||||
this.cv.visitInnerClass(text, text2, text3, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void visitEnd() {
|
||||
if (this.cv != null) {
|
||||
this.cv.visitEnd();
|
||||
}
|
||||
}
|
||||
|
||||
public void visitNestMember(String text) {
|
||||
if (this.api < 458752) {
|
||||
throw new UnsupportedOperationException("NestMember requires ASM7");
|
||||
}
|
||||
if (this.cv != null) {
|
||||
this.cv.visitNestMember(text);
|
||||
}
|
||||
}
|
||||
|
||||
public MethodVisitor visitMethod(
|
||||
int value, String text, String text2, String text3, String[] texts) {
|
||||
return this.cv != null ? this.cv.visitMethod(value, text, text2, text3, texts) : null;
|
||||
}
|
||||
|
||||
public static String stringConcat$0(int value) {
|
||||
return "Unsupported api " + value;
|
||||
}
|
||||
|
||||
public void visitNestHost(String text) {
|
||||
if (this.api < 458752) {
|
||||
throw new UnsupportedOperationException("NestHost requires ASM7");
|
||||
}
|
||||
if (this.cv != null) {
|
||||
this.cv.visitNestHost(text);
|
||||
}
|
||||
}
|
||||
|
||||
public ClassVisitor(int api, ClassVisitor classVisitor) {
|
||||
super();
|
||||
if (api != 589824
|
||||
&& api != 524288
|
||||
&& api != 458752
|
||||
&& api != 393216
|
||||
&& api != 327680
|
||||
&& api != 262144
|
||||
&& api != 17432576) {
|
||||
throw new IllegalArgumentException(stringConcat$0(api));
|
||||
}
|
||||
if (api == 17432576) {
|
||||
Constants.checkAsmExperimental(this);
|
||||
}
|
||||
this.api = api;
|
||||
this.cv = classVisitor;
|
||||
}
|
||||
|
||||
public void visitAttribute(Attribute attribute) {
|
||||
if (this.cv != null) {
|
||||
this.cv.visitAttribute(attribute);
|
||||
}
|
||||
}
|
||||
|
||||
public RecordComponentVisitor visitRecordComponent(String text, String text2, String text3) {
|
||||
if (this.api < 524288) {
|
||||
throw new UnsupportedOperationException("Record requires ASM8");
|
||||
} else {
|
||||
return this.cv != null ? this.cv.visitRecordComponent(text, text2, text3) : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,668 @@
|
||||
package com.allatori.lib.asm;
|
||||
|
||||
public class ClassWriter extends ClassVisitor {
|
||||
|
||||
public int count;
|
||||
|
||||
public int count2;
|
||||
|
||||
public int count3;
|
||||
|
||||
public AnnotationWriter annotationWriter;
|
||||
|
||||
public int count4;
|
||||
|
||||
public AnnotationWriter annotationWriter2;
|
||||
|
||||
public ByteVector byteVector;
|
||||
|
||||
public RecordComponentWriter recordComponentWriter;
|
||||
|
||||
public int count5;
|
||||
|
||||
public AnnotationWriter annotationWriter3;
|
||||
|
||||
public MethodWriter methodWriter;
|
||||
|
||||
public int count6;
|
||||
|
||||
public int count7;
|
||||
|
||||
public int[] interfaces;
|
||||
|
||||
public FieldWriter fieldWriter;
|
||||
|
||||
public final int flags;
|
||||
|
||||
public static final int COMPUTE_MAXS = 1;
|
||||
|
||||
public AnnotationWriter annotationWriter4;
|
||||
|
||||
public ModuleWriter moduleWriter;
|
||||
|
||||
public int count8;
|
||||
|
||||
public int count9;
|
||||
|
||||
public int count10;
|
||||
|
||||
public final SymbolTable symbolTable;
|
||||
|
||||
public int count11;
|
||||
|
||||
public int count12;
|
||||
|
||||
public ByteVector byteVector2;
|
||||
|
||||
public Attribute firstAttribute;
|
||||
|
||||
public RecordComponentWriter recordComponentWriter2;
|
||||
|
||||
public int count13;
|
||||
|
||||
public MethodWriter methodWriter2;
|
||||
|
||||
public static final int COMPUTE_FRAMES = 2;
|
||||
|
||||
public int count14;
|
||||
|
||||
public ByteVector byteVector3;
|
||||
|
||||
public ByteVector byteVector4;
|
||||
|
||||
public FieldWriter fieldWriter2;
|
||||
|
||||
public String getCommonSuperClass(String text, String text2) throws ClassNotFoundException {
|
||||
ClassLoader classLoader = this.getClassLoader();
|
||||
Class classValue;
|
||||
try {
|
||||
classValue = Class.forName(text.replace('/', '.'), false, classLoader);
|
||||
} catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new TypeNotPresentException(text, classNotFoundException);
|
||||
}
|
||||
Class classValue2 = Class.forName(text2.replace('/', '.'), false, classLoader);
|
||||
if (classValue.isAssignableFrom(classValue2)) {
|
||||
return text;
|
||||
}
|
||||
if (classValue2.isAssignableFrom(classValue)) {
|
||||
return text2;
|
||||
}
|
||||
if (!classValue.isInterface() && !classValue2.isInterface()) {
|
||||
while (!(classValue = classValue.getSuperclass()).isAssignableFrom(classValue2)) {}
|
||||
return classValue.getName().replace('.', '/');
|
||||
} else {
|
||||
return "java/lang/Object";
|
||||
}
|
||||
}
|
||||
|
||||
public int calculateCount(String text) {
|
||||
return this.symbolTable.getSymbol(text).index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void visitNestMember(String text) {
|
||||
if (this.byteVector4 == null) {
|
||||
this.byteVector4 = new ByteVector();
|
||||
}
|
||||
this.count7++;
|
||||
this.byteVector4.putShort(this.symbolTable.getSymbol3(text).index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void visitSource(String text, String text2) {
|
||||
if (text != null) {
|
||||
this.count4 = this.symbolTable.addConstantUtf8(text);
|
||||
}
|
||||
if (text2 != null) {
|
||||
this.byteVector2 = new ByteVector().encodeUtf8(text2, 0, Integer.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void visitNestHost(String text) {
|
||||
this.count14 = this.symbolTable.getSymbol3(text).index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void visitEnd() {}
|
||||
|
||||
@Override
|
||||
public final void visitAttribute(Attribute attribute) {
|
||||
attribute.nextAttribute = this.firstAttribute;
|
||||
this.firstAttribute = attribute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void visitPermittedSubclass(String text) {
|
||||
if (this.byteVector3 == null) {
|
||||
this.byteVector3 = new ByteVector();
|
||||
}
|
||||
this.count9++;
|
||||
this.byteVector3.putShort(this.symbolTable.getSymbol3(text).index);
|
||||
}
|
||||
|
||||
public Attribute[] getAttributePrototypes() {
|
||||
Attribute$Set attribute$Set;
|
||||
(attribute$Set = new Attribute$Set()).addAttributes(this.firstAttribute);
|
||||
FieldWriter fieldWriter2;
|
||||
for (FieldWriter fieldWriter3 = fieldWriter2 = this.fieldWriter;
|
||||
fieldWriter3 != null;
|
||||
fieldWriter3 = fieldWriter2 = (FieldWriter) fieldWriter2.fv) {
|
||||
fieldWriter2.collectAttributePrototypes(attribute$Set);
|
||||
}
|
||||
MethodWriter methodWriter2;
|
||||
for (MethodWriter methodWriter3 = methodWriter2 = this.methodWriter;
|
||||
methodWriter3 != null;
|
||||
methodWriter3 = methodWriter2 = (MethodWriter) methodWriter2.mv) {
|
||||
methodWriter2.collectAttributePrototypes(attribute$Set);
|
||||
}
|
||||
RecordComponentWriter recordComponentWriter;
|
||||
for (RecordComponentWriter recordComponentWriter3 =
|
||||
recordComponentWriter = this.recordComponentWriter2;
|
||||
recordComponentWriter3 != null;
|
||||
recordComponentWriter3 =
|
||||
recordComponentWriter = (RecordComponentWriter) recordComponentWriter.delegate) {
|
||||
recordComponentWriter.collectAttributePrototypes(attribute$Set);
|
||||
}
|
||||
return attribute$Set.toArray();
|
||||
}
|
||||
|
||||
public int newConst(Object result) {
|
||||
return this.symbolTable.addConstant(result).index;
|
||||
}
|
||||
|
||||
public int calculateCount2(String text) {
|
||||
return this.symbolTable.getSymbol3(text).index;
|
||||
}
|
||||
|
||||
public int calculateCount3(String text) {
|
||||
return this.symbolTable.getSymbol2(text).index;
|
||||
}
|
||||
|
||||
public ClassLoader getClassLoader() {
|
||||
return this.getClass().getClassLoader();
|
||||
}
|
||||
|
||||
public int newHandle(int value, String text, String text2, String text3, boolean matches) {
|
||||
return this.symbolTable.addConstantMethodHandle(value, text, text2, text3, matches).index;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int newHandle(int value, String text, String text2, String text3) {
|
||||
return this.newHandle(value, text, text2, text3, value == 9);
|
||||
}
|
||||
|
||||
public int newConstantDynamic(String text, String text2, Handle handle, Object... result) {
|
||||
return this.symbolTable.addConstantDynamic(text, text2, handle, (Object[]) result).index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void visit(
|
||||
int count10, int count5, String text, String text2, String text3, String[] texts) {
|
||||
this.count10 = count10;
|
||||
this.count5 = count5;
|
||||
this.count2 = this.symbolTable.setMajorVersionAndClassName(count10 & 65535, text);
|
||||
if (text2 != null) {
|
||||
this.count3 = this.symbolTable.addConstantUtf8(text2);
|
||||
}
|
||||
this.count12 = text3 == null ? 0 : this.symbolTable.getSymbol3(text3).index;
|
||||
if (texts != null && texts.length > 0) {
|
||||
this.count6 = texts.length;
|
||||
int value3 = 0;
|
||||
this.interfaces = new int[this.count6];
|
||||
for (int index2 = 0; value3 < this.count6; value3 = index2) {
|
||||
int[] values = this.interfaces;
|
||||
int value4 = this.symbolTable.getSymbol3(texts[index2]).index;
|
||||
int value5 = index2;
|
||||
index2++;
|
||||
values[value5] = value4;
|
||||
}
|
||||
}
|
||||
if (this.count8 == 1 && (count10 & 65535) >= 51) {
|
||||
this.count8 = 2;
|
||||
}
|
||||
}
|
||||
|
||||
public int newField(String text, String text2, String text3) {
|
||||
return this.symbolTable.addConstantFieldref(text, text2, text3).index;
|
||||
}
|
||||
|
||||
public int newInvokeDynamic(String text, String text2, Handle handle, Object... result) {
|
||||
return this.symbolTable.addConstantInvokeDynamic(text, text2, handle, (Object[]) result).index;
|
||||
}
|
||||
|
||||
public boolean hasFlags(int value) {
|
||||
return (this.flags & value) == value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final RecordComponentVisitor visitRecordComponent(
|
||||
String text, String text2, String text3) {
|
||||
RecordComponentWriter recordComponentWriter3 =
|
||||
new RecordComponentWriter(this.symbolTable, text, text2, text3);
|
||||
ClassWriter classWriter;
|
||||
if (this.recordComponentWriter2 == null) {
|
||||
classWriter = this;
|
||||
this.recordComponentWriter2 = recordComponentWriter3;
|
||||
} else {
|
||||
classWriter = this;
|
||||
this.recordComponentWriter.delegate = recordComponentWriter3;
|
||||
}
|
||||
return classWriter.recordComponentWriter = recordComponentWriter3;
|
||||
}
|
||||
|
||||
public byte[] replaceAsmInstructions(byte[] values, boolean matches)
|
||||
throws ClassNotFoundException {
|
||||
Attribute[] attributePrototypes = this.getAttributePrototypes();
|
||||
this.fieldWriter = null;
|
||||
this.fieldWriter2 = null;
|
||||
this.methodWriter = null;
|
||||
this.methodWriter2 = null;
|
||||
this.annotationWriter = null;
|
||||
this.annotationWriter4 = null;
|
||||
this.annotationWriter3 = null;
|
||||
this.annotationWriter2 = null;
|
||||
this.moduleWriter = null;
|
||||
this.count14 = 0;
|
||||
this.count7 = 0;
|
||||
this.byteVector4 = null;
|
||||
this.count9 = 0;
|
||||
this.byteVector3 = null;
|
||||
this.recordComponentWriter2 = null;
|
||||
this.recordComponentWriter = null;
|
||||
this.firstAttribute = null;
|
||||
this.count8 = matches ? 3 : 0;
|
||||
new ClassReader(values, 0, false).accept(this, attributePrototypes, (matches ? 8 : 0) | 256);
|
||||
return this.toByteArray();
|
||||
}
|
||||
|
||||
public int newNameType(String text, String text2) {
|
||||
return this.symbolTable.addConstantNameAndType(text, text2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ModuleVisitor visitModule(String text, int value, String text2) {
|
||||
return this.moduleWriter =
|
||||
new ModuleWriter(
|
||||
this.symbolTable,
|
||||
this.symbolTable.getSymbol4(text).index,
|
||||
value,
|
||||
text2 == null ? 0 : this.symbolTable.addConstantUtf8(text2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final AnnotationVisitor visitAnnotation(String text, boolean matches) {
|
||||
return matches
|
||||
? (this.annotationWriter =
|
||||
AnnotationWriter.create(this.symbolTable, text, this.annotationWriter))
|
||||
: (this.annotationWriter4 =
|
||||
AnnotationWriter.create(this.symbolTable, text, this.annotationWriter4));
|
||||
}
|
||||
|
||||
public ClassWriter(int value) {
|
||||
this(null, value);
|
||||
}
|
||||
|
||||
public byte[] toByteArray() throws ClassNotFoundException {
|
||||
int value = 24 + 2 * this.count6;
|
||||
int value2 = 0;
|
||||
FieldWriter fieldWriter2;
|
||||
for (FieldWriter fieldWriter3 = fieldWriter2 = this.fieldWriter;
|
||||
fieldWriter3 != null;
|
||||
fieldWriter3 = fieldWriter2 = (FieldWriter) fieldWriter2.fv) {
|
||||
int value3 = fieldWriter2.computeFieldInfoSize();
|
||||
int value4 = value;
|
||||
value2++;
|
||||
value = value4 + value3;
|
||||
}
|
||||
int value5 = 0;
|
||||
MethodWriter methodWriter2;
|
||||
for (MethodWriter methodWriter3 = methodWriter2 = this.methodWriter;
|
||||
methodWriter3 != null;
|
||||
methodWriter3 = methodWriter2 = (MethodWriter) methodWriter2.mv) {
|
||||
int value6 = methodWriter2.computeMethodInfoSize();
|
||||
int value7 = value;
|
||||
value5++;
|
||||
value = value7 + value6;
|
||||
}
|
||||
int value8 = 0;
|
||||
if (this.byteVector != null) {
|
||||
int value9 = value;
|
||||
value8++;
|
||||
value = value9 + (byte) 8 + this.byteVector.length;
|
||||
this.symbolTable.addConstantUtf8("InnerClasses");
|
||||
}
|
||||
if (this.count11 != 0) {
|
||||
value += 10;
|
||||
SymbolTable symbolTable2 = this.symbolTable;
|
||||
value8++;
|
||||
symbolTable2.addConstantUtf8("EnclosingMethod");
|
||||
}
|
||||
if ((this.count5 & 4096) != 0 && (this.count10 & 65535) < 49) {
|
||||
value += 6;
|
||||
SymbolTable symbolTable3 = this.symbolTable;
|
||||
value8++;
|
||||
symbolTable3.addConstantUtf8("Synthetic");
|
||||
}
|
||||
if (this.count3 != 0) {
|
||||
value += 8;
|
||||
SymbolTable symbolTable4 = this.symbolTable;
|
||||
value8++;
|
||||
symbolTable4.addConstantUtf8("Signature");
|
||||
}
|
||||
if (this.count4 != 0) {
|
||||
value += 8;
|
||||
SymbolTable symbolTable5 = this.symbolTable;
|
||||
value8++;
|
||||
symbolTable5.addConstantUtf8("SourceFile");
|
||||
}
|
||||
if (this.byteVector2 != null) {
|
||||
int value10 = value;
|
||||
value8++;
|
||||
value = value10 + (byte) 6 + this.byteVector2.length;
|
||||
this.symbolTable.addConstantUtf8("SourceDebugExtension");
|
||||
}
|
||||
if ((this.count5 & 131072) != 0) {
|
||||
value += 6;
|
||||
SymbolTable symbolTable6 = this.symbolTable;
|
||||
value8++;
|
||||
symbolTable6.addConstantUtf8("Deprecated");
|
||||
}
|
||||
if (this.annotationWriter != null) {
|
||||
AnnotationWriter annotationWriter5 = this.annotationWriter;
|
||||
int value11 = value;
|
||||
value8++;
|
||||
value = value11 + annotationWriter5.computeAnnotationsSize("RuntimeVisibleAnnotations");
|
||||
}
|
||||
if (this.annotationWriter4 != null) {
|
||||
AnnotationWriter annotationWriter6 = this.annotationWriter4;
|
||||
int value12 = value;
|
||||
value8++;
|
||||
value = value12 + annotationWriter6.computeAnnotationsSize("RuntimeInvisibleAnnotations");
|
||||
}
|
||||
if (this.annotationWriter3 != null) {
|
||||
AnnotationWriter annotationWriter7 = this.annotationWriter3;
|
||||
int value13 = value;
|
||||
value8++;
|
||||
value = value13 + annotationWriter7.computeAnnotationsSize("RuntimeVisibleTypeAnnotations");
|
||||
}
|
||||
if (this.annotationWriter2 != null) {
|
||||
AnnotationWriter annotationWriter8 = this.annotationWriter2;
|
||||
int value14 = value;
|
||||
value8++;
|
||||
value = value14 + annotationWriter8.computeAnnotationsSize("RuntimeInvisibleTypeAnnotations");
|
||||
}
|
||||
if (this.symbolTable.computeBootstrapMethodsSize() > 0) {
|
||||
SymbolTable symbolTable7 = this.symbolTable;
|
||||
int value15 = value;
|
||||
value8++;
|
||||
value = value15 + symbolTable7.computeBootstrapMethodsSize();
|
||||
}
|
||||
if (this.moduleWriter != null) {
|
||||
value8 += this.moduleWriter.getAttributeCount();
|
||||
value += this.moduleWriter.computeAttributesSize();
|
||||
}
|
||||
if (this.count14 != 0) {
|
||||
value += 8;
|
||||
SymbolTable symbolTable8 = this.symbolTable;
|
||||
value8++;
|
||||
symbolTable8.addConstantUtf8("NestHost");
|
||||
}
|
||||
if (this.byteVector4 != null) {
|
||||
int value16 = value;
|
||||
value8++;
|
||||
value = value16 + (byte) 8 + this.byteVector4.length;
|
||||
this.symbolTable.addConstantUtf8("NestMembers");
|
||||
}
|
||||
if (this.byteVector3 != null) {
|
||||
int value17 = value;
|
||||
value8++;
|
||||
value = value17 + (byte) 8 + this.byteVector3.length;
|
||||
this.symbolTable.addConstantUtf8("PermittedSubclasses");
|
||||
}
|
||||
int value18 = 0;
|
||||
int value19 = 0;
|
||||
if ((this.count5 & 65536) != 0 || this.recordComponentWriter2 != null) {
|
||||
RecordComponentWriter recordComponentWriter;
|
||||
for (RecordComponentWriter recordComponentWriter3 =
|
||||
recordComponentWriter = this.recordComponentWriter2;
|
||||
recordComponentWriter3 != null;
|
||||
recordComponentWriter3 =
|
||||
recordComponentWriter = (RecordComponentWriter) recordComponentWriter.delegate) {
|
||||
int value20 = recordComponentWriter.computeRecordComponentInfoSize();
|
||||
int value21 = value19;
|
||||
value18++;
|
||||
value19 = value21 + value20;
|
||||
}
|
||||
value8++;
|
||||
value += 8 + value19;
|
||||
this.symbolTable.addConstantUtf8("Record");
|
||||
}
|
||||
if (this.firstAttribute != null) {
|
||||
value8 += this.firstAttribute.getAttributeCount();
|
||||
value += this.firstAttribute.computeAttributesSize(this.symbolTable);
|
||||
}
|
||||
int value22 = value + this.symbolTable.calculateCount();
|
||||
int value23;
|
||||
if ((value23 = this.symbolTable.getConstantPoolCount()) > 65535) {
|
||||
throw new ClassTooLargeException(this.symbolTable.getClassName(), value23);
|
||||
}
|
||||
ByteVector byteVector5;
|
||||
(byteVector5 = new ByteVector(value22)).putInt(-889275714).putInt(this.count10);
|
||||
this.symbolTable.processByteVector(byteVector5);
|
||||
int value24 = (this.count10 & 65535) < 49 ? 4096 : 0;
|
||||
byteVector5.putShort(this.count5 & ~value24).putShort(this.count2).putShort(this.count12);
|
||||
byteVector5.putShort(this.count6);
|
||||
int value25 = 0;
|
||||
for (int value26 = value25; value26 < this.count6; value26 = value25) {
|
||||
int value27 = value25;
|
||||
int[] values = this.interfaces;
|
||||
ByteVector byteVector6 = byteVector5;
|
||||
value25++;
|
||||
byteVector6.putShort(values[value27]);
|
||||
}
|
||||
byteVector5.putShort(value2);
|
||||
FieldWriter fieldWriter4 = this.fieldWriter;
|
||||
for (FieldWriter fieldWriter5 = fieldWriter4;
|
||||
fieldWriter5 != null;
|
||||
fieldWriter5 = fieldWriter4 = (FieldWriter) fieldWriter4.fv) {
|
||||
fieldWriter4.putFieldInfo(byteVector5);
|
||||
}
|
||||
byteVector5.putShort(value5);
|
||||
boolean matches = false;
|
||||
boolean matches2 = false;
|
||||
MethodWriter methodWriter4 = this.methodWriter;
|
||||
for (MethodWriter methodWriter5 = methodWriter4;
|
||||
methodWriter5 != null;
|
||||
methodWriter5 = methodWriter4 = (MethodWriter) methodWriter4.mv) {
|
||||
matches |= methodWriter4.isCount7();
|
||||
matches2 |= methodWriter4.isEnabled2();
|
||||
methodWriter4.putMethodInfo(byteVector5);
|
||||
}
|
||||
byteVector5.putShort(value8);
|
||||
if (this.byteVector != null) {
|
||||
byteVector5
|
||||
.putShort(this.symbolTable.addConstantUtf8("InnerClasses"))
|
||||
.putInt(this.byteVector.length + 2)
|
||||
.putShort(this.count)
|
||||
.putByteArray(this.byteVector.data, 0, this.byteVector.length);
|
||||
}
|
||||
if (this.count11 != 0) {
|
||||
byteVector5
|
||||
.putShort(this.symbolTable.addConstantUtf8("EnclosingMethod"))
|
||||
.putInt(4)
|
||||
.putShort(this.count11)
|
||||
.putShort(this.count13);
|
||||
}
|
||||
if ((this.count5 & 4096) != 0 && (this.count10 & 65535) < 49) {
|
||||
byteVector5.putShort(this.symbolTable.addConstantUtf8("Synthetic")).putInt(0);
|
||||
}
|
||||
if (this.count3 != 0) {
|
||||
byteVector5
|
||||
.putShort(this.symbolTable.addConstantUtf8("Signature"))
|
||||
.putInt(2)
|
||||
.putShort(this.count3);
|
||||
}
|
||||
if (this.count4 != 0) {
|
||||
byteVector5
|
||||
.putShort(this.symbolTable.addConstantUtf8("SourceFile"))
|
||||
.putInt(2)
|
||||
.putShort(this.count4);
|
||||
}
|
||||
if (this.byteVector2 != null) {
|
||||
int value28 = this.byteVector2.length;
|
||||
byteVector5
|
||||
.putShort(this.symbolTable.addConstantUtf8("SourceDebugExtension"))
|
||||
.putInt(value28)
|
||||
.putByteArray(this.byteVector2.data, 0, value28);
|
||||
}
|
||||
if ((this.count5 & 131072) != 0) {
|
||||
byteVector5.putShort(this.symbolTable.addConstantUtf8("Deprecated")).putInt(0);
|
||||
}
|
||||
AnnotationWriter.putAnnotations(
|
||||
this.symbolTable,
|
||||
this.annotationWriter,
|
||||
this.annotationWriter4,
|
||||
this.annotationWriter3,
|
||||
this.annotationWriter2,
|
||||
byteVector5);
|
||||
this.symbolTable.processByteVector2(byteVector5);
|
||||
if (this.moduleWriter != null) {
|
||||
this.moduleWriter.putAttributes(byteVector5);
|
||||
}
|
||||
if (this.count14 != 0) {
|
||||
byteVector5
|
||||
.putShort(this.symbolTable.addConstantUtf8("NestHost"))
|
||||
.putInt(2)
|
||||
.putShort(this.count14);
|
||||
}
|
||||
if (this.byteVector4 != null) {
|
||||
byteVector5
|
||||
.putShort(this.symbolTable.addConstantUtf8("NestMembers"))
|
||||
.putInt(this.byteVector4.length + 2)
|
||||
.putShort(this.count7)
|
||||
.putByteArray(this.byteVector4.data, 0, this.byteVector4.length);
|
||||
}
|
||||
if (this.byteVector3 != null) {
|
||||
byteVector5
|
||||
.putShort(this.symbolTable.addConstantUtf8("PermittedSubclasses"))
|
||||
.putInt(this.byteVector3.length + 2)
|
||||
.putShort(this.count9)
|
||||
.putByteArray(this.byteVector3.data, 0, this.byteVector3.length);
|
||||
}
|
||||
if ((this.count5 & 65536) != 0 || this.recordComponentWriter2 != null) {
|
||||
byteVector5
|
||||
.putShort(this.symbolTable.addConstantUtf8("Record"))
|
||||
.putInt(value19 + 2)
|
||||
.putShort(value18);
|
||||
RecordComponentWriter recordComponentWriter4 = this.recordComponentWriter2;
|
||||
for (RecordComponentWriter recordComponentWriter5 = recordComponentWriter4;
|
||||
recordComponentWriter5 != null;
|
||||
recordComponentWriter5 =
|
||||
recordComponentWriter4 = (RecordComponentWriter) recordComponentWriter4.delegate) {
|
||||
recordComponentWriter4.putRecordComponentInfo(byteVector5);
|
||||
}
|
||||
}
|
||||
if (this.firstAttribute != null) {
|
||||
this.firstAttribute.putAttributes(this.symbolTable, byteVector5);
|
||||
}
|
||||
return matches2 ? this.replaceAsmInstructions(byteVector5.data, matches) : byteVector5.data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final AnnotationVisitor visitTypeAnnotation(
|
||||
int value, TypePath typePath, String text, boolean matches) {
|
||||
return matches
|
||||
? (this.annotationWriter3 =
|
||||
AnnotationWriter.create(
|
||||
this.symbolTable, value, typePath, text, this.annotationWriter3))
|
||||
: (this.annotationWriter2 =
|
||||
AnnotationWriter.create(
|
||||
this.symbolTable, value, typePath, text, this.annotationWriter2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void visitOuterClass(String text, String text2, String text3) {
|
||||
this.count11 = this.symbolTable.getSymbol3(text).index;
|
||||
if (text2 != null && text3 != null) {
|
||||
this.count13 = this.symbolTable.addConstantNameAndType(text2, text3);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void visitInnerClass(String text, String text2, String text3, int value) {
|
||||
if (this.byteVector == null) {
|
||||
this.byteVector = new ByteVector();
|
||||
}
|
||||
Symbol symbol;
|
||||
if ((symbol = this.symbolTable.getSymbol3(text)).count == 0) {
|
||||
this.count++;
|
||||
this.byteVector.putShort(symbol.index);
|
||||
this.byteVector.putShort(text2 == null ? 0 : this.symbolTable.getSymbol3(text2).index);
|
||||
this.byteVector.putShort(text3 == null ? 0 : this.symbolTable.addConstantUtf8(text3));
|
||||
this.byteVector.putShort(value);
|
||||
symbol.count = this.count;
|
||||
}
|
||||
}
|
||||
|
||||
public ClassWriter(ClassReader classReader, int flags) {
|
||||
super(589824);
|
||||
this.flags = flags;
|
||||
this.symbolTable =
|
||||
classReader == null ? new SymbolTable(this) : new SymbolTable(this, classReader);
|
||||
this.setFlags(flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final MethodVisitor visitMethod(
|
||||
int value, String text, String text2, String text3, String[] texts) {
|
||||
MethodWriter methodWriter3 =
|
||||
new MethodWriter(this.symbolTable, value, text, text2, text3, texts, this.count8);
|
||||
ClassWriter classWriter;
|
||||
if (this.methodWriter == null) {
|
||||
classWriter = this;
|
||||
this.methodWriter = methodWriter3;
|
||||
} else {
|
||||
classWriter = this;
|
||||
this.methodWriter2.mv = methodWriter3;
|
||||
}
|
||||
return classWriter.methodWriter2 = methodWriter3;
|
||||
}
|
||||
|
||||
public int calculateCount4(String text) {
|
||||
return this.symbolTable.getSymbol4(text).index;
|
||||
}
|
||||
|
||||
public int newUTF8(String text) {
|
||||
return this.symbolTable.addConstantUtf8(text);
|
||||
}
|
||||
|
||||
public int newMethod(String text, String text2, String text3, boolean matches) {
|
||||
return this.symbolTable.addConstantMethodref(text, text2, text3, matches).index;
|
||||
}
|
||||
|
||||
public final void setFlags(int value) {
|
||||
if ((value & 2) != 0) {
|
||||
this.count8 = 4;
|
||||
} else if ((value & 1) != 0) {
|
||||
this.count8 = 1;
|
||||
} else {
|
||||
this.count8 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final FieldVisitor visitField(
|
||||
int value, String text, String text2, String text3, Object result) {
|
||||
FieldWriter fieldWriter3 = new FieldWriter(this.symbolTable, value, text, text2, text3, result);
|
||||
ClassWriter classWriter;
|
||||
if (this.fieldWriter == null) {
|
||||
classWriter = this;
|
||||
this.fieldWriter = fieldWriter3;
|
||||
} else {
|
||||
classWriter = this;
|
||||
this.fieldWriter2.fv = fieldWriter3;
|
||||
}
|
||||
return classWriter.fieldWriter2 = fieldWriter3;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.allatori.lib.asm;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public final class ConstantDynamic {
|
||||
|
||||
public final String name;
|
||||
|
||||
public final String descriptor;
|
||||
|
||||
public final Handle bootstrapMethod;
|
||||
|
||||
public final Object[] bootstrapMethodArguments;
|
||||
|
||||
public static String stringConcat$0(String text, String text2, String text3, String text4) {
|
||||
return "" + text + " : " + text2 + " " + text3 + " " + text4;
|
||||
}
|
||||
|
||||
public ConstantDynamic(String name, String descriptor, Handle handle, Object... result) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.descriptor = descriptor;
|
||||
this.bootstrapMethod = handle;
|
||||
this.bootstrapMethodArguments = (Object[]) result;
|
||||
}
|
||||
|
||||
public int getBootstrapMethodArgumentCount() {
|
||||
return this.bootstrapMethodArguments.length;
|
||||
}
|
||||
|
||||
public Handle getBootstrapMethod() {
|
||||
return this.bootstrapMethod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object result) {
|
||||
if (result == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(result instanceof ConstantDynamic)) {
|
||||
return false;
|
||||
}
|
||||
ConstantDynamic constantDynamic = (ConstantDynamic) result;
|
||||
return this.name.equals(constantDynamic.name)
|
||||
&& this.descriptor.equals(constantDynamic.descriptor)
|
||||
&& this.bootstrapMethod.equals(constantDynamic.bootstrapMethod)
|
||||
&& Arrays.equals(this.bootstrapMethodArguments, constantDynamic.bootstrapMethodArguments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.name.hashCode()
|
||||
^ Integer.rotateLeft(this.descriptor.hashCode(), 8)
|
||||
^ Integer.rotateLeft(this.bootstrapMethod.hashCode(), 16)
|
||||
^ Integer.rotateLeft(Arrays.hashCode(this.bootstrapMethodArguments), 24);
|
||||
}
|
||||
|
||||
public Object[] getBootstrapMethodArgumentsUnsafe() {
|
||||
return this.bootstrapMethodArguments;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getDescriptor() {
|
||||
return this.descriptor;
|
||||
}
|
||||
|
||||
public Object getBootstrapMethodArgument(int value) {
|
||||
return this.bootstrapMethodArguments[value];
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
char value;
|
||||
return (value = this.descriptor.charAt(0)) != 74 && value != 68 ? 1 : 2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
package com.allatori.lib.asm;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public final class Constants {
|
||||
|
||||
public static final String TEXT8 = "ConstantValue";
|
||||
|
||||
public static final String TEXT26 = "Code";
|
||||
|
||||
public static final String TEXT17 = "StackMapTable";
|
||||
|
||||
public static final String TEXT10 = "Exceptions";
|
||||
|
||||
public static final String TEXT5 = "InnerClasses";
|
||||
|
||||
public static final String TEXT25 = "EnclosingMethod";
|
||||
|
||||
public static final String TEXT29 = "Synthetic";
|
||||
|
||||
public static final String TEXT3 = "Signature";
|
||||
|
||||
public static final String TEXT15 = "SourceFile";
|
||||
|
||||
public static final String TEXT14 = "SourceDebugExtension";
|
||||
|
||||
public static final String TEXT13 = "LineNumberTable";
|
||||
|
||||
public static final String TEXT27 = "LocalVariableTable";
|
||||
|
||||
public static final String TEXT30 = "LocalVariableTypeTable";
|
||||
|
||||
public static final String TEXT2 = "Deprecated";
|
||||
|
||||
public static final String TEXT20 = "RuntimeVisibleAnnotations";
|
||||
|
||||
public static final String TEXT7 = "RuntimeInvisibleAnnotations";
|
||||
|
||||
public static final String TEXT = "RuntimeVisibleParameterAnnotations";
|
||||
|
||||
public static final String TEXT23 = "RuntimeInvisibleParameterAnnotations";
|
||||
|
||||
public static final String TEXT21 = "RuntimeVisibleTypeAnnotations";
|
||||
|
||||
public static final String TEXT9 = "RuntimeInvisibleTypeAnnotations";
|
||||
|
||||
public static final String TEXT22 = "AnnotationDefault";
|
||||
|
||||
public static final String TEXT11 = "BootstrapMethods";
|
||||
|
||||
public static final String TEXT4 = "MethodParameters";
|
||||
|
||||
public static final String TEXT19 = "Module";
|
||||
|
||||
public static final String TEXT16 = "ModulePackages";
|
||||
|
||||
public static final String TEXT18 = "ModuleMainClass";
|
||||
|
||||
public static final String TEXT24 = "NestHost";
|
||||
|
||||
public static final String TEXT12 = "NestMembers";
|
||||
|
||||
public static final String TEXT28 = "PermittedSubclasses";
|
||||
|
||||
public static final String TEXT6 = "Record";
|
||||
|
||||
public static final int FSTORE_3 = 70;
|
||||
|
||||
public static final int ILOAD_1 = 27;
|
||||
|
||||
public static final int LSTORE_3 = 66;
|
||||
|
||||
public static final int COUNT = 20;
|
||||
|
||||
public static final int LSTORE_2 = 65;
|
||||
|
||||
public static final int ASM_GOTO_W = 220;
|
||||
|
||||
public static final int ASM_IFNE = 203;
|
||||
|
||||
public static final int ASM_JSR = 217;
|
||||
|
||||
public static final int ILOAD_3 = 29;
|
||||
|
||||
public static final int FLOAD_3 = 37;
|
||||
|
||||
public static final int ALOAD_0 = 42;
|
||||
|
||||
public static final int ASM_IF_ICMPGT = 212;
|
||||
|
||||
public static final int FLOAD_0 = 34;
|
||||
|
||||
public static final int LSTORE_0 = 63;
|
||||
|
||||
public static final int DLOAD_3 = 41;
|
||||
|
||||
public static final int COUNT2 = 33;
|
||||
|
||||
public static final int ASM_IF_ACMPNE = 215;
|
||||
|
||||
public static final int ASM_IFGE = 205;
|
||||
|
||||
public static final int DSTORE_0 = 71;
|
||||
|
||||
public static final int F_INSERT = 256;
|
||||
|
||||
public static final int ACC_CONSTRUCTOR = 262144;
|
||||
|
||||
public static final int ASTORE_2 = 77;
|
||||
|
||||
public static final int ASM_IF_ICMPLT = 210;
|
||||
|
||||
public static final int ASM_IF_ICMPLE = 213;
|
||||
|
||||
public static final int COUNT3 = 20;
|
||||
|
||||
public static final int ASM_IF_ACMPEQ = 214;
|
||||
|
||||
public static final int GOTO_W = 200;
|
||||
|
||||
public static final int LLOAD_0 = 30;
|
||||
|
||||
public static final int ASM_IFNONNULL = 219;
|
||||
|
||||
public static final int FLOAD_2 = 36;
|
||||
|
||||
public static final int ILOAD_0 = 26;
|
||||
|
||||
public static final int DSTORE_3 = 74;
|
||||
|
||||
public static final int ASM_IF_ICMPEQ = 208;
|
||||
|
||||
public static final int ASM_IFEQ = 202;
|
||||
|
||||
public static final int JSR_W = 201;
|
||||
|
||||
public static final int DLOAD_2 = 40;
|
||||
|
||||
public static final int DLOAD_1 = 39;
|
||||
|
||||
public static final int ASTORE_1 = 76;
|
||||
|
||||
public static final int LLOAD_1 = 31;
|
||||
|
||||
public static final int FLOAD_1 = 35;
|
||||
|
||||
public static final int ASM_IFGT = 206;
|
||||
|
||||
public static final int LSTORE_1 = 64;
|
||||
|
||||
public static final int ASM_IF_ICMPNE = 209;
|
||||
|
||||
public static final int ISTORE_3 = 62;
|
||||
|
||||
public static final int DSTORE_1 = 72;
|
||||
|
||||
public static final int ASTORE_3 = 78;
|
||||
|
||||
public static final int ILOAD_2 = 28;
|
||||
|
||||
public static final int FSTORE_0 = 67;
|
||||
|
||||
public static final int ISTORE_1 = 60;
|
||||
|
||||
public static final int ASM_IF_ICMPGE = 211;
|
||||
|
||||
public static final int DLOAD_0 = 38;
|
||||
|
||||
public static final int FSTORE_2 = 69;
|
||||
|
||||
public static final int ASM_OPCODE_DELTA = 49;
|
||||
|
||||
public static final int COUNT4 = 33;
|
||||
|
||||
public static final int ASM_IFLT = 204;
|
||||
|
||||
public static final int ASM_IFNULL = 218;
|
||||
|
||||
public static final int DSTORE_2 = 73;
|
||||
|
||||
public static final int FSTORE_1 = 68;
|
||||
|
||||
public static final int LDC_W = 19;
|
||||
|
||||
public static final int ASTORE_0 = 75;
|
||||
|
||||
public static final int ISTORE_0 = 59;
|
||||
|
||||
public static final int WIDE = 196;
|
||||
|
||||
public static final int LLOAD_2 = 32;
|
||||
|
||||
public static final int ALOAD_1 = 43;
|
||||
|
||||
public static final int ALOAD_2 = 44;
|
||||
|
||||
public static final int ASM_GOTO = 216;
|
||||
|
||||
public static final int ASM_IFLE = 207;
|
||||
|
||||
public static final int ISTORE_2 = 61;
|
||||
|
||||
public static final int ALOAD_3 = 45;
|
||||
|
||||
public static String createText(String text) {
|
||||
return "" + text + ".class";
|
||||
}
|
||||
|
||||
public static boolean isWhitelisted(String text) {
|
||||
if (!text.startsWith("org/objectweb/asm/")) {
|
||||
return false;
|
||||
}
|
||||
String text2 = "(Annotation|Class|Field|Method|Module|RecordComponent|Signature)";
|
||||
return text.contains("Test$")
|
||||
|| Pattern.matches(createText3(text2), text)
|
||||
|| Pattern.matches(createText2(text2), text);
|
||||
}
|
||||
|
||||
public static void checkAsmExperimental(Object result) {
|
||||
Class classValue;
|
||||
String text;
|
||||
if (!isWhitelisted(text = (classValue = result.getClass()).getName().replace('.', '/'))) {
|
||||
checkIsPreview(classValue.getClassLoader().getResourceAsStream(createText(text)));
|
||||
}
|
||||
}
|
||||
|
||||
public static String createText2(String text) {
|
||||
return "org/objectweb/asm/util/Check" + text + "Adapter(\\$.*)?";
|
||||
}
|
||||
|
||||
public static void checkIsPreview(InputStream inputStream) {
|
||||
if (inputStream == null) {
|
||||
throw new IllegalStateException("Bytecode not available, can't check class version");
|
||||
}
|
||||
int value;
|
||||
try {
|
||||
DataInputStream dataInputStream = new DataInputStream(inputStream);
|
||||
try {
|
||||
dataInputStream.readInt();
|
||||
value = dataInputStream.readUnsignedShort();
|
||||
} catch (Throwable throwable) {
|
||||
try {
|
||||
dataInputStream.close();
|
||||
} catch (Throwable throwable2) {
|
||||
throw throwable;
|
||||
}
|
||||
throw throwable;
|
||||
}
|
||||
dataInputStream.close();
|
||||
} catch (IOException oException) {
|
||||
throw new IllegalStateException("I/O error, can't check class version", oException);
|
||||
}
|
||||
if (value != 65535) {
|
||||
throw new IllegalStateException(
|
||||
"ASM10_EXPERIMENTAL can only be used by classes compiled with --enable-preview");
|
||||
}
|
||||
}
|
||||
|
||||
public static String createText3(String text) {
|
||||
return "org/objectweb/asm/util/Trace" + text + "Visitor(\\$.*)?";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.allatori.lib.asm;
|
||||
|
||||
public final class Context {
|
||||
|
||||
public Object[] values;
|
||||
|
||||
public Attribute[] attributePrototypes;
|
||||
|
||||
public TypePath currentTypeAnnotationTargetPath;
|
||||
|
||||
public int count;
|
||||
|
||||
public Label[] labels;
|
||||
|
||||
public Label[] labels2;
|
||||
|
||||
public int count2;
|
||||
|
||||
public Label[] labels3;
|
||||
|
||||
public int count3;
|
||||
|
||||
public int[] currentLocalVariableAnnotationRangeIndices;
|
||||
|
||||
public int count4;
|
||||
|
||||
public char[] charBuffer;
|
||||
|
||||
public String text;
|
||||
|
||||
public String text2;
|
||||
|
||||
public int count5;
|
||||
|
||||
public int count6;
|
||||
|
||||
public int count7;
|
||||
|
||||
public int count8;
|
||||
|
||||
public Object[] values2;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.allatori.lib.asm;
|
||||
|
||||
public final class CurrentFrame extends Frame {
|
||||
|
||||
public CurrentFrame(Label label) {
|
||||
super(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(int value, int value2, Symbol symbol, SymbolTable symbolTable)
|
||||
throws ClassNotFoundException {
|
||||
super.execute(value, value2, symbol, symbolTable);
|
||||
Frame frame = new Frame(null);
|
||||
this.merge(symbolTable, frame, 0);
|
||||
this.copyFrom(frame);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.allatori.lib.asm;
|
||||
|
||||
public final class Edge {
|
||||
|
||||
public final Label successor;
|
||||
|
||||
public final int info;
|
||||
|
||||
public static final int JUMP = 0;
|
||||
|
||||
public static final int EXCEPTION = Integer.MAX_VALUE;
|
||||
|
||||
public Edge nextEdge;
|
||||
|
||||
public Edge(int info, Label label, Edge edge) {
|
||||
super();
|
||||
this.info = info;
|
||||
this.successor = label;
|
||||
this.nextEdge = edge;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.allatori.lib.asm;
|
||||
|
||||
public abstract class FieldVisitor {
|
||||
|
||||
public FieldVisitor fv;
|
||||
|
||||
public final int api;
|
||||
|
||||
public AnnotationVisitor visitAnnotation(String text, boolean matches) {
|
||||
return this.fv != null ? this.fv.visitAnnotation(text, matches) : null;
|
||||
}
|
||||
|
||||
public void visitEnd() {
|
||||
if (this.fv != null) {
|
||||
this.fv.visitEnd();
|
||||
}
|
||||
}
|
||||
|
||||
public static String stringConcat$0(int value) {
|
||||
return "Unsupported api " + value;
|
||||
}
|
||||
|
||||
public AnnotationVisitor visitTypeAnnotation(
|
||||
int value, TypePath typePath, String text, boolean matches) {
|
||||
if (this.api < 327680) {
|
||||
throw new UnsupportedOperationException("This feature requires ASM5");
|
||||
} else {
|
||||
return this.fv != null ? this.fv.visitTypeAnnotation(value, typePath, text, matches) : null;
|
||||
}
|
||||
}
|
||||
|
||||
public void visitAttribute(Attribute attribute) {
|
||||
if (this.fv != null) {
|
||||
this.fv.visitAttribute(attribute);
|
||||
}
|
||||
}
|
||||
|
||||
public FieldVisitor getDelegate() {
|
||||
return this.fv;
|
||||
}
|
||||
|
||||
public FieldVisitor(int value) {
|
||||
this(value, null);
|
||||
}
|
||||
|
||||
public FieldVisitor(int api, FieldVisitor fieldVisitor) {
|
||||
super();
|
||||
if (api != 589824
|
||||
&& api != 524288
|
||||
&& api != 458752
|
||||
&& api != 393216
|
||||
&& api != 327680
|
||||
&& api != 262144
|
||||
&& api != 17432576) {
|
||||
throw new IllegalArgumentException(stringConcat$0(api));
|
||||
}
|
||||
if (api == 17432576) {
|
||||
Constants.checkAsmExperimental(this);
|
||||
}
|
||||
this.api = api;
|
||||
this.fv = fieldVisitor;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
package com.allatori.lib.asm;
|
||||
|
||||
public final class FieldWriter extends FieldVisitor {
|
||||
|
||||
public final int accessFlags;
|
||||
|
||||
public AnnotationWriter annotationWriter;
|
||||
|
||||
public AnnotationWriter annotationWriter2;
|
||||
|
||||
public AnnotationWriter annotationWriter3;
|
||||
|
||||
public final int descriptorIndex;
|
||||
|
||||
public final int nameIndex;
|
||||
|
||||
public int signatureIndex;
|
||||
|
||||
public int constantValueIndex;
|
||||
|
||||
public Attribute firstAttribute;
|
||||
|
||||
public final SymbolTable symbolTable;
|
||||
|
||||
public AnnotationWriter annotationWriter4;
|
||||
|
||||
@Override
|
||||
public AnnotationVisitor visitAnnotation(String text, boolean matches) {
|
||||
return matches
|
||||
? (this.annotationWriter4 =
|
||||
AnnotationWriter.create(this.symbolTable, text, this.annotationWriter4))
|
||||
: (this.annotationWriter2 =
|
||||
AnnotationWriter.create(this.symbolTable, text, this.annotationWriter2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitAttribute(Attribute attribute) {
|
||||
attribute.nextAttribute = this.firstAttribute;
|
||||
this.firstAttribute = attribute;
|
||||
}
|
||||
|
||||
public FieldWriter(
|
||||
SymbolTable symbolTable2,
|
||||
int accessFlags,
|
||||
String text,
|
||||
String text2,
|
||||
String text3,
|
||||
Object result) {
|
||||
super(589824);
|
||||
this.symbolTable = symbolTable2;
|
||||
this.accessFlags = accessFlags;
|
||||
this.nameIndex = symbolTable2.addConstantUtf8(text);
|
||||
this.descriptorIndex = symbolTable2.addConstantUtf8(text2);
|
||||
if (text3 != null) {
|
||||
this.signatureIndex = symbolTable2.addConstantUtf8(text3);
|
||||
}
|
||||
if (result != null) {
|
||||
this.constantValueIndex = symbolTable2.addConstant(result).index;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotationVisitor visitTypeAnnotation(
|
||||
int value, TypePath typePath, String text, boolean matches) {
|
||||
return matches
|
||||
? (this.annotationWriter =
|
||||
AnnotationWriter.create(this.symbolTable, value, typePath, text, this.annotationWriter))
|
||||
: (this.annotationWriter3 =
|
||||
AnnotationWriter.create(
|
||||
this.symbolTable, value, typePath, text, this.annotationWriter3));
|
||||
}
|
||||
|
||||
public int computeFieldInfoSize() {
|
||||
int value = 8;
|
||||
if (this.constantValueIndex != 0) {
|
||||
SymbolTable symbolTable2 = this.symbolTable;
|
||||
value += 8;
|
||||
symbolTable2.addConstantUtf8("ConstantValue");
|
||||
}
|
||||
int value2 =
|
||||
value
|
||||
+ Attribute.computeAttributesSize(
|
||||
this.symbolTable, this.accessFlags, this.signatureIndex)
|
||||
+ AnnotationWriter.computeAnnotationsSize(
|
||||
this.annotationWriter4,
|
||||
this.annotationWriter2,
|
||||
this.annotationWriter,
|
||||
this.annotationWriter3);
|
||||
if (this.firstAttribute != null) {
|
||||
value2 += this.firstAttribute.computeAttributesSize(this.symbolTable);
|
||||
}
|
||||
return value2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitEnd() {}
|
||||
|
||||
public final void collectAttributePrototypes(Attribute$Set attribute$Set) {
|
||||
attribute$Set.addAttributes(this.firstAttribute);
|
||||
}
|
||||
|
||||
public void putFieldInfo(ByteVector byteVector) {
|
||||
int value = this.symbolTable.getCount() < 49 ? 1 : 0;
|
||||
int value2 = value != 0 ? 4096 : 0;
|
||||
byteVector
|
||||
.putShort(this.accessFlags & ~value2)
|
||||
.putShort(this.nameIndex)
|
||||
.putShort(this.descriptorIndex);
|
||||
int value3 = 0;
|
||||
if (this.constantValueIndex != 0) {
|
||||
value3++;
|
||||
}
|
||||
if ((this.accessFlags & 4096) != 0 && value != 0) {
|
||||
value3++;
|
||||
}
|
||||
if (this.signatureIndex != 0) {
|
||||
value3++;
|
||||
}
|
||||
if ((this.accessFlags & 131072) != 0) {
|
||||
value3++;
|
||||
}
|
||||
if (this.annotationWriter4 != null) {
|
||||
value3++;
|
||||
}
|
||||
if (this.annotationWriter2 != null) {
|
||||
value3++;
|
||||
}
|
||||
if (this.annotationWriter != null) {
|
||||
value3++;
|
||||
}
|
||||
if (this.annotationWriter3 != null) {
|
||||
value3++;
|
||||
}
|
||||
if (this.firstAttribute != null) {
|
||||
value3 += this.firstAttribute.getAttributeCount();
|
||||
}
|
||||
byteVector.putShort(value3);
|
||||
if (this.constantValueIndex != 0) {
|
||||
byteVector
|
||||
.putShort(this.symbolTable.addConstantUtf8("ConstantValue"))
|
||||
.putInt(2)
|
||||
.putShort(this.constantValueIndex);
|
||||
}
|
||||
Attribute.putAttributes(this.symbolTable, this.accessFlags, this.signatureIndex, byteVector);
|
||||
AnnotationWriter.putAnnotations(
|
||||
this.symbolTable,
|
||||
this.annotationWriter4,
|
||||
this.annotationWriter2,
|
||||
this.annotationWriter,
|
||||
this.annotationWriter3,
|
||||
byteVector);
|
||||
if (this.firstAttribute != null) {
|
||||
this.firstAttribute.putAttributes(this.symbolTable, byteVector);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,76 @@
|
||||
package com.allatori.lib.asm;
|
||||
|
||||
public final class Handle {
|
||||
|
||||
public final boolean isInterface;
|
||||
|
||||
public final String name;
|
||||
|
||||
public final int tag;
|
||||
|
||||
public final String descriptor;
|
||||
|
||||
public final String owner;
|
||||
|
||||
public String getOwner() {
|
||||
return this.owner;
|
||||
}
|
||||
|
||||
public int getTag() {
|
||||
return this.tag;
|
||||
}
|
||||
|
||||
public Handle(int tag, String owner, String name, String descriptor, boolean isInterface) {
|
||||
super();
|
||||
this.tag = tag;
|
||||
this.owner = owner;
|
||||
this.name = name;
|
||||
this.descriptor = descriptor;
|
||||
this.isInterface = isInterface;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object result) {
|
||||
if (result == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(result instanceof Handle)) {
|
||||
return false;
|
||||
}
|
||||
Handle handle = (Handle) result;
|
||||
return this.tag == handle.tag
|
||||
&& this.isInterface == handle.isInterface
|
||||
&& this.owner.equals(handle.owner)
|
||||
&& this.name.equals(handle.name)
|
||||
&& this.descriptor.equals(handle.descriptor);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Handle(int value, String text, String text2, String text3) {
|
||||
this(value, text, text2, text3, value == 9);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getDescriptor() {
|
||||
return this.descriptor;
|
||||
}
|
||||
|
||||
public boolean isInterface() {
|
||||
return this.isInterface;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.tag
|
||||
+ (this.isInterface ? 64 : 0)
|
||||
+ this.owner.hashCode() * this.name.hashCode() * this.descriptor.hashCode();
|
||||
}
|
||||
|
||||
public static String stringConcat$0(
|
||||
String text, String text2, String text3, int value, String text4) {
|
||||
return "" + text + "." + text2 + text3 + " (" + value + text4 + ")";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.allatori.lib.asm;
|
||||
|
||||
public final class Handler {
|
||||
|
||||
public final String catchTypeDescriptor;
|
||||
|
||||
public final int catchType;
|
||||
|
||||
public final Label handlerPc;
|
||||
|
||||
public Handler nextHandler;
|
||||
|
||||
public final Label startPc;
|
||||
|
||||
public final Label endPc;
|
||||
|
||||
public static Handler removeRange(Handler handler, Label label, Label label2) {
|
||||
if (handler == null) {
|
||||
return null;
|
||||
}
|
||||
handler.nextHandler = removeRange(handler.nextHandler, label, label2);
|
||||
int value = handler.startPc.bytecodeOffset;
|
||||
int value2 = handler.endPc.bytecodeOffset;
|
||||
int value3 = label.bytecodeOffset;
|
||||
int value4 = label2 == null ? Integer.MAX_VALUE : label2.bytecodeOffset;
|
||||
if (value3 >= value2 || value4 <= value) {
|
||||
return handler;
|
||||
}
|
||||
if (value3 <= value) {
|
||||
return value4 >= value2 ? handler.nextHandler : new Handler(handler, label2, handler.endPc);
|
||||
}
|
||||
if (value4 >= value2) {
|
||||
return new Handler(handler, handler.startPc, label);
|
||||
}
|
||||
handler.nextHandler = new Handler(handler, label2, handler.endPc);
|
||||
return new Handler(handler, handler.startPc, label);
|
||||
}
|
||||
|
||||
public static void putExceptionTable(Handler handler, ByteVector byteVector) {
|
||||
byteVector.putShort(calculateCount(handler));
|
||||
Handler handler2 = handler;
|
||||
for (Handler handler3 = handler2; handler3 != null; handler3 = handler2) {
|
||||
byteVector
|
||||
.putShort(handler2.startPc.bytecodeOffset)
|
||||
.putShort(handler2.endPc.bytecodeOffset)
|
||||
.putShort(handler2.handlerPc.bytecodeOffset)
|
||||
.putShort(handler2.catchType);
|
||||
handler2 = handler2.nextHandler;
|
||||
}
|
||||
}
|
||||
|
||||
public static int calculateCount(Handler handler) {
|
||||
int value = 0;
|
||||
Handler handler2;
|
||||
Handler handler3 = handler2 = handler;
|
||||
while (handler3 != null) {
|
||||
Handler handler4 = handler2.nextHandler;
|
||||
Handler handler5 = handler2.nextHandler;
|
||||
value++;
|
||||
handler3 = handler5;
|
||||
handler2 = handler4;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public Handler(
|
||||
Label label, Label label2, Label label3, int catchType, String catchTypeDescriptor) {
|
||||
super();
|
||||
this.startPc = label;
|
||||
this.endPc = label2;
|
||||
this.handlerPc = label3;
|
||||
this.catchType = catchType;
|
||||
this.catchTypeDescriptor = catchTypeDescriptor;
|
||||
}
|
||||
|
||||
public static int calculateCount2(Handler handler) {
|
||||
return 2 + 8 * calculateCount(handler);
|
||||
}
|
||||
|
||||
public Handler(Handler handler, Label label, Label label2) {
|
||||
this(label, label2, handler.handlerPc, handler.catchType, handler.catchTypeDescriptor);
|
||||
this.nextHandler = handler.nextHandler;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
package com.allatori.lib.asm;
|
||||
|
||||
public class Label {
|
||||
|
||||
public static final int FLAG_DEBUG_ONLY = 1;
|
||||
|
||||
public static final int FORWARD_REFERENCE_TYPE_MASK = -268435456;
|
||||
|
||||
public static final int FLAG_JUMP_TARGET = 2;
|
||||
|
||||
public static final int FORWARD_REFERENCES_CAPACITY_INCREMENT = 6;
|
||||
|
||||
public Frame frame;
|
||||
|
||||
public static final int FLAG_LINE_NUMBER = 128;
|
||||
|
||||
public static final int FORWARD_REFERENCE_TYPE_SHORT = 268435456;
|
||||
|
||||
public Edge outgoingEdges;
|
||||
|
||||
public static final int FLAG_SUBROUTINE_START = 32;
|
||||
|
||||
public short value;
|
||||
|
||||
public short value2;
|
||||
|
||||
public int[] counts;
|
||||
|
||||
public static final int FORWARD_REFERENCE_TYPE_STACK_MAP = 805306368;
|
||||
|
||||
public Label label;
|
||||
|
||||
public int bytecodeOffset;
|
||||
|
||||
public Object info;
|
||||
|
||||
public static final Label EMPTY_LIST = new Label();
|
||||
|
||||
public short value3;
|
||||
|
||||
public short value4;
|
||||
|
||||
public static final int FORWARD_REFERENCE_HANDLE_MASK = 268435455;
|
||||
|
||||
public Label label2;
|
||||
|
||||
public static final int COUNT = 4;
|
||||
|
||||
public static final int FLAG_SUBROUTINE_END = 64;
|
||||
|
||||
public short value5;
|
||||
|
||||
public static final int COUNT2 = 4;
|
||||
|
||||
public static final int FLAG_SUBROUTINE_CALLER = 16;
|
||||
|
||||
public int[] counts2;
|
||||
|
||||
public static final int FLAG_REACHABLE = 8;
|
||||
|
||||
public short value6;
|
||||
|
||||
public static final int FORWARD_REFERENCE_TYPE_WIDE = 536870912;
|
||||
|
||||
public static String stringConcat$0(int value) {
|
||||
return "L" + value;
|
||||
}
|
||||
|
||||
public final void put(ByteVector byteVector) {
|
||||
if ((this.value3 & 4) == 0) {
|
||||
this.addForwardReference(0, 805306368, byteVector.length);
|
||||
}
|
||||
byteVector.putShort(this.bytecodeOffset);
|
||||
}
|
||||
|
||||
public int getOffset() {
|
||||
if ((this.value3 & 4) == 0) {
|
||||
throw new IllegalStateException("Label offset position has not been resolved yet");
|
||||
} else {
|
||||
return this.bytecodeOffset;
|
||||
}
|
||||
}
|
||||
|
||||
public void addForwardReference(int value, int value2, int value3) {
|
||||
if (this.counts2 == null) {
|
||||
this.counts2 = new int[6];
|
||||
}
|
||||
int value4;
|
||||
if ((value4 = this.counts2[0]) + 2 >= this.counts2.length) {
|
||||
int[] values = new int[this.counts2.length + 6];
|
||||
System.arraycopy(this.counts2, 0, values, 0, this.counts2.length);
|
||||
this.counts2 = values;
|
||||
}
|
||||
value4++;
|
||||
int value5 = value4;
|
||||
int[] values2 = this.counts2;
|
||||
value4++;
|
||||
values2[value5] = value;
|
||||
this.counts2[value4] = value2 | value3;
|
||||
this.counts2[0] = value4;
|
||||
}
|
||||
|
||||
public final void addSubroutineRetSuccessors(Label label2) {
|
||||
Label label3 = EMPTY_LIST;
|
||||
Label label4;
|
||||
Label label5 = label4 = this;
|
||||
this.label = EMPTY_LIST;
|
||||
while (label5 != EMPTY_LIST) {
|
||||
Label label6 = label4;
|
||||
Label label7 = label4.label;
|
||||
label4.label = label3;
|
||||
label3 = label4;
|
||||
if ((label4.value3 & 64) != 0 && label6.value2 != label2.value2) {
|
||||
label6.outgoingEdges =
|
||||
new Edge(label6.value5, label2.outgoingEdges.successor, label6.outgoingEdges);
|
||||
}
|
||||
label5 = label4 = label6.pushSuccessors(label7);
|
||||
}
|
||||
label5 = label3;
|
||||
while (label5 != EMPTY_LIST) {
|
||||
Label label8 = label3.label;
|
||||
label3.label = null;
|
||||
label5 = label3 = label8;
|
||||
}
|
||||
}
|
||||
|
||||
public final void addLineNumber(int value2) {
|
||||
if ((this.value3 & 128) == 0) {
|
||||
this.value3 = (short) (this.value3 | 128);
|
||||
this.value = (short) value2;
|
||||
} else {
|
||||
if (this.counts == null) {
|
||||
this.counts = new int[4];
|
||||
}
|
||||
int value4;
|
||||
if ((value4 = ++this.counts[0]) >= this.counts.length) {
|
||||
int[] values = new int[this.counts.length + 4];
|
||||
System.arraycopy(this.counts, 0, values, 0, this.counts.length);
|
||||
this.counts = values;
|
||||
}
|
||||
this.counts[value4] = value2;
|
||||
}
|
||||
}
|
||||
|
||||
public final Label getCanonicalInstance() {
|
||||
return this.frame == null ? this : this.frame.owner;
|
||||
}
|
||||
|
||||
public final boolean resolve(byte[] values, ByteVector byteVector, int bytecodeOffset) {
|
||||
this.value3 = (short) (this.value3 | 4);
|
||||
this.bytecodeOffset = bytecodeOffset;
|
||||
if (this.counts2 == null) {
|
||||
return false;
|
||||
}
|
||||
boolean matches = false;
|
||||
int value2;
|
||||
for (int value4 = value2 = this.counts2[0]; value4 > 0; value4 = value2) {
|
||||
int value5 = this.counts2[value2 - 1];
|
||||
int value6 = this.counts2[value2];
|
||||
int value7 = bytecodeOffset - value5;
|
||||
int value8 = value6 & 268435455;
|
||||
if ((value6 & -268435456) == 268435456) {
|
||||
if (value7 < -32768 || value7 > 32767) {
|
||||
int value9;
|
||||
if ((value9 = values[value5] & 255) < 198) {
|
||||
values[value5] = (byte) (value9 + 49);
|
||||
} else {
|
||||
values[value5] = (byte) (value9 + 20);
|
||||
}
|
||||
matches = true;
|
||||
}
|
||||
int value10 = value7 >>> 8;
|
||||
int value11 = value8;
|
||||
value8++;
|
||||
values[value11] = (byte) value10;
|
||||
values[value8] = (byte) value7;
|
||||
} else if ((value6 & -268435456) == 536870912) {
|
||||
int value12 = value7 >>> 24;
|
||||
int value13 = value8;
|
||||
value8++;
|
||||
values[value13] = (byte) value12;
|
||||
int value14 = value7 >>> 16;
|
||||
int value15 = value8;
|
||||
value8++;
|
||||
values[value15] = (byte) value14;
|
||||
int value16 = value7 >>> 8;
|
||||
int value17 = value8;
|
||||
value8++;
|
||||
values[value17] = (byte) value16;
|
||||
values[value8] = (byte) value7;
|
||||
} else {
|
||||
int value18 = bytecodeOffset >>> 8;
|
||||
int value19 = value8;
|
||||
byte[] values2 = byteVector.data;
|
||||
value8++;
|
||||
values2[value19] = (byte) value18;
|
||||
byteVector.data[value8] = (byte) bytecodeOffset;
|
||||
}
|
||||
value2 -= 2;
|
||||
}
|
||||
return matches;
|
||||
}
|
||||
|
||||
public Label pushSuccessors(Label label2) {
|
||||
Label label3 = label2;
|
||||
Edge edge;
|
||||
for (Edge edge2 = edge = this.outgoingEdges; edge2 != null; edge2 = edge = edge.nextEdge) {
|
||||
int value = (this.value3 & 16) != 0 && edge == this.outgoingEdges.nextEdge ? 1 : 0;
|
||||
if (value == 0 && edge.successor.label == null) {
|
||||
edge.successor.label = label3;
|
||||
label3 = edge.successor;
|
||||
}
|
||||
}
|
||||
return label3;
|
||||
}
|
||||
|
||||
public final void accept(MethodVisitor methodVisitor, boolean matches) {
|
||||
methodVisitor.visitLabel(this);
|
||||
if (matches && (this.value3 & 128) != 0) {
|
||||
methodVisitor.visitLineNumber(this.value & 65535, this);
|
||||
int value2;
|
||||
if (this.counts != null) {
|
||||
for (int value4 = value2 = 1; value4 <= this.counts[0]; value4 = value2) {
|
||||
int value5 = value2;
|
||||
int[] values = this.counts;
|
||||
value2++;
|
||||
methodVisitor.visitLineNumber(values[value5], this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final void put(ByteVector byteVector, int value, boolean matches) {
|
||||
if ((this.value3 & 4) == 0) {
|
||||
if (matches) {
|
||||
this.addForwardReference(value, 536870912, byteVector.length);
|
||||
byteVector.putInt(-1);
|
||||
} else {
|
||||
this.addForwardReference(value, 268435456, byteVector.length);
|
||||
byteVector.putShort(-1);
|
||||
}
|
||||
} else if (matches) {
|
||||
byteVector.putInt(this.bytecodeOffset - value);
|
||||
} else {
|
||||
byteVector.putShort(this.bytecodeOffset - value);
|
||||
}
|
||||
}
|
||||
|
||||
public final void markSubroutine(short value) {
|
||||
Label label2 = this;
|
||||
this.label = EMPTY_LIST;
|
||||
while (label2 != EMPTY_LIST) {
|
||||
Label label3 = label2;
|
||||
label2 = label2.label;
|
||||
label3.label = null;
|
||||
if (label3.value2 == 0) {
|
||||
label3.value2 = value;
|
||||
label2 = label3.pushSuccessors(label2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.allatori.lib.asm;
|
||||
|
||||
public final class MethodTooLargeException extends IndexOutOfBoundsException {
|
||||
|
||||
public final int codeSize;
|
||||
|
||||
public final String className;
|
||||
|
||||
public static final long serialVersionUID = 6807380416709738314L;
|
||||
|
||||
public final String descriptor;
|
||||
|
||||
public final String methodName;
|
||||
|
||||
public static String stringConcat$0(String text, String text2, String text3) {
|
||||
return "Method too large: " + text + "." + text2 + " " + text3;
|
||||
}
|
||||
|
||||
public String getDescriptor() {
|
||||
return this.descriptor;
|
||||
}
|
||||
|
||||
public int getCodeSize() {
|
||||
return this.codeSize;
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return this.className;
|
||||
}
|
||||
|
||||
public String getMethodName() {
|
||||
return this.methodName;
|
||||
}
|
||||
|
||||
public MethodTooLargeException(
|
||||
String className, String methodName, String descriptor, int codeSize) {
|
||||
super(stringConcat$0(className, methodName, descriptor));
|
||||
this.className = className;
|
||||
this.methodName = methodName;
|
||||
this.descriptor = descriptor;
|
||||
this.codeSize = codeSize;
|
||||
}
|
||||
}
|
||||
Loaded 100 of 629 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user