checkstyle - mixin processor

This commit is contained in:
Lucas
2019-05-17 03:04:15 +02:00
parent 0d8dbfee38
commit 7740b7a85e
18 changed files with 51 additions and 78 deletions

View File

@@ -33,10 +33,6 @@ import io.sigpipe.jbsdiff.Patch;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.LoaderClassPath;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import us.runelitepl.mixinprocessor.generators.AnnotationProcessor;
import us.runelitepl.mixinprocessor.generators.PatchGenerator;
@@ -50,14 +46,11 @@ import us.runelitepl.mixinprocessor.util.JavassistUtils;
import us.runelitepl.mixinprocessor.util.RefUtils;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -111,9 +104,9 @@ public class MixinProcessorMojo
public static HashMap<String, MethodGarbageValue> methodGarbageValues = new HashMap<>();
public static HashMap<String, byte[]> gamepack = new HashMap<>();
private static HashMap<String, byte[]> gamepack = new HashMap<>();
public static final int BUFFER_SIZE = 1024 * 1024 * 4;
private static final int BUFFER_SIZE = 1024 * 1024 * 4;
public void execute()
throws MojoExecutionException
@@ -257,7 +250,7 @@ public class MixinProcessorMojo
}
public void stderr(String s, Object... format)
private void stderr(String s, Object... format)
{
getLog().info(String.format(s, format));
}
@@ -267,7 +260,7 @@ public class MixinProcessorMojo
INST.stderr(s, format);
}
static void deleteDir(File file) throws IOException
private static void deleteDir(File file) throws IOException
{
if (!file.exists())
{

View File

@@ -31,5 +31,5 @@ public enum InjectionType
APPEND,
OVERWRITE,
PREPEND,
PROVIDED;
PROVIDED
}

View File

@@ -26,8 +26,6 @@
package us.runelitepl.mixinprocessor.generators;
import us.runelitepl.mixinprocessor.transformers.AnnotationRemoverTransformer;
import us.runelitepl.mixinprocessor.transformers.AsmMethodGarbageTransformer;
import us.runelitepl.mixinprocessor.transformers.AsmMethodSignatureTransformer;
import us.runelitepl.mixinprocessor.transformers.AsmNameTransformer;
import us.runelitepl.mixinprocessor.transformers.AsmStaticUsageTransformer;
import us.runelitepl.mixinprocessor.transformers.DoNothingTransformer;

View File

@@ -25,18 +25,12 @@
package us.runelitepl.mixinprocessor.generators;
import javassist.CannotCompileException;
import javassist.CtClass;
import javassist.NotFoundException;
import us.runelitepl.mixinprocessor.MixinProcessorMojo;
import us.runelitepl.mixinprocessor.util.JavassistUtils;
import us.runelitepl.mixinprocessor.util.RefUtils;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.MethodNode;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -45,11 +39,11 @@ import java.util.Set;
public class StaticGenerator
{
public static HashMap<String, ArrayList<MethodNode>> staticMethods = new HashMap<>();
public static HashMap<String, ArrayList<FieldNode>> staticFields = new HashMap<>();
public static Set<String> modifiedClasses = new HashSet<>();
static HashMap<String, ArrayList<MethodNode>> staticMethods = new HashMap<>();
static HashMap<String, ArrayList<FieldNode>> staticFields = new HashMap<>();
static Set<String> modifiedClasses = new HashSet<>();
public void run(byte[] bytecode) throws NotFoundException, IOException, CannotCompileException
public void run(byte[] bytecode)
{
ClassReader cr = new ClassReader(bytecode);

View File

@@ -36,7 +36,6 @@ import org.objectweb.asm.tree.AnnotationNode;
import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.TypeAnnotationNode;
import us.runelitepl.mixinprocessor.MixinProcessorMojo;
import us.runelitepl.mixinprocessor.parsers.MethodReflector;
import java.util.HashMap;

View File

@@ -56,7 +56,7 @@ public class GamepackDownloader
continue;
}
String key = entry.getName().replace(".class", "");
int len = 0;
int len;
while ((len = zipInputStream.read(buffer)) > 0)
{
fileContent.write(buffer, 0, len);
@@ -83,7 +83,7 @@ public class GamepackDownloader
}
}
public static String getGamepackUrl()
private static String getGamepackUrl()
{
return codebase + initial_jar;
}

View File

@@ -96,7 +96,7 @@ public class AnnotationRemoverTransformer extends AsmBaseTransformer
return cw.toByteArray();
}
public static String makeAnnotationDescriptor(String s)
static String makeAnnotationDescriptor(String s)
{
return "Lus/runelitepl/mixinprocessor/annotations/" + s + ";";
}

View File

@@ -35,9 +35,10 @@ public abstract class AsmBaseTransformer implements Opcodes
protected final ArrayList<String> validMethods = new ArrayList<>();
protected final ArrayList<String> validFields = new ArrayList<>();
// CHECKSTYLE:OFF
protected void buildMethodList(){}
protected void buildFieldList(){}
// CHECKSTYLE:ON
public abstract byte[] transform();

View File

@@ -32,8 +32,6 @@ import org.objectweb.asm.MethodVisitor;
import us.runelitepl.mixinprocessor.MethodGarbageValue;
import us.runelitepl.mixinprocessor.MixinProcessorMojo;
import us.runelitepl.mixinprocessor.util.RefUtils;
import java.sql.Ref;
import java.util.HashMap;
public class AsmMethodGarbageTransformer extends AsmBaseTransformer

View File

@@ -32,11 +32,6 @@ import org.objectweb.asm.MethodVisitor;
import us.runelitepl.mixinprocessor.MixinProcessorMojo;
import us.runelitepl.mixinprocessor.util.RefUtils;
import static org.objectweb.asm.Opcodes.ASM6;
import static org.objectweb.asm.Opcodes.GETSTATIC;
import static org.objectweb.asm.Opcodes.INVOKESTATIC;
import static org.objectweb.asm.Opcodes.PUTSTATIC;
public class AsmStaticUsageTransformer extends AsmBaseTransformer
{

View File

@@ -47,10 +47,10 @@ public class DoNothingTransformer extends AsmBaseTransformer
ClassReader cr = new ClassReader(bytecode);
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES);
// CHECKSTYLE:OFF
cr.accept(new ClassVisitor(ASM6, cw)
{}, 0);
//CHECKSTYLE:ON
return cw.toByteArray();
}
}

View File

@@ -169,11 +169,7 @@ public class RefUtils
i++;
}
}
if (i == 1)
{
return true;
}
return false;
return i == 1;
}
@Deprecated
@@ -187,11 +183,7 @@ public class RefUtils
i++;
}
}
if (i == 1)
{
return true;
}
return false;
return i == 1;
}
public static boolean shouldReobField(String owner, String deob, String desc)
@@ -275,7 +267,7 @@ public class RefUtils
{
obbedName = className;
}
deobbed.append("L" + obbedName + ";");
deobbed.append("L").append(obbedName ).append(";");
strIndex += sigPart.length();
}
catch (StringIndexOutOfBoundsException ex)

View File

@@ -50,14 +50,17 @@ public class WebUtils
return pageText;
}
public static byte[] downloadFile(String urlText) throws IOException {
public static byte[] downloadFile(String urlText) throws IOException
{
URL url = new URL(urlText);
ByteArrayOutputStream output = new ByteArrayOutputStream();
try (InputStream inputStream = url.openStream()) {
int n = 0;
try (InputStream inputStream = url.openStream())
{
int n;
byte [] buffer = new byte[ 1024 ];
while (-1 != (n = inputStream.read(buffer))) {
while (-1 != (n = inputStream.read(buffer)))
{
output.write(buffer, 0, n);
}
}