Skip to content

Commit

Permalink
fix startsWith using wrong mname in string concat factory
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed May 25, 2024
1 parent d37966d commit f074d52
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@

public class TestString {

static {
String a = "aaa";
System.out.println("testa " + a);
System.out.println("testb " + a);
}

public static void main(String[] args) {
String a = "1";
double b = 2.000001d;
String c = null;
String withConstants = a + b + c + "wasd" + Arrays.asList(args);
System.out.println(withConstants);

String withConstantsToo = a + b + c + "asdf" + Arrays.asList(args);
System.out.println(withConstantsToo);

System.out.println("aaa" + b + "bbb" + Arrays.asList(args) + a);

System.out.println(a + b + "ccc");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ private static InsnList makeConcatInternal2(String args, Deque<Type> types) {
}

public static InsnList makeConcatInternal3(String mname, ClassNode node, String args, Deque<Type> types) {
mname = mname.replace("<", "$").replace(">", "$");
if (!args.contains("\u0001")) {
// no args
InsnList list = new InsnList();
Expand Down Expand Up @@ -490,7 +491,6 @@ public static class StringConcatMethodNode extends MethodNode {

public StringConcatMethodNode(String mname, String args, Deque<Type> types, int index) {
super(Opcodes.ASM9);
mname = mname.replace("<", "$").replace(">", "$");
this.args = args;
this.name = "jvmdowngrader$concat$" + mname + "$" + index;
this.access = Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/xyz/wagyourtail/jvmdg/cli/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public static void getTargets(Map<String, List<String[]>> args, Map<Path, Path>
throw new IllegalArgumentException("input \"" + input + "\" does not exist");
}
Path inputPath;
if (input.isDirectory()) {
if (input.isDirectory() || input.toString().endsWith(".class")) {
inputPath = input.toPath();
} else {
FileSystem fs = Utils.openZipFileSystem(input.toPath(), false);
Expand Down

0 comments on commit f074d52

Please sign in to comment.