|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2000-2015 JetBrains s.r.o. |
|
|
|
* Copyright 2000-2016 JetBrains s.r.o. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
@ -37,48 +37,39 @@ import java.util.*; |
|
|
|
import java.util.Map.Entry; |
|
|
|
import java.util.Map.Entry; |
|
|
|
|
|
|
|
|
|
|
|
public class ClassReference14Processor { |
|
|
|
public class ClassReference14Processor { |
|
|
|
|
|
|
|
private static final ExitExprent BODY_EXPR; |
|
|
|
public static final ExitExprent bodyexprent; |
|
|
|
private static final ExitExprent HANDLER_EXPR; |
|
|
|
|
|
|
|
|
|
|
|
public static final ExitExprent handlerexprent; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static { |
|
|
|
static { |
|
|
|
|
|
|
|
InvocationExprent invFor = new InvocationExprent(); |
|
|
|
InvocationExprent invfor = new InvocationExprent(); |
|
|
|
invFor.setName("forName"); |
|
|
|
invfor.setName("forName"); |
|
|
|
invFor.setClassname("java/lang/Class"); |
|
|
|
invfor.setClassname("java/lang/Class"); |
|
|
|
invFor.setStringDescriptor("(Ljava/lang/String;)Ljava/lang/Class;"); |
|
|
|
invfor.setStringDescriptor("(Ljava/lang/String;)Ljava/lang/Class;"); |
|
|
|
invFor.setDescriptor(MethodDescriptor.parseDescriptor("(Ljava/lang/String;)Ljava/lang/Class;")); |
|
|
|
invfor.setDescriptor(MethodDescriptor.parseDescriptor("(Ljava/lang/String;)Ljava/lang/Class;")); |
|
|
|
invFor.setStatic(true); |
|
|
|
invfor.setStatic(true); |
|
|
|
invFor.setLstParameters(Collections.singletonList(new VarExprent(0, VarType.VARTYPE_STRING, null))); |
|
|
|
invfor.setLstParameters(Arrays.asList(new Exprent[]{new VarExprent(0, VarType.VARTYPE_STRING, null)})); |
|
|
|
BODY_EXPR = new ExitExprent(ExitExprent.EXIT_RETURN, invFor, VarType.VARTYPE_CLASS, null); |
|
|
|
|
|
|
|
|
|
|
|
bodyexprent = new ExitExprent(ExitExprent.EXIT_RETURN, |
|
|
|
InvocationExprent ctor = new InvocationExprent(); |
|
|
|
invfor, |
|
|
|
ctor.setName(CodeConstants.INIT_NAME); |
|
|
|
VarType.VARTYPE_CLASS, null); |
|
|
|
ctor.setClassname("java/lang/NoClassDefFoundError"); |
|
|
|
|
|
|
|
ctor.setStringDescriptor("()V"); |
|
|
|
InvocationExprent constr = new InvocationExprent(); |
|
|
|
ctor.setFunctype(InvocationExprent.TYP_INIT); |
|
|
|
constr.setName(CodeConstants.INIT_NAME); |
|
|
|
ctor.setDescriptor(MethodDescriptor.parseDescriptor("()V")); |
|
|
|
constr.setClassname("java/lang/NoClassDefFoundError"); |
|
|
|
|
|
|
|
constr.setStringDescriptor("()V"); |
|
|
|
NewExprent newExpr = new NewExprent(new VarType(CodeConstants.TYPE_OBJECT, 0, "java/lang/NoClassDefFoundError"), new ArrayList<>(), null); |
|
|
|
constr.setFunctype(InvocationExprent.TYP_INIT); |
|
|
|
newExpr.setConstructor(ctor); |
|
|
|
constr.setDescriptor(MethodDescriptor.parseDescriptor("()V")); |
|
|
|
|
|
|
|
|
|
|
|
InvocationExprent invCause = new InvocationExprent(); |
|
|
|
NewExprent newexpr = |
|
|
|
invCause.setName("initCause"); |
|
|
|
new NewExprent(new VarType(CodeConstants.TYPE_OBJECT, 0, "java/lang/NoClassDefFoundError"), new ArrayList<>(), null); |
|
|
|
invCause.setClassname("java/lang/NoClassDefFoundError"); |
|
|
|
newexpr.setConstructor(constr); |
|
|
|
invCause.setStringDescriptor("(Ljava/lang/Throwable;)Ljava/lang/Throwable;"); |
|
|
|
|
|
|
|
invCause.setDescriptor(MethodDescriptor.parseDescriptor("(Ljava/lang/Throwable;)Ljava/lang/Throwable;")); |
|
|
|
InvocationExprent invcause = new InvocationExprent(); |
|
|
|
invCause.setInstance(newExpr); |
|
|
|
invcause.setName("initCause"); |
|
|
|
invCause.setLstParameters( |
|
|
|
invcause.setClassname("java/lang/NoClassDefFoundError"); |
|
|
|
Collections.singletonList(new VarExprent(2, new VarType(CodeConstants.TYPE_OBJECT, 0, "java/lang/ClassNotFoundException"), null))); |
|
|
|
invcause.setStringDescriptor("(Ljava/lang/Throwable;)Ljava/lang/Throwable;"); |
|
|
|
|
|
|
|
invcause.setDescriptor(MethodDescriptor.parseDescriptor("(Ljava/lang/Throwable;)Ljava/lang/Throwable;")); |
|
|
|
HANDLER_EXPR = new ExitExprent(ExitExprent.EXIT_THROW, invCause, null, null); |
|
|
|
invcause.setInstance(newexpr); |
|
|
|
|
|
|
|
invcause.setLstParameters( |
|
|
|
|
|
|
|
Arrays.asList(new Exprent[]{new VarExprent(2, new VarType(CodeConstants.TYPE_OBJECT, 0, "java/lang/ClassNotFoundException"), null)})); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handlerexprent = new ExitExprent(ExitExprent.EXIT_THROW, |
|
|
|
|
|
|
|
invcause, |
|
|
|
|
|
|
|
null, null); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void processClassReferences(ClassNode node) { |
|
|
|
public static void processClassReferences(ClassNode node) { |
|
|
@ -176,8 +167,8 @@ public class ClassReference14Processor { |
|
|
|
BasicBlockStatement handler = (BasicBlockStatement)cst.getStats().get(1); |
|
|
|
BasicBlockStatement handler = (BasicBlockStatement)cst.getStats().get(1); |
|
|
|
|
|
|
|
|
|
|
|
if (body.getExprents().size() == 1 && handler.getExprents().size() == 1) { |
|
|
|
if (body.getExprents().size() == 1 && handler.getExprents().size() == 1) { |
|
|
|
if (bodyexprent.equals(body.getExprents().get(0)) && |
|
|
|
if (BODY_EXPR.equals(body.getExprents().get(0)) && |
|
|
|
handlerexprent.equals(handler.getExprents().get(0))) { |
|
|
|
HANDLER_EXPR.equals(handler.getExprents().get(0))) { |
|
|
|
map.put(wrapper, method); |
|
|
|
map.put(wrapper, method); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|