Java????????????????
???????????? ???????[ 2012/11/27 10:36:20 ] ????????
??????????д???????????
????(???????? depth ???????????????????????????????)
???????????????????????????????????????jdk????????????.* ?????????????java/util/regex/Pattern$CharProperty.match ???????? D ???????java/util/regex/Pattern$BmpCharProperty.match ????????????????????????????ASM
???????????????????????????????????????????£?
????package com.alibaba.taobao.tinyprofiler;
????import java.lang.instrument.ClassFileTransformer;
????import java.lang.instrument.IllegalClassFormatException;
????import java.security.ProtectionDomain;
????import org.objectweb.asm.ClassAdapter;
????import org.objectweb.asm.ClassReader;
????import org.objectweb.asm.ClassWriter;
????public class MethodCallCountTransformer implements ClassFileTransformer {
????@Override
????public byte[] transform(ClassLoader loader?? String className?? Class classBeingRedefined??
????ProtectionDomain protectionDomain?? byte[] classfileBuffer) throws IllegalClassFormatException {
????try {
????if (!“java/util/regex/Pattern$CharProperty”.equals(className)
????&& !“java/util/regex/Pattern$BmpCharProperty”.equals(className)) {
????return classfileBuffer;
????}
????ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
????ClassAdapter adapter = new MethodCallClassAdapter(writer?? className);
????ClassReader reader = new ClassReader(classfileBuffer);
????reader.accept(adapter?? 0);
????// ?????????????
????return writer.toByteArray();
????} catch (Exception e) {
????e.printStackTrace();
????// ????????????
????return classfileBuffer;
????}
????}
????}
????package com.alibaba.taobao.tinyprofiler;
????import java.util.concurrent.atomic.AtomicInteger;
????public class Counter {
????private static AtomicInteger methodCallCount = new AtomicInteger(0);
????public static void printAndIncCount(String className?? String methodName) {
????System.out.println(className + “.” + methodName + “ called?? total times ” + methodCallCount.incrementAndGet());
????}
????}
????OK??????????????
????String regex = “.*.*.*D”;
????String target = “22asdvasdx”;
????Pattern.compile(regex).matcher(target).matches();
????System.out.println(“Xuanyin’s estimated count: ” + findTotalWays(4?? target.length()) + “; depth: ” + recursionDepth);
??????????(???????? depth ???????????????????????????????)??
??????????????????~OK???????????????????????????? .*.*.*.*.*.*D ???? com.taobao.binary.bogda.query.service.RulesInfoQueryService:1.0.0.daily
????????????? 5 ?? ??? ?????????? 2.5 ????
????????????????i7-2600K ??4.5G???????????5???????????????~
????????????????????600???????????????~???????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11