Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Aug 10, 2024
2 parents e668a0d + 1eba37b commit fe48bb4
Show file tree
Hide file tree
Showing 14 changed files with 690 additions and 202 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ kotlin.code.style=official
org.gradle.jvmargs=-Xmx4G
org.gradle.parallel=true

version=1.0.1
version=1.1.0

asm_version=9.7

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,77 +46,77 @@ static boolean isDeprecated(@Coerce(J_U_R_RandomGenerator.class) Object obj) {
return jvmdg$checkcast(obj).isDeprecated();
}

@Stub(noSpecial = true)
@Stub(noSpecial = true, excludeChild = "java/util/Random")
static DoubleStream doubles(@Coerce(J_U_R_RandomGenerator.class) Object obj) {
return jvmdg$checkcast(obj).doubles();
}

@Stub(noSpecial = true)
@Stub(noSpecial = true, excludeChild = "java/util/Random")
static DoubleStream doubles(@Coerce(J_U_R_RandomGenerator.class) Object obj, double lower, double upper) {
return jvmdg$checkcast(obj).doubles(lower, upper);
}

@Stub(noSpecial = true)
@Stub(noSpecial = true, excludeChild = "java/util/Random")
static DoubleStream doubles(@Coerce(J_U_R_RandomGenerator.class) Object obj, long limit) {
return jvmdg$checkcast(obj).doubles(limit);
}

@Stub(noSpecial = true)
@Stub(noSpecial = true, excludeChild = "java/util/Random")
static DoubleStream doubles(@Coerce(J_U_R_RandomGenerator.class) Object obj, long limit, double origin, double bound) {
return jvmdg$checkcast(obj).doubles(limit, origin, bound);
}

@Stub(noSpecial = true)
@Stub(noSpecial = true, excludeChild = "java/util/Random")
static IntStream ints(@Coerce(J_U_R_RandomGenerator.class) Object obj) {
return jvmdg$checkcast(obj).ints();
}

@Stub(noSpecial = true)
@Stub(noSpecial = true, excludeChild = "java/util/Random")
static IntStream ints(@Coerce(J_U_R_RandomGenerator.class) Object obj, int origin, int bound) {
return jvmdg$checkcast(obj).ints(origin, bound);
}

@Stub(noSpecial = true)
@Stub(noSpecial = true, excludeChild = "java/util/Random")
static IntStream ints(@Coerce(J_U_R_RandomGenerator.class) Object obj, long limit) {
return jvmdg$checkcast(obj).ints(limit);
}

@Stub(noSpecial = true)
@Stub(noSpecial = true, excludeChild = "java/util/Random")
static IntStream ints(@Coerce(J_U_R_RandomGenerator.class) Object obj, long limit, int origin, int bound) {
return jvmdg$checkcast(obj).ints(limit, origin, bound);
}

@Stub(noSpecial = true)
@Stub(noSpecial = true, excludeChild = "java/util/Random")
static LongStream longs(@Coerce(J_U_R_RandomGenerator.class) Object obj) {
return jvmdg$checkcast(obj).longs();
}

@Stub(noSpecial = true)
@Stub(noSpecial = true, excludeChild = "java/util/Random")
static LongStream longs(@Coerce(J_U_R_RandomGenerator.class) Object obj, long origin, long bound) {
return jvmdg$checkcast(obj).longs(origin, bound);
}

@Stub(noSpecial = true)
@Stub(noSpecial = true, excludeChild = "java/util/Random")
static LongStream longs(@Coerce(J_U_R_RandomGenerator.class) Object obj, long limit) {
return jvmdg$checkcast(obj).longs(limit);
}

@Stub(noSpecial = true)
@Stub(noSpecial = true, excludeChild = "java/util/Random")
static LongStream longs(@Coerce(J_U_R_RandomGenerator.class) Object obj, long limit, long origin, long bound) {
return jvmdg$checkcast(obj).longs(limit, origin, bound);
}

@Stub(noSpecial = true)
@Stub(noSpecial = true, excludeChild = "java/util/Random")
static boolean nextBoolean(@Coerce(J_U_R_RandomGenerator.class) Object obj) {
return jvmdg$checkcast(obj).nextBoolean();
}

@Stub(noSpecial = true)
@Stub(noSpecial = true, excludeChild = "java/util/Random")
static void nextBytes(@Coerce(J_U_R_RandomGenerator.class) Object obj, byte[] bytes) {
jvmdg$checkcast(obj).nextBytes(bytes);
}

@Stub(noSpecial = true)
@Stub(noSpecial = true, excludeChild = "java/util/Random")
static float nextFloat(@Coerce(J_U_R_RandomGenerator.class) Object obj) {
return jvmdg$checkcast(obj).nextFloat();
}
Expand All @@ -131,7 +131,7 @@ static float nextFloat(@Coerce(J_U_R_RandomGenerator.class) Object obj, float or
return jvmdg$checkcast(obj).nextFloat(origin, bound);
}

@Stub(noSpecial = true)
@Stub(noSpecial = true, excludeChild = "java/util/Random")
static double nextDouble(@Coerce(J_U_R_RandomGenerator.class) Object obj) {
return jvmdg$checkcast(obj).nextDouble();
}
Expand All @@ -146,12 +146,12 @@ static double nextDouble(@Coerce(J_U_R_RandomGenerator.class) Object obj, double
return jvmdg$checkcast(obj).nextDouble(origin, bound);
}

@Stub(noSpecial = true)
@Stub(noSpecial = true, excludeChild = "java/util/Random")
static int nextInt(@Coerce(J_U_R_RandomGenerator.class) Object obj) {
return jvmdg$checkcast(obj).nextInt();
}

@Stub(noSpecial = true)
@Stub(noSpecial = true, excludeChild = "java/util/Random")
static int nextInt(@Coerce(J_U_R_RandomGenerator.class) Object obj, int bound) {
return jvmdg$checkcast(obj).nextInt(bound);
}
Expand All @@ -161,33 +161,33 @@ static int nextInt(@Coerce(J_U_R_RandomGenerator.class) Object obj, int origin,
return jvmdg$checkcast(obj).nextInt(origin, bound);
}

@Stub(noSpecial = true)
static long nextLong(@Coerce(J_U_Random.class) Object obj) {
@Stub(noSpecial = true, excludeChild = "java/util/Random")
static long nextLong(@Coerce(J_U_R_RandomGenerator.class) Object obj) {
return jvmdg$checkcast(obj).nextLong();
}

@Stub(noSpecial = true)
static long nextLong(@Coerce(J_U_Random.class) Object obj, long bound) {
static long nextLong(@Coerce(J_U_R_RandomGenerator.class) Object obj, long bound) {
return jvmdg$checkcast(obj).nextLong(bound);
}

@Stub(noSpecial = true)
static long nextLong(@Coerce(J_U_Random.class) Object obj, long origin, long bound) {
static long nextLong(@Coerce(J_U_R_RandomGenerator.class) Object obj, long origin, long bound) {
return jvmdg$checkcast(obj).nextLong(origin, bound);
}

@Stub(noSpecial = true)
static double nextGaussian(@Coerce(J_U_Random.class) Object obj) {
@Stub(noSpecial = true, excludeChild = "java/util/Random")
static double nextGaussian(@Coerce(J_U_R_RandomGenerator.class) Object obj) {
return jvmdg$checkcast(obj).nextGaussian();
}

@Stub(noSpecial = true)
static double nextGaussian(@Coerce(J_U_Random.class) Object obj, double mean, double stdDev) {
static double nextGaussian(@Coerce(J_U_R_RandomGenerator.class) Object obj, double mean, double stdDev) {
return jvmdg$checkcast(obj).nextGaussian(mean, stdDev);
}

@Stub(noSpecial = true)
static double nextExponential(@Coerce(J_U_Random.class) Object obj) {
static double nextExponential(@Coerce(J_U_R_RandomGenerator.class) Object obj) {
return jvmdg$checkcast(obj).nextExponential();
}

Expand Down
25 changes: 22 additions & 3 deletions src/main/java/xyz/wagyourtail/jvmdg/ClassDowngrader.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.VisibleForTesting;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Handle;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.ClassNode;
Expand Down Expand Up @@ -250,9 +253,25 @@ protected Set<ClassNode> downgrade(ClassNode clazz, boolean enableRuntime, Funct
version = downgrader.outputVersion;
if (flags.multiReleaseVersions.contains(version)) {
// copy to new class node
ClassNode multiRelease = new ClassNode();
clazz.accept(multiRelease);
multiReleaseHolder.add(multiRelease);
for (ClassNode c : classes) {
ClassNode copy = new ClassNode();
c.accept(new ClassVisitor(Opcodes.ASM9, copy) {
@Override
public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) {
return new MethodVisitor(api, super.visitMethod(access, name, descriptor, signature, exceptions)) {

@Override
public void visitInvokeDynamicInsn(String name, String descriptor, Handle bootstrapMethodHandle, Object... bootstrapMethodArguments) {
// copy bsm args
Object[] copy = new Object[bootstrapMethodArguments.length];
System.arraycopy(bootstrapMethodArguments, 0, copy, 0, bootstrapMethodArguments.length);
super.visitInvokeDynamicInsn(name, descriptor, bootstrapMethodHandle, copy);
}
};
}
});
multiReleaseHolder.add(copy);
}
}
}
multiReleaseHolder.addAll(classes);
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/xyz/wagyourtail/jvmdg/cli/Flags.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;

Expand Down Expand Up @@ -145,9 +146,25 @@ public String toString() {
", printDebug=" + printDebug +
", debugSkipStubs=" + debugSkipStubs +
", ignoreWarningsIn=" + ignoreWarningsIn +
", debugDumpClasses=" + debugDumpClasses +
", multiReleaseOriginal=" + multiReleaseOriginal +
", multiReleaseVersions=" + multiReleaseVersions +
'}';
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Flags)) return false;
Flags flags = (Flags) o;
return classVersion == flags.classVersion && quiet == flags.quiet && logAnsiColors == flags.logAnsiColors && allowMaven == flags.allowMaven && printDebug == flags.printDebug && debugDumpClasses == flags.debugDumpClasses && multiReleaseOriginal == flags.multiReleaseOriginal && Objects.equals(api, flags.api) && logLevel == flags.logLevel && Objects.equals(ignoreWarningsIn, flags.ignoreWarningsIn) && Objects.equals(debugSkipStubs, flags.debugSkipStubs) && Objects.equals(multiReleaseVersions, flags.multiReleaseVersions);
}

@Override
public int hashCode() {
return Objects.hash(classVersion, api, quiet, logAnsiColors, logLevel, ignoreWarningsIn, allowMaven, printDebug, debugSkipStubs, debugDumpClasses, multiReleaseOriginal, multiReleaseVersions);
}

public void addIgnore(String s) {
if (s.endsWith("**")) {
ignoreWarningsIn.put(s.substring(0, s.length() - 2), WildcardType.DOUBLE);
Expand Down
Loading

0 comments on commit fe48bb4

Please sign in to comment.