Skip to content

Commit

Permalink
Bump ASM version to 8.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisTestUser committed Jul 25, 2020
1 parent 0017ae8 commit 8ab6965
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 15 deletions.
13 changes: 7 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<version>1.0.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.asm>6.0</version.asm>
<version.asm>8.0.1</version.asm>
</properties>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
Expand Down Expand Up @@ -142,11 +142,6 @@
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.javadeobfuscator</groupId>
<artifactId>javavm</artifactId>
<version>3.0.0</version>
</dependency>

<!-- ASM related dependencies -->
<dependency>
Expand Down Expand Up @@ -174,5 +169,11 @@
<artifactId>asm-analysis</artifactId>
<version>${version.asm}</version>
</dependency>

<dependency>
<groupId>com.javadeobfuscator</groupId>
<artifactId>javavm</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -1706,9 +1706,15 @@ else if(argumentTypes[i + 3].getSort() == Type.DOUBLE)
case CHECKCAST: {
TypeInsnNode cast = (TypeInsnNode) now;
JavaValue obj = stack.get(0);
Type type;
try {
type = Type.getType(cast.desc);
} catch (Throwable ignored) {
type = Type.getObjectType(cast.desc);
}
if (obj.value() != null) {
if (context.provider.canCheckcast(obj, Type.getType(cast.desc), context)) {
if (!context.provider.checkcast(obj, Type.getType(cast.desc), context)) {
if (context.provider.canCheckcast(obj, type, context)) {
if (!context.provider.checkcast(obj, type, context)) {
throw new ClassCastException(cast.desc);
}
} else {
Expand All @@ -1720,8 +1726,14 @@ else if(argumentTypes[i + 3].getSort() == Type.DOUBLE)
case INSTANCEOF: {
TypeInsnNode cast = (TypeInsnNode) now;
JavaValue obj = stack.remove(0);
if (context.provider.canCheckInstanceOf(obj, Type.getType(cast.desc), context)) {
boolean is = context.provider.instanceOf(obj, Type.getType(cast.desc), context);
Type type;
try {
type = Type.getType(cast.desc);
} catch (Throwable ignored) {
type = Type.getObjectType(cast.desc);
}
if (context.provider.canCheckInstanceOf(obj, type, context)) {
boolean is = context.provider.instanceOf(obj, type, context);
stack.add(0, new JavaInteger(is ? 1 : 0));
} else {
throw new NoSuchComparisonHandlerException("No comparator found for " + cast.desc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ public class JVMMethodProvider extends MethodProvider {
targetObject.initialize(new String(args.get(0).as(byte[].class), args.get(1).as(String.class)));
return null;
});
put("getBytes()[B", (targetObject, args, context) -> targetObject.as(String.class).getBytes());
put("getBytes(Ljava/nio/charset/Charset;)[B", (targetObject, args, context) -> targetObject.as(String.class).getBytes(args.get(0).as(Charset.class)));
put("toString()Ljava/lang/String;", (targetObject, args, context) -> targetObject.as(String.class).toString());
put("intern()Ljava/lang/String;", (targetObject, args, context) -> targetObject.as(String.class).intern());
Expand Down Expand Up @@ -674,6 +675,7 @@ public class JVMMethodProvider extends MethodProvider {
return null;
});
put("parseInt(Ljava/lang/String;)I", (targetObject, args, context) -> Integer.parseInt(args.get(0).as(String.class)));
put("parseInt(Ljava/lang/String;I)I", (targetObject, args, context) -> Integer.parseInt(args.get(0).as(String.class), args.get(1).intValue()));
put("valueOf(Ljava/lang/String;)Ljava/lang/Integer;", (targetObject, args, context) -> Integer.valueOf(args.get(0).as(String.class)));
put("valueOf(Ljava/lang/String;I)Ljava/lang/Integer;", (targetObject, args, context) -> Integer.valueOf(args.get(0).as(String.class), args.get(1).intValue()));
put("valueOf(I)Ljava/lang/Integer;", (targetObject, args, context) -> Integer.valueOf(args.get(0).intValue()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public boolean transform()
provider.register(new ComparisonProvider() {
@Override
public boolean instanceOf(JavaValue target, Type type, Context context) {
if(target.type().equals("java/lang/Class")
if(target.type().equals("Ljava/lang/Class;")
&& type.getDescriptor().equals("Ljava/lang/Class;"))
return true;
return false;
Expand All @@ -85,7 +85,7 @@ public boolean checkEquality(JavaValue first, JavaValue second, Context context)

@Override
public boolean canCheckInstanceOf(JavaValue target, Type type, Context context) {
if(type.getDescriptor().equals("java/lang/Class"))
if(type.getDescriptor().equals("Ljava/lang/Class;"))
return true;
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ private class MyInterpreter extends BasicInterpreter
public BasicValue newValue(final Type type)
{
if(type == null)
return new BasicValue(Type.getType("java/lang/Object"));
return new BasicValue(Type.getType("Ljava/lang/Object;"));
switch(type.getSort())
{
case Type.VOID:
Expand Down Expand Up @@ -633,7 +633,7 @@ public BasicValue binaryOperation(final AbstractInsnNode insn,
public BasicValue merge(final BasicValue v, final BasicValue w)
{
if(!v.equals(w))
return new BasicValue(Type.getType("java/lang/Object"));
return new BasicValue(Type.getType("Ljava/lang/Object;"));
return v;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public int inlineReflection(int expected) throws Throwable {
provider.register(new ComparisonProvider() {
@Override
public boolean instanceOf(JavaValue target, Type type, Context context) {
return type.getDescriptor().equals("java/lang/String") && target.value() instanceof String;
return type.getDescriptor().equals("Ljava/lang/String;") && target.value() instanceof String;
}

@Override
Expand Down

0 comments on commit 8ab6965

Please sign in to comment.