| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
package lockedregioncodeinjection; |
| 15 |
|
| 16 |
import org.objectweb.asm.Opcodes; |
| 17 |
|
| 18 |
import java.util.ArrayList; |
| 19 |
import java.util.List; |
| 20 |
|
| 21 |
public class Utils { |
| 22 |
|
| 23 |
public static final int ASM_VERSION = Opcodes.ASM9; |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
public static List<LockTarget> getTargetsFromLegacyJackConfig(String classList, |
| 29 |
String requestList, String resetList) { |
| 30 |
|
| 31 |
String[] classes = classList.split(","); |
| 32 |
String[] requests = requestList.split(","); |
| 33 |
String[] resets = resetList.split(","); |
| 34 |
|
| 35 |
int total = classes.length; |
| 36 |
assert requests.length == total; |
| 37 |
assert resets.length == total; |
| 38 |
|
| 39 |
List<LockTarget> config = new ArrayList<LockTarget>(); |
| 40 |
|
| 41 |
for (int i = 0; i < total; i++) { |
| 42 |
config.add(new LockTarget(classes[i], requests[i], resets[i])); |
| 43 |
} |
| 44 |
|
| 45 |
return config; |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
public static LockTarget getScopedTarget(String arg) { |
| 55 |
String[] c = arg.split(","); |
| 56 |
if (c.length == 3) { |
| 57 |
return new LockTarget(c[0], c[1], c[2], true); |
| 58 |
} else if (c.length == 4) { |
| 59 |
if (c[3].equals("true")) { |
| 60 |
return new LockTarget(c[0], c[1], c[2], true); |
| 61 |
} else if (c[3].equals("false")) { |
| 62 |
return new LockTarget(c[0], c[1], c[2], false); |
| 63 |
} else { |
| 64 |
System.err.println("illegal target parameter \"" + c[3] + "\""); |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
throw new RuntimeException("invalid scoped target format"); |
| 69 |
} |
| 70 |
} |