Preliminary Java 9 Support
This commit is contained in:
parent
2de90be7b9
commit
e9311dc423
6
pom.xml
6
pom.xml
@ -10,7 +10,7 @@
|
||||
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>SpecialSource</artifactId>
|
||||
<version>1.7.5-SNAPSHOT</version>
|
||||
<version>1.8.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>SpecialSource</name>
|
||||
@ -45,7 +45,7 @@
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-debug-all</artifactId>
|
||||
<version>5.2</version>
|
||||
<version>6.0_BETA</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -121,7 +121,7 @@
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<!--<minimizeJar>true</minimizeJar>-->
|
||||
<shadedArtifactAttached>true</shadedArtifactAttached>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
@ -71,7 +71,7 @@ public class JarComparer extends ClassVisitor {
|
||||
}
|
||||
|
||||
public JarComparer(Jar jar) {
|
||||
super(Opcodes.ASM5);
|
||||
super(Opcodes.ASM6);
|
||||
this.jar = jar;
|
||||
this.jarRepo = new JarRepo(jar);
|
||||
this.inheritance = new JarProvider(jar);
|
||||
@ -166,7 +166,7 @@ public class JarComparer extends ClassVisitor {
|
||||
private class MethodReferenceFinder extends MethodVisitor {
|
||||
|
||||
public MethodReferenceFinder() {
|
||||
super(Opcodes.ASM5);
|
||||
super(Opcodes.ASM6);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -60,54 +60,26 @@ package net.md_5.specialsource;
|
||||
*/
|
||||
|
||||
import net.md_5.specialsource.repo.ClassRepo;
|
||||
|
||||
import org.objectweb.asm.AnnotationVisitor;
|
||||
import org.objectweb.asm.Attribute;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.FieldVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import net.md_5.specialsource.CustomRemapper;
|
||||
import org.objectweb.asm.Label;
|
||||
import org.objectweb.asm.commons.RemappingAnnotationAdapter;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.commons.ClassRemapper;
|
||||
import org.objectweb.asm.commons.FieldRemapper;
|
||||
import org.objectweb.asm.commons.MethodRemapper;
|
||||
|
||||
/**
|
||||
* A {@link ClassVisitor} for type remapping.
|
||||
*
|
||||
* @author Eugene Kuleshov
|
||||
*/
|
||||
public class RemappingClassAdapter extends ClassVisitor {
|
||||
public class RemappingClassAdapter extends ClassRemapper {
|
||||
|
||||
protected final CustomRemapper remapper;
|
||||
protected ClassRepo repo;
|
||||
protected String className;
|
||||
|
||||
public RemappingClassAdapter(final ClassVisitor cv, final CustomRemapper remapper, ClassRepo repo) {
|
||||
this(Opcodes.ASM5, cv, remapper);
|
||||
super(cv, remapper);
|
||||
this.repo = repo;
|
||||
}
|
||||
|
||||
protected RemappingClassAdapter(final int api, final ClassVisitor cv, final CustomRemapper remapper) {
|
||||
super(api, cv);
|
||||
this.remapper = remapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(int version, int access, String name, String signature,
|
||||
String superName, String[] interfaces) {
|
||||
this.className = name;
|
||||
super.visit(version, access, remapper.mapType(name), remapper
|
||||
.mapSignature(signature, false), remapper.mapType(superName),
|
||||
interfaces == null ? null : remapper.mapTypes(interfaces));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
|
||||
AnnotationVisitor av;
|
||||
av = super.visitAnnotation(remapper.mapDesc(desc), visible);
|
||||
return av == null ? null : createRemappingAnnotationAdapter(av);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int access, String name, String desc,
|
||||
String signature, String[] exceptions) {
|
||||
@ -116,8 +88,7 @@ public class RemappingClassAdapter extends ClassVisitor {
|
||||
className, name, desc, access), newDesc, remapper.mapSignature(
|
||||
signature, false),
|
||||
exceptions == null ? null : remapper.mapTypes(exceptions));
|
||||
return mv == null ? null : createRemappingMethodAdapter(access,
|
||||
newDesc, mv);
|
||||
return mv == null ? null : createMethodRemapper(mv);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -127,7 +98,7 @@ public class RemappingClassAdapter extends ClassVisitor {
|
||||
remapper.mapFieldName(className, name, desc, access),
|
||||
remapper.mapDesc(desc), remapper.mapSignature(signature, true),
|
||||
remapper.mapValue(value));
|
||||
return fv == null ? null : createRemappingFieldAdapter(fv);
|
||||
return fv == null ? null : createFieldRemapper(fv);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -147,8 +118,9 @@ public class RemappingClassAdapter extends ClassVisitor {
|
||||
desc == null ? null : remapper.mapMethodDesc(desc));
|
||||
}
|
||||
|
||||
protected FieldVisitor createRemappingFieldAdapter(FieldVisitor sup) {
|
||||
return new FieldVisitor(Opcodes.ASM5, sup) {
|
||||
@Override
|
||||
protected FieldVisitor createFieldRemapper(FieldVisitor fv) {
|
||||
return new FieldRemapper(fv, remapper) {
|
||||
@Override
|
||||
public void visitAttribute(Attribute attr) {
|
||||
if (SpecialSource.kill_lvt && attr.type.equals("LocalVariableTable")) {
|
||||
@ -157,16 +129,15 @@ public class RemappingClassAdapter extends ClassVisitor {
|
||||
if (SpecialSource.kill_generics && attr.type.equals("LocalVariableTypeTable")) {
|
||||
return;
|
||||
}
|
||||
if (fv != null) {
|
||||
fv.visitAttribute(attr);
|
||||
}
|
||||
|
||||
super.visitAttribute(attr);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected MethodVisitor createRemappingMethodAdapter(int access, String newDesc, MethodVisitor sup) {
|
||||
MethodVisitor remap = new UnsortedRemappingMethodAdapter(access, newDesc, sup, remapper, repo);
|
||||
return new MethodVisitor(Opcodes.ASM5, remap) {
|
||||
@Override
|
||||
protected MethodVisitor createMethodRemapper(MethodVisitor mv) {
|
||||
return new UnsortedRemappingMethodAdapter(mv, remapper, repo) {
|
||||
@Override
|
||||
public void visitAttribute(Attribute attr) {
|
||||
if (SpecialSource.kill_lvt && attr.type.equals("LocalVariableTable")) {
|
||||
@ -175,9 +146,8 @@ public class RemappingClassAdapter extends ClassVisitor {
|
||||
if (SpecialSource.kill_generics && attr.type.equals("LocalVariableTypeTable")) {
|
||||
return;
|
||||
}
|
||||
if (mv != null) {
|
||||
mv.visitAttribute(attr);
|
||||
}
|
||||
|
||||
super.visitAttribute(attr);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -189,15 +159,10 @@ public class RemappingClassAdapter extends ClassVisitor {
|
||||
};
|
||||
}
|
||||
|
||||
protected AnnotationVisitor createRemappingAnnotationAdapter(
|
||||
AnnotationVisitor av) {
|
||||
return new RemappingAnnotationAdapter(av, remapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitSource(String source, String debug) {
|
||||
if (!SpecialSource.kill_source && cv != null) {
|
||||
cv.visitSource(source, debug);
|
||||
if (!SpecialSource.kill_source) {
|
||||
super.visitSource(source, debug);
|
||||
}
|
||||
}
|
||||
|
||||
@ -206,8 +171,7 @@ public class RemappingClassAdapter extends ClassVisitor {
|
||||
if (SpecialSource.kill_generics && attr.type.equals("Signature")) {
|
||||
return;
|
||||
}
|
||||
if (cv != null) {
|
||||
cv.visitAttribute(attr);
|
||||
}
|
||||
|
||||
super.visitAttribute(attr);
|
||||
}
|
||||
}
|
||||
|
@ -32,97 +32,33 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import net.md_5.specialsource.repo.ClassRepo;
|
||||
import net.md_5.specialsource.repo.RuntimeRepo;
|
||||
import org.objectweb.asm.AnnotationVisitor;
|
||||
import org.objectweb.asm.Handle;
|
||||
import org.objectweb.asm.Label;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.commons.RemappingAnnotationAdapter;
|
||||
import org.objectweb.asm.commons.MethodRemapper;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.FieldNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
/**
|
||||
* A {@link LocalVariablesSorter} for type mapping.
|
||||
*
|
||||
* @author Eugene Kuleshov
|
||||
*
|
||||
* Edited 04-24-2013 LexManos: Changed super class to MethodVisitor, using
|
||||
* LocalVariablesSorter caused the LV indexes to be reassigned improperly.
|
||||
* Causing decompiled code to not follow a predictable pattern and not coincide
|
||||
* with RetroGuard's output.
|
||||
*/
|
||||
public class UnsortedRemappingMethodAdapter extends MethodVisitor { //Lex: Changed LocalVariablesSorter to MethodVisitor
|
||||
public class UnsortedRemappingMethodAdapter extends MethodRemapper {
|
||||
|
||||
private static final Collection<Handle> META_FACTORIES = Arrays.asList(
|
||||
new Handle(Opcodes.H_INVOKESTATIC, "java/lang/invoke/LambdaMetafactory", "metafactory",
|
||||
"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;"),
|
||||
"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;", false),
|
||||
new Handle(Opcodes.H_INVOKESTATIC, "java/lang/invoke/LambdaMetafactory", "altMetafactory",
|
||||
"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite;")
|
||||
"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite;", false)
|
||||
);
|
||||
|
||||
protected final CustomRemapper remapper;
|
||||
private final ClassRepo classRepo;
|
||||
|
||||
public UnsortedRemappingMethodAdapter(final int access, final String desc,
|
||||
final MethodVisitor mv, final CustomRemapper remapper, ClassRepo classRepo) {
|
||||
this(Opcodes.ASM5, access, desc, mv, remapper, classRepo);
|
||||
}
|
||||
|
||||
protected UnsortedRemappingMethodAdapter(final int api, final int access,
|
||||
final String desc, final MethodVisitor mv, final CustomRemapper remapper, ClassRepo classRepo) {
|
||||
super(api, mv); //Lex: Removed access, desc
|
||||
public UnsortedRemappingMethodAdapter(final MethodVisitor mv, final CustomRemapper remapper, ClassRepo classRepo) {
|
||||
super(mv, remapper);
|
||||
this.remapper = remapper;
|
||||
this.classRepo = classRepo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotationVisitor visitAnnotationDefault() {
|
||||
AnnotationVisitor av = mv.visitAnnotationDefault();
|
||||
return av == null ? av : new RemappingAnnotationAdapter(av, remapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
|
||||
AnnotationVisitor av = mv.visitAnnotation(remapper.mapDesc(desc),
|
||||
visible);
|
||||
return av == null ? av : new RemappingAnnotationAdapter(av, remapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotationVisitor visitParameterAnnotation(int parameter,
|
||||
String desc, boolean visible) {
|
||||
AnnotationVisitor av = mv.visitParameterAnnotation(parameter,
|
||||
remapper.mapDesc(desc), visible);
|
||||
return av == null ? av : new RemappingAnnotationAdapter(av, remapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitFrame(int type, int nLocal, Object[] local, int nStack,
|
||||
Object[] stack) {
|
||||
super.visitFrame(type, nLocal, remapEntries(nLocal, local), nStack,
|
||||
remapEntries(nStack, stack));
|
||||
}
|
||||
|
||||
private Object[] remapEntries(int n, Object[] entries) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (entries[i] instanceof String) {
|
||||
Object[] newEntries = new Object[n];
|
||||
if (i > 0) {
|
||||
System.arraycopy(entries, 0, newEntries, 0, i);
|
||||
}
|
||||
do {
|
||||
Object t = entries[i];
|
||||
newEntries[i++] = t instanceof String ? remapper
|
||||
.mapType((String) t) : t;
|
||||
} while (i < n);
|
||||
return newEntries;
|
||||
}
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitFieldInsn(int opcode, String owner, String name,
|
||||
String desc) {
|
||||
@ -200,33 +136,4 @@ public class UnsortedRemappingMethodAdapter extends MethodVisitor { //Lex: Chang
|
||||
remapper.mapMethodDesc(desc), (Handle) remapper.mapValue(bsm),
|
||||
bsmArgs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitTypeInsn(int opcode, String type) {
|
||||
super.visitTypeInsn(opcode, remapper.mapType(type));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitLdcInsn(Object cst) {
|
||||
super.visitLdcInsn(remapper.mapValue(cst));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitMultiANewArrayInsn(String desc, int dims) {
|
||||
super.visitMultiANewArrayInsn(remapper.mapDesc(desc), dims);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitTryCatchBlock(Label start, Label end, Label handler,
|
||||
String type) {
|
||||
super.visitTryCatchBlock(start, end, handler, type == null ? null
|
||||
: remapper.mapType(type));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitLocalVariable(String name, String desc, String signature,
|
||||
Label start, Label end, int index) {
|
||||
super.visitLocalVariable(name, remapper.mapDesc(desc),
|
||||
remapper.mapSignature(signature, true), start, end, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class FileLocator {
|
||||
}
|
||||
|
||||
// Create our own cache file here, replacing potentially invalid characters
|
||||
String id = CharMatcher.JAVA_LETTER_OR_DIGIT.or(CharMatcher.anyOf("-_.")).negate().replaceFrom(url.toString(), '_');
|
||||
String id = CharMatcher.javaLetterOrDigit().or(CharMatcher.anyOf("-_.")).negate().replaceFrom(url.toString(), '_');
|
||||
File file = new File(tempDir, id);
|
||||
|
||||
// Check cache for a hit
|
||||
|
Loading…
Reference in New Issue
Block a user